@kitelev/exocortex-cli 13.270.0 → 13.272.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +97 -97
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// @kitelev/exocortex-cli v13.
|
|
2
|
+
// @kitelev/exocortex-cli v13.272.0
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
6
|
-
"use strict";var EA=Object.create;var nc=Object.defineProperty;var TA=Object.getOwnPropertyDescriptor;var AA=Object.getOwnPropertyNames;var xA=Object.getPrototypeOf,CA=Object.prototype.hasOwnProperty;var o=(n,e)=>nc(n,"name",{value:e,configurable:!0});var IA=(n,e)=>()=>(n&&(e=n(n=0)),e);var v=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),OA=(n,e)=>{for(var t in e)nc(n,t,{get:e[t],enumerable:!0})},S2=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of AA(e))!CA.call(n,i)&&i!==t&&nc(n,i,{get:()=>e[i],enumerable:!(r=TA(e,i))||r.enumerable});return n};var Ne=(n,e,t)=>(t=n!=null?EA(xA(n)):{},S2(e||!n||!n.__esModule?nc(t,"default",{value:n,enumerable:!0}):t,n)),Rd=n=>S2(nc({},"__esModule",{value:!0}),n);var Qu=v(()=>{var _2;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(n);typeof t.Reflect<"u"&&(r=i(t.Reflect,r)),e(r,t),typeof t.Reflect>"u"&&(t.Reflect=n);function i(u,l){return function(f,h){Object.defineProperty(u,f,{configurable:!0,writable:!0,value:h}),l&&l(f,h)}}o(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}o(s,"functionThis");function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}o(a,"indirectEvalThis");function c(){return s()||a()}o(c,"sloppyModeThis")})(function(e,t){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",u={__proto__:[]}instanceof Array,l=!c&&!u,f={create:c?function(){return be(Object.create(null))}:u?function(){return be({__proto__:null})}:function(){return be({})},has:l?function(w,E){return r.call(w,E)}:function(w,E){return E in w},get:l?function(w,E){return r.call(w,E)?w[E]:void 0}:function(w,E){return w[E]}},h=Object.getPrototypeOf(Function),d=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:fe(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:$e(),S=typeof WeakMap=="function"?WeakMap:Fe(),b=i?Symbol.for("@reflect-metadata:registry"):void 0,T=ce(),I=ue(T);function O(w,E,_,C){if(V(_)){if(!Ae(w))throw new TypeError;if(!xe(E))throw new TypeError;return nt(w,E)}else{if(!Ae(w))throw new TypeError;if(!z(E))throw new TypeError;if(!z(C)&&!V(C)&&!me(C))throw new TypeError;return me(C)&&(C=void 0),_=he(_),Ke(w,E,_,C)}}o(O,"decorate"),e("decorate",O);function L(w,E){function _(C,W){if(!z(C))throw new TypeError;if(!V(W)&&!Re(W))throw new TypeError;Q(w,E,C,W)}return o(_,"decorator"),_}o(L,"metadata"),e("metadata",L);function M(w,E,_,C){if(!z(_))throw new TypeError;return V(C)||(C=he(C)),Q(w,E,_,C)}o(M,"defineMetadata"),e("defineMetadata",M);function G(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),at(w,E,_)}o(G,"hasMetadata"),e("hasMetadata",G);function Ee(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),Ue(w,E,_)}o(Ee,"hasOwnMetadata"),e("hasOwnMetadata",Ee);function je(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),Be(w,E,_)}o(je,"getMetadata"),e("getMetadata",je);function Me(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),ke(w,E,_)}o(Me,"getOwnMetadata"),e("getOwnMetadata",Me);function q(w,E){if(!z(w))throw new TypeError;return V(E)||(E=he(E)),k(w,E)}o(q,"getMetadataKeys"),e("getMetadataKeys",q);function ie(w,E){if(!z(w))throw new TypeError;return V(E)||(E=he(E)),qe(w,E)}o(ie,"getOwnMetadataKeys"),e("getOwnMetadataKeys",ie);function Se(w,E,_){if(!z(E))throw new TypeError;if(V(_)||(_=he(_)),!z(E))throw new TypeError;V(_)||(_=he(_));var C=X(E,_,!1);return V(C)?!1:C.OrdinaryDeleteMetadata(w,E,_)}o(Se,"deleteMetadata"),e("deleteMetadata",Se);function nt(w,E){for(var _=w.length-1;_>=0;--_){var C=w[_],W=C(E);if(!V(W)&&!me(W)){if(!xe(W))throw new TypeError;E=W}}return E}o(nt,"DecorateConstructor");function Ke(w,E,_,C){for(var W=w.length-1;W>=0;--W){var it=w[W],ut=it(E,_,C);if(!V(ut)&&!me(ut)){if(!z(ut))throw new TypeError;C=ut}}return C}o(Ke,"DecorateProperty");function at(w,E,_){var C=Ue(w,E,_);if(C)return!0;var W=ne(E);return me(W)?!1:at(w,W,_)}o(at,"OrdinaryHasMetadata");function Ue(w,E,_){var C=X(E,_,!1);return V(C)?!1:Te(C.OrdinaryHasOwnMetadata(w,E,_))}o(Ue,"OrdinaryHasOwnMetadata");function Be(w,E,_){var C=Ue(w,E,_);if(C)return ke(w,E,_);var W=ne(E);if(!me(W))return Be(w,W,_)}o(Be,"OrdinaryGetMetadata");function ke(w,E,_){var C=X(E,_,!1);if(!V(C))return C.OrdinaryGetOwnMetadata(w,E,_)}o(ke,"OrdinaryGetOwnMetadata");function Q(w,E,_,C){var W=X(_,C,!0);W.OrdinaryDefineOwnMetadata(w,E,_,C)}o(Q,"OrdinaryDefineOwnMetadata");function k(w,E){var _=qe(w,E),C=ne(w);if(C===null)return _;var W=k(C,E);if(W.length<=0)return _;if(_.length<=0)return W;for(var it=new p,ut=[],we=0,j=_;we<j.length;we++){var $=j[we],U=it.has($);U||(it.add($),ut.push($))}for(var H=0,ve=W;H<ve.length;H++){var $=ve[H],U=it.has($);U||(it.add($),ut.push($))}return ut}o(k,"OrdinaryMetadataKeys");function qe(w,E){var _=X(w,E,!1);return _?_.OrdinaryOwnMetadataKeys(w,E):[]}o(qe,"OrdinaryOwnMetadataKeys");function Xe(w){if(w===null)return 1;switch(typeof w){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return w===null?1:6;default:return 6}}o(Xe,"Type");function V(w){return w===void 0}o(V,"IsUndefined");function me(w){return w===null}o(me,"IsNull");function Ie(w){return typeof w=="symbol"}o(Ie,"IsSymbol");function z(w){return typeof w=="object"?w!==null:typeof w=="function"}o(z,"IsObject");function Oe(w,E){switch(Xe(w)){case 0:return w;case 1:return w;case 2:return w;case 3:return w;case 4:return w;case 5:return w}var _=E===3?"string":E===5?"number":"default",C=se(w,s);if(C!==void 0){var W=C.call(w,_);if(z(W))throw new TypeError;return W}return Pe(w,_==="default"?"number":_)}o(Oe,"ToPrimitive");function Pe(w,E){if(E==="string"){var _=w.toString;if(ge(_)){var C=_.call(w);if(!z(C))return C}var W=w.valueOf;if(ge(W)){var C=W.call(w);if(!z(C))return C}}else{var W=w.valueOf;if(ge(W)){var C=W.call(w);if(!z(C))return C}var it=w.toString;if(ge(it)){var C=it.call(w);if(!z(C))return C}}throw new TypeError}o(Pe,"OrdinaryToPrimitive");function Te(w){return!!w}o(Te,"ToBoolean");function De(w){return""+w}o(De,"ToString");function he(w){var E=Oe(w,3);return Ie(E)?E:De(E)}o(he,"ToPropertyKey");function Ae(w){return Array.isArray?Array.isArray(w):w instanceof Object?w instanceof Array:Object.prototype.toString.call(w)==="[object Array]"}o(Ae,"IsArray");function ge(w){return typeof w=="function"}o(ge,"IsCallable");function xe(w){return typeof w=="function"}o(xe,"IsConstructor");function Re(w){switch(Xe(w)){case 3:return!0;case 4:return!0;default:return!1}}o(Re,"IsPropertyKey");function Z(w,E){return w===E||w!==w&&E!==E}o(Z,"SameValueZero");function se(w,E){var _=w[E];if(_!=null){if(!ge(_))throw new TypeError;return _}}o(se,"GetMethod");function ae(w){var E=se(w,a);if(!ge(E))throw new TypeError;var _=E.call(w);if(!z(_))throw new TypeError;return _}o(ae,"GetIterator");function ee(w){return w.value}o(ee,"IteratorValue");function te(w){var E=w.next();return E.done?!1:E}o(te,"IteratorStep");function re(w){var E=w.return;E&&E.call(w)}o(re,"IteratorClose");function ne(w){var E=Object.getPrototypeOf(w);if(typeof w!="function"||w===h||E!==h)return E;var _=w.prototype,C=_&&Object.getPrototypeOf(_);if(C==null||C===Object.prototype)return E;var W=C.constructor;return typeof W!="function"||W===w?E:W}o(ne,"OrdinaryGetPrototypeOf");function oe(){var w;!V(b)&&typeof t.Reflect<"u"&&!(b in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(w=le(t.Reflect));var E,_,C,W=new S,it={registerProvider:ut,getProvider:j,setProvider:U};return it;function ut(H){if(!Object.isExtensible(it))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case w===H:break;case V(E):E=H;break;case E===H:break;case V(_):_=H;break;case _===H:break;default:C===void 0&&(C=new p),C.add(H);break}}function we(H,ve){if(!V(E)){if(E.isProviderFor(H,ve))return E;if(!V(_)){if(_.isProviderFor(H,ve))return E;if(!V(C))for(var Ge=ae(C);;){var We=te(Ge);if(!We)return;var Ut=ee(We);if(Ut.isProviderFor(H,ve))return re(Ge),Ut}}}if(!V(w)&&w.isProviderFor(H,ve))return w}function j(H,ve){var Ge=W.get(H),We;return V(Ge)||(We=Ge.get(ve)),V(We)&&(We=we(H,ve),V(We)||(V(Ge)&&(Ge=new d,W.set(H,Ge)),Ge.set(ve,We))),We}function $(H){if(V(H))throw new TypeError;return E===H||_===H||!V(C)&&C.has(H)}function U(H,ve,Ge){if(!$(Ge))throw new Error("Metadata provider not registered.");var We=j(H,ve);if(We!==Ge){if(!V(We))return!1;var Ut=W.get(H);V(Ut)&&(Ut=new d,W.set(H,Ut)),Ut.set(ve,Ge)}return!0}}o(oe,"CreateMetadataRegistry");function ce(){var w;return!V(b)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&(w=t.Reflect[b]),V(w)&&(w=oe()),!V(b)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,b,{enumerable:!1,configurable:!1,writable:!1,value:w}),w}o(ce,"GetOrCreateMetadataRegistry");function ue(w){var E=new S,_={isProviderFor:o(function($,U){var H=E.get($);return V(H)?!1:H.has(U)},"isProviderFor"),OrdinaryDefineOwnMetadata:ut,OrdinaryHasOwnMetadata:W,OrdinaryGetOwnMetadata:it,OrdinaryOwnMetadataKeys:we,OrdinaryDeleteMetadata:j};return T.registerProvider(_),_;function C($,U,H){var ve=E.get($),Ge=!1;if(V(ve)){if(!H)return;ve=new d,E.set($,ve),Ge=!0}var We=ve.get(U);if(V(We)){if(!H)return;if(We=new d,ve.set(U,We),!w.setProvider($,U,_))throw ve.delete(U),Ge&&E.delete($),new Error("Wrong provider for target.")}return We}o(C,"GetOrCreateMetadataMap");function W($,U,H){var ve=C(U,H,!1);return V(ve)?!1:Te(ve.has($))}o(W,"OrdinaryHasOwnMetadata");function it($,U,H){var ve=C(U,H,!1);if(!V(ve))return ve.get($)}o(it,"OrdinaryGetOwnMetadata");function ut($,U,H,ve){var Ge=C(H,ve,!0);Ge.set($,U)}o(ut,"OrdinaryDefineOwnMetadata");function we($,U){var H=[],ve=C($,U,!1);if(V(ve))return H;for(var Ge=ve.keys(),We=ae(Ge),Ut=0;;){var Or=te(We);if(!Or)return H.length=Ut,H;var $r=ee(Or);try{H[Ut]=$r}catch(hr){try{re(We)}finally{throw hr}}Ut++}}o(we,"OrdinaryOwnMetadataKeys");function j($,U,H){var ve=C(U,H,!1);if(V(ve)||!ve.delete($))return!1;if(ve.size===0){var Ge=E.get(U);V(Ge)||(Ge.delete(H),Ge.size===0&&E.delete(Ge))}return!0}o(j,"OrdinaryDeleteMetadata")}o(ue,"CreateMetadataProvider");function le(w){var E=w.defineMetadata,_=w.hasOwnMetadata,C=w.getOwnMetadata,W=w.getOwnMetadataKeys,it=w.deleteMetadata,ut=new S,we={isProviderFor:o(function(j,$){var U=ut.get(j);return!V(U)&&U.has($)?!0:W(j,$).length?(V(U)&&(U=new p,ut.set(j,U)),U.add($),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:E,OrdinaryHasOwnMetadata:_,OrdinaryGetOwnMetadata:C,OrdinaryOwnMetadataKeys:W,OrdinaryDeleteMetadata:it};return we}o(le,"CreateFallbackProvider");function X(w,E,_){var C=T.getProvider(w,E);if(!V(C))return C;if(_){if(T.setProvider(w,E,I))return I;throw new Error("Illegal state.")}}o(X,"GetMetadataProvider");function fe(){var w={},E=[],_=(function(){function we(j,$,U){this._index=0,this._keys=j,this._values=$,this._selector=U}return o(we,"MapIterator"),we.prototype["@@iterator"]=function(){return this},we.prototype[a]=function(){return this},we.prototype.next=function(){var j=this._index;if(j>=0&&j<this._keys.length){var $=this._selector(this._keys[j],this._values[j]);return j+1>=this._keys.length?(this._index=-1,this._keys=E,this._values=E):this._index++,{value:$,done:!1}}return{value:void 0,done:!0}},we.prototype.throw=function(j){throw this._index>=0&&(this._index=-1,this._keys=E,this._values=E),j},we.prototype.return=function(j){return this._index>=0&&(this._index=-1,this._keys=E,this._values=E),{value:j,done:!0}},we})(),C=(function(){function we(){this._keys=[],this._values=[],this._cacheKey=w,this._cacheIndex=-2}return o(we,"Map"),Object.defineProperty(we.prototype,"size",{get:o(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),we.prototype.has=function(j){return this._find(j,!1)>=0},we.prototype.get=function(j){var $=this._find(j,!1);return $>=0?this._values[$]:void 0},we.prototype.set=function(j,$){var U=this._find(j,!0);return this._values[U]=$,this},we.prototype.delete=function(j){var $=this._find(j,!1);if($>=0){for(var U=this._keys.length,H=$+1;H<U;H++)this._keys[H-1]=this._keys[H],this._values[H-1]=this._values[H];return this._keys.length--,this._values.length--,Z(j,this._cacheKey)&&(this._cacheKey=w,this._cacheIndex=-2),!0}return!1},we.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=w,this._cacheIndex=-2},we.prototype.keys=function(){return new _(this._keys,this._values,W)},we.prototype.values=function(){return new _(this._keys,this._values,it)},we.prototype.entries=function(){return new _(this._keys,this._values,ut)},we.prototype["@@iterator"]=function(){return this.entries()},we.prototype[a]=function(){return this.entries()},we.prototype._find=function(j,$){if(!Z(this._cacheKey,j)){this._cacheIndex=-1;for(var U=0;U<this._keys.length;U++)if(Z(this._keys[U],j)){this._cacheIndex=U;break}}return this._cacheIndex<0&&$&&(this._cacheIndex=this._keys.length,this._keys.push(j),this._values.push(void 0)),this._cacheIndex},we})();return C;function W(we,j){return we}function it(we,j){return j}function ut(we,j){return[we,j]}}o(fe,"CreateMapPolyfill");function $e(){var w=(function(){function E(){this._map=new d}return o(E,"Set"),Object.defineProperty(E.prototype,"size",{get:o(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),E.prototype.has=function(_){return this._map.has(_)},E.prototype.add=function(_){return this._map.set(_,_),this},E.prototype.delete=function(_){return this._map.delete(_)},E.prototype.clear=function(){this._map.clear()},E.prototype.keys=function(){return this._map.keys()},E.prototype.values=function(){return this._map.keys()},E.prototype.entries=function(){return this._map.entries()},E.prototype["@@iterator"]=function(){return this.keys()},E.prototype[a]=function(){return this.keys()},E})();return w}o($e,"CreateSetPolyfill");function Fe(){var w=16,E=f.create(),_=C();return(function(){function j(){this._key=C()}return o(j,"WeakMap"),j.prototype.has=function($){var U=W($,!1);return U!==void 0?f.has(U,this._key):!1},j.prototype.get=function($){var U=W($,!1);return U!==void 0?f.get(U,this._key):void 0},j.prototype.set=function($,U){var H=W($,!0);return H[this._key]=U,this},j.prototype.delete=function($){var U=W($,!1);return U!==void 0?delete U[this._key]:!1},j.prototype.clear=function(){this._key=C()},j})();function C(){var j;do j="@@WeakMap@@"+we();while(f.has(E,j));return E[j]=!0,j}function W(j,$){if(!r.call(j,_)){if(!$)return;Object.defineProperty(j,_,{value:f.create()})}return j[_]}function it(j,$){for(var U=0;U<$;++U)j[U]=Math.random()*255|0;return j}function ut(j){if(typeof Uint8Array=="function"){var $=new Uint8Array(j);return typeof crypto<"u"?crypto.getRandomValues($):typeof msCrypto<"u"?msCrypto.getRandomValues($):it($,j),$}return it(new Array(j),j)}function we(){var j=ut(w);j[6]=j[6]&79|64,j[8]=j[8]&191|128;for(var $="",U=0;U<w;++U){var H=j[U];(U===4||U===6||U===8)&&($+="-"),H<16&&($+="0"),$+=H.toString(16).toLowerCase()}return $}}o(Fe,"CreateWeakMapPolyfill");function be(w){return w.__=void 0,delete w.__,w}o(be,"MakeDictionary")})})(_2||(_2={}))});var ic=v(Nd=>{var Yu=class extends Error{static{o(this,"CommanderError")}constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Fd=class extends Yu{static{o(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Nd.CommanderError=Yu;Nd.InvalidArgumentError=Fd});var Ku=v(kd=>{var{InvalidArgumentError:PA}=ic(),Ld=class{static{o(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new PA(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function DA(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}o(DA,"humanReadableArgName");kd.Argument=Ld;kd.humanReadableArgName=DA});var $d=v(jd=>{var{humanReadableArgName:RA}=Ku(),Md=class{static{o(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=o(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>RA(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatItemList(e,t,r){return t.length===0?[]:[r.styleTitle(e),...t,""]}groupItems(e,t,r){let i=new Map;return e.forEach(s=>{let a=r(s);i.has(a)||i.set(a,[])}),t.forEach(s=>{let a=r(s);i.has(a)||i.set(a,[]),i.get(a).push(s)}),i}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth??80;function s(h,d){return t.formatItem(h,r,d,t)}o(s,"callFormatItem");let a=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(c),i),""]));let u=t.visibleArguments(e).map(h=>s(t.styleArgumentTerm(t.argumentTerm(h)),t.styleArgumentDescription(t.argumentDescription(h))));if(a=a.concat(this.formatItemList("Arguments:",u,t)),this.groupItems(e.options,t.visibleOptions(e),h=>h.helpGroupHeading??"Options:").forEach((h,d)=>{let p=h.map(S=>s(t.styleOptionTerm(t.optionTerm(S)),t.styleOptionDescription(t.optionDescription(S))));a=a.concat(this.formatItemList(d,p,t))}),t.showGlobalOptions){let h=t.visibleGlobalOptions(e).map(d=>s(t.styleOptionTerm(t.optionTerm(d)),t.styleOptionDescription(t.optionDescription(d))));a=a.concat(this.formatItemList("Global Options:",h,t))}return this.groupItems(e.commands,t.visibleCommands(e),h=>h.helpGroup()||"Commands:").forEach((h,d)=>{let p=h.map(S=>s(t.styleSubcommandTerm(t.subcommandTerm(S)),t.styleSubcommandDescription(t.subcommandDescription(S))));a=a.concat(this.formatItemList(d,p,t))}),a.join(`
|
|
7
|
-
`)}displayWidth(e){return
|
|
6
|
+
"use strict";var xA=Object.create;var nc=Object.defineProperty;var CA=Object.getOwnPropertyDescriptor;var IA=Object.getOwnPropertyNames;var OA=Object.getPrototypeOf,PA=Object.prototype.hasOwnProperty;var o=(n,e)=>nc(n,"name",{value:e,configurable:!0});var DA=(n,e)=>()=>(n&&(e=n(n=0)),e);var v=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),RA=(n,e)=>{for(var t in e)nc(n,t,{get:e[t],enumerable:!0})},b2=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of IA(e))!PA.call(n,i)&&i!==t&&nc(n,i,{get:()=>e[i],enumerable:!(r=CA(e,i))||r.enumerable});return n};var Ne=(n,e,t)=>(t=n!=null?xA(OA(n)):{},b2(e||!n||!n.__esModule?nc(t,"default",{value:n,enumerable:!0}):t,n)),Fd=n=>b2(nc({},"__esModule",{value:!0}),n);var Qu=v(()=>{var w2;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(n);typeof t.Reflect<"u"&&(r=i(t.Reflect,r)),e(r,t),typeof t.Reflect>"u"&&(t.Reflect=n);function i(u,l){return function(f,h){Object.defineProperty(u,f,{configurable:!0,writable:!0,value:h}),l&&l(f,h)}}o(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}o(s,"functionThis");function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}o(a,"indirectEvalThis");function c(){return s()||a()}o(c,"sloppyModeThis")})(function(e,t){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",u={__proto__:[]}instanceof Array,l=!c&&!u,f={create:c?function(){return be(Object.create(null))}:u?function(){return be({__proto__:null})}:function(){return be({})},has:l?function(w,E){return r.call(w,E)}:function(w,E){return E in w},get:l?function(w,E){return r.call(w,E)?w[E]:void 0}:function(w,E){return w[E]}},h=Object.getPrototypeOf(Function),d=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:fe(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:$e(),S=typeof WeakMap=="function"?WeakMap:Fe(),b=i?Symbol.for("@reflect-metadata:registry"):void 0,T=ce(),I=ue(T);function O(w,E,_,C){if(V(_)){if(!Ae(w))throw new TypeError;if(!xe(E))throw new TypeError;return nt(w,E)}else{if(!Ae(w))throw new TypeError;if(!z(E))throw new TypeError;if(!z(C)&&!V(C)&&!me(C))throw new TypeError;return me(C)&&(C=void 0),_=he(_),Ke(w,E,_,C)}}o(O,"decorate"),e("decorate",O);function L(w,E){function _(C,W){if(!z(C))throw new TypeError;if(!V(W)&&!Re(W))throw new TypeError;Q(w,E,C,W)}return o(_,"decorator"),_}o(L,"metadata"),e("metadata",L);function M(w,E,_,C){if(!z(_))throw new TypeError;return V(C)||(C=he(C)),Q(w,E,_,C)}o(M,"defineMetadata"),e("defineMetadata",M);function G(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),at(w,E,_)}o(G,"hasMetadata"),e("hasMetadata",G);function Ee(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),Ue(w,E,_)}o(Ee,"hasOwnMetadata"),e("hasOwnMetadata",Ee);function je(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),Be(w,E,_)}o(je,"getMetadata"),e("getMetadata",je);function Me(w,E,_){if(!z(E))throw new TypeError;return V(_)||(_=he(_)),ke(w,E,_)}o(Me,"getOwnMetadata"),e("getOwnMetadata",Me);function q(w,E){if(!z(w))throw new TypeError;return V(E)||(E=he(E)),k(w,E)}o(q,"getMetadataKeys"),e("getMetadataKeys",q);function ie(w,E){if(!z(w))throw new TypeError;return V(E)||(E=he(E)),qe(w,E)}o(ie,"getOwnMetadataKeys"),e("getOwnMetadataKeys",ie);function Se(w,E,_){if(!z(E))throw new TypeError;if(V(_)||(_=he(_)),!z(E))throw new TypeError;V(_)||(_=he(_));var C=X(E,_,!1);return V(C)?!1:C.OrdinaryDeleteMetadata(w,E,_)}o(Se,"deleteMetadata"),e("deleteMetadata",Se);function nt(w,E){for(var _=w.length-1;_>=0;--_){var C=w[_],W=C(E);if(!V(W)&&!me(W)){if(!xe(W))throw new TypeError;E=W}}return E}o(nt,"DecorateConstructor");function Ke(w,E,_,C){for(var W=w.length-1;W>=0;--W){var it=w[W],ut=it(E,_,C);if(!V(ut)&&!me(ut)){if(!z(ut))throw new TypeError;C=ut}}return C}o(Ke,"DecorateProperty");function at(w,E,_){var C=Ue(w,E,_);if(C)return!0;var W=ne(E);return me(W)?!1:at(w,W,_)}o(at,"OrdinaryHasMetadata");function Ue(w,E,_){var C=X(E,_,!1);return V(C)?!1:Te(C.OrdinaryHasOwnMetadata(w,E,_))}o(Ue,"OrdinaryHasOwnMetadata");function Be(w,E,_){var C=Ue(w,E,_);if(C)return ke(w,E,_);var W=ne(E);if(!me(W))return Be(w,W,_)}o(Be,"OrdinaryGetMetadata");function ke(w,E,_){var C=X(E,_,!1);if(!V(C))return C.OrdinaryGetOwnMetadata(w,E,_)}o(ke,"OrdinaryGetOwnMetadata");function Q(w,E,_,C){var W=X(_,C,!0);W.OrdinaryDefineOwnMetadata(w,E,_,C)}o(Q,"OrdinaryDefineOwnMetadata");function k(w,E){var _=qe(w,E),C=ne(w);if(C===null)return _;var W=k(C,E);if(W.length<=0)return _;if(_.length<=0)return W;for(var it=new p,ut=[],we=0,j=_;we<j.length;we++){var $=j[we],U=it.has($);U||(it.add($),ut.push($))}for(var H=0,ve=W;H<ve.length;H++){var $=ve[H],U=it.has($);U||(it.add($),ut.push($))}return ut}o(k,"OrdinaryMetadataKeys");function qe(w,E){var _=X(w,E,!1);return _?_.OrdinaryOwnMetadataKeys(w,E):[]}o(qe,"OrdinaryOwnMetadataKeys");function Xe(w){if(w===null)return 1;switch(typeof w){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return w===null?1:6;default:return 6}}o(Xe,"Type");function V(w){return w===void 0}o(V,"IsUndefined");function me(w){return w===null}o(me,"IsNull");function Ie(w){return typeof w=="symbol"}o(Ie,"IsSymbol");function z(w){return typeof w=="object"?w!==null:typeof w=="function"}o(z,"IsObject");function Oe(w,E){switch(Xe(w)){case 0:return w;case 1:return w;case 2:return w;case 3:return w;case 4:return w;case 5:return w}var _=E===3?"string":E===5?"number":"default",C=se(w,s);if(C!==void 0){var W=C.call(w,_);if(z(W))throw new TypeError;return W}return Pe(w,_==="default"?"number":_)}o(Oe,"ToPrimitive");function Pe(w,E){if(E==="string"){var _=w.toString;if(ge(_)){var C=_.call(w);if(!z(C))return C}var W=w.valueOf;if(ge(W)){var C=W.call(w);if(!z(C))return C}}else{var W=w.valueOf;if(ge(W)){var C=W.call(w);if(!z(C))return C}var it=w.toString;if(ge(it)){var C=it.call(w);if(!z(C))return C}}throw new TypeError}o(Pe,"OrdinaryToPrimitive");function Te(w){return!!w}o(Te,"ToBoolean");function De(w){return""+w}o(De,"ToString");function he(w){var E=Oe(w,3);return Ie(E)?E:De(E)}o(he,"ToPropertyKey");function Ae(w){return Array.isArray?Array.isArray(w):w instanceof Object?w instanceof Array:Object.prototype.toString.call(w)==="[object Array]"}o(Ae,"IsArray");function ge(w){return typeof w=="function"}o(ge,"IsCallable");function xe(w){return typeof w=="function"}o(xe,"IsConstructor");function Re(w){switch(Xe(w)){case 3:return!0;case 4:return!0;default:return!1}}o(Re,"IsPropertyKey");function Z(w,E){return w===E||w!==w&&E!==E}o(Z,"SameValueZero");function se(w,E){var _=w[E];if(_!=null){if(!ge(_))throw new TypeError;return _}}o(se,"GetMethod");function ae(w){var E=se(w,a);if(!ge(E))throw new TypeError;var _=E.call(w);if(!z(_))throw new TypeError;return _}o(ae,"GetIterator");function ee(w){return w.value}o(ee,"IteratorValue");function te(w){var E=w.next();return E.done?!1:E}o(te,"IteratorStep");function re(w){var E=w.return;E&&E.call(w)}o(re,"IteratorClose");function ne(w){var E=Object.getPrototypeOf(w);if(typeof w!="function"||w===h||E!==h)return E;var _=w.prototype,C=_&&Object.getPrototypeOf(_);if(C==null||C===Object.prototype)return E;var W=C.constructor;return typeof W!="function"||W===w?E:W}o(ne,"OrdinaryGetPrototypeOf");function oe(){var w;!V(b)&&typeof t.Reflect<"u"&&!(b in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(w=le(t.Reflect));var E,_,C,W=new S,it={registerProvider:ut,getProvider:j,setProvider:U};return it;function ut(H){if(!Object.isExtensible(it))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case w===H:break;case V(E):E=H;break;case E===H:break;case V(_):_=H;break;case _===H:break;default:C===void 0&&(C=new p),C.add(H);break}}function we(H,ve){if(!V(E)){if(E.isProviderFor(H,ve))return E;if(!V(_)){if(_.isProviderFor(H,ve))return E;if(!V(C))for(var Ge=ae(C);;){var We=te(Ge);if(!We)return;var Ut=ee(We);if(Ut.isProviderFor(H,ve))return re(Ge),Ut}}}if(!V(w)&&w.isProviderFor(H,ve))return w}function j(H,ve){var Ge=W.get(H),We;return V(Ge)||(We=Ge.get(ve)),V(We)&&(We=we(H,ve),V(We)||(V(Ge)&&(Ge=new d,W.set(H,Ge)),Ge.set(ve,We))),We}function $(H){if(V(H))throw new TypeError;return E===H||_===H||!V(C)&&C.has(H)}function U(H,ve,Ge){if(!$(Ge))throw new Error("Metadata provider not registered.");var We=j(H,ve);if(We!==Ge){if(!V(We))return!1;var Ut=W.get(H);V(Ut)&&(Ut=new d,W.set(H,Ut)),Ut.set(ve,Ge)}return!0}}o(oe,"CreateMetadataRegistry");function ce(){var w;return!V(b)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&(w=t.Reflect[b]),V(w)&&(w=oe()),!V(b)&&z(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,b,{enumerable:!1,configurable:!1,writable:!1,value:w}),w}o(ce,"GetOrCreateMetadataRegistry");function ue(w){var E=new S,_={isProviderFor:o(function($,U){var H=E.get($);return V(H)?!1:H.has(U)},"isProviderFor"),OrdinaryDefineOwnMetadata:ut,OrdinaryHasOwnMetadata:W,OrdinaryGetOwnMetadata:it,OrdinaryOwnMetadataKeys:we,OrdinaryDeleteMetadata:j};return T.registerProvider(_),_;function C($,U,H){var ve=E.get($),Ge=!1;if(V(ve)){if(!H)return;ve=new d,E.set($,ve),Ge=!0}var We=ve.get(U);if(V(We)){if(!H)return;if(We=new d,ve.set(U,We),!w.setProvider($,U,_))throw ve.delete(U),Ge&&E.delete($),new Error("Wrong provider for target.")}return We}o(C,"GetOrCreateMetadataMap");function W($,U,H){var ve=C(U,H,!1);return V(ve)?!1:Te(ve.has($))}o(W,"OrdinaryHasOwnMetadata");function it($,U,H){var ve=C(U,H,!1);if(!V(ve))return ve.get($)}o(it,"OrdinaryGetOwnMetadata");function ut($,U,H,ve){var Ge=C(H,ve,!0);Ge.set($,U)}o(ut,"OrdinaryDefineOwnMetadata");function we($,U){var H=[],ve=C($,U,!1);if(V(ve))return H;for(var Ge=ve.keys(),We=ae(Ge),Ut=0;;){var Or=te(We);if(!Or)return H.length=Ut,H;var $r=ee(Or);try{H[Ut]=$r}catch(hr){try{re(We)}finally{throw hr}}Ut++}}o(we,"OrdinaryOwnMetadataKeys");function j($,U,H){var ve=C(U,H,!1);if(V(ve)||!ve.delete($))return!1;if(ve.size===0){var Ge=E.get(U);V(Ge)||(Ge.delete(H),Ge.size===0&&E.delete(Ge))}return!0}o(j,"OrdinaryDeleteMetadata")}o(ue,"CreateMetadataProvider");function le(w){var E=w.defineMetadata,_=w.hasOwnMetadata,C=w.getOwnMetadata,W=w.getOwnMetadataKeys,it=w.deleteMetadata,ut=new S,we={isProviderFor:o(function(j,$){var U=ut.get(j);return!V(U)&&U.has($)?!0:W(j,$).length?(V(U)&&(U=new p,ut.set(j,U)),U.add($),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:E,OrdinaryHasOwnMetadata:_,OrdinaryGetOwnMetadata:C,OrdinaryOwnMetadataKeys:W,OrdinaryDeleteMetadata:it};return we}o(le,"CreateFallbackProvider");function X(w,E,_){var C=T.getProvider(w,E);if(!V(C))return C;if(_){if(T.setProvider(w,E,I))return I;throw new Error("Illegal state.")}}o(X,"GetMetadataProvider");function fe(){var w={},E=[],_=(function(){function we(j,$,U){this._index=0,this._keys=j,this._values=$,this._selector=U}return o(we,"MapIterator"),we.prototype["@@iterator"]=function(){return this},we.prototype[a]=function(){return this},we.prototype.next=function(){var j=this._index;if(j>=0&&j<this._keys.length){var $=this._selector(this._keys[j],this._values[j]);return j+1>=this._keys.length?(this._index=-1,this._keys=E,this._values=E):this._index++,{value:$,done:!1}}return{value:void 0,done:!0}},we.prototype.throw=function(j){throw this._index>=0&&(this._index=-1,this._keys=E,this._values=E),j},we.prototype.return=function(j){return this._index>=0&&(this._index=-1,this._keys=E,this._values=E),{value:j,done:!0}},we})(),C=(function(){function we(){this._keys=[],this._values=[],this._cacheKey=w,this._cacheIndex=-2}return o(we,"Map"),Object.defineProperty(we.prototype,"size",{get:o(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),we.prototype.has=function(j){return this._find(j,!1)>=0},we.prototype.get=function(j){var $=this._find(j,!1);return $>=0?this._values[$]:void 0},we.prototype.set=function(j,$){var U=this._find(j,!0);return this._values[U]=$,this},we.prototype.delete=function(j){var $=this._find(j,!1);if($>=0){for(var U=this._keys.length,H=$+1;H<U;H++)this._keys[H-1]=this._keys[H],this._values[H-1]=this._values[H];return this._keys.length--,this._values.length--,Z(j,this._cacheKey)&&(this._cacheKey=w,this._cacheIndex=-2),!0}return!1},we.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=w,this._cacheIndex=-2},we.prototype.keys=function(){return new _(this._keys,this._values,W)},we.prototype.values=function(){return new _(this._keys,this._values,it)},we.prototype.entries=function(){return new _(this._keys,this._values,ut)},we.prototype["@@iterator"]=function(){return this.entries()},we.prototype[a]=function(){return this.entries()},we.prototype._find=function(j,$){if(!Z(this._cacheKey,j)){this._cacheIndex=-1;for(var U=0;U<this._keys.length;U++)if(Z(this._keys[U],j)){this._cacheIndex=U;break}}return this._cacheIndex<0&&$&&(this._cacheIndex=this._keys.length,this._keys.push(j),this._values.push(void 0)),this._cacheIndex},we})();return C;function W(we,j){return we}function it(we,j){return j}function ut(we,j){return[we,j]}}o(fe,"CreateMapPolyfill");function $e(){var w=(function(){function E(){this._map=new d}return o(E,"Set"),Object.defineProperty(E.prototype,"size",{get:o(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),E.prototype.has=function(_){return this._map.has(_)},E.prototype.add=function(_){return this._map.set(_,_),this},E.prototype.delete=function(_){return this._map.delete(_)},E.prototype.clear=function(){this._map.clear()},E.prototype.keys=function(){return this._map.keys()},E.prototype.values=function(){return this._map.keys()},E.prototype.entries=function(){return this._map.entries()},E.prototype["@@iterator"]=function(){return this.keys()},E.prototype[a]=function(){return this.keys()},E})();return w}o($e,"CreateSetPolyfill");function Fe(){var w=16,E=f.create(),_=C();return(function(){function j(){this._key=C()}return o(j,"WeakMap"),j.prototype.has=function($){var U=W($,!1);return U!==void 0?f.has(U,this._key):!1},j.prototype.get=function($){var U=W($,!1);return U!==void 0?f.get(U,this._key):void 0},j.prototype.set=function($,U){var H=W($,!0);return H[this._key]=U,this},j.prototype.delete=function($){var U=W($,!1);return U!==void 0?delete U[this._key]:!1},j.prototype.clear=function(){this._key=C()},j})();function C(){var j;do j="@@WeakMap@@"+we();while(f.has(E,j));return E[j]=!0,j}function W(j,$){if(!r.call(j,_)){if(!$)return;Object.defineProperty(j,_,{value:f.create()})}return j[_]}function it(j,$){for(var U=0;U<$;++U)j[U]=Math.random()*255|0;return j}function ut(j){if(typeof Uint8Array=="function"){var $=new Uint8Array(j);return typeof crypto<"u"?crypto.getRandomValues($):typeof msCrypto<"u"?msCrypto.getRandomValues($):it($,j),$}return it(new Array(j),j)}function we(){var j=ut(w);j[6]=j[6]&79|64,j[8]=j[8]&191|128;for(var $="",U=0;U<w;++U){var H=j[U];(U===4||U===6||U===8)&&($+="-"),H<16&&($+="0"),$+=H.toString(16).toLowerCase()}return $}}o(Fe,"CreateWeakMapPolyfill");function be(w){return w.__=void 0,delete w.__,w}o(be,"MakeDictionary")})})(w2||(w2={}))});var ic=v(Ld=>{var Yu=class extends Error{static{o(this,"CommanderError")}constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Nd=class extends Yu{static{o(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Ld.CommanderError=Yu;Ld.InvalidArgumentError=Nd});var Ku=v(Md=>{var{InvalidArgumentError:FA}=ic(),kd=class{static{o(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new FA(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function NA(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}o(NA,"humanReadableArgName");Md.Argument=kd;Md.humanReadableArgName=NA});var Vd=v($d=>{var{humanReadableArgName:LA}=Ku(),jd=class{static{o(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=o(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>LA(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatItemList(e,t,r){return t.length===0?[]:[r.styleTitle(e),...t,""]}groupItems(e,t,r){let i=new Map;return e.forEach(s=>{let a=r(s);i.has(a)||i.set(a,[])}),t.forEach(s=>{let a=r(s);i.has(a)||i.set(a,[]),i.get(a).push(s)}),i}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth??80;function s(h,d){return t.formatItem(h,r,d,t)}o(s,"callFormatItem");let a=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(c),i),""]));let u=t.visibleArguments(e).map(h=>s(t.styleArgumentTerm(t.argumentTerm(h)),t.styleArgumentDescription(t.argumentDescription(h))));if(a=a.concat(this.formatItemList("Arguments:",u,t)),this.groupItems(e.options,t.visibleOptions(e),h=>h.helpGroupHeading??"Options:").forEach((h,d)=>{let p=h.map(S=>s(t.styleOptionTerm(t.optionTerm(S)),t.styleOptionDescription(t.optionDescription(S))));a=a.concat(this.formatItemList(d,p,t))}),t.showGlobalOptions){let h=t.visibleGlobalOptions(e).map(d=>s(t.styleOptionTerm(t.optionTerm(d)),t.styleOptionDescription(t.optionDescription(d))));a=a.concat(this.formatItemList("Global Options:",h,t))}return this.groupItems(e.commands,t.visibleCommands(e),h=>h.helpGroup()||"Commands:").forEach((h,d)=>{let p=h.map(S=>s(t.styleSubcommandTerm(t.subcommandTerm(S)),t.styleSubcommandDescription(t.subcommandDescription(S))));a=a.concat(this.formatItemList(d,p,t))}),a.join(`
|
|
7
|
+
`)}displayWidth(e){return E2(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,i){let a=" ".repeat(2);if(!r)return a+e;let c=e.padEnd(t+e.length-i.displayWidth(e)),u=2,f=(this.helpWidth??80)-t-u-2,h;return f<this.minWidthToWrap||i.preformatted(r)?h=r:h=i.boxWrap(r,f).replace(/\n/g,`
|
|
8
8
|
`+" ".repeat(t+u)),a+c+" ".repeat(u)+h.replace(/\n/g,`
|
|
9
9
|
${a}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return r.forEach(a=>{let c=a.match(i);if(c===null){s.push("");return}let u=[c.shift()],l=this.displayWidth(u[0]);c.forEach(f=>{let h=this.displayWidth(f);if(l+h<=t){u.push(f),l+=h;return}s.push(u.join(""));let d=f.trimStart();u=[d],l=this.displayWidth(d)}),s.push(u.join(""))}),s.join(`
|
|
10
|
-
`)}};function
|
|
10
|
+
`)}};function E2(n){let e=/\x1b\[\d*(;\d*)*m/g;return n.replace(e,"")}o(E2,"stripColor");$d.Help=jd;$d.stripColor=E2});var Gd=v(qd=>{var{InvalidArgumentError:kA}=ic(),Ud=class{static{o(this,"Option")}constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=MA(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new kA(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?T2(this.name().replace(/^no-/,"")):T2(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Bd=class{static{o(this,"DualOptions")}constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let i=this.negativeOptions.get(r).presetArg,s=i!==void 0?i:!1;return t.negate===(s===e)}};function T2(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}o(T2,"camelcase");function MA(n){let e,t,r=/^-[^-]$/,i=/^--[^-]/,s=n.split(/[ |,]+/).concat("guard");if(r.test(s[0])&&(e=s.shift()),i.test(s[0])&&(t=s.shift()),!e&&r.test(s[0])&&(e=s.shift()),!e&&i.test(s[0])&&(e=t,t=s.shift()),s[0].startsWith("-")){let a=s[0],c=`option creation failed due to '${a}' in option flags '${n}'`;throw/^-[^-][^-]/.test(a)?new Error(`${c}
|
|
11
11
|
- a short flag is a single dash and a single character
|
|
12
12
|
- either use a single dash and a single character (for a short flag)
|
|
13
13
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(a)?new Error(`${c}
|
|
14
14
|
- too many short flags`):i.test(a)?new Error(`${c}
|
|
15
15
|
- too many long flags`):new Error(`${c}
|
|
16
|
-
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:e,longFlag:t}}o(
|
|
16
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:e,longFlag:t}}o(MA,"splitOptionFlags");qd.Option=Ud;qd.DualOptions=Bd});var x2=v(A2=>{function jA(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let r=0;r<=n.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let i=1;i<=n.length;i++){let s=1;n[i-1]===e[r-1]?s=0:s=1,t[i][r]=Math.min(t[i-1][r]+1,t[i][r-1]+1,t[i-1][r-1]+s),i>1&&r>1&&n[i-1]===e[r-2]&&n[i-2]===e[r-1]&&(t[i][r]=Math.min(t[i][r],t[i-2][r-2]+1))}return t[n.length][e.length]}o(jA,"editDistance");function $A(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(a=>a.slice(2)));let r=[],i=3,s=.4;return e.forEach(a=>{if(a.length<=1)return;let c=jA(n,a),u=Math.max(n.length,a.length);(u-c)/u>s&&(c<i?(i=c,r=[a]):c===i&&r.push(a))}),r.sort((a,c)=>a.localeCompare(c)),t&&(r=r.map(a=>`--${a}`)),r.length>1?`
|
|
17
17
|
(Did you mean one of ${r.join(", ")}?)`:r.length===1?`
|
|
18
|
-
(Did you mean ${r[0]}?)`:""}o(
|
|
19
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new
|
|
20
|
-
Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new
|
|
21
|
-
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=o(i=>[i.name()].concat(i.aliases()),"knownBy"),r=t(e).find(i=>this._findCommand(i));if(r){let i=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let i=o((s,a,c)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let u=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,u,a):s!==null&&e.variadic&&(s=e._collectValue(s,u)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,c)},"handleOptionValue");return this.on("option:"+t,s=>{let a=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let a=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,a,"env")}),this}_optionEx(e,t,r,i,s){if(typeof t=="object"&&t instanceof
|
|
18
|
+
(Did you mean ${r[0]}?)`:""}o($A,"suggestSimilar");A2.suggestSimilar=$A});var P2=v(Yd=>{var VA=require("node:events").EventEmitter,Wd=require("node:child_process"),Ai=require("node:path"),Xu=require("node:fs"),ze=require("node:process"),{Argument:UA,humanReadableArgName:BA}=Ku(),{CommanderError:Hd}=ic(),{Help:qA,stripColor:GA}=Vd(),{Option:C2,DualOptions:WA}=Gd(),{suggestSimilar:I2}=x2(),zd=class n extends VA{static{o(this,"Command")}constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:o(t=>ze.stdout.write(t),"writeOut"),writeErr:o(t=>ze.stderr.write(t),"writeErr"),outputError:o((t,r)=>r(t),"outputError"),getOutHelpWidth:o(()=>ze.stdout.isTTY?ze.stdout.columns:void 0,"getOutHelpWidth"),getErrHelpWidth:o(()=>ze.stderr.isTTY?ze.stderr.columns:void 0,"getErrHelpWidth"),getOutHasColors:o(()=>Qd()??(ze.stdout.isTTY&&ze.stdout.hasColors?.()),"getOutHasColors"),getErrHasColors:o(()=>Qd()??(ze.stderr.isTTY&&ze.stderr.hasColors?.()),"getErrHasColors"),stripColor:o(t=>GA(t),"stripColor")},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let i=t,s=r;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,a,c]=e.match(/([^ ]+) *(.*)/),u=this.createCommand(a);return i&&(u.description(i),u._executableHandler=!0),s.isDefault&&(this._defaultCommandName=u._name),u._hidden=!!(s.noHelp||s.hidden),u._executableFile=s.executableFile||null,c&&u.arguments(c),this._registerCommand(u),u.parent=this,u.copyInheritedSettings(this),i?this:u}createCommand(e){return new n(e)}createHelp(){return Object.assign(new qA,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
19
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new UA(e,t)}argument(e,t,r,i){let s=this.createArgument(e,t);return typeof r=="function"?s.default(i).argParser(r):s.default(r),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let r=e??"help [command]",[,i,s]=r.match(/([^ ]+) *(.*)/),a=t??"display help for command",c=this.createCommand(i);return c.helpOption(!1),s&&c.arguments(s),a&&c.description(a),this._addImplicitHelpCommand=!0,this._helpCommand=c,(e||t)&&this._initCommandGroup(c),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
20
|
+
Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new Hd(e,t,r)),ze.exit(e)}action(e){let t=o(r=>{let i=this.registeredArguments.length,s=r.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)},"listener");return this._actionHandler=t,this}createOption(e,t){return new C2(e,t)}_callParseArg(e,t,r,i){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let a=`${i} ${s.message}`;this.error(a,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
|
|
21
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=o(i=>[i.name()].concat(i.aliases()),"knownBy"),r=t(e).find(i=>this._findCommand(i));if(r){let i=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let i=o((s,a,c)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let u=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,u,a):s!==null&&e.variadic&&(s=e._collectValue(s,u)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,c)},"handleOptionValue");return this.on("option:"+t,s=>{let a=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let a=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,a,"env")}),this}_optionEx(e,t,r,i,s){if(typeof t=="object"&&t instanceof C2)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,r);if(a.makeOptionMandatory(!!e.mandatory),typeof i=="function")a.default(s).argParser(i);else if(i instanceof RegExp){let c=i;i=o((u,l)=>{let f=c.exec(u);return f?f[0]:l},"fn"),a.default(s).argParser(i)}else a.default(i);return this.addOption(a)}option(e,t,r,i){return this._optionEx({},e,t,r,i)}requiredOption(e,t,r,i){return this._optionEx({mandatory:!0},e,t,r,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){ze.versions?.electron&&(t.from="electron");let i=ze.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=ze.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":ze.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
22
22
|
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,r){if(Xu.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${e}' does not exist
|
|
23
23
|
- if '${r}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
24
24
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
25
|
-
- ${i}`;throw new Error(s)}_executeSubCommand(e,t){t=t.slice();let r=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function s(f,h){let d=Ai.resolve(f,h);if(Xu.existsSync(d))return d;if(i.includes(Ai.extname(h)))return;let p=i.find(S=>Xu.existsSync(`${d}${S}`));if(p)return`${d}${p}`}o(s,"findFile"),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let f;try{f=Xu.realpathSync(this._scriptPath)}catch{f=this._scriptPath}c=Ai.resolve(Ai.dirname(f),c)}if(c){let f=s(c,a);if(!f&&!e._executableFile&&this._scriptPath){let h=Ai.basename(this._scriptPath,Ai.extname(this._scriptPath));h!==this._name&&(f=s(c,`${h}-${e._name}`))}a=f||a}r=i.includes(Ai.extname(a));let u;ze.platform!=="win32"?r?(t.unshift(a),t=
|
|
25
|
+
- ${i}`;throw new Error(s)}_executeSubCommand(e,t){t=t.slice();let r=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function s(f,h){let d=Ai.resolve(f,h);if(Xu.existsSync(d))return d;if(i.includes(Ai.extname(h)))return;let p=i.find(S=>Xu.existsSync(`${d}${S}`));if(p)return`${d}${p}`}o(s,"findFile"),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let f;try{f=Xu.realpathSync(this._scriptPath)}catch{f=this._scriptPath}c=Ai.resolve(Ai.dirname(f),c)}if(c){let f=s(c,a);if(!f&&!e._executableFile&&this._scriptPath){let h=Ai.basename(this._scriptPath,Ai.extname(this._scriptPath));h!==this._name&&(f=s(c,`${h}-${e._name}`))}a=f||a}r=i.includes(Ai.extname(a));let u;ze.platform!=="win32"?r?(t.unshift(a),t=O2(ze.execArgv).concat(t),u=Wd.spawn(ze.argv[0],t,{stdio:"inherit"})):u=Wd.spawn(a,t,{stdio:"inherit"}):(this._checkForMissingExecutable(a,c,e._name),t.unshift(a),t=O2(ze.execArgv).concat(t),u=Wd.spawn(ze.execPath,t,{stdio:"inherit"})),u.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{ze.on(h,()=>{u.killed===!1&&u.exitCode===null&&u.kill(h)})});let l=this._exitCallback;u.on("close",f=>{f=f??1,l?l(new Hd(f,"commander.executeSubCommandAsync","(close)")):ze.exit(f)}),u.on("error",f=>{if(f.code==="ENOENT")this._checkForMissingExecutable(a,c,e._name);else if(f.code==="EACCES")throw new Error(`'${a}' not executable`);if(!l)ze.exit(1);else{let h=new Hd(1,"commander.executeSubCommandAsync","(error)");h.nestedError=f,l(h)}}),this.runningCommand=u}_dispatchSubcommand(e,t,r){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,i,"preSubcommand"),s=this._chainOrCall(s,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(r));else return i._parseCommand(t,r)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=o((r,i,s)=>{let a=i;if(i!==null&&r.parseArg){let c=`error: command-argument value '${i}' is invalid for argument '${r.name()}'.`;a=this._callParseArg(r,i,s,c)}return a},"myParseArg");this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,i)=>{let s=r.defaultValue;r.variadic?i<this.args.length?(s=this.args.slice(i),r.parseArg&&(s=s.reduce((a,c)=>e(r,c,a),r.defaultValue))):s===void 0&&(s=[]):i<this.args.length&&(s=this.args[i],r.parseArg&&(s=e(r,s,r.defaultValue))),t[i]=s}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,i=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(a=>{i.push({hookedCommand:s,callback:a})})}),t==="postAction"&&i.reverse(),i.forEach(s=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let i=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(s=>{i=this._chainOrCall(i,()=>s(this,t))}),i}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=o(()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},"checkForUnknownOptions"),s=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let a;return a=this._chainOrCallHooks(a,"preAction"),a=this._chainOrCall(a,()=>this._actionHandler(this.processedArgs)),this.parent&&(a=this._chainOrCall(a,()=>{this.parent.emit(s,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent?.listenerCount(s))i(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let i=r.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let i=e.find(s=>r.conflictsWith.includes(s.attributeName()));i&&this._conflictingOption(r,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],i=t;function s(f){return f.length>1&&f[0]==="-"}o(s,"maybeOption");let a=o(f=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(f)?!this._getCommandAndAncestors().some(h=>h.options.map(d=>d.short).some(d=>/^-\d$/.test(d))):!1,"negativeNumberArg"),c=null,u=null,l=0;for(;l<e.length||u;){let f=u??e[l++];if(u=null,f==="--"){i===r&&i.push(f),i.push(...e.slice(l));break}if(c&&(!s(f)||a(f))){this.emit(`option:${c.name()}`,f);continue}if(c=null,s(f)){let h=this._findOption(f);if(h){if(h.required){let d=e[l++];d===void 0&&this.optionMissingArgument(h),this.emit(`option:${h.name()}`,d)}else if(h.optional){let d=null;l<e.length&&(!s(e[l])||a(e[l]))&&(d=e[l++]),this.emit(`option:${h.name()}`,d)}else this.emit(`option:${h.name()}`);c=h.variadic?h:null;continue}}if(f.length>2&&f[0]==="-"&&f[1]!=="-"){let h=this._findOption(`-${f[1]}`);if(h){h.required||h.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${h.name()}`,f.slice(2)):(this.emit(`option:${h.name()}`),u=`-${f.slice(2)}`);continue}}if(/^--[^=]+=/.test(f)){let h=f.indexOf("="),d=this._findOption(f.slice(0,h));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,f.slice(h+1));continue}}if(i===t&&s(f)&&!(this.commands.length===0&&a(f))&&(i=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(f)){t.push(f),r.push(...e.slice(l));break}else if(this._getHelpCommand()&&f===this._getHelpCommand().name()){t.push(f,...e.slice(l));break}else if(this._defaultCommandName){r.push(f,...e.slice(l));break}}if(this._passThroughOptions){i.push(f,...e.slice(l));break}i.push(f)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let i=this.options[r].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
26
26
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
27
27
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
28
|
-
`),this.outputHelp({error:!0}));let r=t||{},i=r.exitCode||1,s=r.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in ze.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,ze.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new
|
|
29
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let i=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r
|
|
28
|
+
`),this.outputHelp({error:!0}));let r=t||{},i=r.exitCode||1,s=r.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in ze.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,ze.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new WA(this.options),t=o(r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r)),"hasCustomOptionValue");this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,r.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=o(a=>{let c=a.attributeName(),u=this.getOptionValue(c),l=this.options.find(h=>h.negate&&c===h.attributeName()),f=this.options.find(h=>!h.negate&&c===h.attributeName());return l&&(l.presetArg===void 0&&u===!1||l.presetArg!==void 0&&u===l.presetArg)?l:f||a},"findBestOptionFromValue"),i=o(a=>{let c=r(a),u=c.attributeName();return this.getOptionValueSource(u)==="env"?`environment variable '${c.envVar}'`:`option '${c.flags}'`},"getErrorMessage"),s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let a=s.createHelp().visibleOptions(s).filter(c=>c.long).map(c=>c.long);i=i.concat(a),s=s.parent}while(s&&!s._enablePositionalOptions);t=I2(e,i)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),t=I2(e,i)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let i=this.createOption(t,r);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
29
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let i=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r=>BA(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=Ai.basename(e,Ai.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});let i=t.formatHelp(this,t);return r.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,r,i,s;return t?(r=o(c=>this._outputConfiguration.writeErr(c),"baseWrite"),i=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(r=o(c=>this._outputConfiguration.writeOut(c),"baseWrite"),i=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:t,write:o(c=>(i||(c=this._outputConfiguration.stripColor(c)),r(c)),"write"),hasColors:i,helpWidth:s}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getOutputContext(e),i={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let s=this.helpInformation({error:r.error});if(t&&(s=t(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(a=>a.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(ze.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
30
30
|
Expecting one of '${r.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let a;typeof t=="function"?a=t({error:s.error,command:s.command}):a=t,a&&s.write(`${a}
|
|
31
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function C2(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],i=s[4]),t&&i!=="0"?`${t}=${r}:${parseInt(i)+1}`:e})}o(C2,"incrementNodeInspectorPort");function zd(){if(ze.env.NO_COLOR||ze.env.FORCE_COLOR==="0"||ze.env.FORCE_COLOR==="false")return!1;if(ze.env.FORCE_COLOR||ze.env.CLICOLOR_FORCE!==void 0)return!0}o(zd,"useColor");Qd.Command=Hd;Qd.useColor=zd});var R2=v(Qr=>{var{Argument:O2}=Ku(),{Command:Yd}=I2(),{CommanderError:qA,InvalidArgumentError:P2}=ic(),{Help:GA}=$d(),{Option:D2}=qd();Qr.program=new Yd;Qr.createCommand=n=>new Yd(n);Qr.createOption=(n,e)=>new D2(n,e);Qr.createArgument=(n,e)=>new O2(n,e);Qr.Command=Yd;Qr.Option=D2;Qr.Argument=O2;Qr.Help=GA;Qr.CommanderError=qA;Qr.InvalidArgumentError=P2;Qr.InvalidOptionArgumentError=P2});var Kd=v(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});Ju.AssetClass=void 0;var N2;(function(n){n.AREA="ems__Area",n.TASK="ems__Task",n.PROJECT="ems__Project",n.MEETING="ems__Meeting",n.INITIATIVE="ems__Initiative",n.TASK_PROTOTYPE="ems__TaskPrototype",n.MEETING_PROTOTYPE="ems__MeetingPrototype",n.EVENT_PROTOTYPE="exo__EventPrototype",n.PROJECT_PROTOTYPE="ems__ProjectPrototype",n.EVENT="exo__Event",n.DAILY_NOTE="pn__DailyNote",n.CONCEPT="ims__Concept",n.SESSION_START_EVENT="ems__SessionStartEvent",n.SESSION_END_EVENT="ems__SessionEndEvent",n.PROTOTYPE="exo__Prototype",n.CLASS="exo__Class"})(N2||(Ju.AssetClass=N2={}))});var Xd=v(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.EffortStatus=void 0;var L2;(function(n){n.DRAFT="ems__EffortStatusDraft",n.BACKLOG="ems__EffortStatusBacklog",n.ANALYSIS="ems__EffortStatusAnalysis",n.TODO="ems__EffortStatusToDo",n.DOING="ems__EffortStatusDoing",n.DONE="ems__EffortStatusDone",n.TRASHED="ems__EffortStatusTrashed"})(L2||(Zu.EffortStatus=L2={}))});var k2=v(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});el.hasPosition=WA;el.isFixed=HA;function WA(n){return typeof n.x=="number"&&typeof n.y=="number"}o(WA,"hasPosition");function HA(n){return n.fx!==null&&n.fx!==void 0&&n.fy!==null&&n.fy!==void 0}o(HA,"isFixed")});var M2=v(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});tl.createEmptyGraphData=zA;tl.mergeGraphData=QA;function zA(){return{nodes:[],edges:[],lastUpdated:Date.now(),version:0}}o(zA,"createEmptyGraphData");function QA(n,e){let t=new Map,r=new Set,i=[];for(let s of n.nodes)t.set(s.id,s);for(let s of e.nodes)t.set(s.id,s);for(let s of n.edges){let a=`${s.source}->${s.target}:${s.type}`;r.has(a)||(r.add(a),i.push(s))}for(let s of e.edges){let a=`${s.source}->${s.target}:${s.type}`;r.has(a)||(r.add(a),i.push(s))}return{nodes:Array.from(t.values()),edges:i,lastUpdated:Date.now(),version:Math.max(n.version??0,e.version??0)+1}}o(QA,"mergeGraphData")});var Jd=v(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.createEdgeId=YA;rl.edgesEqual=KA;function YA(n,e,t,r){let i=r?`|${r}`:"";return`${n}->${e}:${t}${i}`}o(YA,"createEdgeId");function KA(n,e){return n.source===e.source&&n.target===e.target&&n.type===e.type&&n.predicate===e.predicate}o(KA,"edgesEqual")});var Zd=v(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.BUILT_IN_EDGE_STYLES=gt.BUILT_IN_NODE_STYLES=gt.DEFAULT_EDGE_STYLE=gt.DEFAULT_NODE_STYLE=gt.RDF_TYPE_PREDICATES=void 0;gt.mergeNodeStyles=XA;gt.mergeEdgeStyles=JA;gt.extractLocalName=ZA;gt.isClassType=ex;gt.isTypePredicate=tx;gt.isSubClassPredicate=rx;gt.RDF_TYPE_PREDICATES={RDF_TYPE:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",RDFS_CLASS:"http://www.w3.org/2000/01/rdf-schema#Class",OWL_CLASS:"http://www.w3.org/2002/07/owl#Class",RDFS_SUBCLASS_OF:"http://www.w3.org/2000/01/rdf-schema#subClassOf",OWL_EQUIVALENT_CLASS:"http://www.w3.org/2002/07/owl#equivalentClass",RDFS_LABEL:"http://www.w3.org/2000/01/rdf-schema#label",RDFS_COMMENT:"http://www.w3.org/2000/01/rdf-schema#comment"};gt.DEFAULT_NODE_STYLE={color:"#6366f1",borderColor:"#4f46e5",borderWidth:2,size:30,shape:"circle",icon:"",opacity:1,shadow:!1,animation:"none"};gt.DEFAULT_EDGE_STYLE={color:"#9ca3af",width:1,lineStyle:"solid",arrow:"standard",curvature:0,opacity:.6,showLabel:!1,labelPosition:.5};gt.BUILT_IN_NODE_STYLES={"http://www.w3.org/2000/01/rdf-schema#Class":{color:"#f59e0b",shape:"diamond",size:40},"http://www.w3.org/2002/07/owl#Class":{color:"#f59e0b",shape:"diamond",size:40},ems__Task:{color:"#22c55e",shape:"circle"},ems__Project:{color:"#3b82f6",shape:"square"},ems__Area:{color:"#8b5cf6",shape:"hexagon",size:40},ems__Meeting:{color:"#ec4899",shape:"circle"},exo__Class:{color:"#f59e0b",shape:"diamond"},ims__Person:{color:"#06b6d4",shape:"circle"}};gt.BUILT_IN_EDGE_STYLES={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":{color:"#f59e0b",lineStyle:"dashed",arrow:"standard"},"http://www.w3.org/2000/01/rdf-schema#subClassOf":{color:"#8b5cf6",width:2,arrow:"triangle"},"https://exocortex.my/ontology/ems#Effort_parent":{color:"#6366f1",width:2,arrow:"standard"},"https://exocortex.my/ontology/exo#Asset_prototype":{color:"#f59e0b",lineStyle:"dashed",arrow:"circle"},"https://exocortex.my/ontology/exo#references":{color:"#22c55e",opacity:.4,arrow:"standard"}};function XA(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}o(XA,"mergeNodeStyles");function JA(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}o(JA,"mergeEdgeStyles");function ZA(n){let e=n.lastIndexOf("#"),t=n.lastIndexOf("/"),r=Math.max(e,t);return r>=0?n.substring(r+1):n}o(ZA,"extractLocalName");function ex(n){return n===gt.RDF_TYPE_PREDICATES.RDFS_CLASS||n===gt.RDF_TYPE_PREDICATES.OWL_CLASS}o(ex,"isClassType");function tx(n){return n===gt.RDF_TYPE_PREDICATES.RDF_TYPE}o(tx,"isTypePredicate");function rx(n){return n===gt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF}o(rx,"isSubClassPredicate")});var $2=v(j2=>{"use strict";Object.defineProperty(j2,"__esModule",{value:!0})});var Qe=v(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});nl.IRI=void 0;var ep=class n{static{o(this,"IRI")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("IRI cannot be empty");if(!n.isValidIRI(t))throw new Error("Invalid IRI format");this._value=t}get value(){return this._value}equals(e){return this._value===e._value}toString(){return this._value}static isValidIRI(e){if(!e||e.trim().length===0||/\s/.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=["http","https","ftp","ftps","file","mailto","tel","data","ws","wss","urn","obsidian"],i=e.match(/^([a-z][a-z0-9+.-]*?):/i);if(i){let s=i[1].toLowerCase();if(!r.includes(s))return!1}try{return new URL(e),!0}catch{return/^urn:[a-z0-9][a-z0-9-]{0,31}:[^\s]+$/i.test(e)}}};nl.IRI=ep});var lt=v(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.Literal=void 0;Rs.parseLanguageTag=V2;Rs.createDirectionalLiteral=ix;Rs.createLiteralFromLanguageTag=sx;var nx="http://www.w3.org/2001/XMLSchema#string",sc=class{static{o(this,"Literal")}constructor(e,t,r,i){if(e.length===0)throw new Error("Literal value cannot be empty");if(t&&r)throw new Error("Literal cannot have both datatype and language tag");if(i&&!r)throw new Error("Literal cannot have direction without language tag");if(i&&i!=="ltr"&&i!=="rtl")throw new Error('Direction must be "ltr" or "rtl"');this._value=e,this._datatype=t,this._language=r?r.toLowerCase():void 0,this._direction=i}get value(){return this._value}get datatype(){return this._datatype}get language(){return this._language}get direction(){return this._direction}hasDirection(){return this._direction!==void 0}equals(e){if(this._value!==e._value||this._language!==e._language||this._direction!==e._direction)return!1;let t=this.normalizedDatatype(),r=e.normalizedDatatype();return t===r}normalizedDatatype(){return!this._datatype||this._datatype.value===nx?null:this._datatype.value}toString(){let e=`"${this._value}"`;return this._datatype?e+=`^^<${this._datatype.value}>`:this._language&&(e+=`@${this._language}`,this._direction&&(e+=`--${this._direction}`)),e}};Rs.Literal=sc;function V2(n){let t=n.lastIndexOf("--");if(t===-1)return{language:n.toLowerCase()};let r=n.substring(t+2),i=n.substring(0,t);return r==="ltr"||r==="rtl"?{language:i.toLowerCase(),direction:r}:{language:n.toLowerCase()}}o(V2,"parseLanguageTag");function ix(n,e,t){return new sc(n,void 0,e,t)}o(ix,"createDirectionalLiteral");function sx(n,e){let{language:t,direction:r}=V2(e);return new sc(n,void 0,t,r)}o(sx,"createLiteralFromLanguageTag")});var Ot=v(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});sl.BlankNode=void 0;var il=class n{static{o(this,"BlankNode")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("BlankNode id cannot be empty");this._id=t}get id(){return this._id}equals(e){return this._id===e._id}toString(){return`_:${this._id}`}static generateId(){return`b${++n.counter}`}static create(){return new n(n.generateId())}};sl.BlankNode=il;il.counter=0});var Yr=v(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});al.Namespace=void 0;var U2=Qe(),gr=class{static{o(this,"Namespace")}constructor(e,t){if(e.trim().length===0)throw new Error("Namespace prefix cannot be empty");this._prefix=e,this._iri=new U2.IRI(t)}get prefix(){return this._prefix}get iri(){return this._iri}term(e){return new U2.IRI(`${this._iri.value}${e}`)}expand(e){let t=e.split(":");if(t.length!==2)return null;let[r,i]=t;return r!==this._prefix?null:this.term(i)}};al.Namespace=gr;gr.RDF=new gr("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");gr.RDFS=new gr("rdfs","http://www.w3.org/2000/01/rdf-schema#");gr.OWL=new gr("owl","http://www.w3.org/2002/07/owl#");gr.XSD=new gr("xsd","http://www.w3.org/2001/XMLSchema#");gr.EXO=new gr("exo","https://exocortex.my/ontology/exo#");gr.EMS=new gr("ems","https://exocortex.my/ontology/ems#")});var xi=v(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.Triple=void 0;var tp=Qe(),rp=lt(),np=Ot(),ip=class{static{o(this,"Triple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof tp.IRI&&t instanceof tp.IRI||e instanceof np.BlankNode&&t instanceof np.BlankNode||e instanceof rp.Literal&&t instanceof rp.Literal||this.isQuotedTriple(e)&&this.isQuotedTriple(t)?e.equals(t):!1}isQuotedTriple(e){return typeof e=="object"&&e!==null&&"termType"in e&&e.termType==="QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`${e} ${t} ${r} .`}nodeToString(e){return e instanceof tp.IRI?`<${e.value}>`:e instanceof np.BlankNode||e instanceof rp.Literal||this.isQuotedTriple(e)?e.toString():""}};ol.Triple=ip});var ac=v(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});cl.QuotedTriple=void 0;var sp=Qe(),ap=lt(),op=Ot(),cp=class n{static{o(this,"QuotedTriple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof sp.IRI&&t instanceof sp.IRI||e instanceof op.BlankNode&&t instanceof op.BlankNode||e instanceof ap.Literal&&t instanceof ap.Literal||e instanceof n&&t instanceof n?e.equals(t):!1}get termType(){return"QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`<< ${e} ${t} ${r} >>`}nodeToString(e){return e instanceof sp.IRI?`<${e.value}>`:e instanceof op.BlankNode||e instanceof ap.Literal||e instanceof n?e.toString():""}};cl.QuotedTriple=cp});var B2=v(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.QuotedTriple=At.Triple=At.Namespace=At.BlankNode=At.createLiteralFromLanguageTag=At.createDirectionalLiteral=At.parseLanguageTag=At.Literal=At.IRI=void 0;var ax=Qe();Object.defineProperty(At,"IRI",{enumerable:!0,get:o(function(){return ax.IRI},"get")});var ul=lt();Object.defineProperty(At,"Literal",{enumerable:!0,get:o(function(){return ul.Literal},"get")});Object.defineProperty(At,"parseLanguageTag",{enumerable:!0,get:o(function(){return ul.parseLanguageTag},"get")});Object.defineProperty(At,"createDirectionalLiteral",{enumerable:!0,get:o(function(){return ul.createDirectionalLiteral},"get")});Object.defineProperty(At,"createLiteralFromLanguageTag",{enumerable:!0,get:o(function(){return ul.createLiteralFromLanguageTag},"get")});var ox=Ot();Object.defineProperty(At,"BlankNode",{enumerable:!0,get:o(function(){return ox.BlankNode},"get")});var cx=Yr();Object.defineProperty(At,"Namespace",{enumerable:!0,get:o(function(){return cx.Namespace},"get")});var ux=xi();Object.defineProperty(At,"Triple",{enumerable:!0,get:o(function(){return ux.Triple},"get")});var lx=ac();Object.defineProperty(At,"QuotedTriple",{enumerable:!0,get:o(function(){return lx.QuotedTriple},"get")})});var ll=v(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.UUID_URL_NAMESPACE=Xr.DEFAULT_LANGUAGE_TAG=Xr.REQUIRED_PROPERTIES=Xr.ALLOWED_PROPERTIES=Xr.Exo003MetadataType=void 0;var Kr;(function(n){n.Namespace="namespace",n.Anchor="anchor",n.BlankNode="blank_node",n.Statement="statement",n.Body="body"})(Kr||(Xr.Exo003MetadataType=Kr={}));Xr.ALLOWED_PROPERTIES={[Kr.Namespace]:["metadata","uri","aliases"],[Kr.Anchor]:["metadata","uri","aliases"],[Kr.BlankNode]:["metadata","uri","aliases"],[Kr.Statement]:["metadata","subject","predicate","object","aliases"],[Kr.Body]:["metadata","subject","predicate","aliases"]};Xr.REQUIRED_PROPERTIES={[Kr.Namespace]:["metadata","uri"],[Kr.Anchor]:["metadata","uri"],[Kr.BlankNode]:["metadata","uri"],[Kr.Statement]:["metadata","subject","predicate","object"],[Kr.Body]:["metadata","subject","predicate"]};Xr.DEFAULT_LANGUAGE_TAG="ru";Xr.UUID_URL_NAMESPACE="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});var q2=v(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var G2=v(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});lp.default="00000000-0000-0000-0000-000000000000"});var W2=v(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i});var oc=v(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});var fx=W2();function hx(n){return typeof n=="string"&&fx.default.test(n)}o(hx,"validate");hp.default=hx});var cc=v(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var dx=oc();function px(n){if(!(0,dx.default)(n))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(n.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(n.slice(9,13),16))>>>8,e&255,(e=parseInt(n.slice(14,18),16))>>>8,e&255,(e=parseInt(n.slice(19,23),16))>>>8,e&255,(e=parseInt(n.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}o(px,"parse");dp.default=px});var Ci=v(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.unsafeStringify=void 0;var mx=oc(),Gt=[];for(let n=0;n<256;++n)Gt.push((n+256).toString(16).slice(1));function H2(n,e=0){return(Gt[n[e+0]]+Gt[n[e+1]]+Gt[n[e+2]]+Gt[n[e+3]]+"-"+Gt[n[e+4]]+Gt[n[e+5]]+"-"+Gt[n[e+6]]+Gt[n[e+7]]+"-"+Gt[n[e+8]]+Gt[n[e+9]]+"-"+Gt[n[e+10]]+Gt[n[e+11]]+Gt[n[e+12]]+Gt[n[e+13]]+Gt[n[e+14]]+Gt[n[e+15]]).toLowerCase()}o(H2,"unsafeStringify");uc.unsafeStringify=H2;function gx(n,e=0){let t=H2(n,e);if(!(0,mx.default)(t))throw TypeError("Stringified UUID is invalid");return t}o(gx,"stringify");uc.default=gx});var dl=v(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var yx=require("crypto"),hl=new Uint8Array(256),fl=hl.length;function vx(){return fl>hl.length-16&&((0,yx.randomFillSync)(hl),fl=0),hl.slice(fl,fl+=16)}o(vx,"rng");pp.default=vx});var mp=v(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});fc.updateV1State=void 0;var z2=dl(),Sx=Ci(),lc={};function _x(n,e,t){let r,i=n?._v6??!1;if(n){let s=Object.keys(n);s.length===1&&s[0]==="_v6"&&(n=void 0)}if(n)r=Q2(n.random??n.rng?.()??(0,z2.default)(),n.msecs,n.nsecs,n.clockseq,n.node,e,t);else{let s=Date.now(),a=(0,z2.default)();Y2(lc,s,a),r=Q2(a,lc.msecs,lc.nsecs,i?void 0:lc.clockseq,i?void 0:lc.node,e,t)}return e??(0,Sx.unsafeStringify)(r)}o(_x,"v1");function Y2(n,e,t){return n.msecs??=-1/0,n.nsecs??=0,e===n.msecs?(n.nsecs++,n.nsecs>=1e4&&(n.node=void 0,n.nsecs=0)):e>n.msecs?n.nsecs=0:e<n.msecs&&(n.node=void 0),n.node||(n.node=t.slice(10,16),n.node[0]|=1,n.clockseq=(t[8]<<8|t[9])&16383),n.msecs=e,n}o(Y2,"updateV1State");fc.updateV1State=Y2;function Q2(n,e,t,r,i,s,a=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!s)s=new Uint8Array(16),a=0;else if(a<0||a+16>s.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);e??=Date.now(),t??=0,r??=(n[8]<<8|n[9])&16383,i??=n.slice(10,16),e+=122192928e5;let c=((e&268435455)*1e4+t)%4294967296;s[a++]=c>>>24&255,s[a++]=c>>>16&255,s[a++]=c>>>8&255,s[a++]=c&255;let u=e/4294967296*1e4&268435455;s[a++]=u>>>8&255,s[a++]=u&255,s[a++]=u>>>24&15|16,s[a++]=u>>>16&255,s[a++]=r>>>8|128,s[a++]=r&255;for(let l=0;l<6;++l)s[a++]=i[l];return s}o(Q2,"v1Bytes");fc.default=_x});var yp=v(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});var bx=cc(),wx=Ci();function Ex(n){let e=typeof n=="string"?(0,bx.default)(n):n,t=Tx(e);return typeof n=="string"?(0,wx.unsafeStringify)(t):t}o(Ex,"v1ToV6");gp.default=Ex;function Tx(n){return Uint8Array.of((n[6]&15)<<4|n[7]>>4&15,(n[7]&15)<<4|(n[4]&240)>>4,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,(n[1]&15)<<4|(n[2]&240)>>4,96|n[2]&15,n[3],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}o(Tx,"_v1ToV6")});var K2=v(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var Ax=require("crypto");function xx(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,Ax.createHash)("md5").update(n).digest()}o(xx,"md5");vp.default=xx});var hc=v(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.URL=Ii.DNS=Ii.stringToBytes=void 0;var X2=cc(),Cx=Ci();function J2(n){n=unescape(encodeURIComponent(n));let e=new Uint8Array(n.length);for(let t=0;t<n.length;++t)e[t]=n.charCodeAt(t);return e}o(J2,"stringToBytes");Ii.stringToBytes=J2;Ii.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Ii.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Ix(n,e,t,r,i,s){let a=typeof t=="string"?J2(t):t,c=typeof r=="string"?(0,X2.default)(r):r;if(typeof r=="string"&&(r=(0,X2.default)(r)),r?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+a.length);if(u.set(c),u.set(a,c.length),u=e(u),u[6]=u[6]&15|n,u[8]=u[8]&63|128,i){s=s||0;for(let l=0;l<16;++l)i[s+l]=u[l];return i}return(0,Cx.unsafeStringify)(u)}o(Ix,"v35");Ii.default=Ix});var ev=v(Fs=>{"use strict";Object.defineProperty(Fs,"__esModule",{value:!0});Fs.URL=Fs.DNS=void 0;var Ox=K2(),Sp=hc(),Z2=hc();Object.defineProperty(Fs,"DNS",{enumerable:!0,get:o(function(){return Z2.DNS},"get")});Object.defineProperty(Fs,"URL",{enumerable:!0,get:o(function(){return Z2.URL},"get")});function _p(n,e,t,r){return(0,Sp.default)(48,Ox.default,n,e,t,r)}o(_p,"v3");_p.DNS=Sp.DNS;_p.URL=Sp.URL;Fs.default=_p});var tv=v(bp=>{"use strict";Object.defineProperty(bp,"__esModule",{value:!0});var Px=require("crypto");bp.default={randomUUID:Px.randomUUID}});var nv=v(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var rv=tv(),Dx=dl(),Rx=Ci();function Fx(n,e,t){if(rv.default.randomUUID&&!e&&!n)return rv.default.randomUUID();n=n||{};let r=n.random??n.rng?.()??(0,Dx.default)();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=r[i];return e}return(0,Rx.unsafeStringify)(r)}o(Fx,"v4");wp.default=Fx});var iv=v(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});var Nx=require("crypto");function Lx(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,Nx.createHash)("sha1").update(n).digest()}o(Lx,"sha1");Ep.default=Lx});var av=v(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.URL=Ns.DNS=void 0;var kx=iv(),Tp=hc(),sv=hc();Object.defineProperty(Ns,"DNS",{enumerable:!0,get:o(function(){return sv.DNS},"get")});Object.defineProperty(Ns,"URL",{enumerable:!0,get:o(function(){return sv.URL},"get")});function Ap(n,e,t,r){return(0,Tp.default)(80,kx.default,n,e,t,r)}o(Ap,"v5");Ap.DNS=Tp.DNS;Ap.URL=Tp.URL;Ns.default=Ap});var ov=v(xp=>{"use strict";Object.defineProperty(xp,"__esModule",{value:!0});var Mx=Ci(),jx=mp(),$x=yp();function Vx(n,e,t){n??={},t??=0;let r=(0,jx.default)({...n,_v6:!0},new Uint8Array(16));if(r=(0,$x.default)(r),e){for(let i=0;i<16;i++)e[t+i]=r[i];return e}return(0,Mx.unsafeStringify)(r)}o(Vx,"v6");xp.default=Vx});var cv=v(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});var Ux=cc(),Bx=Ci();function qx(n){let e=typeof n=="string"?(0,Ux.default)(n):n,t=Gx(e);return typeof n=="string"?(0,Bx.unsafeStringify)(t):t}o(qx,"v6ToV1");Cp.default=qx;function Gx(n){return Uint8Array.of((n[3]&15)<<4|n[4]>>4&15,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|n[6]&15,n[7],(n[1]&15)<<4|(n[2]&240)>>4,(n[2]&15)<<4|(n[3]&240)>>4,16|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}o(Gx,"_v6ToV1")});var hv=v(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});dc.updateV7State=void 0;var uv=dl(),Wx=Ci(),Ip={};function Hx(n,e,t){let r;if(n)r=lv(n.random??n.rng?.()??(0,uv.default)(),n.msecs,n.seq,e,t);else{let i=Date.now(),s=(0,uv.default)();fv(Ip,i,s),r=lv(s,Ip.msecs,Ip.seq,e,t)}return e??(0,Wx.unsafeStringify)(r)}o(Hx,"v7");function fv(n,e,t){return n.msecs??=-1/0,n.seq??=0,e>n.msecs?(n.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],n.msecs=e):(n.seq=n.seq+1|0,n.seq===0&&n.msecs++),n}o(fv,"updateV7State");dc.updateV7State=fv;function lv(n,e,t,r,i=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return e??=Date.now(),t??=n[6]*127<<24|n[7]<<16|n[8]<<8|n[9],r[i++]=e/1099511627776&255,r[i++]=e/4294967296&255,r[i++]=e/16777216&255,r[i++]=e/65536&255,r[i++]=e/256&255,r[i++]=e&255,r[i++]=112|t>>>28&15,r[i++]=t>>>20&255,r[i++]=128|t>>>14&63,r[i++]=t>>>6&255,r[i++]=t<<2&255|n[10]&3,r[i++]=n[11],r[i++]=n[12],r[i++]=n[13],r[i++]=n[14],r[i++]=n[15],r}o(lv,"v7Bytes");dc.default=Hx});var dv=v(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});var zx=oc();function Qx(n){if(!(0,zx.default)(n))throw TypeError("Invalid UUID");return parseInt(n.slice(14,15),16)}o(Qx,"version");Op.default=Qx});var yr=v(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.version=Je.validate=Je.v7=Je.v6ToV1=Je.v6=Je.v5=Je.v4=Je.v3=Je.v1ToV6=Je.v1=Je.stringify=Je.parse=Je.NIL=Je.MAX=void 0;var Yx=q2();Object.defineProperty(Je,"MAX",{enumerable:!0,get:o(function(){return Yx.default},"get")});var Kx=G2();Object.defineProperty(Je,"NIL",{enumerable:!0,get:o(function(){return Kx.default},"get")});var Xx=cc();Object.defineProperty(Je,"parse",{enumerable:!0,get:o(function(){return Xx.default},"get")});var Jx=Ci();Object.defineProperty(Je,"stringify",{enumerable:!0,get:o(function(){return Jx.default},"get")});var Zx=mp();Object.defineProperty(Je,"v1",{enumerable:!0,get:o(function(){return Zx.default},"get")});var eC=yp();Object.defineProperty(Je,"v1ToV6",{enumerable:!0,get:o(function(){return eC.default},"get")});var tC=ev();Object.defineProperty(Je,"v3",{enumerable:!0,get:o(function(){return tC.default},"get")});var rC=nv();Object.defineProperty(Je,"v4",{enumerable:!0,get:o(function(){return rC.default},"get")});var nC=av();Object.defineProperty(Je,"v5",{enumerable:!0,get:o(function(){return nC.default},"get")});var iC=ov();Object.defineProperty(Je,"v6",{enumerable:!0,get:o(function(){return iC.default},"get")});var sC=cv();Object.defineProperty(Je,"v6ToV1",{enumerable:!0,get:o(function(){return sC.default},"get")});var aC=hv();Object.defineProperty(Je,"v7",{enumerable:!0,get:o(function(){return aC.default},"get")});var oC=oc();Object.defineProperty(Je,"validate",{enumerable:!0,get:o(function(){return oC.default},"get")});var cC=dv();Object.defineProperty(Je,"version",{enumerable:!0,get:o(function(){return cC.default},"get")})});var Rp=v(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.Exo003UUIDGenerator=void 0;var Pp=yr(),pv=ll(),Dp=class{static{o(this,"Exo003UUIDGenerator")}static generateNamespaceUUID(e){if(!e||e.trim().length===0)throw new Error("Namespace URI cannot be empty");return(0,Pp.v5)(e,pv.UUID_URL_NAMESPACE)}static generateAssetUUID(e,t){if(!t||t.trim().length===0)throw new Error("Local identifier cannot be empty");let r=this.generateNamespaceUUID(e);return(0,Pp.v5)(t,r)}static generateFromIRI(e){if(!e||e.trim().length===0)throw new Error("IRI cannot be empty");let{namespace:t,localName:r}=this.splitIRI(e);return r?this.generateAssetUUID(t,r):(0,Pp.v5)(e,pv.UUID_URL_NAMESPACE)}static generateBlankNodeUUID(e,t){if(!e||e.trim().length===0)throw new Error("Blank node ID cannot be empty");let r="urn:exocortex:blank-node:",i=t?`${t}#${e}`:e;return this.generateAssetUUID(r,i)}static generateStatementUUID(e,t,r){if(!e||!t||!r)throw new Error("Subject, predicate, and object cannot be empty");let i="urn:exocortex:statement:",s=`${e} ${t} ${r}`;return this.generateAssetUUID(i,s)}static generateBodyUUID(e,t){let r="urn:exocortex:body:",i=e;return t?.datatype?i+=`^^${t.datatype}`:t?.language&&(i+=`@${t.language}`,t.direction&&(i+=`--${t.direction}`)),this.generateAssetUUID(r,i)}static splitIRI(e){let t=e.lastIndexOf("#");if(t!==-1&&t<e.length-1)return{namespace:e.substring(0,t+1),localName:e.substring(t+1)};let r=e.lastIndexOf("/"),i=e.indexOf("://");return r!==-1&&r>i+2&&r<e.length-1?{namespace:e.substring(0,r+1),localName:e.substring(r+1)}:{namespace:e,localName:""}}static isValidUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};pl.Exo003UUIDGenerator=Dp});var gv=v(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});gl.Exo003Parser=void 0;var tt=ll(),pc=Rp(),Wi=Qe(),ml=lt(),mv=Ot(),uC=xi(),Fp=class{static{o(this,"Exo003Parser")}static parse(e,t){let r=this.validate(e);if(!r.valid)return{success:!1,errors:r.errors};let i=e.metadata;try{return{success:!0,metadata:this.parseByType(e,i),bodyContent:i===tt.Exo003MetadataType.Body?t:void 0}}catch(s){return{success:!1,errors:[s instanceof Error?s.message:String(s)]}}}static validate(e){let t=[],r=[];if(!e.metadata)return t.push("Missing required property: metadata"),{valid:!1,errors:t,warnings:r};let i=e.metadata;if(!Object.values(tt.Exo003MetadataType).includes(i))return t.push(`Invalid metadata: ${i}. Valid types: ${Object.values(tt.Exo003MetadataType).join(", ")}`),{valid:!1,errors:t,warnings:r};let s=i,a=tt.ALLOWED_PROPERTIES[s],c=tt.REQUIRED_PROPERTIES[s];for(let u of c)(e[u]===void 0||e[u]===null)&&t.push(`Missing required property: ${u}`);for(let u of Object.keys(e))a.includes(u)||t.push(`Forbidden property for ${s}: ${u}`);switch(s){case tt.Exo003MetadataType.Namespace:this.validateNamespaceMetadata(e,t);break;case tt.Exo003MetadataType.Anchor:this.validateAnchorMetadata(e,t);break;case tt.Exo003MetadataType.BlankNode:this.validateBlankNodeMetadata(e,t);break;case tt.Exo003MetadataType.Statement:this.validateStatementMetadata(e,t);break;case tt.Exo003MetadataType.Body:this.validateBodyMetadata(e,t,r);break}return{valid:t.length===0,errors:t,warnings:r}}static parseByType(e,t){let r={metadata:t,aliases:e.aliases};switch(t){case tt.Exo003MetadataType.Namespace:return{...r,metadata:tt.Exo003MetadataType.Namespace,uri:e.uri};case tt.Exo003MetadataType.Anchor:return{...r,metadata:tt.Exo003MetadataType.Anchor,uri:e.uri};case tt.Exo003MetadataType.BlankNode:return{...r,metadata:tt.Exo003MetadataType.BlankNode,uri:e.uri};case tt.Exo003MetadataType.Statement:return{...r,metadata:tt.Exo003MetadataType.Statement,subject:e.subject,predicate:e.predicate,object:e.object};case tt.Exo003MetadataType.Body:return{...r,metadata:tt.Exo003MetadataType.Body,subject:e.subject,predicate:e.predicate}}}static validateNamespaceMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new Wi.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateAnchorMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new Wi.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateBlankNodeMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new Wi.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateStatementMetadata(e,t){let r=e.subject,i=e.predicate,s=e.object,a=[["subject",r],["predicate",i],["object",s]];for(let[c,u]of a)u&&typeof u!="string"&&t.push(`${c} must be a string`)}static validateBodyMetadata(e,t,r){let i=e.subject,s=e.predicate;i&&typeof i!="string"&&t.push("subject must be a string"),s&&typeof s!="string"&&t.push("predicate must be a string")}static toTriple(e,t,r){let i=t(e.subject),s;if(i.type==="iri")s=new Wi.IRI(i.value);else if(i.type==="blank")s=new mv.BlankNode(i.value);else throw new Error("Statement subject cannot be a literal");let a=t(e.predicate);if(a.type!=="iri")throw new Error("Statement predicate must be an IRI");let c=new Wi.IRI(a.value),u=t(e.object),l;if(u.type==="iri")l=new Wi.IRI(u.value);else if(u.type==="blank")l=new mv.BlankNode(u.value);else{let f=r||u.value;if(u.datatype)l=new ml.Literal(f,new Wi.IRI(u.datatype));else{let h=u.language||tt.DEFAULT_LANGUAGE_TAG;l=(0,ml.createDirectionalLiteral)(f,h,u.direction)}}return new uC.Triple(s,c,l)}static toLiteral(e,t,r){if(r?.datatype)return new ml.Literal(t,new Wi.IRI(r.datatype));let i=r?.language||tt.DEFAULT_LANGUAGE_TAG;return(0,ml.createDirectionalLiteral)(t,i,r?.direction)}static isExo003Format(e){let t=e.metadata;return typeof t=="string"&&Object.values(tt.Exo003MetadataType).includes(t)}static generateUUID(e,t){switch(e.metadata){case tt.Exo003MetadataType.Namespace:return pc.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case tt.Exo003MetadataType.Anchor:return pc.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case tt.Exo003MetadataType.BlankNode:return pc.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case tt.Exo003MetadataType.Statement:{let r=e;return pc.Exo003UUIDGenerator.generateStatementUUID(r.subject,r.predicate,r.object)}case tt.Exo003MetadataType.Body:{let r=e;return pc.Exo003UUIDGenerator.generateBodyUUID(r.subject+"|"+r.predicate)}}}};gl.Exo003Parser=Fp});var Np=v(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.Exo003Parser=rr.Exo003UUIDGenerator=rr.UUID_URL_NAMESPACE=rr.DEFAULT_LANGUAGE_TAG=rr.REQUIRED_PROPERTIES=rr.ALLOWED_PROPERTIES=rr.Exo003MetadataType=void 0;var mc=ll();Object.defineProperty(rr,"Exo003MetadataType",{enumerable:!0,get:o(function(){return mc.Exo003MetadataType},"get")});Object.defineProperty(rr,"ALLOWED_PROPERTIES",{enumerable:!0,get:o(function(){return mc.ALLOWED_PROPERTIES},"get")});Object.defineProperty(rr,"REQUIRED_PROPERTIES",{enumerable:!0,get:o(function(){return mc.REQUIRED_PROPERTIES},"get")});Object.defineProperty(rr,"DEFAULT_LANGUAGE_TAG",{enumerable:!0,get:o(function(){return mc.DEFAULT_LANGUAGE_TAG},"get")});Object.defineProperty(rr,"UUID_URL_NAMESPACE",{enumerable:!0,get:o(function(){return mc.UUID_URL_NAMESPACE},"get")});var lC=Rp();Object.defineProperty(rr,"Exo003UUIDGenerator",{enumerable:!0,get:o(function(){return lC.Exo003UUIDGenerator},"get")});var fC=gv();Object.defineProperty(rr,"Exo003Parser",{enumerable:!0,get:o(function(){return fC.Exo003Parser},"get")})});var Ls=v(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.WikiLinkHelpers=void 0;var yl=class{static{o(this,"WikiLinkHelpers")}static normalize(e){return e?e.replace(this.WIKI_LINK_PATTERN,"").trim():""}static normalizeArray(e){return e?(Array.isArray(e)?e:[e]).map(r=>this.normalize(r)).filter(r=>r.length>0):[]}static equals(e,t){return this.normalize(e)===this.normalize(t)}static includes(e,t){let r=this.normalizeArray(e),i=this.normalize(t);return r.includes(i)}};vl.WikiLinkHelpers=yl;yl.WIKI_LINK_PATTERN=/\[\[|\]\]/g});var nr=v(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.EffortStatus=Pa.AssetClass=void 0;var hC=Kd();Object.defineProperty(Pa,"AssetClass",{enumerable:!0,get:o(function(){return hC.AssetClass},"get")});var dC=Xd();Object.defineProperty(Pa,"EffortStatus",{enumerable:!0,get:o(function(){return dC.EffortStatus},"get")})});var Hi=v(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.hasClass=Ms;ir.isAreaOrProject=pC;ir.isEffort=mC;ir.hasStatus=gC;ir.isAssetArchived=yC;ir.hasEmptyProperties=vC;ir.needsFolderRepair=SC;ir.getTodayDateString=Lp;ir.isPlannedForToday=_C;ir.hasPlannedStartTimestamp=bC;ir.extractDailyNoteDate=wC;ir.isCurrentDateGteDay=EC;ir.inheritsFromPrototype=Sv;ir.isPrototypeClass=AC;var vv=Ls(),ks=nr();function Ms(n,e){return n?(Array.isArray(n)?n:[n]).some(r=>vv.WikiLinkHelpers.normalize(r)===e):!1}o(Ms,"hasClass");function pC(n){return Ms(n,ks.AssetClass.AREA)||Ms(n,ks.AssetClass.PROJECT)}o(pC,"isAreaOrProject");function mC(n){return Ms(n,ks.AssetClass.TASK)||Ms(n,ks.AssetClass.PROJECT)||Ms(n,ks.AssetClass.MEETING)}o(mC,"isEffort");function gC(n,e){if(!n)return!1;let t=Array.isArray(n)?n[0]:n;return t?vv.WikiLinkHelpers.normalize(t)===e:!1}o(gC,"hasStatus");function yC(n){if(n===!0||n===1)return!0;if(typeof n=="string"){let e=n.toLowerCase();return e==="true"||e==="yes"}return!1}o(yC,"isAssetArchived");function vC(n){return!n||Object.keys(n).length===0?!1:Object.values(n).some(e=>!!(e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0))}o(vC,"hasEmptyProperties");function SC(n,e){if(!e)return!1;let t=n.replace(/\/$/,""),r=e.replace(/\/$/,"");return t!==r}o(SC,"needsFolderRepair");function Lp(){let n=new Date,e=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0");return`${e}-${t}-${r}`}o(Lp,"getTodayDateString");function _C(n){let e=n.ems__Effort_plannedStartTimestamp;if(!e)return!1;let t=Lp();return typeof e=="string"?e.split("T")[0]===t:Array.isArray(e)&&e.length>0?String(e[0]).split("T")[0]===t:!1}o(_C,"isPlannedForToday");function bC(n){let e=n.ems__Effort_plannedStartTimestamp;return e?typeof e=="string"?e.trim().length>0:Array.isArray(e)&&e.length>0?String(e[0]).trim().length>0:!1:!1}o(bC,"hasPlannedStartTimestamp");function wC(n){let e=n.pn__DailyNote_day;if(!e)return null;if(typeof e=="string"){let t=e.match(/\[\[([^\[\]]+)\]\]/);return t?t[1]:e}if(Array.isArray(e)&&e.length>0){let t=String(e[0]),r=t.match(/\[\[([^\[\]]+)\]\]/);return r?r[1]:t}return null}o(wC,"extractDailyNoteDate");function EC(n){return Lp()>=n}o(EC,"isCurrentDateGteDay");function yv(n){return n?n.replace(/^["']|["']$/g,"").replace(/\[\[|\]\]/g,"").trim():""}o(yv,"normalizeWithQuotes");var TC=10;function Sv(n,e=TC){let t=n.exo__Class_superClass;if(!t)return!1;let r=new Set,i=[],s=Array.isArray(t)?t:[t];for(let a of s){let c=yv(a);c&&i.push({className:c,depth:0})}for(;i.length>0;){let a=i.shift();if(!a)continue;let{className:c,depth:u}=a;if(u>e)continue;if(c===ks.AssetClass.PROTOTYPE)return!0;if(r.has(c))continue;r.add(c);let l=`${c}__exo__Class_superClass`,f=n[l];if(f){let h=Array.isArray(f)?f:[f];for(let d of h){let p=yv(d);p&&!r.has(p)&&i.push({className:p,depth:u+1})}}}return!1}o(Sv,"inheritsFromPrototype");function AC(n,e){return Ms(n,ks.AssetClass.CLASS)?Sv(e):!1}o(AC,"isPrototypeClass")});var bv=v(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.canCreateTask=xC;gc.canCreateRelatedTask=CC;gc.canConvertTaskToProject=IC;var Sl=Hi(),_v=nr();function xC(n){return(0,Sl.isAreaOrProject)(n.instanceClass)}o(xC,"canCreateTask");function CC(n){return!(!(0,Sl.hasClass)(n.instanceClass,_v.AssetClass.TASK)||(0,Sl.isAssetArchived)(n.isArchived))}o(CC,"canCreateRelatedTask");function IC(n){return(0,Sl.hasClass)(n.instanceClass,_v.AssetClass.TASK)}o(IC,"canConvertTaskToProject")});var wv=v(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});Da.canCreateProject=OC;Da.canMoveToAnalysis=PC;Da.canMoveToToDo=DC;Da.canConvertProjectToTask=RC;var zi=Hi(),Qi=nr();function OC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.AREA)||(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.INITIATIVE)||(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)}o(OC,"canCreateProject");function PC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)?(0,zi.hasStatus)(n.currentStatus,Qi.EffortStatus.BACKLOG):!1}o(PC,"canMoveToAnalysis");function DC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)?(0,zi.hasStatus)(n.currentStatus,Qi.EffortStatus.ANALYSIS):!1}o(DC,"canMoveToToDo");function RC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)}o(RC,"canConvertProjectToTask")});var Av=v(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.canCreateChildArea=FC;_l.canSetActiveFocus=NC;var Ev=Hi(),Tv=nr();function FC(n){return(0,Ev.hasClass)(n.instanceClass,Tv.AssetClass.AREA)}o(FC,"canCreateChildArea");function NC(n){return(0,Ev.hasClass)(n.instanceClass,Tv.AssetClass.AREA)}o(NC,"canSetActiveFocus")});var Cv=v(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.canPlanOnToday=LC;Dr.canPlanForEvening=kC;Dr.canShiftDayBackward=MC;Dr.canShiftDayForward=jC;Dr.canSetDraftStatus=$C;Dr.canMoveToBacklog=VC;Dr.canStartEffort=UC;Dr.canMarkDone=BC;Dr.canTrashEffort=qC;Dr.canVoteOnEffort=GC;Dr.canRollbackStatus=WC;Dr.canArchiveTask=HC;var xv=Ls(),ot=Hi(),Vr=nr();function LC(n){return!(!(0,ot.isEffort)(n.instanceClass)||(0,ot.isPlannedForToday)(n.metadata))}o(LC,"canPlanOnToday");function kC(n){return!(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.TASK)&&!(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.MEETING)?!1:(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.BACKLOG)}o(kC,"canPlanForEvening");function MC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasPlannedStartTimestamp)(n.metadata):!1}o(MC,"canShiftDayBackward");function jC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasPlannedStartTimestamp)(n.metadata):!1}o(jC,"canShiftDayForward");function $C(n){return(0,ot.isEffort)(n.instanceClass)?!n.currentStatus:!1}o($C,"canSetDraftStatus");function VC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.DRAFT):!1}o(VC,"canMoveToBacklog");function UC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.TASK)||(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.MEETING)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.BACKLOG):(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.PROJECT)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.TODO):!1:!1}o(UC,"canStartEffort");function BC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.DOING):!1}o(BC,"canMarkDone");function qC(n){return(0,ot.isEffort)(n.instanceClass)?n.currentStatus?!(Array.isArray(n.currentStatus)?n.currentStatus:[n.currentStatus]).some(r=>{let i=xv.WikiLinkHelpers.normalize(r);return i===Vr.EffortStatus.TRASHED||i===Vr.EffortStatus.DONE}):!0:!1}o(qC,"canTrashEffort");function GC(n){return!(!(0,ot.isEffort)(n.instanceClass)||(0,ot.isAssetArchived)(n.isArchived))}o(GC,"canVoteOnEffort");function WC(n){if(!(0,ot.isEffort)(n.instanceClass)||(0,ot.isAssetArchived)(n.isArchived)||!n.currentStatus)return!1;let e=Array.isArray(n.currentStatus)?n.currentStatus[0]:n.currentStatus;return!(!e||xv.WikiLinkHelpers.normalize(e)===Vr.EffortStatus.TRASHED)}o(WC,"canRollbackStatus");function HC(n){return!(0,ot.isAssetArchived)(n.isArchived)}o(HC,"canArchiveTask")});var Iv=v(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.canCreateEvent=zC;dn.canCreateInstance=QC;dn.canCleanProperties=YC;dn.canRepairFolder=KC;dn.canRenameToUid=XC;dn.canCopyLabelToAliases=JC;dn.canCreateNarrowerConcept=ZC;dn.canCreateSubclass=eI;dn.canCreateTaskForDailyNote=tI;var Jr=Hi(),js=nr();function zC(n){return(0,Jr.isAreaOrProject)(n.instanceClass)}o(zC,"canCreateEvent");function QC(n){return(0,Jr.hasClass)(n.instanceClass,js.AssetClass.TASK_PROTOTYPE)||(0,Jr.hasClass)(n.instanceClass,js.AssetClass.MEETING_PROTOTYPE)||(0,Jr.hasClass)(n.instanceClass,js.AssetClass.EVENT_PROTOTYPE)||(0,Jr.hasClass)(n.instanceClass,js.AssetClass.PROJECT_PROTOTYPE)?!0:(0,Jr.isPrototypeClass)(n.instanceClass,n.metadata)}o(QC,"canCreateInstance");function YC(n){return(0,Jr.hasEmptyProperties)(n.metadata)}o(YC,"canCleanProperties");function KC(n){return(0,Jr.needsFolderRepair)(n.currentFolder,n.expectedFolder)}o(KC,"canRepairFolder");function XC(n,e){let t=n.metadata.exo__Asset_uid;return t?e!==t:!1}o(XC,"canRenameToUid");function JC(n){let e=n.metadata.exo__Asset_label;if(!e||typeof e!="string"||e.trim()==="")return!1;let t=e.trim(),r=n.metadata.aliases;return!r||!Array.isArray(r)||r.length===0?!0:!r.some(i=>typeof i!="string"?!1:i.trim()===t)}o(JC,"canCopyLabelToAliases");function ZC(n){return(0,Jr.hasClass)(n.instanceClass,js.AssetClass.CONCEPT)}o(ZC,"canCreateNarrowerConcept");function eI(n){return(0,Jr.hasClass)(n.instanceClass,js.AssetClass.CLASS)}o(eI,"canCreateSubclass");function tI(n){return!(!(0,Jr.hasClass)(n.instanceClass,js.AssetClass.DAILY_NOTE)||n.isArchived||!(0,Jr.extractDailyNoteDate)(n.metadata))}o(tI,"canCreateTaskForDailyNote")});var Pv=v(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.canCreateTaskForDailyNote=N.canCreateSubclass=N.canCreateNarrowerConcept=N.canCopyLabelToAliases=N.canRenameToUid=N.canRepairFolder=N.canCleanProperties=N.canCreateInstance=N.canCreateEvent=N.canArchiveTask=N.canRollbackStatus=N.canVoteOnEffort=N.canTrashEffort=N.canMarkDone=N.canStartEffort=N.canMoveToBacklog=N.canSetDraftStatus=N.canShiftDayForward=N.canShiftDayBackward=N.canPlanForEvening=N.canPlanOnToday=N.canSetActiveFocus=N.canCreateChildArea=N.canConvertProjectToTask=N.canMoveToToDo=N.canMoveToAnalysis=N.canCreateProject=N.canConvertTaskToProject=N.canCreateRelatedTask=N.canCreateTask=N.isPrototypeClass=N.inheritsFromPrototype=N.isCurrentDateGteDay=N.extractDailyNoteDate=N.hasPlannedStartTimestamp=N.isPlannedForToday=N.getTodayDateString=N.needsFolderRepair=N.hasEmptyProperties=N.isAssetArchived=N.hasStatus=N.isEffort=N.isAreaOrProject=N.hasClass=void 0;var Rr=Hi();Object.defineProperty(N,"hasClass",{enumerable:!0,get:o(function(){return Rr.hasClass},"get")});Object.defineProperty(N,"isAreaOrProject",{enumerable:!0,get:o(function(){return Rr.isAreaOrProject},"get")});Object.defineProperty(N,"isEffort",{enumerable:!0,get:o(function(){return Rr.isEffort},"get")});Object.defineProperty(N,"hasStatus",{enumerable:!0,get:o(function(){return Rr.hasStatus},"get")});Object.defineProperty(N,"isAssetArchived",{enumerable:!0,get:o(function(){return Rr.isAssetArchived},"get")});Object.defineProperty(N,"hasEmptyProperties",{enumerable:!0,get:o(function(){return Rr.hasEmptyProperties},"get")});Object.defineProperty(N,"needsFolderRepair",{enumerable:!0,get:o(function(){return Rr.needsFolderRepair},"get")});Object.defineProperty(N,"getTodayDateString",{enumerable:!0,get:o(function(){return Rr.getTodayDateString},"get")});Object.defineProperty(N,"isPlannedForToday",{enumerable:!0,get:o(function(){return Rr.isPlannedForToday},"get")});Object.defineProperty(N,"hasPlannedStartTimestamp",{enumerable:!0,get:o(function(){return Rr.hasPlannedStartTimestamp},"get")});Object.defineProperty(N,"extractDailyNoteDate",{enumerable:!0,get:o(function(){return Rr.extractDailyNoteDate},"get")});Object.defineProperty(N,"isCurrentDateGteDay",{enumerable:!0,get:o(function(){return Rr.isCurrentDateGteDay},"get")});Object.defineProperty(N,"inheritsFromPrototype",{enumerable:!0,get:o(function(){return Rr.inheritsFromPrototype},"get")});Object.defineProperty(N,"isPrototypeClass",{enumerable:!0,get:o(function(){return Rr.isPrototypeClass},"get")});var kp=bv();Object.defineProperty(N,"canCreateTask",{enumerable:!0,get:o(function(){return kp.canCreateTask},"get")});Object.defineProperty(N,"canCreateRelatedTask",{enumerable:!0,get:o(function(){return kp.canCreateRelatedTask},"get")});Object.defineProperty(N,"canConvertTaskToProject",{enumerable:!0,get:o(function(){return kp.canConvertTaskToProject},"get")});var bl=wv();Object.defineProperty(N,"canCreateProject",{enumerable:!0,get:o(function(){return bl.canCreateProject},"get")});Object.defineProperty(N,"canMoveToAnalysis",{enumerable:!0,get:o(function(){return bl.canMoveToAnalysis},"get")});Object.defineProperty(N,"canMoveToToDo",{enumerable:!0,get:o(function(){return bl.canMoveToToDo},"get")});Object.defineProperty(N,"canConvertProjectToTask",{enumerable:!0,get:o(function(){return bl.canConvertProjectToTask},"get")});var Ov=Av();Object.defineProperty(N,"canCreateChildArea",{enumerable:!0,get:o(function(){return Ov.canCreateChildArea},"get")});Object.defineProperty(N,"canSetActiveFocus",{enumerable:!0,get:o(function(){return Ov.canSetActiveFocus},"get")});var Zr=Cv();Object.defineProperty(N,"canPlanOnToday",{enumerable:!0,get:o(function(){return Zr.canPlanOnToday},"get")});Object.defineProperty(N,"canPlanForEvening",{enumerable:!0,get:o(function(){return Zr.canPlanForEvening},"get")});Object.defineProperty(N,"canShiftDayBackward",{enumerable:!0,get:o(function(){return Zr.canShiftDayBackward},"get")});Object.defineProperty(N,"canShiftDayForward",{enumerable:!0,get:o(function(){return Zr.canShiftDayForward},"get")});Object.defineProperty(N,"canSetDraftStatus",{enumerable:!0,get:o(function(){return Zr.canSetDraftStatus},"get")});Object.defineProperty(N,"canMoveToBacklog",{enumerable:!0,get:o(function(){return Zr.canMoveToBacklog},"get")});Object.defineProperty(N,"canStartEffort",{enumerable:!0,get:o(function(){return Zr.canStartEffort},"get")});Object.defineProperty(N,"canMarkDone",{enumerable:!0,get:o(function(){return Zr.canMarkDone},"get")});Object.defineProperty(N,"canTrashEffort",{enumerable:!0,get:o(function(){return Zr.canTrashEffort},"get")});Object.defineProperty(N,"canVoteOnEffort",{enumerable:!0,get:o(function(){return Zr.canVoteOnEffort},"get")});Object.defineProperty(N,"canRollbackStatus",{enumerable:!0,get:o(function(){return Zr.canRollbackStatus},"get")});Object.defineProperty(N,"canArchiveTask",{enumerable:!0,get:o(function(){return Zr.canArchiveTask},"get")});var Oi=Iv();Object.defineProperty(N,"canCreateEvent",{enumerable:!0,get:o(function(){return Oi.canCreateEvent},"get")});Object.defineProperty(N,"canCreateInstance",{enumerable:!0,get:o(function(){return Oi.canCreateInstance},"get")});Object.defineProperty(N,"canCleanProperties",{enumerable:!0,get:o(function(){return Oi.canCleanProperties},"get")});Object.defineProperty(N,"canRepairFolder",{enumerable:!0,get:o(function(){return Oi.canRepairFolder},"get")});Object.defineProperty(N,"canRenameToUid",{enumerable:!0,get:o(function(){return Oi.canRenameToUid},"get")});Object.defineProperty(N,"canCopyLabelToAliases",{enumerable:!0,get:o(function(){return Oi.canCopyLabelToAliases},"get")});Object.defineProperty(N,"canCreateNarrowerConcept",{enumerable:!0,get:o(function(){return Oi.canCreateNarrowerConcept},"get")});Object.defineProperty(N,"canCreateSubclass",{enumerable:!0,get:o(function(){return Oi.canCreateSubclass},"get")});Object.defineProperty(N,"canCreateTaskForDailyNote",{enumerable:!0,get:o(function(){return Oi.canCreateTaskForDailyNote},"get")})});var Dv=v($s=>{"use strict";var rI=$s&&$s.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),nI=$s&&$s.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&rI(e,n,t)};Object.defineProperty($s,"__esModule",{value:!0});nI(Pv(),$s)});var jp=v(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});yc.PropertyFieldType=void 0;yc.rangeToFieldType=aI;var Wt;(function(n){n.Text="text",n.Number="number",n.Date="date",n.DateTime="datetime",n.Boolean="boolean",n.Reference="reference",n.Enum="enum",n.StatusSelect="status-select",n.SizeSelect="size-select",n.Wikilink="wikilink",n.Timestamp="timestamp",n.Unknown="unknown"})(Wt||(yc.PropertyFieldType=Wt={}));var Rv="http://www.w3.org/2001/XMLSchema#",iI="https://exocortex.my/ontology/exo#",sI="https://exocortex.my/ontology/ems#";function aI(n){if(!n)return Wt.Unknown;let e=n.trim();if(!e)return Wt.Unknown;if(e.startsWith(Rv)){let t=e.substring(Rv.length);return Mp(t)}if(e.startsWith("xsd:")){let t=e.substring(4);return Mp(t)}if(e.includes("XMLSchema#")){let t=e.indexOf("XMLSchema#"),r=e.substring(t+10);return Mp(r)}return e.startsWith(sI)||e.startsWith("ems:")?oI(e):e.startsWith(iI)||e.startsWith("exo:")||cI(e)?Wt.Reference:Wt.Text}o(aI,"rangeToFieldType");function Mp(n){switch(n.toLowerCase()){case"string":case"normalizedstring":case"token":case"language":case"nmtoken":case"name":case"ncname":case"anyuri":return Wt.Text;case"integer":case"int":case"long":case"short":case"byte":case"nonnegativeinteger":case"positiveinteger":case"nonpositiveinteger":case"negativeinteger":case"unsignedlong":case"unsignedint":case"unsignedshort":case"unsignedbyte":case"decimal":case"float":case"double":return Wt.Number;case"date":return Wt.Date;case"datetime":case"datetimestamp":return Wt.DateTime;case"boolean":return Wt.Boolean;case"time":return Wt.Timestamp;default:return Wt.Text}}o(Mp,"xsdTypeToFieldType");function oI(n){let e=n.toLowerCase();return e.includes("effortstatus")?Wt.StatusSelect:e.includes("tasksize")?Wt.SizeSelect:Wt.Reference}o(oI,"emsTypeToFieldType");function cI(n){let e=n.toLowerCase();return e.includes("exocortex.my/ontology")?!0:["asset","task","project","area","effort","class","property","concept"].some(r=>e.includes(r))}o(cI,"isClassReference")});var Nv=v(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.propertyNameToUri=uI;vc.uriToPropertyName=Fv;vc.extractPropertyLabel=lI;function uI(n){return n.replace(/^([a-z]+)__/,"$1:")}o(uI,"propertyNameToUri");function Fv(n){if(n.startsWith("http://")||n.startsWith("https://")){let e=n.match(/\/([a-z]+)#([A-Za-z0-9_]+)$/);if(e)return`${e[1]}__${e[2]}`;let t=n.lastIndexOf("#"),r=n.lastIndexOf("/"),i=Math.max(t,r);return i>=0?n.substring(i+1):n}return n.replace(/^([a-z]+):/,"$1__")}o(Fv,"uriToPropertyName");function lI(n){let r=(n.includes(":")?Fv(n):n).replace(/^[a-z]+__/,"").split("_");return(r.length>1?r.slice(1).join(" "):r[0]).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,s=>s.toUpperCase())}o(lI,"extractPropertyLabel")});var wl={};OA(wl,{__assign:()=>Vp,__asyncDelegator:()=>EI,__asyncGenerator:()=>wI,__asyncValues:()=>TI,__await:()=>Sc,__awaiter:()=>gI,__classPrivateFieldGet:()=>II,__classPrivateFieldSet:()=>OI,__createBinding:()=>vI,__decorate:()=>dI,__exportStar:()=>SI,__extends:()=>fI,__generator:()=>yI,__importDefault:()=>CI,__importStar:()=>xI,__makeTemplateObject:()=>AI,__metadata:()=>mI,__param:()=>pI,__read:()=>Lv,__rest:()=>hI,__spread:()=>_I,__spreadArrays:()=>bI,__values:()=>Up});function fI(n,e){$p(n,e);function t(){this.constructor=n}o(t,"__"),n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function hI(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function dI(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function pI(n,e){return function(t,r){e(t,r,n)}}function mI(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function gI(n,e,t,r){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return o(i,"adopt"),new(t||(t=Promise))(function(s,a){function c(f){try{l(r.next(f))}catch(h){a(h)}}o(c,"fulfilled");function u(f){try{l(r.throw(f))}catch(h){a(h)}}o(u,"rejected");function l(f){f.done?s(f.value):i(f.value).then(c,u)}o(l,"step"),l((r=r.apply(n,e||[])).next())})}function yI(n,e){var t={label:0,sent:o(function(){if(s[0]&1)throw s[1];return s[1]},"sent"),trys:[],ops:[]},r,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(l){return function(f){return u([l,f])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;t;)try{if(r=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(f){l=[6,f],i=0}finally{r=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function vI(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}function SI(n,e){for(var t in n)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=n[t])}function Up(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:o(function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}},"next")};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Lv(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return s}function _I(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(Lv(arguments[e]));return n}function bI(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),i=0,e=0;e<t;e++)for(var s=arguments[e],a=0,c=s.length;a<c;a++,i++)r[i]=s[a];return r}function Sc(n){return this instanceof Sc?(this.v=n,this):new Sc(n)}function wI(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(d){r[d]&&(i[d]=function(p){return new Promise(function(S,b){s.push([d,p,S,b])>1||c(d,p)})})}function c(d,p){try{u(r[d](p))}catch(S){h(s[0][3],S)}}function u(d){d.value instanceof Sc?Promise.resolve(d.value.v).then(l,f):h(s[0][2],d)}function l(d){c("next",d)}function f(d){c("throw",d)}function h(d,p){d(p),s.shift(),s.length&&c(s[0][0],s[0][1])}}function EI(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(a){return(t=!t)?{value:Sc(n[i](a)),done:i==="return"}:s?s(a):a}:s}}function TI(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof Up=="function"?Up(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(a){return new Promise(function(c,u){a=n[s](a),i(c,u,a.done,a.value)})}}function i(s,a,c,u){Promise.resolve(u).then(function(l){s({value:l,done:c})},a)}}function AI(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function xI(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)Object.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function CI(n){return n&&n.__esModule?n:{default:n}}function II(n,e){if(!e.has(n))throw new TypeError("attempted to get private field on non-instance");return e.get(n)}function OI(n,e,t){if(!e.has(n))throw new TypeError("attempted to set private field on non-instance");return e.set(n,t),t}var $p,Vp,El=IA(()=>{$p=o(function(n,e){return $p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])},$p(n,e)},"extendStatics");o(fI,"__extends");Vp=o(function(){return Vp=Object.assign||o(function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},"__assign"),Vp.apply(this,arguments)},"__assign");o(hI,"__rest");o(dI,"__decorate");o(pI,"__param");o(mI,"__metadata");o(gI,"__awaiter");o(yI,"__generator");o(vI,"__createBinding");o(SI,"__exportStar");o(Up,"__values");o(Lv,"__read");o(_I,"__spread");o(bI,"__spreadArrays");o(Sc,"__await");o(wI,"__asyncGenerator");o(EI,"__asyncDelegator");o(TI,"__asyncValues");o(AI,"__makeTemplateObject");o(xI,"__importStar");o(CI,"__importDefault");o(II,"__classPrivateFieldGet");o(OI,"__classPrivateFieldSet")});var Gp=v(qp=>{"use strict";Object.defineProperty(qp,"__esModule",{value:!0});var Bp;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(Bp||(Bp={}));qp.default=Bp});var kv=v(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});var PI=Gp();Object.defineProperty(Wp,"Lifecycle",{enumerable:!0,get:o(function(){return PI.default},"get")})});var Vs=v(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.defineInjectionTokenMetadata=pn.getParamInfo=pn.INJECTION_TOKEN_METADATA_KEY=void 0;pn.INJECTION_TOKEN_METADATA_KEY="injectionTokens";function DI(n){let e=Reflect.getMetadata("design:paramtypes",n)||[],t=Reflect.getOwnMetadata(pn.INJECTION_TOKEN_METADATA_KEY,n)||{};return Object.keys(t).forEach(r=>{e[+r]=t[r]}),e}o(DI,"getParamInfo");pn.getParamInfo=DI;function RI(n,e){return function(t,r,i){let s=Reflect.getOwnMetadata(pn.INJECTION_TOKEN_METADATA_KEY,t)||{};s[i]=e?{token:n,transform:e.transformToken,transformArgs:e.args||[]}:n,Reflect.defineMetadata(pn.INJECTION_TOKEN_METADATA_KEY,s,t)}}o(RI,"defineInjectionTokenMetadata");pn.defineInjectionTokenMetadata=RI});var Hp=v(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});Tl.isClassProvider=void 0;function FI(n){return!!n.useClass}o(FI,"isClassProvider");Tl.isClassProvider=FI});var zp=v(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});Al.isFactoryProvider=void 0;function NI(n){return!!n.useFactory}o(NI,"isFactoryProvider");Al.isFactoryProvider=NI});var Cl=v(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.delay=Ra.DelayedConstructor=void 0;var xl=class{static{o(this,"DelayedConstructor")}constructor(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}createProxy(e){let t={},r=!1,i,s=o(()=>(r||(i=e(this.wrap()),r=!0),i),"delayedObject");return new Proxy(t,this.createHandler(s))}createHandler(e){let t={},r=o(i=>{t[i]=(...s)=>{s[0]=e();let a=Reflect[i];return a(...s)}},"install");return this.reflectMethods.forEach(r),t}};Ra.DelayedConstructor=xl;function LI(n){if(typeof n>"u")throw new Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new xl(n)}o(LI,"delay");Ra.delay=LI});var Il=v(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.isConstructorToken=ei.isTransformDescriptor=ei.isTokenDescriptor=ei.isNormalToken=void 0;var kI=Cl();function MI(n){return typeof n=="string"||typeof n=="symbol"}o(MI,"isNormalToken");ei.isNormalToken=MI;function jI(n){return typeof n=="object"&&"token"in n&&"multiple"in n}o(jI,"isTokenDescriptor");ei.isTokenDescriptor=jI;function $I(n){return typeof n=="object"&&"token"in n&&"transform"in n}o($I,"isTransformDescriptor");ei.isTransformDescriptor=$I;function VI(n){return typeof n=="function"||n instanceof kI.DelayedConstructor}o(VI,"isConstructorToken");ei.isConstructorToken=VI});var Qp=v(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.isTokenProvider=void 0;function UI(n){return!!n.useToken}o(UI,"isTokenProvider");Ol.isTokenProvider=UI});var Yp=v(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.isValueProvider=void 0;function BI(n){return n.useValue!=null}o(BI,"isValueProvider");Pl.isValueProvider=BI});var Kp=v(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});var qI=Hp();Object.defineProperty(Us,"isClassProvider",{enumerable:!0,get:o(function(){return qI.isClassProvider},"get")});var GI=zp();Object.defineProperty(Us,"isFactoryProvider",{enumerable:!0,get:o(function(){return GI.isFactoryProvider},"get")});var WI=Il();Object.defineProperty(Us,"isNormalToken",{enumerable:!0,get:o(function(){return WI.isNormalToken},"get")});var HI=Qp();Object.defineProperty(Us,"isTokenProvider",{enumerable:!0,get:o(function(){return HI.isTokenProvider},"get")});var zI=Yp();Object.defineProperty(Us,"isValueProvider",{enumerable:!0,get:o(function(){return zI.isValueProvider},"get")})});var Mv=v(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});Dl.isProvider=void 0;var QI=Hp(),YI=Yp(),KI=Qp(),XI=zp();function JI(n){return QI.isClassProvider(n)||YI.isValueProvider(n)||KI.isTokenProvider(n)||XI.isFactoryProvider(n)}o(JI,"isProvider");Dl.isProvider=JI});var Zp=v(Jp=>{"use strict";Object.defineProperty(Jp,"__esModule",{value:!0});var Xp=class{static{o(this,"RegistryBase")}constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let t=this._registryMap.get(e);return t[t.length-1]||null}set(e,t){this.ensure(e),this._registryMap.get(e).push(t)}setAll(e,t){this._registryMap.set(e,t)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}};Jp.default=Xp});var jv=v(tm=>{"use strict";Object.defineProperty(tm,"__esModule",{value:!0});var ZI=Zp(),em=class extends ZI.default{static{o(this,"Registry")}};tm.default=em});var $v=v(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});var rm=class{static{o(this,"ResolutionContext")}constructor(){this.scopedResolutions=new Map}};nm.default=rm});var im=v(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.formatErrorCtor=void 0;function eO(n,e){return n===null?`at position #${e}`:`"${n.split(",")[e].trim()}" at position #${e}`}o(eO,"formatDependency");function tO(n,e,t=" "){return[n,...e.message.split(`
|
|
31
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function O2(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],i=s[4]),t&&i!=="0"?`${t}=${r}:${parseInt(i)+1}`:e})}o(O2,"incrementNodeInspectorPort");function Qd(){if(ze.env.NO_COLOR||ze.env.FORCE_COLOR==="0"||ze.env.FORCE_COLOR==="false")return!1;if(ze.env.FORCE_COLOR||ze.env.CLICOLOR_FORCE!==void 0)return!0}o(Qd,"useColor");Yd.Command=zd;Yd.useColor=Qd});var N2=v(Qr=>{var{Argument:D2}=Ku(),{Command:Kd}=P2(),{CommanderError:HA,InvalidArgumentError:R2}=ic(),{Help:zA}=Vd(),{Option:F2}=Gd();Qr.program=new Kd;Qr.createCommand=n=>new Kd(n);Qr.createOption=(n,e)=>new F2(n,e);Qr.createArgument=(n,e)=>new D2(n,e);Qr.Command=Kd;Qr.Option=F2;Qr.Argument=D2;Qr.Help=zA;Qr.CommanderError=HA;Qr.InvalidArgumentError=R2;Qr.InvalidOptionArgumentError=R2});var Xd=v(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});Ju.AssetClass=void 0;var k2;(function(n){n.AREA="ems__Area",n.TASK="ems__Task",n.PROJECT="ems__Project",n.MEETING="ems__Meeting",n.INITIATIVE="ems__Initiative",n.TASK_PROTOTYPE="ems__TaskPrototype",n.MEETING_PROTOTYPE="ems__MeetingPrototype",n.EVENT_PROTOTYPE="exo__EventPrototype",n.PROJECT_PROTOTYPE="ems__ProjectPrototype",n.EVENT="exo__Event",n.DAILY_NOTE="pn__DailyNote",n.CONCEPT="ims__Concept",n.SESSION_START_EVENT="ems__SessionStartEvent",n.SESSION_END_EVENT="ems__SessionEndEvent",n.PROTOTYPE="exo__Prototype",n.CLASS="exo__Class"})(k2||(Ju.AssetClass=k2={}))});var Jd=v(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.EffortStatus=void 0;var M2;(function(n){n.DRAFT="ems__EffortStatusDraft",n.BACKLOG="ems__EffortStatusBacklog",n.ANALYSIS="ems__EffortStatusAnalysis",n.TODO="ems__EffortStatusToDo",n.DOING="ems__EffortStatusDoing",n.DONE="ems__EffortStatusDone",n.TRASHED="ems__EffortStatusTrashed"})(M2||(Zu.EffortStatus=M2={}))});var j2=v(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});el.hasPosition=QA;el.isFixed=YA;function QA(n){return typeof n.x=="number"&&typeof n.y=="number"}o(QA,"hasPosition");function YA(n){return n.fx!==null&&n.fx!==void 0&&n.fy!==null&&n.fy!==void 0}o(YA,"isFixed")});var $2=v(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});tl.createEmptyGraphData=KA;tl.mergeGraphData=XA;function KA(){return{nodes:[],edges:[],lastUpdated:Date.now(),version:0}}o(KA,"createEmptyGraphData");function XA(n,e){let t=new Map,r=new Set,i=[];for(let s of n.nodes)t.set(s.id,s);for(let s of e.nodes)t.set(s.id,s);for(let s of n.edges){let a=`${s.source}->${s.target}:${s.type}`;r.has(a)||(r.add(a),i.push(s))}for(let s of e.edges){let a=`${s.source}->${s.target}:${s.type}`;r.has(a)||(r.add(a),i.push(s))}return{nodes:Array.from(t.values()),edges:i,lastUpdated:Date.now(),version:Math.max(n.version??0,e.version??0)+1}}o(XA,"mergeGraphData")});var Zd=v(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.createEdgeId=JA;rl.edgesEqual=ZA;function JA(n,e,t,r){let i=r?`|${r}`:"";return`${n}->${e}:${t}${i}`}o(JA,"createEdgeId");function ZA(n,e){return n.source===e.source&&n.target===e.target&&n.type===e.type&&n.predicate===e.predicate}o(ZA,"edgesEqual")});var ep=v(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.BUILT_IN_EDGE_STYLES=gt.BUILT_IN_NODE_STYLES=gt.DEFAULT_EDGE_STYLE=gt.DEFAULT_NODE_STYLE=gt.RDF_TYPE_PREDICATES=void 0;gt.mergeNodeStyles=ex;gt.mergeEdgeStyles=tx;gt.extractLocalName=rx;gt.isClassType=nx;gt.isTypePredicate=ix;gt.isSubClassPredicate=sx;gt.RDF_TYPE_PREDICATES={RDF_TYPE:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",RDFS_CLASS:"http://www.w3.org/2000/01/rdf-schema#Class",OWL_CLASS:"http://www.w3.org/2002/07/owl#Class",RDFS_SUBCLASS_OF:"http://www.w3.org/2000/01/rdf-schema#subClassOf",OWL_EQUIVALENT_CLASS:"http://www.w3.org/2002/07/owl#equivalentClass",RDFS_LABEL:"http://www.w3.org/2000/01/rdf-schema#label",RDFS_COMMENT:"http://www.w3.org/2000/01/rdf-schema#comment"};gt.DEFAULT_NODE_STYLE={color:"#6366f1",borderColor:"#4f46e5",borderWidth:2,size:30,shape:"circle",icon:"",opacity:1,shadow:!1,animation:"none"};gt.DEFAULT_EDGE_STYLE={color:"#9ca3af",width:1,lineStyle:"solid",arrow:"standard",curvature:0,opacity:.6,showLabel:!1,labelPosition:.5};gt.BUILT_IN_NODE_STYLES={"http://www.w3.org/2000/01/rdf-schema#Class":{color:"#f59e0b",shape:"diamond",size:40},"http://www.w3.org/2002/07/owl#Class":{color:"#f59e0b",shape:"diamond",size:40},ems__Task:{color:"#22c55e",shape:"circle"},ems__Project:{color:"#3b82f6",shape:"square"},ems__Area:{color:"#8b5cf6",shape:"hexagon",size:40},ems__Meeting:{color:"#ec4899",shape:"circle"},exo__Class:{color:"#f59e0b",shape:"diamond"},ims__Person:{color:"#06b6d4",shape:"circle"}};gt.BUILT_IN_EDGE_STYLES={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":{color:"#f59e0b",lineStyle:"dashed",arrow:"standard"},"http://www.w3.org/2000/01/rdf-schema#subClassOf":{color:"#8b5cf6",width:2,arrow:"triangle"},"https://exocortex.my/ontology/ems#Effort_parent":{color:"#6366f1",width:2,arrow:"standard"},"https://exocortex.my/ontology/exo#Asset_prototype":{color:"#f59e0b",lineStyle:"dashed",arrow:"circle"},"https://exocortex.my/ontology/exo#references":{color:"#22c55e",opacity:.4,arrow:"standard"}};function ex(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}o(ex,"mergeNodeStyles");function tx(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}o(tx,"mergeEdgeStyles");function rx(n){let e=n.lastIndexOf("#"),t=n.lastIndexOf("/"),r=Math.max(e,t);return r>=0?n.substring(r+1):n}o(rx,"extractLocalName");function nx(n){return n===gt.RDF_TYPE_PREDICATES.RDFS_CLASS||n===gt.RDF_TYPE_PREDICATES.OWL_CLASS}o(nx,"isClassType");function ix(n){return n===gt.RDF_TYPE_PREDICATES.RDF_TYPE}o(ix,"isTypePredicate");function sx(n){return n===gt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF}o(sx,"isSubClassPredicate")});var U2=v(V2=>{"use strict";Object.defineProperty(V2,"__esModule",{value:!0})});var Qe=v(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});nl.IRI=void 0;var tp=class n{static{o(this,"IRI")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("IRI cannot be empty");if(!n.isValidIRI(t))throw new Error("Invalid IRI format");this._value=t}get value(){return this._value}equals(e){return this._value===e._value}toString(){return this._value}static isValidIRI(e){if(!e||e.trim().length===0||/\s/.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=["http","https","ftp","ftps","file","mailto","tel","data","ws","wss","urn","obsidian"],i=e.match(/^([a-z][a-z0-9+.-]*?):/i);if(i){let s=i[1].toLowerCase();if(!r.includes(s))return!1}try{return new URL(e),!0}catch{return/^urn:[a-z0-9][a-z0-9-]{0,31}:[^\s]+$/i.test(e)}}};nl.IRI=tp});var lt=v(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.Literal=void 0;Rs.parseLanguageTag=B2;Rs.createDirectionalLiteral=ox;Rs.createLiteralFromLanguageTag=cx;var ax="http://www.w3.org/2001/XMLSchema#string",sc=class{static{o(this,"Literal")}constructor(e,t,r,i){if(e.length===0)throw new Error("Literal value cannot be empty");if(t&&r)throw new Error("Literal cannot have both datatype and language tag");if(i&&!r)throw new Error("Literal cannot have direction without language tag");if(i&&i!=="ltr"&&i!=="rtl")throw new Error('Direction must be "ltr" or "rtl"');this._value=e,this._datatype=t,this._language=r?r.toLowerCase():void 0,this._direction=i}get value(){return this._value}get datatype(){return this._datatype}get language(){return this._language}get direction(){return this._direction}hasDirection(){return this._direction!==void 0}equals(e){if(this._value!==e._value||this._language!==e._language||this._direction!==e._direction)return!1;let t=this.normalizedDatatype(),r=e.normalizedDatatype();return t===r}normalizedDatatype(){return!this._datatype||this._datatype.value===ax?null:this._datatype.value}toString(){let e=`"${this._value}"`;return this._datatype?e+=`^^<${this._datatype.value}>`:this._language&&(e+=`@${this._language}`,this._direction&&(e+=`--${this._direction}`)),e}};Rs.Literal=sc;function B2(n){let t=n.lastIndexOf("--");if(t===-1)return{language:n.toLowerCase()};let r=n.substring(t+2),i=n.substring(0,t);return r==="ltr"||r==="rtl"?{language:i.toLowerCase(),direction:r}:{language:n.toLowerCase()}}o(B2,"parseLanguageTag");function ox(n,e,t){return new sc(n,void 0,e,t)}o(ox,"createDirectionalLiteral");function cx(n,e){let{language:t,direction:r}=B2(e);return new sc(n,void 0,t,r)}o(cx,"createLiteralFromLanguageTag")});var Ot=v(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});sl.BlankNode=void 0;var il=class n{static{o(this,"BlankNode")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("BlankNode id cannot be empty");this._id=t}get id(){return this._id}equals(e){return this._id===e._id}toString(){return`_:${this._id}`}static generateId(){return`b${++n.counter}`}static create(){return new n(n.generateId())}};sl.BlankNode=il;il.counter=0});var Yr=v(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});al.Namespace=void 0;var q2=Qe(),gr=class{static{o(this,"Namespace")}constructor(e,t){if(e.trim().length===0)throw new Error("Namespace prefix cannot be empty");this._prefix=e,this._iri=new q2.IRI(t)}get prefix(){return this._prefix}get iri(){return this._iri}term(e){return new q2.IRI(`${this._iri.value}${e}`)}expand(e){let t=e.split(":");if(t.length!==2)return null;let[r,i]=t;return r!==this._prefix?null:this.term(i)}};al.Namespace=gr;gr.RDF=new gr("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");gr.RDFS=new gr("rdfs","http://www.w3.org/2000/01/rdf-schema#");gr.OWL=new gr("owl","http://www.w3.org/2002/07/owl#");gr.XSD=new gr("xsd","http://www.w3.org/2001/XMLSchema#");gr.EXO=new gr("exo","https://exocortex.my/ontology/exo#");gr.EMS=new gr("ems","https://exocortex.my/ontology/ems#")});var xi=v(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.Triple=void 0;var rp=Qe(),np=lt(),ip=Ot(),sp=class{static{o(this,"Triple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof rp.IRI&&t instanceof rp.IRI||e instanceof ip.BlankNode&&t instanceof ip.BlankNode||e instanceof np.Literal&&t instanceof np.Literal||this.isQuotedTriple(e)&&this.isQuotedTriple(t)?e.equals(t):!1}isQuotedTriple(e){return typeof e=="object"&&e!==null&&"termType"in e&&e.termType==="QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`${e} ${t} ${r} .`}nodeToString(e){return e instanceof rp.IRI?`<${e.value}>`:e instanceof ip.BlankNode||e instanceof np.Literal||this.isQuotedTriple(e)?e.toString():""}};ol.Triple=sp});var ac=v(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});cl.QuotedTriple=void 0;var ap=Qe(),op=lt(),cp=Ot(),up=class n{static{o(this,"QuotedTriple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof ap.IRI&&t instanceof ap.IRI||e instanceof cp.BlankNode&&t instanceof cp.BlankNode||e instanceof op.Literal&&t instanceof op.Literal||e instanceof n&&t instanceof n?e.equals(t):!1}get termType(){return"QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`<< ${e} ${t} ${r} >>`}nodeToString(e){return e instanceof ap.IRI?`<${e.value}>`:e instanceof cp.BlankNode||e instanceof op.Literal||e instanceof n?e.toString():""}};cl.QuotedTriple=up});var G2=v(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.QuotedTriple=At.Triple=At.Namespace=At.BlankNode=At.createLiteralFromLanguageTag=At.createDirectionalLiteral=At.parseLanguageTag=At.Literal=At.IRI=void 0;var ux=Qe();Object.defineProperty(At,"IRI",{enumerable:!0,get:o(function(){return ux.IRI},"get")});var ul=lt();Object.defineProperty(At,"Literal",{enumerable:!0,get:o(function(){return ul.Literal},"get")});Object.defineProperty(At,"parseLanguageTag",{enumerable:!0,get:o(function(){return ul.parseLanguageTag},"get")});Object.defineProperty(At,"createDirectionalLiteral",{enumerable:!0,get:o(function(){return ul.createDirectionalLiteral},"get")});Object.defineProperty(At,"createLiteralFromLanguageTag",{enumerable:!0,get:o(function(){return ul.createLiteralFromLanguageTag},"get")});var lx=Ot();Object.defineProperty(At,"BlankNode",{enumerable:!0,get:o(function(){return lx.BlankNode},"get")});var fx=Yr();Object.defineProperty(At,"Namespace",{enumerable:!0,get:o(function(){return fx.Namespace},"get")});var hx=xi();Object.defineProperty(At,"Triple",{enumerable:!0,get:o(function(){return hx.Triple},"get")});var dx=ac();Object.defineProperty(At,"QuotedTriple",{enumerable:!0,get:o(function(){return dx.QuotedTriple},"get")})});var ll=v(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.UUID_URL_NAMESPACE=Xr.DEFAULT_LANGUAGE_TAG=Xr.REQUIRED_PROPERTIES=Xr.ALLOWED_PROPERTIES=Xr.Exo003MetadataType=void 0;var Kr;(function(n){n.Namespace="namespace",n.Anchor="anchor",n.BlankNode="blank_node",n.Statement="statement",n.Body="body"})(Kr||(Xr.Exo003MetadataType=Kr={}));Xr.ALLOWED_PROPERTIES={[Kr.Namespace]:["metadata","uri","aliases"],[Kr.Anchor]:["metadata","uri","aliases"],[Kr.BlankNode]:["metadata","uri","aliases"],[Kr.Statement]:["metadata","subject","predicate","object","aliases"],[Kr.Body]:["metadata","subject","predicate","aliases"]};Xr.REQUIRED_PROPERTIES={[Kr.Namespace]:["metadata","uri"],[Kr.Anchor]:["metadata","uri"],[Kr.BlankNode]:["metadata","uri"],[Kr.Statement]:["metadata","subject","predicate","object"],[Kr.Body]:["metadata","subject","predicate"]};Xr.DEFAULT_LANGUAGE_TAG="ru";Xr.UUID_URL_NAMESPACE="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});var W2=v(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});lp.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var H2=v(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.default="00000000-0000-0000-0000-000000000000"});var z2=v(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i});var oc=v(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var px=z2();function mx(n){return typeof n=="string"&&px.default.test(n)}o(mx,"validate");dp.default=mx});var cc=v(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var gx=oc();function yx(n){if(!(0,gx.default)(n))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(n.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(n.slice(9,13),16))>>>8,e&255,(e=parseInt(n.slice(14,18),16))>>>8,e&255,(e=parseInt(n.slice(19,23),16))>>>8,e&255,(e=parseInt(n.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}o(yx,"parse");pp.default=yx});var Ci=v(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.unsafeStringify=void 0;var vx=oc(),Gt=[];for(let n=0;n<256;++n)Gt.push((n+256).toString(16).slice(1));function Q2(n,e=0){return(Gt[n[e+0]]+Gt[n[e+1]]+Gt[n[e+2]]+Gt[n[e+3]]+"-"+Gt[n[e+4]]+Gt[n[e+5]]+"-"+Gt[n[e+6]]+Gt[n[e+7]]+"-"+Gt[n[e+8]]+Gt[n[e+9]]+"-"+Gt[n[e+10]]+Gt[n[e+11]]+Gt[n[e+12]]+Gt[n[e+13]]+Gt[n[e+14]]+Gt[n[e+15]]).toLowerCase()}o(Q2,"unsafeStringify");uc.unsafeStringify=Q2;function Sx(n,e=0){let t=Q2(n,e);if(!(0,vx.default)(t))throw TypeError("Stringified UUID is invalid");return t}o(Sx,"stringify");uc.default=Sx});var dl=v(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});var _x=require("crypto"),hl=new Uint8Array(256),fl=hl.length;function bx(){return fl>hl.length-16&&((0,_x.randomFillSync)(hl),fl=0),hl.slice(fl,fl+=16)}o(bx,"rng");mp.default=bx});var gp=v(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});fc.updateV1State=void 0;var Y2=dl(),wx=Ci(),lc={};function Ex(n,e,t){let r,i=n?._v6??!1;if(n){let s=Object.keys(n);s.length===1&&s[0]==="_v6"&&(n=void 0)}if(n)r=K2(n.random??n.rng?.()??(0,Y2.default)(),n.msecs,n.nsecs,n.clockseq,n.node,e,t);else{let s=Date.now(),a=(0,Y2.default)();X2(lc,s,a),r=K2(a,lc.msecs,lc.nsecs,i?void 0:lc.clockseq,i?void 0:lc.node,e,t)}return e??(0,wx.unsafeStringify)(r)}o(Ex,"v1");function X2(n,e,t){return n.msecs??=-1/0,n.nsecs??=0,e===n.msecs?(n.nsecs++,n.nsecs>=1e4&&(n.node=void 0,n.nsecs=0)):e>n.msecs?n.nsecs=0:e<n.msecs&&(n.node=void 0),n.node||(n.node=t.slice(10,16),n.node[0]|=1,n.clockseq=(t[8]<<8|t[9])&16383),n.msecs=e,n}o(X2,"updateV1State");fc.updateV1State=X2;function K2(n,e,t,r,i,s,a=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!s)s=new Uint8Array(16),a=0;else if(a<0||a+16>s.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);e??=Date.now(),t??=0,r??=(n[8]<<8|n[9])&16383,i??=n.slice(10,16),e+=122192928e5;let c=((e&268435455)*1e4+t)%4294967296;s[a++]=c>>>24&255,s[a++]=c>>>16&255,s[a++]=c>>>8&255,s[a++]=c&255;let u=e/4294967296*1e4&268435455;s[a++]=u>>>8&255,s[a++]=u&255,s[a++]=u>>>24&15|16,s[a++]=u>>>16&255,s[a++]=r>>>8|128,s[a++]=r&255;for(let l=0;l<6;++l)s[a++]=i[l];return s}o(K2,"v1Bytes");fc.default=Ex});var vp=v(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});var Tx=cc(),Ax=Ci();function xx(n){let e=typeof n=="string"?(0,Tx.default)(n):n,t=Cx(e);return typeof n=="string"?(0,Ax.unsafeStringify)(t):t}o(xx,"v1ToV6");yp.default=xx;function Cx(n){return Uint8Array.of((n[6]&15)<<4|n[7]>>4&15,(n[7]&15)<<4|(n[4]&240)>>4,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,(n[1]&15)<<4|(n[2]&240)>>4,96|n[2]&15,n[3],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}o(Cx,"_v1ToV6")});var J2=v(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});var Ix=require("crypto");function Ox(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,Ix.createHash)("md5").update(n).digest()}o(Ox,"md5");Sp.default=Ox});var hc=v(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.URL=Ii.DNS=Ii.stringToBytes=void 0;var Z2=cc(),Px=Ci();function ev(n){n=unescape(encodeURIComponent(n));let e=new Uint8Array(n.length);for(let t=0;t<n.length;++t)e[t]=n.charCodeAt(t);return e}o(ev,"stringToBytes");Ii.stringToBytes=ev;Ii.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Ii.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Dx(n,e,t,r,i,s){let a=typeof t=="string"?ev(t):t,c=typeof r=="string"?(0,Z2.default)(r):r;if(typeof r=="string"&&(r=(0,Z2.default)(r)),r?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+a.length);if(u.set(c),u.set(a,c.length),u=e(u),u[6]=u[6]&15|n,u[8]=u[8]&63|128,i){s=s||0;for(let l=0;l<16;++l)i[s+l]=u[l];return i}return(0,Px.unsafeStringify)(u)}o(Dx,"v35");Ii.default=Dx});var rv=v(Fs=>{"use strict";Object.defineProperty(Fs,"__esModule",{value:!0});Fs.URL=Fs.DNS=void 0;var Rx=J2(),_p=hc(),tv=hc();Object.defineProperty(Fs,"DNS",{enumerable:!0,get:o(function(){return tv.DNS},"get")});Object.defineProperty(Fs,"URL",{enumerable:!0,get:o(function(){return tv.URL},"get")});function bp(n,e,t,r){return(0,_p.default)(48,Rx.default,n,e,t,r)}o(bp,"v3");bp.DNS=_p.DNS;bp.URL=_p.URL;Fs.default=bp});var nv=v(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var Fx=require("crypto");wp.default={randomUUID:Fx.randomUUID}});var sv=v(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});var iv=nv(),Nx=dl(),Lx=Ci();function kx(n,e,t){if(iv.default.randomUUID&&!e&&!n)return iv.default.randomUUID();n=n||{};let r=n.random??n.rng?.()??(0,Nx.default)();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=r[i];return e}return(0,Lx.unsafeStringify)(r)}o(kx,"v4");Ep.default=kx});var av=v(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});var Mx=require("crypto");function jx(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,Mx.createHash)("sha1").update(n).digest()}o(jx,"sha1");Tp.default=jx});var cv=v(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.URL=Ns.DNS=void 0;var $x=av(),Ap=hc(),ov=hc();Object.defineProperty(Ns,"DNS",{enumerable:!0,get:o(function(){return ov.DNS},"get")});Object.defineProperty(Ns,"URL",{enumerable:!0,get:o(function(){return ov.URL},"get")});function xp(n,e,t,r){return(0,Ap.default)(80,$x.default,n,e,t,r)}o(xp,"v5");xp.DNS=Ap.DNS;xp.URL=Ap.URL;Ns.default=xp});var uv=v(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});var Vx=Ci(),Ux=gp(),Bx=vp();function qx(n,e,t){n??={},t??=0;let r=(0,Ux.default)({...n,_v6:!0},new Uint8Array(16));if(r=(0,Bx.default)(r),e){for(let i=0;i<16;i++)e[t+i]=r[i];return e}return(0,Vx.unsafeStringify)(r)}o(qx,"v6");Cp.default=qx});var lv=v(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});var Gx=cc(),Wx=Ci();function Hx(n){let e=typeof n=="string"?(0,Gx.default)(n):n,t=zx(e);return typeof n=="string"?(0,Wx.unsafeStringify)(t):t}o(Hx,"v6ToV1");Ip.default=Hx;function zx(n){return Uint8Array.of((n[3]&15)<<4|n[4]>>4&15,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|n[6]&15,n[7],(n[1]&15)<<4|(n[2]&240)>>4,(n[2]&15)<<4|(n[3]&240)>>4,16|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}o(zx,"_v6ToV1")});var pv=v(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});dc.updateV7State=void 0;var fv=dl(),Qx=Ci(),Op={};function Yx(n,e,t){let r;if(n)r=hv(n.random??n.rng?.()??(0,fv.default)(),n.msecs,n.seq,e,t);else{let i=Date.now(),s=(0,fv.default)();dv(Op,i,s),r=hv(s,Op.msecs,Op.seq,e,t)}return e??(0,Qx.unsafeStringify)(r)}o(Yx,"v7");function dv(n,e,t){return n.msecs??=-1/0,n.seq??=0,e>n.msecs?(n.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],n.msecs=e):(n.seq=n.seq+1|0,n.seq===0&&n.msecs++),n}o(dv,"updateV7State");dc.updateV7State=dv;function hv(n,e,t,r,i=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return e??=Date.now(),t??=n[6]*127<<24|n[7]<<16|n[8]<<8|n[9],r[i++]=e/1099511627776&255,r[i++]=e/4294967296&255,r[i++]=e/16777216&255,r[i++]=e/65536&255,r[i++]=e/256&255,r[i++]=e&255,r[i++]=112|t>>>28&15,r[i++]=t>>>20&255,r[i++]=128|t>>>14&63,r[i++]=t>>>6&255,r[i++]=t<<2&255|n[10]&3,r[i++]=n[11],r[i++]=n[12],r[i++]=n[13],r[i++]=n[14],r[i++]=n[15],r}o(hv,"v7Bytes");dc.default=Yx});var mv=v(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});var Kx=oc();function Xx(n){if(!(0,Kx.default)(n))throw TypeError("Invalid UUID");return parseInt(n.slice(14,15),16)}o(Xx,"version");Pp.default=Xx});var yr=v(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.version=Je.validate=Je.v7=Je.v6ToV1=Je.v6=Je.v5=Je.v4=Je.v3=Je.v1ToV6=Je.v1=Je.stringify=Je.parse=Je.NIL=Je.MAX=void 0;var Jx=W2();Object.defineProperty(Je,"MAX",{enumerable:!0,get:o(function(){return Jx.default},"get")});var Zx=H2();Object.defineProperty(Je,"NIL",{enumerable:!0,get:o(function(){return Zx.default},"get")});var eC=cc();Object.defineProperty(Je,"parse",{enumerable:!0,get:o(function(){return eC.default},"get")});var tC=Ci();Object.defineProperty(Je,"stringify",{enumerable:!0,get:o(function(){return tC.default},"get")});var rC=gp();Object.defineProperty(Je,"v1",{enumerable:!0,get:o(function(){return rC.default},"get")});var nC=vp();Object.defineProperty(Je,"v1ToV6",{enumerable:!0,get:o(function(){return nC.default},"get")});var iC=rv();Object.defineProperty(Je,"v3",{enumerable:!0,get:o(function(){return iC.default},"get")});var sC=sv();Object.defineProperty(Je,"v4",{enumerable:!0,get:o(function(){return sC.default},"get")});var aC=cv();Object.defineProperty(Je,"v5",{enumerable:!0,get:o(function(){return aC.default},"get")});var oC=uv();Object.defineProperty(Je,"v6",{enumerable:!0,get:o(function(){return oC.default},"get")});var cC=lv();Object.defineProperty(Je,"v6ToV1",{enumerable:!0,get:o(function(){return cC.default},"get")});var uC=pv();Object.defineProperty(Je,"v7",{enumerable:!0,get:o(function(){return uC.default},"get")});var lC=oc();Object.defineProperty(Je,"validate",{enumerable:!0,get:o(function(){return lC.default},"get")});var fC=mv();Object.defineProperty(Je,"version",{enumerable:!0,get:o(function(){return fC.default},"get")})});var Fp=v(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.Exo003UUIDGenerator=void 0;var Dp=yr(),gv=ll(),Rp=class{static{o(this,"Exo003UUIDGenerator")}static generateNamespaceUUID(e){if(!e||e.trim().length===0)throw new Error("Namespace URI cannot be empty");return(0,Dp.v5)(e,gv.UUID_URL_NAMESPACE)}static generateAssetUUID(e,t){if(!t||t.trim().length===0)throw new Error("Local identifier cannot be empty");let r=this.generateNamespaceUUID(e);return(0,Dp.v5)(t,r)}static generateFromIRI(e){if(!e||e.trim().length===0)throw new Error("IRI cannot be empty");let{namespace:t,localName:r}=this.splitIRI(e);return r?this.generateAssetUUID(t,r):(0,Dp.v5)(e,gv.UUID_URL_NAMESPACE)}static generateBlankNodeUUID(e,t){if(!e||e.trim().length===0)throw new Error("Blank node ID cannot be empty");let r="urn:exocortex:blank-node:",i=t?`${t}#${e}`:e;return this.generateAssetUUID(r,i)}static generateStatementUUID(e,t,r){if(!e||!t||!r)throw new Error("Subject, predicate, and object cannot be empty");let i="urn:exocortex:statement:",s=`${e} ${t} ${r}`;return this.generateAssetUUID(i,s)}static generateBodyUUID(e,t){let r="urn:exocortex:body:",i=e;return t?.datatype?i+=`^^${t.datatype}`:t?.language&&(i+=`@${t.language}`,t.direction&&(i+=`--${t.direction}`)),this.generateAssetUUID(r,i)}static splitIRI(e){let t=e.lastIndexOf("#");if(t!==-1&&t<e.length-1)return{namespace:e.substring(0,t+1),localName:e.substring(t+1)};let r=e.lastIndexOf("/"),i=e.indexOf("://");return r!==-1&&r>i+2&&r<e.length-1?{namespace:e.substring(0,r+1),localName:e.substring(r+1)}:{namespace:e,localName:""}}static isValidUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};pl.Exo003UUIDGenerator=Rp});var vv=v(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});gl.Exo003Parser=void 0;var tt=ll(),pc=Fp(),Wi=Qe(),ml=lt(),yv=Ot(),hC=xi(),Np=class{static{o(this,"Exo003Parser")}static parse(e,t){let r=this.validate(e);if(!r.valid)return{success:!1,errors:r.errors};let i=e.metadata;try{return{success:!0,metadata:this.parseByType(e,i),bodyContent:i===tt.Exo003MetadataType.Body?t:void 0}}catch(s){return{success:!1,errors:[s instanceof Error?s.message:String(s)]}}}static validate(e){let t=[],r=[];if(!e.metadata)return t.push("Missing required property: metadata"),{valid:!1,errors:t,warnings:r};let i=e.metadata;if(!Object.values(tt.Exo003MetadataType).includes(i))return t.push(`Invalid metadata: ${i}. Valid types: ${Object.values(tt.Exo003MetadataType).join(", ")}`),{valid:!1,errors:t,warnings:r};let s=i,a=tt.ALLOWED_PROPERTIES[s],c=tt.REQUIRED_PROPERTIES[s];for(let u of c)(e[u]===void 0||e[u]===null)&&t.push(`Missing required property: ${u}`);for(let u of Object.keys(e))a.includes(u)||t.push(`Forbidden property for ${s}: ${u}`);switch(s){case tt.Exo003MetadataType.Namespace:this.validateNamespaceMetadata(e,t);break;case tt.Exo003MetadataType.Anchor:this.validateAnchorMetadata(e,t);break;case tt.Exo003MetadataType.BlankNode:this.validateBlankNodeMetadata(e,t);break;case tt.Exo003MetadataType.Statement:this.validateStatementMetadata(e,t);break;case tt.Exo003MetadataType.Body:this.validateBodyMetadata(e,t,r);break}return{valid:t.length===0,errors:t,warnings:r}}static parseByType(e,t){let r={metadata:t,aliases:e.aliases};switch(t){case tt.Exo003MetadataType.Namespace:return{...r,metadata:tt.Exo003MetadataType.Namespace,uri:e.uri};case tt.Exo003MetadataType.Anchor:return{...r,metadata:tt.Exo003MetadataType.Anchor,uri:e.uri};case tt.Exo003MetadataType.BlankNode:return{...r,metadata:tt.Exo003MetadataType.BlankNode,uri:e.uri};case tt.Exo003MetadataType.Statement:return{...r,metadata:tt.Exo003MetadataType.Statement,subject:e.subject,predicate:e.predicate,object:e.object};case tt.Exo003MetadataType.Body:return{...r,metadata:tt.Exo003MetadataType.Body,subject:e.subject,predicate:e.predicate}}}static validateNamespaceMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new Wi.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateAnchorMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new Wi.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateBlankNodeMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new Wi.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateStatementMetadata(e,t){let r=e.subject,i=e.predicate,s=e.object,a=[["subject",r],["predicate",i],["object",s]];for(let[c,u]of a)u&&typeof u!="string"&&t.push(`${c} must be a string`)}static validateBodyMetadata(e,t,r){let i=e.subject,s=e.predicate;i&&typeof i!="string"&&t.push("subject must be a string"),s&&typeof s!="string"&&t.push("predicate must be a string")}static toTriple(e,t,r){let i=t(e.subject),s;if(i.type==="iri")s=new Wi.IRI(i.value);else if(i.type==="blank")s=new yv.BlankNode(i.value);else throw new Error("Statement subject cannot be a literal");let a=t(e.predicate);if(a.type!=="iri")throw new Error("Statement predicate must be an IRI");let c=new Wi.IRI(a.value),u=t(e.object),l;if(u.type==="iri")l=new Wi.IRI(u.value);else if(u.type==="blank")l=new yv.BlankNode(u.value);else{let f=r||u.value;if(u.datatype)l=new ml.Literal(f,new Wi.IRI(u.datatype));else{let h=u.language||tt.DEFAULT_LANGUAGE_TAG;l=(0,ml.createDirectionalLiteral)(f,h,u.direction)}}return new hC.Triple(s,c,l)}static toLiteral(e,t,r){if(r?.datatype)return new ml.Literal(t,new Wi.IRI(r.datatype));let i=r?.language||tt.DEFAULT_LANGUAGE_TAG;return(0,ml.createDirectionalLiteral)(t,i,r?.direction)}static isExo003Format(e){let t=e.metadata;return typeof t=="string"&&Object.values(tt.Exo003MetadataType).includes(t)}static generateUUID(e,t){switch(e.metadata){case tt.Exo003MetadataType.Namespace:return pc.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case tt.Exo003MetadataType.Anchor:return pc.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case tt.Exo003MetadataType.BlankNode:return pc.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case tt.Exo003MetadataType.Statement:{let r=e;return pc.Exo003UUIDGenerator.generateStatementUUID(r.subject,r.predicate,r.object)}case tt.Exo003MetadataType.Body:{let r=e;return pc.Exo003UUIDGenerator.generateBodyUUID(r.subject+"|"+r.predicate)}}}};gl.Exo003Parser=Np});var Lp=v(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.Exo003Parser=rr.Exo003UUIDGenerator=rr.UUID_URL_NAMESPACE=rr.DEFAULT_LANGUAGE_TAG=rr.REQUIRED_PROPERTIES=rr.ALLOWED_PROPERTIES=rr.Exo003MetadataType=void 0;var mc=ll();Object.defineProperty(rr,"Exo003MetadataType",{enumerable:!0,get:o(function(){return mc.Exo003MetadataType},"get")});Object.defineProperty(rr,"ALLOWED_PROPERTIES",{enumerable:!0,get:o(function(){return mc.ALLOWED_PROPERTIES},"get")});Object.defineProperty(rr,"REQUIRED_PROPERTIES",{enumerable:!0,get:o(function(){return mc.REQUIRED_PROPERTIES},"get")});Object.defineProperty(rr,"DEFAULT_LANGUAGE_TAG",{enumerable:!0,get:o(function(){return mc.DEFAULT_LANGUAGE_TAG},"get")});Object.defineProperty(rr,"UUID_URL_NAMESPACE",{enumerable:!0,get:o(function(){return mc.UUID_URL_NAMESPACE},"get")});var dC=Fp();Object.defineProperty(rr,"Exo003UUIDGenerator",{enumerable:!0,get:o(function(){return dC.Exo003UUIDGenerator},"get")});var pC=vv();Object.defineProperty(rr,"Exo003Parser",{enumerable:!0,get:o(function(){return pC.Exo003Parser},"get")})});var Ls=v(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.WikiLinkHelpers=void 0;var yl=class{static{o(this,"WikiLinkHelpers")}static normalize(e){return e?e.replace(this.WIKI_LINK_PATTERN,"").trim():""}static normalizeArray(e){return e?(Array.isArray(e)?e:[e]).map(r=>this.normalize(r)).filter(r=>r.length>0):[]}static equals(e,t){return this.normalize(e)===this.normalize(t)}static includes(e,t){let r=this.normalizeArray(e),i=this.normalize(t);return r.includes(i)}};vl.WikiLinkHelpers=yl;yl.WIKI_LINK_PATTERN=/\[\[|\]\]/g});var nr=v(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.EffortStatus=Pa.AssetClass=void 0;var mC=Xd();Object.defineProperty(Pa,"AssetClass",{enumerable:!0,get:o(function(){return mC.AssetClass},"get")});var gC=Jd();Object.defineProperty(Pa,"EffortStatus",{enumerable:!0,get:o(function(){return gC.EffortStatus},"get")})});var Hi=v(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.hasClass=Ms;ir.isAreaOrProject=yC;ir.isEffort=vC;ir.hasStatus=SC;ir.isAssetArchived=_C;ir.hasEmptyProperties=bC;ir.needsFolderRepair=wC;ir.getTodayDateString=kp;ir.isPlannedForToday=EC;ir.hasPlannedStartTimestamp=TC;ir.extractDailyNoteDate=AC;ir.isCurrentDateGteDay=xC;ir.inheritsFromPrototype=bv;ir.isPrototypeClass=IC;var _v=Ls(),ks=nr();function Ms(n,e){return n?(Array.isArray(n)?n:[n]).some(r=>_v.WikiLinkHelpers.normalize(r)===e):!1}o(Ms,"hasClass");function yC(n){return Ms(n,ks.AssetClass.AREA)||Ms(n,ks.AssetClass.PROJECT)}o(yC,"isAreaOrProject");function vC(n){return Ms(n,ks.AssetClass.TASK)||Ms(n,ks.AssetClass.PROJECT)||Ms(n,ks.AssetClass.MEETING)}o(vC,"isEffort");function SC(n,e){if(!n)return!1;let t=Array.isArray(n)?n[0]:n;return t?_v.WikiLinkHelpers.normalize(t)===e:!1}o(SC,"hasStatus");function _C(n){if(n===!0||n===1)return!0;if(typeof n=="string"){let e=n.toLowerCase();return e==="true"||e==="yes"}return!1}o(_C,"isAssetArchived");function bC(n){return!n||Object.keys(n).length===0?!1:Object.values(n).some(e=>!!(e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0))}o(bC,"hasEmptyProperties");function wC(n,e){if(!e)return!1;let t=n.replace(/\/$/,""),r=e.replace(/\/$/,"");return t!==r}o(wC,"needsFolderRepair");function kp(){let n=new Date,e=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0");return`${e}-${t}-${r}`}o(kp,"getTodayDateString");function EC(n){let e=n.ems__Effort_plannedStartTimestamp;if(!e)return!1;let t=kp();return typeof e=="string"?e.split("T")[0]===t:Array.isArray(e)&&e.length>0?String(e[0]).split("T")[0]===t:!1}o(EC,"isPlannedForToday");function TC(n){let e=n.ems__Effort_plannedStartTimestamp;return e?typeof e=="string"?e.trim().length>0:Array.isArray(e)&&e.length>0?String(e[0]).trim().length>0:!1:!1}o(TC,"hasPlannedStartTimestamp");function AC(n){let e=n.pn__DailyNote_day;if(!e)return null;if(typeof e=="string"){let t=e.match(/\[\[([^\[\]]+)\]\]/);return t?t[1]:e}if(Array.isArray(e)&&e.length>0){let t=String(e[0]),r=t.match(/\[\[([^\[\]]+)\]\]/);return r?r[1]:t}return null}o(AC,"extractDailyNoteDate");function xC(n){return kp()>=n}o(xC,"isCurrentDateGteDay");function Sv(n){return n?n.replace(/^["']|["']$/g,"").replace(/\[\[|\]\]/g,"").trim():""}o(Sv,"normalizeWithQuotes");var CC=10;function bv(n,e=CC){let t=n.exo__Class_superClass;if(!t)return!1;let r=new Set,i=[],s=Array.isArray(t)?t:[t];for(let a of s){let c=Sv(a);c&&i.push({className:c,depth:0})}for(;i.length>0;){let a=i.shift();if(!a)continue;let{className:c,depth:u}=a;if(u>e)continue;if(c===ks.AssetClass.PROTOTYPE)return!0;if(r.has(c))continue;r.add(c);let l=`${c}__exo__Class_superClass`,f=n[l];if(f){let h=Array.isArray(f)?f:[f];for(let d of h){let p=Sv(d);p&&!r.has(p)&&i.push({className:p,depth:u+1})}}}return!1}o(bv,"inheritsFromPrototype");function IC(n,e){return Ms(n,ks.AssetClass.CLASS)?bv(e):!1}o(IC,"isPrototypeClass")});var Ev=v(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.canCreateTask=OC;gc.canCreateRelatedTask=PC;gc.canConvertTaskToProject=DC;var Sl=Hi(),wv=nr();function OC(n){return(0,Sl.isAreaOrProject)(n.instanceClass)}o(OC,"canCreateTask");function PC(n){return!(!(0,Sl.hasClass)(n.instanceClass,wv.AssetClass.TASK)||(0,Sl.isAssetArchived)(n.isArchived))}o(PC,"canCreateRelatedTask");function DC(n){return(0,Sl.hasClass)(n.instanceClass,wv.AssetClass.TASK)}o(DC,"canConvertTaskToProject")});var Tv=v(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});Da.canCreateProject=RC;Da.canMoveToAnalysis=FC;Da.canMoveToToDo=NC;Da.canConvertProjectToTask=LC;var zi=Hi(),Qi=nr();function RC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.AREA)||(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.INITIATIVE)||(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)}o(RC,"canCreateProject");function FC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)?(0,zi.hasStatus)(n.currentStatus,Qi.EffortStatus.BACKLOG):!1}o(FC,"canMoveToAnalysis");function NC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)?(0,zi.hasStatus)(n.currentStatus,Qi.EffortStatus.ANALYSIS):!1}o(NC,"canMoveToToDo");function LC(n){return(0,zi.hasClass)(n.instanceClass,Qi.AssetClass.PROJECT)}o(LC,"canConvertProjectToTask")});var Cv=v(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.canCreateChildArea=kC;_l.canSetActiveFocus=MC;var Av=Hi(),xv=nr();function kC(n){return(0,Av.hasClass)(n.instanceClass,xv.AssetClass.AREA)}o(kC,"canCreateChildArea");function MC(n){return(0,Av.hasClass)(n.instanceClass,xv.AssetClass.AREA)}o(MC,"canSetActiveFocus")});var Ov=v(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.canPlanOnToday=jC;Dr.canPlanForEvening=$C;Dr.canShiftDayBackward=VC;Dr.canShiftDayForward=UC;Dr.canSetDraftStatus=BC;Dr.canMoveToBacklog=qC;Dr.canStartEffort=GC;Dr.canMarkDone=WC;Dr.canTrashEffort=HC;Dr.canVoteOnEffort=zC;Dr.canRollbackStatus=QC;Dr.canArchiveTask=YC;var Iv=Ls(),ot=Hi(),Vr=nr();function jC(n){return!(!(0,ot.isEffort)(n.instanceClass)||(0,ot.isPlannedForToday)(n.metadata))}o(jC,"canPlanOnToday");function $C(n){return!(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.TASK)&&!(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.MEETING)?!1:(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.BACKLOG)}o($C,"canPlanForEvening");function VC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasPlannedStartTimestamp)(n.metadata):!1}o(VC,"canShiftDayBackward");function UC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasPlannedStartTimestamp)(n.metadata):!1}o(UC,"canShiftDayForward");function BC(n){return(0,ot.isEffort)(n.instanceClass)?!n.currentStatus:!1}o(BC,"canSetDraftStatus");function qC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.DRAFT):!1}o(qC,"canMoveToBacklog");function GC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.TASK)||(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.MEETING)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.BACKLOG):(0,ot.hasClass)(n.instanceClass,Vr.AssetClass.PROJECT)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.TODO):!1:!1}o(GC,"canStartEffort");function WC(n){return(0,ot.isEffort)(n.instanceClass)?(0,ot.hasStatus)(n.currentStatus,Vr.EffortStatus.DOING):!1}o(WC,"canMarkDone");function HC(n){return(0,ot.isEffort)(n.instanceClass)?n.currentStatus?!(Array.isArray(n.currentStatus)?n.currentStatus:[n.currentStatus]).some(r=>{let i=Iv.WikiLinkHelpers.normalize(r);return i===Vr.EffortStatus.TRASHED||i===Vr.EffortStatus.DONE}):!0:!1}o(HC,"canTrashEffort");function zC(n){return!(!(0,ot.isEffort)(n.instanceClass)||(0,ot.isAssetArchived)(n.isArchived))}o(zC,"canVoteOnEffort");function QC(n){if(!(0,ot.isEffort)(n.instanceClass)||(0,ot.isAssetArchived)(n.isArchived)||!n.currentStatus)return!1;let e=Array.isArray(n.currentStatus)?n.currentStatus[0]:n.currentStatus;return!(!e||Iv.WikiLinkHelpers.normalize(e)===Vr.EffortStatus.TRASHED)}o(QC,"canRollbackStatus");function YC(n){return!(0,ot.isAssetArchived)(n.isArchived)}o(YC,"canArchiveTask")});var Pv=v(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.canCreateEvent=KC;dn.canCreateInstance=XC;dn.canCleanProperties=JC;dn.canRepairFolder=ZC;dn.canRenameToUid=eI;dn.canCopyLabelToAliases=tI;dn.canCreateNarrowerConcept=rI;dn.canCreateSubclass=nI;dn.canCreateTaskForDailyNote=iI;var Jr=Hi(),js=nr();function KC(n){return(0,Jr.isAreaOrProject)(n.instanceClass)}o(KC,"canCreateEvent");function XC(n){return(0,Jr.hasClass)(n.instanceClass,js.AssetClass.TASK_PROTOTYPE)||(0,Jr.hasClass)(n.instanceClass,js.AssetClass.MEETING_PROTOTYPE)||(0,Jr.hasClass)(n.instanceClass,js.AssetClass.EVENT_PROTOTYPE)||(0,Jr.hasClass)(n.instanceClass,js.AssetClass.PROJECT_PROTOTYPE)?!0:(0,Jr.isPrototypeClass)(n.instanceClass,n.metadata)}o(XC,"canCreateInstance");function JC(n){return(0,Jr.hasEmptyProperties)(n.metadata)}o(JC,"canCleanProperties");function ZC(n){return(0,Jr.needsFolderRepair)(n.currentFolder,n.expectedFolder)}o(ZC,"canRepairFolder");function eI(n,e){let t=n.metadata.exo__Asset_uid;return t?e!==t:!1}o(eI,"canRenameToUid");function tI(n){let e=n.metadata.exo__Asset_label;if(!e||typeof e!="string"||e.trim()==="")return!1;let t=e.trim(),r=n.metadata.aliases;return!r||!Array.isArray(r)||r.length===0?!0:!r.some(i=>typeof i!="string"?!1:i.trim()===t)}o(tI,"canCopyLabelToAliases");function rI(n){return(0,Jr.hasClass)(n.instanceClass,js.AssetClass.CONCEPT)}o(rI,"canCreateNarrowerConcept");function nI(n){return(0,Jr.hasClass)(n.instanceClass,js.AssetClass.CLASS)}o(nI,"canCreateSubclass");function iI(n){return!(!(0,Jr.hasClass)(n.instanceClass,js.AssetClass.DAILY_NOTE)||n.isArchived||!(0,Jr.extractDailyNoteDate)(n.metadata))}o(iI,"canCreateTaskForDailyNote")});var Rv=v(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.canCreateTaskForDailyNote=N.canCreateSubclass=N.canCreateNarrowerConcept=N.canCopyLabelToAliases=N.canRenameToUid=N.canRepairFolder=N.canCleanProperties=N.canCreateInstance=N.canCreateEvent=N.canArchiveTask=N.canRollbackStatus=N.canVoteOnEffort=N.canTrashEffort=N.canMarkDone=N.canStartEffort=N.canMoveToBacklog=N.canSetDraftStatus=N.canShiftDayForward=N.canShiftDayBackward=N.canPlanForEvening=N.canPlanOnToday=N.canSetActiveFocus=N.canCreateChildArea=N.canConvertProjectToTask=N.canMoveToToDo=N.canMoveToAnalysis=N.canCreateProject=N.canConvertTaskToProject=N.canCreateRelatedTask=N.canCreateTask=N.isPrototypeClass=N.inheritsFromPrototype=N.isCurrentDateGteDay=N.extractDailyNoteDate=N.hasPlannedStartTimestamp=N.isPlannedForToday=N.getTodayDateString=N.needsFolderRepair=N.hasEmptyProperties=N.isAssetArchived=N.hasStatus=N.isEffort=N.isAreaOrProject=N.hasClass=void 0;var Rr=Hi();Object.defineProperty(N,"hasClass",{enumerable:!0,get:o(function(){return Rr.hasClass},"get")});Object.defineProperty(N,"isAreaOrProject",{enumerable:!0,get:o(function(){return Rr.isAreaOrProject},"get")});Object.defineProperty(N,"isEffort",{enumerable:!0,get:o(function(){return Rr.isEffort},"get")});Object.defineProperty(N,"hasStatus",{enumerable:!0,get:o(function(){return Rr.hasStatus},"get")});Object.defineProperty(N,"isAssetArchived",{enumerable:!0,get:o(function(){return Rr.isAssetArchived},"get")});Object.defineProperty(N,"hasEmptyProperties",{enumerable:!0,get:o(function(){return Rr.hasEmptyProperties},"get")});Object.defineProperty(N,"needsFolderRepair",{enumerable:!0,get:o(function(){return Rr.needsFolderRepair},"get")});Object.defineProperty(N,"getTodayDateString",{enumerable:!0,get:o(function(){return Rr.getTodayDateString},"get")});Object.defineProperty(N,"isPlannedForToday",{enumerable:!0,get:o(function(){return Rr.isPlannedForToday},"get")});Object.defineProperty(N,"hasPlannedStartTimestamp",{enumerable:!0,get:o(function(){return Rr.hasPlannedStartTimestamp},"get")});Object.defineProperty(N,"extractDailyNoteDate",{enumerable:!0,get:o(function(){return Rr.extractDailyNoteDate},"get")});Object.defineProperty(N,"isCurrentDateGteDay",{enumerable:!0,get:o(function(){return Rr.isCurrentDateGteDay},"get")});Object.defineProperty(N,"inheritsFromPrototype",{enumerable:!0,get:o(function(){return Rr.inheritsFromPrototype},"get")});Object.defineProperty(N,"isPrototypeClass",{enumerable:!0,get:o(function(){return Rr.isPrototypeClass},"get")});var Mp=Ev();Object.defineProperty(N,"canCreateTask",{enumerable:!0,get:o(function(){return Mp.canCreateTask},"get")});Object.defineProperty(N,"canCreateRelatedTask",{enumerable:!0,get:o(function(){return Mp.canCreateRelatedTask},"get")});Object.defineProperty(N,"canConvertTaskToProject",{enumerable:!0,get:o(function(){return Mp.canConvertTaskToProject},"get")});var bl=Tv();Object.defineProperty(N,"canCreateProject",{enumerable:!0,get:o(function(){return bl.canCreateProject},"get")});Object.defineProperty(N,"canMoveToAnalysis",{enumerable:!0,get:o(function(){return bl.canMoveToAnalysis},"get")});Object.defineProperty(N,"canMoveToToDo",{enumerable:!0,get:o(function(){return bl.canMoveToToDo},"get")});Object.defineProperty(N,"canConvertProjectToTask",{enumerable:!0,get:o(function(){return bl.canConvertProjectToTask},"get")});var Dv=Cv();Object.defineProperty(N,"canCreateChildArea",{enumerable:!0,get:o(function(){return Dv.canCreateChildArea},"get")});Object.defineProperty(N,"canSetActiveFocus",{enumerable:!0,get:o(function(){return Dv.canSetActiveFocus},"get")});var Zr=Ov();Object.defineProperty(N,"canPlanOnToday",{enumerable:!0,get:o(function(){return Zr.canPlanOnToday},"get")});Object.defineProperty(N,"canPlanForEvening",{enumerable:!0,get:o(function(){return Zr.canPlanForEvening},"get")});Object.defineProperty(N,"canShiftDayBackward",{enumerable:!0,get:o(function(){return Zr.canShiftDayBackward},"get")});Object.defineProperty(N,"canShiftDayForward",{enumerable:!0,get:o(function(){return Zr.canShiftDayForward},"get")});Object.defineProperty(N,"canSetDraftStatus",{enumerable:!0,get:o(function(){return Zr.canSetDraftStatus},"get")});Object.defineProperty(N,"canMoveToBacklog",{enumerable:!0,get:o(function(){return Zr.canMoveToBacklog},"get")});Object.defineProperty(N,"canStartEffort",{enumerable:!0,get:o(function(){return Zr.canStartEffort},"get")});Object.defineProperty(N,"canMarkDone",{enumerable:!0,get:o(function(){return Zr.canMarkDone},"get")});Object.defineProperty(N,"canTrashEffort",{enumerable:!0,get:o(function(){return Zr.canTrashEffort},"get")});Object.defineProperty(N,"canVoteOnEffort",{enumerable:!0,get:o(function(){return Zr.canVoteOnEffort},"get")});Object.defineProperty(N,"canRollbackStatus",{enumerable:!0,get:o(function(){return Zr.canRollbackStatus},"get")});Object.defineProperty(N,"canArchiveTask",{enumerable:!0,get:o(function(){return Zr.canArchiveTask},"get")});var Oi=Pv();Object.defineProperty(N,"canCreateEvent",{enumerable:!0,get:o(function(){return Oi.canCreateEvent},"get")});Object.defineProperty(N,"canCreateInstance",{enumerable:!0,get:o(function(){return Oi.canCreateInstance},"get")});Object.defineProperty(N,"canCleanProperties",{enumerable:!0,get:o(function(){return Oi.canCleanProperties},"get")});Object.defineProperty(N,"canRepairFolder",{enumerable:!0,get:o(function(){return Oi.canRepairFolder},"get")});Object.defineProperty(N,"canRenameToUid",{enumerable:!0,get:o(function(){return Oi.canRenameToUid},"get")});Object.defineProperty(N,"canCopyLabelToAliases",{enumerable:!0,get:o(function(){return Oi.canCopyLabelToAliases},"get")});Object.defineProperty(N,"canCreateNarrowerConcept",{enumerable:!0,get:o(function(){return Oi.canCreateNarrowerConcept},"get")});Object.defineProperty(N,"canCreateSubclass",{enumerable:!0,get:o(function(){return Oi.canCreateSubclass},"get")});Object.defineProperty(N,"canCreateTaskForDailyNote",{enumerable:!0,get:o(function(){return Oi.canCreateTaskForDailyNote},"get")})});var Fv=v($s=>{"use strict";var sI=$s&&$s.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),aI=$s&&$s.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&sI(e,n,t)};Object.defineProperty($s,"__esModule",{value:!0});aI(Rv(),$s)});var $p=v(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});yc.PropertyFieldType=void 0;yc.rangeToFieldType=uI;var Wt;(function(n){n.Text="text",n.Number="number",n.Date="date",n.DateTime="datetime",n.Boolean="boolean",n.Reference="reference",n.Enum="enum",n.StatusSelect="status-select",n.SizeSelect="size-select",n.Wikilink="wikilink",n.Timestamp="timestamp",n.Unknown="unknown"})(Wt||(yc.PropertyFieldType=Wt={}));var Nv="http://www.w3.org/2001/XMLSchema#",oI="https://exocortex.my/ontology/exo#",cI="https://exocortex.my/ontology/ems#";function uI(n){if(!n)return Wt.Unknown;let e=n.trim();if(!e)return Wt.Unknown;if(e.startsWith(Nv)){let t=e.substring(Nv.length);return jp(t)}if(e.startsWith("xsd:")){let t=e.substring(4);return jp(t)}if(e.includes("XMLSchema#")){let t=e.indexOf("XMLSchema#"),r=e.substring(t+10);return jp(r)}return e.startsWith(cI)||e.startsWith("ems:")?lI(e):e.startsWith(oI)||e.startsWith("exo:")||fI(e)?Wt.Reference:Wt.Text}o(uI,"rangeToFieldType");function jp(n){switch(n.toLowerCase()){case"string":case"normalizedstring":case"token":case"language":case"nmtoken":case"name":case"ncname":case"anyuri":return Wt.Text;case"integer":case"int":case"long":case"short":case"byte":case"nonnegativeinteger":case"positiveinteger":case"nonpositiveinteger":case"negativeinteger":case"unsignedlong":case"unsignedint":case"unsignedshort":case"unsignedbyte":case"decimal":case"float":case"double":return Wt.Number;case"date":return Wt.Date;case"datetime":case"datetimestamp":return Wt.DateTime;case"boolean":return Wt.Boolean;case"time":return Wt.Timestamp;default:return Wt.Text}}o(jp,"xsdTypeToFieldType");function lI(n){let e=n.toLowerCase();return e.includes("effortstatus")?Wt.StatusSelect:e.includes("tasksize")?Wt.SizeSelect:Wt.Reference}o(lI,"emsTypeToFieldType");function fI(n){let e=n.toLowerCase();return e.includes("exocortex.my/ontology")?!0:["asset","task","project","area","effort","class","property","concept"].some(r=>e.includes(r))}o(fI,"isClassReference")});var kv=v(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});vc.propertyNameToUri=hI;vc.uriToPropertyName=Lv;vc.extractPropertyLabel=dI;function hI(n){return n.replace(/^([a-z]+)__/,"$1:")}o(hI,"propertyNameToUri");function Lv(n){if(n.startsWith("http://")||n.startsWith("https://")){let e=n.match(/\/([a-z]+)#([A-Za-z0-9_]+)$/);if(e)return`${e[1]}__${e[2]}`;let t=n.lastIndexOf("#"),r=n.lastIndexOf("/"),i=Math.max(t,r);return i>=0?n.substring(i+1):n}return n.replace(/^([a-z]+):/,"$1__")}o(Lv,"uriToPropertyName");function dI(n){let r=(n.includes(":")?Lv(n):n).replace(/^[a-z]+__/,"").split("_");return(r.length>1?r.slice(1).join(" "):r[0]).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,s=>s.toUpperCase())}o(dI,"extractPropertyLabel")});var wl={};RA(wl,{__assign:()=>Up,__asyncDelegator:()=>xI,__asyncGenerator:()=>AI,__asyncValues:()=>CI,__await:()=>Sc,__awaiter:()=>SI,__classPrivateFieldGet:()=>DI,__classPrivateFieldSet:()=>RI,__createBinding:()=>bI,__decorate:()=>gI,__exportStar:()=>wI,__extends:()=>pI,__generator:()=>_I,__importDefault:()=>PI,__importStar:()=>OI,__makeTemplateObject:()=>II,__metadata:()=>vI,__param:()=>yI,__read:()=>Mv,__rest:()=>mI,__spread:()=>EI,__spreadArrays:()=>TI,__values:()=>Bp});function pI(n,e){Vp(n,e);function t(){this.constructor=n}o(t,"__"),n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function mI(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function gI(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function yI(n,e){return function(t,r){e(t,r,n)}}function vI(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function SI(n,e,t,r){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return o(i,"adopt"),new(t||(t=Promise))(function(s,a){function c(f){try{l(r.next(f))}catch(h){a(h)}}o(c,"fulfilled");function u(f){try{l(r.throw(f))}catch(h){a(h)}}o(u,"rejected");function l(f){f.done?s(f.value):i(f.value).then(c,u)}o(l,"step"),l((r=r.apply(n,e||[])).next())})}function _I(n,e){var t={label:0,sent:o(function(){if(s[0]&1)throw s[1];return s[1]},"sent"),trys:[],ops:[]},r,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(l){return function(f){return u([l,f])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;t;)try{if(r=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(f){l=[6,f],i=0}finally{r=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function bI(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}function wI(n,e){for(var t in n)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=n[t])}function Bp(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:o(function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}},"next")};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Mv(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(a)throw a.error}}return s}function EI(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(Mv(arguments[e]));return n}function TI(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),i=0,e=0;e<t;e++)for(var s=arguments[e],a=0,c=s.length;a<c;a++,i++)r[i]=s[a];return r}function Sc(n){return this instanceof Sc?(this.v=n,this):new Sc(n)}function AI(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(d){r[d]&&(i[d]=function(p){return new Promise(function(S,b){s.push([d,p,S,b])>1||c(d,p)})})}function c(d,p){try{u(r[d](p))}catch(S){h(s[0][3],S)}}function u(d){d.value instanceof Sc?Promise.resolve(d.value.v).then(l,f):h(s[0][2],d)}function l(d){c("next",d)}function f(d){c("throw",d)}function h(d,p){d(p),s.shift(),s.length&&c(s[0][0],s[0][1])}}function xI(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(a){return(t=!t)?{value:Sc(n[i](a)),done:i==="return"}:s?s(a):a}:s}}function CI(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof Bp=="function"?Bp(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(a){return new Promise(function(c,u){a=n[s](a),i(c,u,a.done,a.value)})}}function i(s,a,c,u){Promise.resolve(u).then(function(l){s({value:l,done:c})},a)}}function II(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function OI(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)Object.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function PI(n){return n&&n.__esModule?n:{default:n}}function DI(n,e){if(!e.has(n))throw new TypeError("attempted to get private field on non-instance");return e.get(n)}function RI(n,e,t){if(!e.has(n))throw new TypeError("attempted to set private field on non-instance");return e.set(n,t),t}var Vp,Up,El=DA(()=>{Vp=o(function(n,e){return Vp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])},Vp(n,e)},"extendStatics");o(pI,"__extends");Up=o(function(){return Up=Object.assign||o(function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},"__assign"),Up.apply(this,arguments)},"__assign");o(mI,"__rest");o(gI,"__decorate");o(yI,"__param");o(vI,"__metadata");o(SI,"__awaiter");o(_I,"__generator");o(bI,"__createBinding");o(wI,"__exportStar");o(Bp,"__values");o(Mv,"__read");o(EI,"__spread");o(TI,"__spreadArrays");o(Sc,"__await");o(AI,"__asyncGenerator");o(xI,"__asyncDelegator");o(CI,"__asyncValues");o(II,"__makeTemplateObject");o(OI,"__importStar");o(PI,"__importDefault");o(DI,"__classPrivateFieldGet");o(RI,"__classPrivateFieldSet")});var Wp=v(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});var qp;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(qp||(qp={}));Gp.default=qp});var jv=v(Hp=>{"use strict";Object.defineProperty(Hp,"__esModule",{value:!0});var FI=Wp();Object.defineProperty(Hp,"Lifecycle",{enumerable:!0,get:o(function(){return FI.default},"get")})});var Vs=v(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.defineInjectionTokenMetadata=pn.getParamInfo=pn.INJECTION_TOKEN_METADATA_KEY=void 0;pn.INJECTION_TOKEN_METADATA_KEY="injectionTokens";function NI(n){let e=Reflect.getMetadata("design:paramtypes",n)||[],t=Reflect.getOwnMetadata(pn.INJECTION_TOKEN_METADATA_KEY,n)||{};return Object.keys(t).forEach(r=>{e[+r]=t[r]}),e}o(NI,"getParamInfo");pn.getParamInfo=NI;function LI(n,e){return function(t,r,i){let s=Reflect.getOwnMetadata(pn.INJECTION_TOKEN_METADATA_KEY,t)||{};s[i]=e?{token:n,transform:e.transformToken,transformArgs:e.args||[]}:n,Reflect.defineMetadata(pn.INJECTION_TOKEN_METADATA_KEY,s,t)}}o(LI,"defineInjectionTokenMetadata");pn.defineInjectionTokenMetadata=LI});var zp=v(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});Tl.isClassProvider=void 0;function kI(n){return!!n.useClass}o(kI,"isClassProvider");Tl.isClassProvider=kI});var Qp=v(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});Al.isFactoryProvider=void 0;function MI(n){return!!n.useFactory}o(MI,"isFactoryProvider");Al.isFactoryProvider=MI});var Cl=v(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.delay=Ra.DelayedConstructor=void 0;var xl=class{static{o(this,"DelayedConstructor")}constructor(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}createProxy(e){let t={},r=!1,i,s=o(()=>(r||(i=e(this.wrap()),r=!0),i),"delayedObject");return new Proxy(t,this.createHandler(s))}createHandler(e){let t={},r=o(i=>{t[i]=(...s)=>{s[0]=e();let a=Reflect[i];return a(...s)}},"install");return this.reflectMethods.forEach(r),t}};Ra.DelayedConstructor=xl;function jI(n){if(typeof n>"u")throw new Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new xl(n)}o(jI,"delay");Ra.delay=jI});var Il=v(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.isConstructorToken=ei.isTransformDescriptor=ei.isTokenDescriptor=ei.isNormalToken=void 0;var $I=Cl();function VI(n){return typeof n=="string"||typeof n=="symbol"}o(VI,"isNormalToken");ei.isNormalToken=VI;function UI(n){return typeof n=="object"&&"token"in n&&"multiple"in n}o(UI,"isTokenDescriptor");ei.isTokenDescriptor=UI;function BI(n){return typeof n=="object"&&"token"in n&&"transform"in n}o(BI,"isTransformDescriptor");ei.isTransformDescriptor=BI;function qI(n){return typeof n=="function"||n instanceof $I.DelayedConstructor}o(qI,"isConstructorToken");ei.isConstructorToken=qI});var Yp=v(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.isTokenProvider=void 0;function GI(n){return!!n.useToken}o(GI,"isTokenProvider");Ol.isTokenProvider=GI});var Kp=v(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.isValueProvider=void 0;function WI(n){return n.useValue!=null}o(WI,"isValueProvider");Pl.isValueProvider=WI});var Xp=v(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});var HI=zp();Object.defineProperty(Us,"isClassProvider",{enumerable:!0,get:o(function(){return HI.isClassProvider},"get")});var zI=Qp();Object.defineProperty(Us,"isFactoryProvider",{enumerable:!0,get:o(function(){return zI.isFactoryProvider},"get")});var QI=Il();Object.defineProperty(Us,"isNormalToken",{enumerable:!0,get:o(function(){return QI.isNormalToken},"get")});var YI=Yp();Object.defineProperty(Us,"isTokenProvider",{enumerable:!0,get:o(function(){return YI.isTokenProvider},"get")});var KI=Kp();Object.defineProperty(Us,"isValueProvider",{enumerable:!0,get:o(function(){return KI.isValueProvider},"get")})});var $v=v(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});Dl.isProvider=void 0;var XI=zp(),JI=Kp(),ZI=Yp(),eO=Qp();function tO(n){return XI.isClassProvider(n)||JI.isValueProvider(n)||ZI.isTokenProvider(n)||eO.isFactoryProvider(n)}o(tO,"isProvider");Dl.isProvider=tO});var em=v(Zp=>{"use strict";Object.defineProperty(Zp,"__esModule",{value:!0});var Jp=class{static{o(this,"RegistryBase")}constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let t=this._registryMap.get(e);return t[t.length-1]||null}set(e,t){this.ensure(e),this._registryMap.get(e).push(t)}setAll(e,t){this._registryMap.set(e,t)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}};Zp.default=Jp});var Vv=v(rm=>{"use strict";Object.defineProperty(rm,"__esModule",{value:!0});var rO=em(),tm=class extends rO.default{static{o(this,"Registry")}};rm.default=tm});var Uv=v(im=>{"use strict";Object.defineProperty(im,"__esModule",{value:!0});var nm=class{static{o(this,"ResolutionContext")}constructor(){this.scopedResolutions=new Map}};im.default=nm});var sm=v(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.formatErrorCtor=void 0;function nO(n,e){return n===null?`at position #${e}`:`"${n.split(",")[e].trim()}" at position #${e}`}o(nO,"formatDependency");function iO(n,e,t=" "){return[n,...e.message.split(`
|
|
32
32
|
`).map(r=>t+r)].join(`
|
|
33
|
-
`)}o(tO,"composeErrorMessage");function rO(n,e,t){let[,r=null]=n.toString().match(/constructor\(([\w, ]+)\)/)||[],i=eO(r,e);return tO(`Cannot inject the dependency ${i} of "${n.name}" constructor. Reason:`,t)}o(rO,"formatErrorCtor");Rl.formatErrorCtor=rO});var Vv=v(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});Fl.isDisposable=void 0;function nO(n){return!(typeof n.dispose!="function"||n.dispose.length>0)}o(nO,"isDisposable");Fl.isDisposable=nO});var Bv=v(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.PostResolutionInterceptors=Bs.PreResolutionInterceptors=void 0;var Uv=Zp(),Nl=class extends Uv.default{static{o(this,"PreResolutionInterceptors")}};Bs.PreResolutionInterceptors=Nl;var Ll=class extends Uv.default{static{o(this,"PostResolutionInterceptors")}};Bs.PostResolutionInterceptors=Ll;var sm=class{static{o(this,"Interceptors")}constructor(){this.preResolution=new Nl,this.postResolution=new Ll}};Bs.default=sm});var Yi=v(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.instance=Pi.typeInfo=void 0;var iO=(El(),Rd(wl)),vr=Kp(),sO=Mv(),kl=Il(),aO=jv(),Fr=Gp(),Ml=$v(),oO=im(),cO=Cl(),uO=Vv(),lO=Bv();Pi.typeInfo=new Map;var am=class n{static{o(this,"InternalDependencyContainer")}constructor(e){this.parent=e,this._registry=new aO.default,this.interceptors=new lO.default,this.disposed=!1,this.disposables=new Set}register(e,t,r={lifecycle:Fr.default.Transient}){this.ensureNotDisposed();let i;if(sO.isProvider(t)?i=t:i={useClass:t},vr.isTokenProvider(i)){let s=[e],a=i;for(;a!=null;){let c=a.useToken;if(s.includes(c))throw new Error(`Token registration cycle detected! ${[...s,c].join(" -> ")}`);s.push(c);let u=this._registry.get(c);u&&vr.isTokenProvider(u.provider)?a=u.provider:a=null}}if((r.lifecycle===Fr.default.Singleton||r.lifecycle==Fr.default.ContainerScoped||r.lifecycle==Fr.default.ResolutionScoped)&&(vr.isValueProvider(i)||vr.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Fr.default[r.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:r}),this}registerType(e,t){return this.ensureNotDisposed(),vr.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),vr.isNormalToken(e)){if(vr.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:Fr.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Fr.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let r=e;return t&&!vr.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:Fr.default.Singleton})}resolve(e,t=new Ml.default,r=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&vr.isNormalToken(e)){if(r)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(kl.isConstructorToken(e)){let s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let r=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&r.push(i),i.callback(e,t);this.interceptors.preResolution.setAll(e,r)}}executePostResolutionInterceptor(e,t,r){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,t,r);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Fr.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===Fr.default.Singleton,i=e.options.lifecycle===Fr.default.ContainerScoped,s=r||i,a;return vr.isValueProvider(e.provider)?a=e.provider.useValue:vr.isTokenProvider(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):vr.isClassProvider(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):vr.isFactoryProvider(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===Fr.default.ResolutionScoped&&t.scopedResolutions.set(e,a),a}resolveAll(e,t=new Ml.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&vr.isNormalToken(e)){if(r)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let a=i.map(c=>this.resolveRegistration(c,t));return this.executePostResolutionInterceptor(e,a,"All"),a}let s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(r=>!vr.isValueProvider(r.provider)).map(r=>(r.instance=void 0,r)))}createChildContainer(){this.ensureNotDisposed();let e=new n(this);for(let[t,r]of this._registry.entries())r.some(({options:i})=>i.lifecycle===Fr.default.ContainerScoped)&&e._registry.setAll(t,r.map(i=>i.options.lifecycle===Fr.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,t,r={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:t,options:r})}afterResolution(e,t,r={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:t,options:r})}dispose(){return iO.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let r=t.dispose();r&&e.push(r)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,t){if(e instanceof cO.DelayedConstructor)return e.createProxy(i=>this.resolve(i,t));let r=(()=>{let i=Pi.typeInfo.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error(`TypeInfo not known for "${e.name}"`)}let s=i.map(this.resolveParams(t,e));return new e(...s)})();return uO.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(r,i)=>{try{return kl.isTokenDescriptor(r)?kl.isTransformDescriptor(r)?r.multiple?this.resolve(r.transform).transform(this.resolveAll(r.token,new Ml.default,r.isOptional),...r.transformArgs):this.resolve(r.transform).transform(this.resolve(r.token,e,r.isOptional),...r.transformArgs):r.multiple?this.resolveAll(r.token,new Ml.default,r.isOptional):this.resolve(r.token,e,r.isOptional):kl.isTransformDescriptor(r)?this.resolve(r.transform,e).transform(this.resolve(r.token,e),...r.transformArgs):this.resolve(r,e)}catch(s){throw new Error(oO.formatErrorCtor(t,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};Pi.instance=new am;Pi.default=Pi.instance});var qv=v(cm=>{"use strict";Object.defineProperty(cm,"__esModule",{value:!0});var fO=Vs(),Di=Yi(),om=Il(),hO=im();function dO(){return function(n){let e=fO.getParamInfo(n);return class extends n{constructor(...t){super(...t.concat(e.slice(t.length).map((r,i)=>{try{return om.isTokenDescriptor(r)?om.isTransformDescriptor(r)?r.multiple?Di.instance.resolve(r.transform).transform(Di.instance.resolveAll(r.token),...r.transformArgs):Di.instance.resolve(r.transform).transform(Di.instance.resolve(r.token),...r.transformArgs):r.multiple?Di.instance.resolveAll(r.token):Di.instance.resolve(r.token):om.isTransformDescriptor(r)?Di.instance.resolve(r.transform).transform(Di.instance.resolve(r.token),...r.transformArgs):Di.instance.resolve(r)}catch(s){let a=i+t.length;throw new Error(hO.formatErrorCtor(n,a,s))}})))}}}}o(dO,"autoInjectable");cm.default=dO});var Gv=v(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0});var pO=Vs();function mO(n,e){let t={token:n,multiple:!1,isOptional:e&&e.isOptional};return pO.defineInjectionTokenMetadata(t)}o(mO,"inject");um.default=mO});var jl=v(lm=>{"use strict";Object.defineProperty(lm,"__esModule",{value:!0});var gO=Vs(),yO=Yi(),Wv=Yi();function vO(n){return function(e){yO.typeInfo.set(e,gO.getParamInfo(e)),n&&n.token&&(Array.isArray(n.token)?n.token.forEach(t=>{Wv.instance.register(t,e)}):Wv.instance.register(n.token,e))}}o(vO,"injectable");lm.default=vO});var Hv=v(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});var SO=(El(),Rd(wl)),_O=Yi();function bO(n=[]){return function(e){return n.forEach(t=>{var{token:r,options:i}=t,s=SO.__rest(t,["token","options"]);return _O.instance.register(r,s,i)}),e}}o(bO,"registry");fm.default=bO});var zv=v(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});var wO=jl(),EO=Yi();function TO(){return function(n){wO.default()(n),EO.instance.registerSingleton(n)}}o(TO,"singleton");hm.default=TO});var Qv=v(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0});var AO=Vs();function xO(n,e){let t={token:n,multiple:!0,isOptional:e&&e.isOptional};return AO.defineInjectionTokenMetadata(t)}o(xO,"injectAll");dm.default=xO});var Yv=v(pm=>{"use strict";Object.defineProperty(pm,"__esModule",{value:!0});var CO=Vs();function IO(n,e,...t){let r={token:n,multiple:!0,transform:e,transformArgs:t};return CO.defineInjectionTokenMetadata(r)}o(IO,"injectAllWithTransform");pm.default=IO});var Kv=v(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});var OO=Vs();function PO(n,e,...t){return OO.defineInjectionTokenMetadata(n,{transformToken:e,args:t})}o(PO,"injectWithTransform");mm.default=PO});var Xv=v(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});var DO=jl(),RO=Yi();function FO(n,e){return function(t){DO.default()(t),RO.instance.register(e||t,t,{lifecycle:n})}}o(FO,"scoped");gm.default=FO});var Jv=v(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});var NO=qv();Object.defineProperty(mn,"autoInjectable",{enumerable:!0,get:o(function(){return NO.default},"get")});var LO=Gv();Object.defineProperty(mn,"inject",{enumerable:!0,get:o(function(){return LO.default},"get")});var kO=jl();Object.defineProperty(mn,"injectable",{enumerable:!0,get:o(function(){return kO.default},"get")});var MO=Hv();Object.defineProperty(mn,"registry",{enumerable:!0,get:o(function(){return MO.default},"get")});var jO=zv();Object.defineProperty(mn,"singleton",{enumerable:!0,get:o(function(){return jO.default},"get")});var $O=Qv();Object.defineProperty(mn,"injectAll",{enumerable:!0,get:o(function(){return $O.default},"get")});var VO=Yv();Object.defineProperty(mn,"injectAllWithTransform",{enumerable:!0,get:o(function(){return VO.default},"get")});var UO=Kv();Object.defineProperty(mn,"injectWithTransform",{enumerable:!0,get:o(function(){return UO.default},"get")});var BO=Xv();Object.defineProperty(mn,"scoped",{enumerable:!0,get:o(function(){return BO.default},"get")})});var Zv=v(ym=>{"use strict";Object.defineProperty(ym,"__esModule",{value:!0});function qO(n){let e;return t=>(e==null&&(e=n(t)),e)}o(qO,"instanceCachingFactory");ym.default=qO});var eS=v(vm=>{"use strict";Object.defineProperty(vm,"__esModule",{value:!0});function GO(n){let e=new WeakMap;return t=>{let r=e.get(t);return r==null&&(r=n(t),e.set(t,r)),r}}o(GO,"instancePerContainerCachingFactory");vm.default=GO});var tS=v(Sm=>{"use strict";Object.defineProperty(Sm,"__esModule",{value:!0});function WO(n,e,t,r=!0){let i,s;return a=>{let c=n(a);return(!r||s!==c)&&((s=c)?i=a.resolve(e):i=a.resolve(t)),i}}o(WO,"predicateAwareClassFactory");Sm.default=WO});var rS=v(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var HO=Zv();Object.defineProperty(_c,"instanceCachingFactory",{enumerable:!0,get:o(function(){return HO.default},"get")});var zO=eS();Object.defineProperty(_c,"instancePerContainerCachingFactory",{enumerable:!0,get:o(function(){return zO.default},"get")});var QO=tS();Object.defineProperty(_c,"predicateAwareClassFactory",{enumerable:!0,get:o(function(){return QO.default},"get")})});var Le=v(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});var _m=(El(),Rd(wl));if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var YO=kv();Object.defineProperty(Ki,"Lifecycle",{enumerable:!0,get:o(function(){return YO.Lifecycle},"get")});_m.__exportStar(Jv(),Ki);_m.__exportStar(rS(),Ki);_m.__exportStar(Kp(),Ki);var KO=Cl();Object.defineProperty(Ki,"delay",{enumerable:!0,get:o(function(){return KO.delay},"get")});var XO=Yi();Object.defineProperty(Ki,"container",{enumerable:!0,get:o(function(){return XO.instance},"get")})});var en=v($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});$l.MetadataHelpers=void 0;var bm=class{static{o(this,"MetadataHelpers")}static findAllReferencingProperties(e,t){let r=[];for(let[i,s]of Object.entries(e))this.containsReference(s,t)&&r.push(i);return r}static findReferencingProperty(e,t){for(let[r,i]of Object.entries(e))if(this.containsReference(i,t))return r}static containsReference(e,t){if(!e)return!1;let r=t.replace(/\.md$/,"");if(typeof e=="string"){let i=/\[\[([^\[\]]+)\]\]/g,s;for(;(s=i.exec(e))!==null;){let c=s[1].split("|")[0].trim();if(c===r||c.endsWith(`/${r}`))return!0}return!1}return Array.isArray(e)?e.some(i=>this.containsReference(i,t)):!1}static isAssetArchived(e){let t=e?.exo__Asset_isArchived;if(t!=null){if(t===!0||t===1)return!0;if(typeof t=="string"){let i=t.toLowerCase().trim();if(i==="true"||i==="yes"||i==="1")return!0}if(typeof t=="boolean")return t}let r=e?.archived;if(r==null)return!1;if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0;if(typeof r=="string"){let i=r.toLowerCase().trim();return i==="true"||i==="yes"||i==="1"}return!1}static getPropertyValue(e,t){return t==="Name"||t==="title"?e.title:t==="created"?e.created:t==="modified"?e.modified:t==="path"?e.path:e.metadata?.[t]}static ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}static buildFileContent(e,t){let r=Object.entries(e).map(([s,a])=>{if(Array.isArray(a)){let c=a.map(u=>` - ${u}`).join(`
|
|
33
|
+
`)}o(iO,"composeErrorMessage");function sO(n,e,t){let[,r=null]=n.toString().match(/constructor\(([\w, ]+)\)/)||[],i=nO(r,e);return iO(`Cannot inject the dependency ${i} of "${n.name}" constructor. Reason:`,t)}o(sO,"formatErrorCtor");Rl.formatErrorCtor=sO});var Bv=v(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});Fl.isDisposable=void 0;function aO(n){return!(typeof n.dispose!="function"||n.dispose.length>0)}o(aO,"isDisposable");Fl.isDisposable=aO});var Gv=v(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.PostResolutionInterceptors=Bs.PreResolutionInterceptors=void 0;var qv=em(),Nl=class extends qv.default{static{o(this,"PreResolutionInterceptors")}};Bs.PreResolutionInterceptors=Nl;var Ll=class extends qv.default{static{o(this,"PostResolutionInterceptors")}};Bs.PostResolutionInterceptors=Ll;var am=class{static{o(this,"Interceptors")}constructor(){this.preResolution=new Nl,this.postResolution=new Ll}};Bs.default=am});var Yi=v(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.instance=Pi.typeInfo=void 0;var oO=(El(),Fd(wl)),vr=Xp(),cO=$v(),kl=Il(),uO=Vv(),Fr=Wp(),Ml=Uv(),lO=sm(),fO=Cl(),hO=Bv(),dO=Gv();Pi.typeInfo=new Map;var om=class n{static{o(this,"InternalDependencyContainer")}constructor(e){this.parent=e,this._registry=new uO.default,this.interceptors=new dO.default,this.disposed=!1,this.disposables=new Set}register(e,t,r={lifecycle:Fr.default.Transient}){this.ensureNotDisposed();let i;if(cO.isProvider(t)?i=t:i={useClass:t},vr.isTokenProvider(i)){let s=[e],a=i;for(;a!=null;){let c=a.useToken;if(s.includes(c))throw new Error(`Token registration cycle detected! ${[...s,c].join(" -> ")}`);s.push(c);let u=this._registry.get(c);u&&vr.isTokenProvider(u.provider)?a=u.provider:a=null}}if((r.lifecycle===Fr.default.Singleton||r.lifecycle==Fr.default.ContainerScoped||r.lifecycle==Fr.default.ResolutionScoped)&&(vr.isValueProvider(i)||vr.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Fr.default[r.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:r}),this}registerType(e,t){return this.ensureNotDisposed(),vr.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),vr.isNormalToken(e)){if(vr.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:Fr.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Fr.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let r=e;return t&&!vr.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:Fr.default.Singleton})}resolve(e,t=new Ml.default,r=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&vr.isNormalToken(e)){if(r)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(kl.isConstructorToken(e)){let s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let r=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&r.push(i),i.callback(e,t);this.interceptors.preResolution.setAll(e,r)}}executePostResolutionInterceptor(e,t,r){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,t,r);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Fr.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===Fr.default.Singleton,i=e.options.lifecycle===Fr.default.ContainerScoped,s=r||i,a;return vr.isValueProvider(e.provider)?a=e.provider.useValue:vr.isTokenProvider(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):vr.isClassProvider(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):vr.isFactoryProvider(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===Fr.default.ResolutionScoped&&t.scopedResolutions.set(e,a),a}resolveAll(e,t=new Ml.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&vr.isNormalToken(e)){if(r)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let a=i.map(c=>this.resolveRegistration(c,t));return this.executePostResolutionInterceptor(e,a,"All"),a}let s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(r=>!vr.isValueProvider(r.provider)).map(r=>(r.instance=void 0,r)))}createChildContainer(){this.ensureNotDisposed();let e=new n(this);for(let[t,r]of this._registry.entries())r.some(({options:i})=>i.lifecycle===Fr.default.ContainerScoped)&&e._registry.setAll(t,r.map(i=>i.options.lifecycle===Fr.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,t,r={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:t,options:r})}afterResolution(e,t,r={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:t,options:r})}dispose(){return oO.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let r=t.dispose();r&&e.push(r)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,t){if(e instanceof fO.DelayedConstructor)return e.createProxy(i=>this.resolve(i,t));let r=(()=>{let i=Pi.typeInfo.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error(`TypeInfo not known for "${e.name}"`)}let s=i.map(this.resolveParams(t,e));return new e(...s)})();return hO.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(r,i)=>{try{return kl.isTokenDescriptor(r)?kl.isTransformDescriptor(r)?r.multiple?this.resolve(r.transform).transform(this.resolveAll(r.token,new Ml.default,r.isOptional),...r.transformArgs):this.resolve(r.transform).transform(this.resolve(r.token,e,r.isOptional),...r.transformArgs):r.multiple?this.resolveAll(r.token,new Ml.default,r.isOptional):this.resolve(r.token,e,r.isOptional):kl.isTransformDescriptor(r)?this.resolve(r.transform,e).transform(this.resolve(r.token,e),...r.transformArgs):this.resolve(r,e)}catch(s){throw new Error(lO.formatErrorCtor(t,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};Pi.instance=new om;Pi.default=Pi.instance});var Wv=v(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0});var pO=Vs(),Di=Yi(),cm=Il(),mO=sm();function gO(){return function(n){let e=pO.getParamInfo(n);return class extends n{constructor(...t){super(...t.concat(e.slice(t.length).map((r,i)=>{try{return cm.isTokenDescriptor(r)?cm.isTransformDescriptor(r)?r.multiple?Di.instance.resolve(r.transform).transform(Di.instance.resolveAll(r.token),...r.transformArgs):Di.instance.resolve(r.transform).transform(Di.instance.resolve(r.token),...r.transformArgs):r.multiple?Di.instance.resolveAll(r.token):Di.instance.resolve(r.token):cm.isTransformDescriptor(r)?Di.instance.resolve(r.transform).transform(Di.instance.resolve(r.token),...r.transformArgs):Di.instance.resolve(r)}catch(s){let a=i+t.length;throw new Error(mO.formatErrorCtor(n,a,s))}})))}}}}o(gO,"autoInjectable");um.default=gO});var Hv=v(lm=>{"use strict";Object.defineProperty(lm,"__esModule",{value:!0});var yO=Vs();function vO(n,e){let t={token:n,multiple:!1,isOptional:e&&e.isOptional};return yO.defineInjectionTokenMetadata(t)}o(vO,"inject");lm.default=vO});var jl=v(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});var SO=Vs(),_O=Yi(),zv=Yi();function bO(n){return function(e){_O.typeInfo.set(e,SO.getParamInfo(e)),n&&n.token&&(Array.isArray(n.token)?n.token.forEach(t=>{zv.instance.register(t,e)}):zv.instance.register(n.token,e))}}o(bO,"injectable");fm.default=bO});var Qv=v(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});var wO=(El(),Fd(wl)),EO=Yi();function TO(n=[]){return function(e){return n.forEach(t=>{var{token:r,options:i}=t,s=wO.__rest(t,["token","options"]);return EO.instance.register(r,s,i)}),e}}o(TO,"registry");hm.default=TO});var Yv=v(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0});var AO=jl(),xO=Yi();function CO(){return function(n){AO.default()(n),xO.instance.registerSingleton(n)}}o(CO,"singleton");dm.default=CO});var Kv=v(pm=>{"use strict";Object.defineProperty(pm,"__esModule",{value:!0});var IO=Vs();function OO(n,e){let t={token:n,multiple:!0,isOptional:e&&e.isOptional};return IO.defineInjectionTokenMetadata(t)}o(OO,"injectAll");pm.default=OO});var Xv=v(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});var PO=Vs();function DO(n,e,...t){let r={token:n,multiple:!0,transform:e,transformArgs:t};return PO.defineInjectionTokenMetadata(r)}o(DO,"injectAllWithTransform");mm.default=DO});var Jv=v(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});var RO=Vs();function FO(n,e,...t){return RO.defineInjectionTokenMetadata(n,{transformToken:e,args:t})}o(FO,"injectWithTransform");gm.default=FO});var Zv=v(ym=>{"use strict";Object.defineProperty(ym,"__esModule",{value:!0});var NO=jl(),LO=Yi();function kO(n,e){return function(t){NO.default()(t),LO.instance.register(e||t,t,{lifecycle:n})}}o(kO,"scoped");ym.default=kO});var eS=v(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});var MO=Wv();Object.defineProperty(mn,"autoInjectable",{enumerable:!0,get:o(function(){return MO.default},"get")});var jO=Hv();Object.defineProperty(mn,"inject",{enumerable:!0,get:o(function(){return jO.default},"get")});var $O=jl();Object.defineProperty(mn,"injectable",{enumerable:!0,get:o(function(){return $O.default},"get")});var VO=Qv();Object.defineProperty(mn,"registry",{enumerable:!0,get:o(function(){return VO.default},"get")});var UO=Yv();Object.defineProperty(mn,"singleton",{enumerable:!0,get:o(function(){return UO.default},"get")});var BO=Kv();Object.defineProperty(mn,"injectAll",{enumerable:!0,get:o(function(){return BO.default},"get")});var qO=Xv();Object.defineProperty(mn,"injectAllWithTransform",{enumerable:!0,get:o(function(){return qO.default},"get")});var GO=Jv();Object.defineProperty(mn,"injectWithTransform",{enumerable:!0,get:o(function(){return GO.default},"get")});var WO=Zv();Object.defineProperty(mn,"scoped",{enumerable:!0,get:o(function(){return WO.default},"get")})});var tS=v(vm=>{"use strict";Object.defineProperty(vm,"__esModule",{value:!0});function HO(n){let e;return t=>(e==null&&(e=n(t)),e)}o(HO,"instanceCachingFactory");vm.default=HO});var rS=v(Sm=>{"use strict";Object.defineProperty(Sm,"__esModule",{value:!0});function zO(n){let e=new WeakMap;return t=>{let r=e.get(t);return r==null&&(r=n(t),e.set(t,r)),r}}o(zO,"instancePerContainerCachingFactory");Sm.default=zO});var nS=v(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});function QO(n,e,t,r=!0){let i,s;return a=>{let c=n(a);return(!r||s!==c)&&((s=c)?i=a.resolve(e):i=a.resolve(t)),i}}o(QO,"predicateAwareClassFactory");_m.default=QO});var iS=v(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var YO=tS();Object.defineProperty(_c,"instanceCachingFactory",{enumerable:!0,get:o(function(){return YO.default},"get")});var KO=rS();Object.defineProperty(_c,"instancePerContainerCachingFactory",{enumerable:!0,get:o(function(){return KO.default},"get")});var XO=nS();Object.defineProperty(_c,"predicateAwareClassFactory",{enumerable:!0,get:o(function(){return XO.default},"get")})});var Le=v(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});var bm=(El(),Fd(wl));if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var JO=jv();Object.defineProperty(Ki,"Lifecycle",{enumerable:!0,get:o(function(){return JO.Lifecycle},"get")});bm.__exportStar(eS(),Ki);bm.__exportStar(iS(),Ki);bm.__exportStar(Xp(),Ki);var ZO=Cl();Object.defineProperty(Ki,"delay",{enumerable:!0,get:o(function(){return ZO.delay},"get")});var eP=Yi();Object.defineProperty(Ki,"container",{enumerable:!0,get:o(function(){return eP.instance},"get")})});var en=v($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});$l.MetadataHelpers=void 0;var wm=class{static{o(this,"MetadataHelpers")}static findAllReferencingProperties(e,t){let r=[];for(let[i,s]of Object.entries(e))this.containsReference(s,t)&&r.push(i);return r}static findReferencingProperty(e,t){for(let[r,i]of Object.entries(e))if(this.containsReference(i,t))return r}static containsReference(e,t){if(!e)return!1;let r=t.replace(/\.md$/,"");if(typeof e=="string"){let i=/\[\[([^\[\]]+)\]\]/g,s;for(;(s=i.exec(e))!==null;){let c=s[1].split("|")[0].trim();if(c===r||c.endsWith(`/${r}`))return!0}return!1}return Array.isArray(e)?e.some(i=>this.containsReference(i,t)):!1}static isAssetArchived(e){let t=e?.exo__Asset_isArchived;if(t!=null){if(t===!0||t===1)return!0;if(typeof t=="string"){let i=t.toLowerCase().trim();if(i==="true"||i==="yes"||i==="1")return!0}if(typeof t=="boolean")return t}let r=e?.archived;if(r==null)return!1;if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0;if(typeof r=="string"){let i=r.toLowerCase().trim();return i==="true"||i==="yes"||i==="1"}return!1}static getPropertyValue(e,t){return t==="Name"||t==="title"?e.title:t==="created"?e.created:t==="modified"?e.modified:t==="path"?e.path:e.metadata?.[t]}static ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}static buildFileContent(e,t){let r=Object.entries(e).map(([s,a])=>{if(Array.isArray(a)){let c=a.map(u=>` - ${u}`).join(`
|
|
34
34
|
`);return`${s}:
|
|
35
35
|
${c}`}return`${s}: ${a}`}).join(`
|
|
36
36
|
`),i=t?`
|
|
@@ -39,14 +39,14 @@ ${t}
|
|
|
39
39
|
`;return`---
|
|
40
40
|
${r}
|
|
41
41
|
---
|
|
42
|
-
${i}`}};$l.MetadataHelpers=
|
|
42
|
+
${i}`}};$l.MetadataHelpers=wm});var Ht=v(Vl=>{"use strict";Object.defineProperty(Vl,"__esModule",{value:!0});Vl.DateFormatter=void 0;var Em=class n{static{o(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${r}-${i}T${s}:${a}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${r}-${i}]]"`}static getTodayWikilink(){return n.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${i}`}static parseWikilink(e){let r=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return r?r[1]:null}static addDays(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),n.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[r,i,s]=t,a=new Date(r,i-1,s,0,0,0,0);if(isNaN(a.getTime()))throw new Error(`Invalid date values: ${e}`);return n.toLocalTimestamp(a)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return n.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};Vl.DateFormatter=Em});var bc=v(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.MetadataExtractor=void 0;var tP=en(),Tm=class{static{o(this,"MetadataExtractor")}constructor(e){this.vault=e}extractMetadata(e){return e?this.vault.getFrontmatter(e)||{}:{}}extractInstanceClass(e){return e.exo__Instance_class||null}extractStatus(e){return e.ems__Effort_status||null}extractIsArchived(e){return tP.MetadataHelpers.isAssetArchived(e)}static extractIsDefinedBy(e){let t=e.exo__Asset_isDefinedBy||'""';return Array.isArray(t)&&(t=t[0]||'""'),t}extractExpectedFolder(e){let t=e.exo__Asset_isDefinedBy;if(!t)return null;let r=Array.isArray(t)?t[0]:t;if(!r||typeof r!="string")return null;let i=r.replace(/["'[\]]/g,"").trim();if(!i)return null;let s=i.split("/");return s.pop(),s.join("/")}extractCommandVisibilityContext(e){let t=this.extractMetadata(e),r=this.extractInstanceClass(t),i=this.extractStatus(t),s=this.extractIsArchived(t),a=e.parent?.path||"",c=this.extractExpectedFolder(t);return{instanceClass:r,currentStatus:i,metadata:t,isArchived:s,currentFolder:a,expectedFolder:c}}extractCache(e){return e?this.vault.getFrontmatter(e):null}};Ul.MetadataExtractor=Tm});var Bl=v(qs=>{"use strict";var rP=qs&&qs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(qs,"__esModule",{value:!0});qs.TaskFrontmatterGenerator=void 0;var nP=Le(),sS=yr(),Am=Ht(),iP=Ls(),aS=bc(),oS=en(),vt=nr(),sP=Hi(),aP={[vt.AssetClass.AREA]:"ems__Effort_area",[vt.AssetClass.PROJECT]:"ems__Effort_parent",[vt.AssetClass.TASK_PROTOTYPE]:"exo__Asset_prototype",[vt.AssetClass.MEETING_PROTOTYPE]:"exo__Asset_prototype",[vt.AssetClass.EVENT_PROTOTYPE]:"exo__Asset_prototype",[vt.AssetClass.PROJECT_PROTOTYPE]:"exo__Asset_prototype"},oP={[vt.AssetClass.AREA]:vt.AssetClass.TASK,[vt.AssetClass.PROJECT]:vt.AssetClass.TASK,[vt.AssetClass.TASK_PROTOTYPE]:vt.AssetClass.TASK,[vt.AssetClass.MEETING_PROTOTYPE]:vt.AssetClass.MEETING,[vt.AssetClass.EVENT_PROTOTYPE]:vt.AssetClass.EVENT,[vt.AssetClass.PROJECT_PROTOTYPE]:vt.AssetClass.PROJECT},xm=class{static{o(this,"TaskFrontmatterGenerator")}generateTaskFrontmatter(e,t,r,i,s,a,c){let u=new Date,l=Am.DateFormatter.toLocalTimestamp(u),f=aS.MetadataExtractor.extractIsDefinedBy(e),h=iP.WikiLinkHelpers.normalize(r),d=aP[h],p=oP[h]||vt.AssetClass.TASK,S={};S.exo__Asset_isDefinedBy=oS.MetadataHelpers.ensureQuoted(f),S.exo__Asset_uid=s||(0,sS.v4)(),S.exo__Asset_createdAt=l,S.exo__Instance_class=[`"[[${p}]]"`],S.ems__Effort_status='"[[ems__EffortStatusDraft]]"',d?S[d]=`"[[${t}]]"`:(0,sP.isPrototypeClass)(r,e)&&(S.exo__Asset_prototype=`"[[${t}]]"`);let b=i;if(p===vt.AssetClass.MEETING&&(!i||i.trim()==="")){let T=e.exo__Asset_label||t,I=Am.DateFormatter.toDateString(u);b=`${T} ${I}`}if(b&&b.trim()!==""){let T=b.trim();S.exo__Asset_label=T,S.aliases=[T]}return a&&(S.ems__Task_size=a),c&&(S.ems__Effort_plannedStartTimestamp=c),S}generateRelatedTaskFrontmatter(e,t,r,i,s){let a=new Date,c=Am.DateFormatter.toLocalTimestamp(a),u=aS.MetadataExtractor.extractIsDefinedBy(e),l={};if(l.exo__Asset_isDefinedBy=oS.MetadataHelpers.ensureQuoted(u),l.exo__Asset_uid=i||(0,sS.v4)(),l.exo__Asset_createdAt=c,l.exo__Instance_class=[`"[[${vt.AssetClass.TASK}]]"`],l.ems__Effort_status='"[[ems__EffortStatusDraft]]"',l.exo__Asset_relates=[`"[[${t}]]"`],r&&r.trim()!==""){let f=r.trim();l.exo__Asset_label=f,l.aliases=[f]}return s&&(l.ems__Task_size=s),l}};qs.TaskFrontmatterGenerator=xm;qs.TaskFrontmatterGenerator=xm=rP([(0,nP.injectable)()],xm)});var ql=v(Gs=>{"use strict";var cP=Gs&&Gs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.AlgorithmExtractor=void 0;var uP=Le(),Cm=class{static{o(this,"AlgorithmExtractor")}extractH2Section(e,t){let r=e.split(`
|
|
43
43
|
`),i=`## ${t}`,s=!1,a=[];for(let u of r){if(u.trim()===i){s=!0;continue}if(s){if(u.startsWith("## ")||u.startsWith("# "))break;a.push(u)}}return a.length===0?null:a.join(`
|
|
44
|
-
`).trim()||null}};Gs.AlgorithmExtractor=
|
|
44
|
+
`).trim()||null}};Gs.AlgorithmExtractor=Cm;Gs.AlgorithmExtractor=Cm=cP([(0,uP.injectable)()],Cm)});var uS=v(cS=>{"use strict";Object.defineProperty(cS,"__esModule",{value:!0})});var ct=v(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.DI_TOKENS=void 0;Gl.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"),TaskCreationService:Symbol.for("TaskCreationService"),ProjectCreationService:Symbol.for("ProjectCreationService"),AreaCreationService:Symbol.for("AreaCreationService"),ClassCreationService:Symbol.for("ClassCreationService"),ConceptCreationService:Symbol.for("ConceptCreationService"),FleetingNoteCreationService:Symbol.for("FleetingNoteCreationService"),SupervisionCreationService:Symbol.for("SupervisionCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),TaskFrontmatterGenerator:Symbol.for("TaskFrontmatterGenerator"),DynamicFrontmatterGenerator:Symbol.for("DynamicFrontmatterGenerator"),AlgorithmExtractor:Symbol.for("AlgorithmExtractor"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),LabelToAliasService:Symbol.for("LabelToAliasService"),RenameToUidService:Symbol.for("RenameToUidService"),PlanningService:Symbol.for("PlanningService"),EffortVotingService:Symbol.for("EffortVotingService"),SessionEventService:Symbol.for("SessionEventService"),AssetConversionService:Symbol.for("AssetConversionService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),URIConstructionService:Symbol.for("URIConstructionService"),WebhookService:Symbol.for("WebhookService"),EmbeddingService:Symbol.for("EmbeddingService"),VectorStore:Symbol.for("VectorStore"),SemanticSearchService:Symbol.for("SemanticSearchService")}});var Om=v(zt=>{"use strict";var lP=zt&&zt.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),fP=zt&&zt.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),hP=zt&&zt.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},dP=zt&&zt.__importStar||(function(){var n=o(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&lP(t,e,r[i]);return fP(t,e),t}})(),pP=zt&&zt.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},mP=zt&&zt.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(zt,"__esModule",{value:!0});zt.TaskCreationService=void 0;var lS=Le(),fS=yr(),gP=Ls(),hS=en(),yP=nr(),vP=Bl(),SP=ql(),GV=dP(uS()),_P=ct(),Im=class{static{o(this,"TaskCreationService")}constructor(e,t,r){this.vault=e,this.frontmatterGenerator=t,this.algorithmExtractor=r}async createTask(e,t,r,i,s,a){let c=(0,fS.v4)(),u=`${c}.md`,l=this.frontmatterGenerator.generateTaskFrontmatter(t,e.basename,r,i,c,s,a),f="";if(gP.WikiLinkHelpers.normalize(r)===yP.AssetClass.TASK_PROTOTYPE){let T=await this.vault.read(e),I=this.algorithmExtractor.extractH2Section(T,"Algorithm");I&&(f=`## Algorithm
|
|
45
45
|
|
|
46
|
-
${I}`)}let d=
|
|
46
|
+
${I}`)}let d=hS.MetadataHelpers.buildFileContent(l,f),p=e.parent?.path||"",S=p?`${p}/${u}`:u;return await this.vault.create(S,d)}async createRelatedTask(e,t,r,i){let s=(0,fS.v4)(),a=`${s}.md`,c=this.frontmatterGenerator.generateRelatedTaskFrontmatter(t,e.basename,r,s,i),u=hS.MetadataHelpers.buildFileContent(c),l=e.parent?.path||"",f=l?`${l}/${a}`:a,h=await this.vault.create(f,u);return await this.addRelationToSourceFile(e,s),h}generateTaskFrontmatter(e,t,r,i,s,a,c){return this.frontmatterGenerator.generateTaskFrontmatter(e,t,r,i,s,a,c)}generateRelatedTaskFrontmatter(e,t,r,i,s){return this.frontmatterGenerator.generateRelatedTaskFrontmatter(e,t,r,i,s)}extractH2Section(e,t){return this.algorithmExtractor.extractH2Section(e,t)}async addRelationToSourceFile(e,t){let r=await this.vault.read(e),i=this.addRelationToFrontmatter(r,t);await this.vault.modify(e,i)}addRelationToFrontmatter(e,t){let r=/^---\r?\n([\s\S]*?)\r?\n---/,i=e.match(r),s=e.includes(`\r
|
|
47
47
|
`)?`\r
|
|
48
48
|
`:`
|
|
49
|
-
`;if(!i)return`---${s}exo__Asset_relates:${s} - "[[${t}]]"${s}---${s}${e}`;let c=i[1];if(c.includes("exo__Asset_relates:")){let u=c.match(/exo__Asset_relates:\r?\n((?: {2}- .*\r?\n)*)/);if(u){let l=u[1],f=` - "[[${t}]]"${s}`;c=c.replace(/exo__Asset_relates:\r?\n((?: {2}- .*\r?\n)*)/,`exo__Asset_relates:${s}${l}${f}`)}}else c+=`${s}exo__Asset_relates:${s} - "[[${t}]]"`;return e.replace(r,`---${s}${c}${s}---`)}};zt.TaskCreationService=
|
|
49
|
+
`;if(!i)return`---${s}exo__Asset_relates:${s} - "[[${t}]]"${s}---${s}${e}`;let c=i[1];if(c.includes("exo__Asset_relates:")){let u=c.match(/exo__Asset_relates:\r?\n((?: {2}- .*\r?\n)*)/);if(u){let l=u[1],f=` - "[[${t}]]"${s}`;c=c.replace(/exo__Asset_relates:\r?\n((?: {2}- .*\r?\n)*)/,`exo__Asset_relates:${s}${l}${f}`)}}else c+=`${s}exo__Asset_relates:${s} - "[[${t}]]"`;return e.replace(r,`---${s}${c}${s}---`)}};zt.TaskCreationService=Im;zt.TaskCreationService=Im=hP([(0,lS.injectable)(),mP(0,(0,lS.inject)(_P.DI_TOKENS.IVaultAdapter)),pP("design:paramtypes",[Object,vP.TaskFrontmatterGenerator,SP.AlgorithmExtractor])],Im)});var Dm=v(gn=>{"use strict";var bP=gn&&gn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},wP=gn&&gn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},EP=gn&&gn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(gn,"__esModule",{value:!0});gn.ProjectCreationService=void 0;var dS=Le(),pS=yr(),TP=Ls(),Wl=nr(),AP=Ht(),xP=bc(),mS=en(),CP=ct(),IP={[Wl.AssetClass.AREA]:"ems__Effort_area",[Wl.AssetClass.INITIATIVE]:"ems__Effort_parent",[Wl.AssetClass.PROJECT]:"ems__Effort_parent"},Pm=class{static{o(this,"ProjectCreationService")}constructor(e){this.vault=e}async createProject(e,t,r,i){let s=(0,pS.v4)(),a=`${s}.md`,c=this.generateProjectFrontmatter(t,e.basename,r,i,s),u=mS.MetadataHelpers.buildFileContent(c),l=e.parent?.path||"",f=l?`${l}/${a}`:a;return await this.vault.create(f,u)}generateProjectFrontmatter(e,t,r,i,s){let a=new Date,c=AP.DateFormatter.toLocalTimestamp(a),u=xP.MetadataExtractor.extractIsDefinedBy(e),l=TP.WikiLinkHelpers.normalize(r),f=IP[l]||"ems__Effort_area",h={};if(h.exo__Asset_isDefinedBy=mS.MetadataHelpers.ensureQuoted(u),h.exo__Asset_uid=s||(0,pS.v4)(),h.exo__Asset_createdAt=c,h.exo__Instance_class=[`"[[${Wl.AssetClass.PROJECT}]]"`],h.ems__Effort_status='"[[ems__EffortStatusDraft]]"',h[f]=`"[[${t}]]"`,i&&i.trim()!==""){let d=i.trim();h.exo__Asset_label=d,h.aliases=[d]}return h}};gn.ProjectCreationService=Pm;gn.ProjectCreationService=Pm=bP([(0,dS.injectable)(),EP(0,(0,dS.inject)(CP.DI_TOKENS.IVaultAdapter)),wP("design:paramtypes",[Object])],Pm)});var Xi=v(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});zl.FrontmatterService=void 0;var Hl=class n{static{o(this,"FrontmatterService")}parse(e){let t=e.match(n.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}updateProperty(e,t,r){let i=this.parse(e);if(!i.exists)return this.createFrontmatter(e,{[t]:r});let s=i.content;if(this.hasProperty(s,t)){let a=new RegExp(`${this.escapeRegex(t)}:.*$`,"m");s=s.replace(a,`${t}: ${r}`)}else{let a=s.length>0?`
|
|
50
50
|
`:"";s+=`${a}${t}: ${r}`}return e.replace(n.FRONTMATTER_REGEX,`---
|
|
51
51
|
${s}
|
|
52
52
|
---`)}addProperty(e,t,r){return this.updateProperty(e,t,r)}removeProperty(e,t){let r=this.parse(e);if(!r.exists||!this.hasProperty(r.content,t))return e;let i=new RegExp(`
|
|
@@ -58,31 +58,31 @@ ${Object.entries(t).map(([a,c])=>`${a}: ${c}`).join(`
|
|
|
58
58
|
`)}
|
|
59
59
|
---`,s=e.startsWith(`
|
|
60
60
|
`)?"":`
|
|
61
|
-
`;return`${i}${s}${e}`}getPropertyValue(e,t){let r=new RegExp(`${this.escapeRegex(t)}:\\s*(.*)$`,"m"),i=e.match(r);return i?i[1].trim():null}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};zl.FrontmatterService=Hl;Hl.FRONTMATTER_REGEX=/^---\n([\s\S]*?)\n---/});var Ql=v(Ws=>{"use strict";var
|
|
61
|
+
`;return`${i}${s}${e}`}getPropertyValue(e,t){let r=new RegExp(`${this.escapeRegex(t)}:\\s*(.*)$`,"m"),i=e.match(r);return i?i[1].trim():null}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};zl.FrontmatterService=Hl;Hl.FRONTMATTER_REGEX=/^---\n([\s\S]*?)\n---/});var Ql=v(Ws=>{"use strict";var OP=Ws&&Ws.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.EffortStatusWorkflow=void 0;var PP=Le(),Ur=nr(),Rm=class{static{o(this,"EffortStatusWorkflow")}getPreviousStatus(e,t){let r=this.normalizeStatus(e);if(r===Ur.EffortStatus.DRAFT)return null;if(r===Ur.EffortStatus.BACKLOG)return this.wrapStatus(Ur.EffortStatus.DRAFT);if(r===Ur.EffortStatus.ANALYSIS)return this.wrapStatus(Ur.EffortStatus.BACKLOG);if(r===Ur.EffortStatus.TODO)return this.wrapStatus(Ur.EffortStatus.ANALYSIS);if(r===Ur.EffortStatus.DOING)return this.hasInstanceClass(t,Ur.AssetClass.PROJECT)?this.wrapStatus(Ur.EffortStatus.TODO):this.wrapStatus(Ur.EffortStatus.BACKLOG);if(r===Ur.EffortStatus.DONE)return this.wrapStatus(Ur.EffortStatus.DOING)}normalizeStatus(e){return e.replace(/["'[\]]/g,"").trim()}wrapStatus(e){return`"[[${e}]]"`}hasInstanceClass(e,t){return e?(Array.isArray(e)?e:[e]).some(i=>i.replace(/["'[\]]/g,"").trim()===t):!1}};Ws.EffortStatusWorkflow=Rm;Ws.EffortStatusWorkflow=Rm=OP([(0,PP.injectable)()],Rm)});var Yl=v(yn=>{"use strict";var DP=yn&&yn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},RP=yn&&yn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},FP=yn&&yn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(yn,"__esModule",{value:!0});yn.StatusTimestampService=void 0;var gS=Le(),NP=Xi(),wc=Ht(),LP=ct(),Fm=class{static{o(this,"StatusTimestampService")}constructor(e){this.vault=e,this.frontmatterService=new NP.FrontmatterService}async addStartTimestamp(e){let t=await this.vault.read(e),r=wc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_startTimestamp",r);await this.vault.modify(e,i)}async addEndTimestamp(e,t){let r=await this.vault.read(e),i=t||new Date,s=wc.DateFormatter.toLocalTimestamp(i),a=this.frontmatterService.updateProperty(r,"ems__Effort_endTimestamp",s);await this.vault.modify(e,a)}async addResolutionTimestamp(e){let t=await this.vault.read(e),r=wc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_resolutionTimestamp",r);await this.vault.modify(e,i)}async addEndAndResolutionTimestamps(e,t){let r=await this.vault.read(e),i=t||new Date,s=wc.DateFormatter.toLocalTimestamp(i),a=this.frontmatterService.updateProperty(r,"ems__Effort_endTimestamp",s);a=this.frontmatterService.updateProperty(a,"ems__Effort_resolutionTimestamp",s),await this.vault.modify(e,a)}async removeStartTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_startTimestamp");await this.vault.modify(e,r)}async removeEndTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_endTimestamp");await this.vault.modify(e,r)}async removeResolutionTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_resolutionTimestamp");await this.vault.modify(e,r)}async removeEndAndResolutionTimestamps(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_endTimestamp");r=this.frontmatterService.removeProperty(r,"ems__Effort_resolutionTimestamp"),await this.vault.modify(e,r)}async shiftPlannedEndTimestamp(e,t){let r=await this.vault.read(e),i=this.frontmatterService.parse(r);if(!i.exists)return;let s=this.frontmatterService.getPropertyValue(i.content,"ems__Effort_plannedEndTimestamp");if(!s)return;let a=new Date(s.replace(/["']/g,""));if(isNaN(a.getTime()))return;let c=new Date(a.getTime()+t),u=wc.DateFormatter.toLocalTimestamp(c),l=this.frontmatterService.updateProperty(r,"ems__Effort_plannedEndTimestamp",u);await this.vault.modify(e,l)}};yn.StatusTimestampService=Fm;yn.StatusTimestampService=Fm=DP([(0,gS.injectable)(),FP(0,(0,gS.inject)(LP.DI_TOKENS.IVaultAdapter)),RP("design:paramtypes",[Object])],Fm)});var Lm=v(vn=>{"use strict";var kP=vn&&vn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},MP=vn&&vn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},jP=vn&&vn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(vn,"__esModule",{value:!0});vn.TaskStatusService=void 0;var yS=Le(),$P=Xi(),Hs=Ht(),VP=Ql(),UP=Yl(),BP=ct(),Nm=class{static{o(this,"TaskStatusService")}constructor(e,t,r){this.vault=e,this.workflow=t,this.timestampService=r,this.frontmatterService=new $P.FrontmatterService}async setDraftStatus(e){await this.updateStatus(e,"ems__EffortStatusDraft")}async moveToBacklog(e){await this.updateStatus(e,"ems__EffortStatusBacklog")}async moveToAnalysis(e){await this.updateStatus(e,"ems__EffortStatusAnalysis")}async moveToToDo(e){await this.updateStatus(e,"ems__EffortStatusToDo")}async startEffort(e){let t=await this.vault.read(e),r=Hs.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_status",'"[[ems__EffortStatusDoing]]"');i=this.frontmatterService.updateProperty(i,"ems__Effort_startTimestamp",r),await this.vault.modify(e,i)}async markTaskAsDone(e){let t=await this.vault.read(e),r=Hs.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');i=this.frontmatterService.updateProperty(i,"ems__Effort_endTimestamp",r),i=this.frontmatterService.updateProperty(i,"ems__Effort_resolutionTimestamp",r),await this.vault.modify(e,i)}async syncEffortEndTimestamp(e,t){await this.timestampService.addEndAndResolutionTimestamps(e,t)}async shiftPlannedEndTimestamp(e,t){await this.timestampService.shiftPlannedEndTimestamp(e,t)}async trashEffort(e,t){let r=await this.vault.read(e),i=Hs.DateFormatter.toLocalTimestamp(new Date),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusTrashed]]"');s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),t&&(s=this.appendTrashReason(s,t)),await this.vault.modify(e,s)}appendTrashReason(e,t){let r=`
|
|
62
62
|
|
|
63
63
|
## Trash Reason
|
|
64
64
|
|
|
65
65
|
${t}`;return e.trimEnd()+r}async archiveTask(e){let t=await this.vault.read(e),r=this.frontmatterService.updateProperty(t,"archived","true");r=this.frontmatterService.removeProperty(r,"aliases"),await this.vault.modify(e,r)}async planOnToday(e){let t=await this.vault.read(e),r=Hs.DateFormatter.getTodayStartTimestamp(),i=this.frontmatterService.updateProperty(t,"ems__Effort_plannedStartTimestamp",r);await this.vault.modify(e,i)}async planForEvening(e){let t=await this.vault.read(e),r=new Date;r.setHours(19,0,0,0);let i=Hs.DateFormatter.toLocalTimestamp(r),s=this.frontmatterService.updateProperty(t,"ems__Effort_plannedStartTimestamp",i);await this.vault.modify(e,s)}async shiftDayBackward(e){await this.shiftDay(e,-1)}async shiftDayForward(e){await this.shiftDay(e,1)}async rollbackStatus(e){let t=await this.vault.read(e),r=this.extractCurrentStatus(t),i=this.extractInstanceClass(t);if(!r)throw new Error("No current status to rollback from");let s=this.workflow.getPreviousStatus(r,i);if(s===void 0)throw new Error("Cannot rollback from current status");let a=t;s===null?a=this.frontmatterService.removeProperty(a,"ems__Effort_status"):a=this.frontmatterService.updateProperty(a,"ems__Effort_status",s);let c=this.workflow.normalizeStatus(r);c==="ems__EffortStatusDone"?(a=this.frontmatterService.removeProperty(a,"ems__Effort_endTimestamp"),a=this.frontmatterService.removeProperty(a,"ems__Effort_resolutionTimestamp")):c==="ems__EffortStatusDoing"&&(a=this.frontmatterService.removeProperty(a,"ems__Effort_startTimestamp")),await this.vault.modify(e,a)}async updateStatus(e,t){let r=await this.vault.read(e),i=this.frontmatterService.updateProperty(r,"ems__Effort_status",`"[[${t}]]"`);await this.vault.modify(e,i)}async shiftDay(e,t){let r=await this.vault.read(e),i=this.extractPlannedStartTimestamp(r);if(!i)throw new Error("ems__Effort_plannedStartTimestamp property not found");let s=this.parseDateFromTimestamp(i);if(!s)throw new Error("Invalid date format in ems__Effort_plannedStartTimestamp");let a=Hs.DateFormatter.addDays(s,t);a.setHours(0,0,0,0);let c=Hs.DateFormatter.toLocalTimestamp(a),u=this.frontmatterService.updateProperty(r,"ems__Effort_plannedStartTimestamp",c);await this.vault.modify(e,u)}parseDateFromTimestamp(e){let t=new Date(e);return isNaN(t.getTime())?null:t}extractPlannedStartTimestamp(e){let t=this.frontmatterService.parse(e);return t.exists?this.frontmatterService.getPropertyValue(t.content,"ems__Effort_plannedStartTimestamp"):null}extractCurrentStatus(e){let t=this.frontmatterService.parse(e);return t.exists?this.frontmatterService.getPropertyValue(t.content,"ems__Effort_status"):null}extractInstanceClass(e){let t=this.frontmatterService.parse(e);if(!t.exists)return null;let r=t.content.match(/exo__Instance_class:\s*\n((?:\s*-\s*.*\n?)+)/);return r?r[1].split(`
|
|
66
|
-
`).filter(s=>s.trim()).map(s=>s.replace(/^\s*-\s*/,"").trim()):this.frontmatterService.getPropertyValue(t.content,"exo__Instance_class")}};vn.TaskStatusService=
|
|
66
|
+
`).filter(s=>s.trim()).map(s=>s.replace(/^\s*-\s*/,"").trim()):this.frontmatterService.getPropertyValue(t.content,"exo__Instance_class")}};vn.TaskStatusService=Nm;vn.TaskStatusService=Nm=kP([(0,yS.injectable)(),jP(0,(0,yS.inject)(BP.DI_TOKENS.IVaultAdapter)),MP("design:paramtypes",[Object,VP.EffortStatusWorkflow,UP.StatusTimestampService])],Nm)});var Mm=v(Sn=>{"use strict";var qP=Sn&&Sn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},GP=Sn&&Sn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},WP=Sn&&Sn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Sn,"__esModule",{value:!0});Sn.AreaCreationService=void 0;var vS=Le(),SS=yr(),HP=nr(),zP=Ht(),QP=bc(),_S=en(),YP=ct(),km=class{static{o(this,"AreaCreationService")}constructor(e){this.vault=e}async createChildArea(e,t,r){let i=(0,SS.v4)(),s=`${i}.md`,a=this.generateChildAreaFrontmatter(t,e.basename,r,i),c=_S.MetadataHelpers.buildFileContent(a),u=e.parent?.path||"",l=u?`${u}/${s}`:s;return await this.vault.create(l,c)}generateChildAreaFrontmatter(e,t,r,i){let s=new Date,a=zP.DateFormatter.toLocalTimestamp(s),c=QP.MetadataExtractor.extractIsDefinedBy(e),u={};if(u.exo__Asset_isDefinedBy=_S.MetadataHelpers.ensureQuoted(c),u.exo__Asset_uid=i||(0,SS.v4)(),u.exo__Asset_createdAt=a,u.exo__Instance_class=[`"[[${HP.AssetClass.AREA}]]"`],u.ems__Area_parent=`"[[${t}]]"`,r&&r.trim()!==""){let l=r.trim();u.exo__Asset_label=l,u.aliases=[l]}return u}};Sn.AreaCreationService=km;Sn.AreaCreationService=km=qP([(0,vS.injectable)(),WP(0,(0,vS.inject)(YP.DI_TOKENS.IVaultAdapter)),GP("design:paramtypes",[Object])],km)});var $m=v(_n=>{"use strict";var KP=_n&&_n.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},XP=_n&&_n.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},JP=_n&&_n.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(_n,"__esModule",{value:!0});_n.AreaHierarchyBuilder=void 0;var bS=Le(),wS=nr(),ZP=ct(),jm=class{static{o(this,"AreaHierarchyBuilder")}constructor(e){this.vault=e}buildHierarchy(e,t){let r=this.vault.getAbstractFileByPath(e);if(!this.isFile(r))return null;let i=this.vault.getFrontmatter(r)||{};if(this.extractInstanceClass(i)!==wS.AssetClass.AREA)return null;let a=this.collectAllAreasFromVault(),c=new Set;return this.buildTree(e,a,c,0)}isFile(e){return e&&typeof e=="object"&&"basename"in e&&"path"in e}extractInstanceClass(e){let t=e.exo__Instance_class||"";return Array.isArray(t)?this.cleanWikiLink(t[0]||""):this.cleanWikiLink(t)}cleanWikiLink(e){return typeof e!="string"?"":e.replace(/^\[\[|\]\]$/g,"").trim()}collectAllAreasFromVault(){let e=new Map,t=new Map,r=this.vault.getAllFiles();for(let i of r){let s=this.vault.getFrontmatter(i)||{};if(this.extractInstanceClass(s)===wS.AssetClass.AREA){let c=this.extractParentPath(s);e.set(i.path,{path:i.path,title:i.basename,label:s.exo__Asset_label||void 0,isArchived:this.isArchived(s),depth:0,parentPath:c||void 0}),t.set(i.basename,i.path)}}for(let[,i]of e.entries())i.parentPath&&t.has(i.parentPath)&&(i.parentPath=t.get(i.parentPath));return e}extractParentPath(e){let t=e.ems__Area_parent;if(!t)return null;if(Array.isArray(t)){let r=t[0]||"";return this.cleanWikiLink(r)}return this.cleanWikiLink(t)}isArchived(e){let t=e.exo__Asset_archived;if(t===!0||t==="true")return!0;if(Array.isArray(t)&&t.length>0){let r=t[0];return r===!0||r==="true"}return!1}buildTree(e,t,r,i){if(r.has(e))return null;r.add(e);let s=t.get(e);if(!s)return null;let a=[];for(let[c,u]of t.entries())if(u.parentPath===e){let l=this.buildTree(c,t,r,i+1);l&&a.push(l)}return a.sort((c,u)=>{let l=c.label||c.title,f=u.label||u.title;return l.localeCompare(f)}),{path:s.path,title:s.title,label:s.label,isArchived:s.isArchived,depth:i,parentPath:s.parentPath,children:a}}};_n.AreaHierarchyBuilder=jm;_n.AreaHierarchyBuilder=jm=KP([(0,bS.injectable)(),JP(0,(0,bS.inject)(ZP.DI_TOKENS.IVaultAdapter)),XP("design:paramtypes",[Object])],jm)});var Um=v(bn=>{"use strict";var eD=bn&&bn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},tD=bn&&bn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},rD=bn&&bn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(bn,"__esModule",{value:!0});bn.ClassCreationService=void 0;var ES=Le(),nD=yr(),iD=Ht(),sD=en(),aD=ct(),Vm=class{static{o(this,"ClassCreationService")}constructor(e){this.vault=e}async createSubclass(e,t,r){let i=(0,nD.v4)(),s=this.generateFileName(t),a=s.endsWith(".md")?s:`${s}.md`,c=this.generateClassFrontmatter(e.basename,t,i,r),u=sD.MetadataHelpers.buildFileContent(c),l="classes",f=`${l}/${a}`;return this.vault.getAbstractFileByPath(l)||await this.vault.createFolder(l),await this.vault.create(f,u)}generateFileName(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-");for(;t.startsWith("-");)t=t.slice(1);for(;t.endsWith("-");)t=t.slice(0,-1);return t}generateClassFrontmatter(e,t,r,i){let s=new Date,a=iD.DateFormatter.toLocalTimestamp(s),c={};c.exo__Asset_uid=r,c.exo__Asset_label=t,c.exo__Asset_createdAt=a,c.exo__Instance_class=['"[[exo__Class]]"'],c.exo__Class_superClass=`"[[${e}]]"`;let u=i.exo__Asset_isDefinedBy||'"[[Ontology/EXO]]"';return c.exo__Asset_isDefinedBy=u,c.aliases=[t],c}};bn.ClassCreationService=Vm;bn.ClassCreationService=Vm=eD([(0,ES.injectable)(),rD(0,(0,ES.inject)(aD.DI_TOKENS.IVaultAdapter)),tD("design:paramtypes",[Object])],Vm)});var qm=v(wn=>{"use strict";var oD=wn&&wn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},cD=wn&&wn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},uD=wn&&wn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(wn,"__esModule",{value:!0});wn.ConceptCreationService=void 0;var TS=Le(),lD=yr(),fD=Ht(),hD=en(),dD=nr(),pD=ct(),Bm=class{static{o(this,"ConceptCreationService")}constructor(e){this.vault=e}async createNarrowerConcept(e,t,r,i){let s=(0,lD.v4)(),a=t.endsWith(".md")?t:`${t}.md`,c=this.generateConceptFrontmatter(e.basename,r,i,s),u=hD.MetadataHelpers.buildFileContent(c),l="concepts",f=`${l}/${a}`;return this.vault.getAbstractFileByPath(l)||await this.vault.createFolder(l),await this.vault.create(f,u)}generateConceptFrontmatter(e,t,r,i){let s=new Date,a=fD.DateFormatter.toLocalTimestamp(s),c={};return c.exo__Asset_isDefinedBy='"[[!concepts]]"',c.exo__Asset_uid=i,c.exo__Asset_createdAt=a,c.exo__Instance_class=[`"[[${dD.AssetClass.CONCEPT}]]"`],c.ims__Concept_broader=`"[[${e}]]"`,c.ims__Concept_definition=t,r.length>0&&(c.aliases=r),c}};wn.ConceptCreationService=Bm;wn.ConceptCreationService=Bm=oD([(0,TS.injectable)(),uD(0,(0,TS.inject)(pD.DI_TOKENS.IVaultAdapter)),cD("design:paramtypes",[Object])],Bm)});var Wm=v(En=>{"use strict";var mD=En&&En.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},gD=En&&En.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},yD=En&&En.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(En,"__esModule",{value:!0});En.EffortVotingService=void 0;var AS=Le(),vD=ct(),Gm=class{static{o(this,"EffortVotingService")}constructor(e){this.vault=e}async incrementEffortVotes(e){let t=await this.vault.read(e),i=this.extractVoteCount(t)+1,s=this.updateFrontmatterWithVotes(t,i);return await this.vault.modify(e,s),i}extractVoteCount(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/,r=e.match(t);if(!r)return 0;let s=r[1].match(/ems__Effort_votes:\s*(\d+)/);return s&&s[1]?parseInt(s[1],10):0}updateFrontmatterWithVotes(e,t){let r=/^---\r?\n([\s\S]*?)\r?\n---/,i=e.match(r),s=e.includes(`\r
|
|
67
67
|
`)?`\r
|
|
68
68
|
`:`
|
|
69
|
-
`;if(!i)return`---${s}ems__Effort_votes: ${t}${s}---${s}${e}`;let c=i[1];return c.includes("ems__Effort_votes:")?c=c.replace(/ems__Effort_votes:.*$/m,`ems__Effort_votes: ${t}`):c+=`${s}ems__Effort_votes: ${t}`,e.replace(r,`---${s}${c}${s}---`)}};En.EffortVotingService=
|
|
69
|
+
`;if(!i)return`---${s}ems__Effort_votes: ${t}${s}---${s}${e}`;let c=i[1];return c.includes("ems__Effort_votes:")?c=c.replace(/ems__Effort_votes:.*$/m,`ems__Effort_votes: ${t}`):c+=`${s}ems__Effort_votes: ${t}`,e.replace(r,`---${s}${c}${s}---`)}};En.EffortVotingService=Gm;En.EffortVotingService=Gm=mD([(0,AS.injectable)(),yD(0,(0,AS.inject)(vD.DI_TOKENS.IVaultAdapter)),gD("design:paramtypes",[Object])],Gm)});var zm=v(Tn=>{"use strict";var SD=Tn&&Tn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_D=Tn&&Tn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},bD=Tn&&Tn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Tn,"__esModule",{value:!0});Tn.FolderRepairService=void 0;var xS=Le(),wD=ct(),Hm=class{static{o(this,"FolderRepairService")}constructor(e){this.vault=e}async getExpectedFolder(e,t){let r=t?.exo__Asset_isDefinedBy;if(!r)return null;let i=this.extractReference(r);if(!i)return null;let s=this.vault.getFirstLinkpathDest(i,e.path);return s?this.getFileFolder(s):null}async repairFolder(e,t){let r=`${t}/${e.name}`;if(this.vault.getAbstractFileByPath(r))throw new Error(`Cannot move file: ${r} already exists`);await this.ensureFolderExists(t),await this.vault.rename(e,r)}getFileFolder(e){return e.parent?.path||""}extractReference(e){if(typeof e!="string")return null;let t=e.trim().replace(/^["']|["']$/g,"");return t=t.replace(/^\[\[|\]\]$/g,""),t||null}async ensureFolderExists(e){if(!e)return;let t=this.vault.getAbstractFileByPath(e);if(!(t&&"children"in t))try{await this.vault.createFolder(e)}catch(r){if(r instanceof Error&&r.message.includes("Folder already exists"))return;throw r}}};Tn.FolderRepairService=Hm;Tn.FolderRepairService=Hm=SD([(0,xS.injectable)(),bD(0,(0,xS.inject)(wD.DI_TOKENS.IVaultAdapter)),_D("design:paramtypes",[Object])],Hm)});var Ym=v(An=>{"use strict";var ED=An&&An.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},TD=An&&An.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},AD=An&&An.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(An,"__esModule",{value:!0});An.LabelToAliasService=void 0;var CS=Le(),xD=ct(),Qm=class{static{o(this,"LabelToAliasService")}constructor(e){this.vault=e}async copyLabelToAliases(e){let t=await this.vault.read(e),r=this.extractLabel(t);if(!r)throw new Error("No exo__Asset_label found in file");let i=this.addLabelToAliases(t,r);await this.vault.modify(e,i)}extractLabel(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/,r=e.match(t);if(!r)return null;let s=r[1].match(/exo__Asset_label:\s*["']?([^"'\r\n]+)["']?/);return s&&s[1]?s[1].trim():null}addLabelToAliases(e,t){let r=/^---\r?\n([\s\S]*?)\r?\n---/,i=e.match(r),s=e.includes(`\r
|
|
70
70
|
`)?`\r
|
|
71
71
|
`:`
|
|
72
|
-
`;if(!i)return`---${s}aliases:${s} - "${t}"${s}---${s}${e}`;let c=i[1];return c.includes("aliases:")?c.match(/(aliases:\r?\n(?: {2}- .*\r?\n)*)/)&&(c=c.replace(/(aliases:\r?\n(?: {2}- .*\r?\n)*)/,`$1 - "${t}"${s}`)):c+=`${s}aliases:${s} - "${t}"`,e.replace(r,`---${s}${c}${s}---`)}};An.LabelToAliasService=
|
|
72
|
+
`;if(!i)return`---${s}aliases:${s} - "${t}"${s}---${s}${e}`;let c=i[1];return c.includes("aliases:")?c.match(/(aliases:\r?\n(?: {2}- .*\r?\n)*)/)&&(c=c.replace(/(aliases:\r?\n(?: {2}- .*\r?\n)*)/,`$1 - "${t}"${s}`)):c+=`${s}aliases:${s} - "${t}"`,e.replace(r,`---${s}${c}${s}---`)}};An.LabelToAliasService=Qm;An.LabelToAliasService=Qm=ED([(0,CS.injectable)(),AD(0,(0,CS.inject)(xD.DI_TOKENS.IVaultAdapter)),TD("design:paramtypes",[Object])],Qm)});var Ji=v(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.LoggingService=void 0;var Ec=class{static{o(this,"LoggingService")}static setVerbose(e){this.isVerbose=e}static setDevelopmentMode(e){this.isDevelopment=e}static checkIsDevelopment(){return this.isDevelopment!==void 0?this.isDevelopment:typeof process<"u"?(this.isDevelopment=!1,this.isDevelopment):(this.isDevelopment=!1,this.isDevelopment)}static debug(e,t){this.isVerbose&&console.debug(`[Exocortex] ${e}`,t??"")}static info(e,t){console.log(`[Exocortex] ${e}`,t??"")}static warn(e,t){console.warn(`[Exocortex] ${e}`,t??"")}static error(e,t,r){let i=this.checkIsDevelopment(),s=r?` [${r}]`:"";if(i){let a=t?.stack?`
|
|
73
73
|
Stack trace:
|
|
74
74
|
${t.stack}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`,t??"")}else{let a=t?.message?`
|
|
75
|
-
Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`)}}};Kl.LoggingService=Ec;Ec.isVerbose=!1;Ec.isDevelopment=void 0});var
|
|
75
|
+
Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`)}}};Kl.LoggingService=Ec;Ec.isVerbose=!1;Ec.isDevelopment=void 0});var Jm=v(xn=>{"use strict";var CD=xn&&xn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ID=xn&&xn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},IS=xn&&xn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(xn,"__esModule",{value:!0});xn.PropertyCleanupService=void 0;var Km=Le(),OS=ct(),Xm=class{static{o(this,"PropertyCleanupService")}constructor(e,t){this.vault=e,this.logger=t,this.logger.debug("PropertyCleanupService initialized")}async cleanEmptyProperties(e){this.logger.debug("Cleaning empty properties",{path:e.path});let t=await this.vault.read(e),r=this.removeEmptyPropertiesFromContent(t);await this.vault.modify(e,r),this.logger.info("Empty properties cleaned",{path:e.path})}removeEmptyPropertiesFromContent(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return e;let s=r[1].split(`
|
|
76
76
|
`),a=[],c=0;for(;c<s.length;){let l=s[c],f=l.trim();if(f===""){a.push(l),c++;continue}let h=f.match(/^([^:]+):\s*(.*)$/);if(h){let d=h[2];if(d===""&&c+1<s.length&&s[c+1].match(/^\s+- /)){let S=[],b=c+1;for(;b<s.length&&s[b].match(/^\s+- /);)S.push(s[b]),b++;if(S.every(I=>{let O=I.replace(/^\s+- /,"").trim();return this.isEmptyValue(O)})){c=b;continue}else{a.push(l);for(let I=c+1;I<b;I++)a.push(s[I]);c=b;continue}}if(this.isEmptyValue(d)){c++;continue}a.push(l),c++}else f.match(/^\s*- /)||a.push(l),c++}let u=a.join(`
|
|
77
77
|
`);return e.replace(t,`---
|
|
78
78
|
${u}
|
|
79
|
-
---`)}isEmptyValue(e){let t=e.trim();return t===""||t==="null"||t==="undefined"||t==="[]"||t==="{}"||t==='""'||t==="''"}};xn.PropertyCleanupService=
|
|
79
|
+
---`)}isEmptyValue(e){let t=e.trim();return t===""||t==="null"||t==="undefined"||t==="[]"||t==="{}"||t==='""'||t==="''"}};xn.PropertyCleanupService=Xm;xn.PropertyCleanupService=Xm=CD([(0,Km.injectable)(),IS(0,(0,Km.inject)(OS.DI_TOKENS.IVaultAdapter)),IS(1,(0,Km.inject)(OS.DI_TOKENS.ILogger)),ID("design:paramtypes",[Object,Object])],Xm)});var eg=v(Cn=>{"use strict";var OD=Cn&&Cn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},PD=Cn&&Cn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},DD=Cn&&Cn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.RenameToUidService=void 0;var PS=Le(),RD=ct(),Zm=class{static{o(this,"RenameToUidService")}constructor(e){this.vault=e}async renameToUid(e,t){let r=t.exo__Asset_uid;if(!r)throw new Error("Asset has no exo__Asset_uid property");let i=e.basename,s=r;if(i===s)throw new Error("File is already named according to UID");let a=t.exo__Asset_label;if(!a||a.trim()===""){let f=this.isAssetArchived(t);await this.updateLabel(e,i,f)}let u=e.parent?.path||"",l=u?`${u}/${s}.md`:`${s}.md`;await this.vault.updateLinks(e.path,l,i),await this.vault.rename(e,l)}async updateLabel(e,t,r){await this.vault.process(e,i=>{let s=/^---\n([\s\S]*?)\n---/,a=i.match(s);if(!a)return i;let c=a[1];if(c=`${c}
|
|
80
80
|
exo__Asset_label: ${t}`,!r){if(/^aliases\s*:/m.test(c)){let l=/^aliases\s*:\s*(?:\[\s*\]|null|~)?(?:\n(?![ \t]*-))?/gm;c=c.replace(l,""),c=c.replace(/\n{2,}/g,`
|
|
81
81
|
`)}c=`${c}
|
|
82
82
|
aliases:
|
|
83
83
|
- ${t}`}return i.replace(s,`---
|
|
84
84
|
${c}
|
|
85
|
-
---`)})}isAssetArchived(e){if(e?.exo__Asset_isArchived===!0)return!0;let t=e?.archived;if(t==null)return!1;if(typeof t=="boolean")return t;if(typeof t=="number")return t!==0;if(typeof t=="string"){let r=t.toLowerCase().trim();return r==="true"||r==="yes"||r==="1"}return!1}};Cn.RenameToUidService=
|
|
85
|
+
---`)})}isAssetArchived(e){if(e?.exo__Asset_isArchived===!0)return!0;let t=e?.archived;if(t==null)return!1;if(typeof t=="boolean")return t;if(typeof t=="number")return t!==0;if(typeof t=="string"){let r=t.toLowerCase().trim();return r==="true"||r==="yes"||r==="1"}return!1}};Cn.RenameToUidService=Zm;Cn.RenameToUidService=Zm=OD([(0,PS.injectable)(),DD(0,(0,PS.inject)(RD.DI_TOKENS.IVaultAdapter)),PD("design:paramtypes",[Object])],Zm)});var rg=v(In=>{"use strict";var FD=In&&In.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ND=In&&In.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},LD=In&&In.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(In,"__esModule",{value:!0});In.SupervisionCreationService=void 0;var DS=Le(),kD=yr(),MD=Ht(),jD=ct(),tg=class{static{o(this,"SupervisionCreationService")}constructor(e){this.vault=e}async createSupervision(e){let t=(0,kD.v4)(),r=`${t}.md`,i=this.generateFrontmatter(t),s=this.generateBody(e),a=this.buildFileContent(i,s),c=`01 Inbox/${r}`;return await this.vault.create(c,a)}generateFrontmatter(e){let t=new Date,r=MD.DateFormatter.toLocalTimestamp(t);return{exo__Asset_isDefinedBy:'"[[!kitelev]]"',exo__Asset_uid:e,exo__Asset_createdAt:r,exo__Instance_class:['"[[ztlk__FleetingNote]]"'],ztlk__FleetingNote_type:'"[[CBT-Diary Record]]"'}}generateBody(e){return[{label:"\u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044F/\u0442\u0440\u0438\u0433\u0433\u0435\u0440",value:e.situation},{label:"\u042D\u043C\u043E\u0446\u0438\u0438",value:e.emotions},{label:"\u041C\u044B\u0441\u043B\u0438",value:e.thoughts},{label:"\u041F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435",value:e.behavior},{label:"\u041A\u0440\u0430\u0442\u043A\u043E\u0441\u0440\u043E\u0447\u043D\u044B\u0435 \u043F\u043E\u0441\u043B\u0435\u0434\u0441\u0442\u0432\u0438\u044F \u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F",value:e.shortTermConsequences},{label:"\u0414\u043E\u043B\u0433\u043E\u0441\u0440\u043E\u0447\u043D\u044B\u0435 \u043F\u043E\u0441\u043B\u0435\u0434\u0441\u0442\u0432\u0438\u044F \u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u044F",value:e.longTermConsequences}].map(r=>`- ${r.label}: ${r.value}`).join(`
|
|
86
86
|
`)}buildFileContent(e,t){return`---
|
|
87
87
|
${Object.entries(e).map(([i,s])=>{if(Array.isArray(s)){let a=s.map(c=>` - ${c}`).join(`
|
|
88
88
|
`);return`${i}:
|
|
@@ -91,19 +91,19 @@ ${a}`}return`${i}: ${s}`}).join(`
|
|
|
91
91
|
---
|
|
92
92
|
|
|
93
93
|
${t}
|
|
94
|
-
`}};In.SupervisionCreationService=
|
|
94
|
+
`}};In.SupervisionCreationService=tg;In.SupervisionCreationService=tg=FD([(0,DS.injectable)(),LD(0,(0,DS.inject)(jD.DI_TOKENS.IVaultAdapter)),ND("design:paramtypes",[Object])],tg)});var ig=v(On=>{"use strict";var $D=On&&On.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},VD=On&&On.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},UD=On&&On.__param||function(n,e){return function(t,r){e(t,r,n)}},ng;Object.defineProperty(On,"__esModule",{value:!0});On.FleetingNoteCreationService=void 0;var RS=Le(),BD=yr(),qD=Ht(),GD=en(),WD=ct(),Xl=ng=class{static{o(this,"FleetingNoteCreationService")}constructor(e){this.vault=e}async createFleetingNote(e){let t=(0,BD.v4)(),r=`${t}.md`,i=this.generateFrontmatter(t,e),s=GD.MetadataHelpers.buildFileContent(i),a=`${ng.INBOX_FOLDER}/${r}`;return await this.vault.create(a,s)}generateFrontmatter(e,t){let r=new Date,i=qD.DateFormatter.toLocalTimestamp(r),s=t.trim();return{exo__Asset_isDefinedBy:'"[[!kitelev]]"',exo__Asset_uid:e,exo__Asset_createdAt:i,exo__Instance_class:['"[[ztlk__FleetingNote]]"'],exo__Asset_label:s,aliases:[s]}}};On.FleetingNoteCreationService=Xl;Xl.INBOX_FOLDER="01 Inbox";On.FleetingNoteCreationService=Xl=ng=$D([(0,RS.injectable)(),UD(0,(0,RS.inject)(WD.DI_TOKENS.IVaultAdapter)),VD("design:paramtypes",[Object])],Xl)});var ag=v(zs=>{"use strict";var HD=zs&&zs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(zs,"__esModule",{value:!0});zs.DynamicFrontmatterGenerator=void 0;var zD=Le(),QD=yr(),Tc=Ht(),sg=class{static{o(this,"DynamicFrontmatterGenerator")}generate(e,t,r,i){let s={},a=new Date;i?.isDefinedBy&&(s.exo__Asset_isDefinedBy=this.ensureQuoted(i.isDefinedBy)),s.exo__Asset_uid=i?.uid||(0,QD.v4)(),s.exo__Asset_createdAt=i?.createdAt||Tc.DateFormatter.toLocalTimestamp(a),s.exo__Instance_class=[this.formatWikilink(e)];let c=new Map;for(let l of r)c.set(l.name,l.type);for(let[l,f]of Object.entries(t)){if(f==null||l==="exo__Asset_uid"||l==="exo__Asset_createdAt"||l==="exo__Instance_class"||l==="exo__Asset_isDefinedBy")continue;let h=c.get(l);s[l]=this.formatValue(f,h)}let u=t.exo__Asset_label;if(u&&typeof u=="string"&&u.trim()!==""){let l=u.trim();s.exo__Asset_label=l,s.aliases=[l]}return s}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case"text":return this.formatText(e);case"wikilink":return this.formatWikilink(e);case"status-select":case"size-select":return this.formatWikilink(e);case"number":return this.formatNumber(e);case"boolean":return this.formatBoolean(e);case"timestamp":return this.formatTimestamp(e);default:return this.formatText(e)}}formatText(e){return typeof e=="string"?e:String(e)}formatWikilink(e){let t=String(e);return t.startsWith('"[[')&&t.endsWith(']]"')?t:t.startsWith("[[")&&t.endsWith("]]")?`"${t}"`:`"[[${t}]]"`}formatNumber(e){if(typeof e=="number")return e;let t=Number(e);return isNaN(t)?0:t}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return Tc.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:Tc.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Tc.DateFormatter.toLocalTimestamp(t)}return String(e)}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Tc.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}generateYAML(e,t,r,i){let s=this.generate(e,t,r,i);return this.toYAML(s)}toYAML(e){return`---
|
|
95
95
|
${Object.entries(e).map(([r,i])=>{if(Array.isArray(i)){let s=i.map(a=>` - ${a}`).join(`
|
|
96
96
|
`);return`${r}:
|
|
97
97
|
${s}`}return`${r}: ${i}`}).join(`
|
|
98
98
|
`)}
|
|
99
|
-
---`}};zs.DynamicFrontmatterGenerator=
|
|
99
|
+
---`}};zs.DynamicFrontmatterGenerator=sg;zs.DynamicFrontmatterGenerator=sg=HD([(0,zD.injectable)()],sg)});var cg=v(Pn=>{"use strict";var YD=Pn&&Pn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},KD=Pn&&Pn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},XD=Pn&&Pn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Pn,"__esModule",{value:!0});Pn.PlanningService=void 0;var FS=Le(),JD=Xi(),ZD=Ht(),eR=ct(),og=class{static{o(this,"PlanningService")}constructor(e){this.vault=e,this.frontmatterService=new JD.FrontmatterService}async planOnToday(e){let t=this.vault.getAbstractFileByPath(e);if(!t||!this.isFile(t))throw new Error(`File not found: ${e}`);let r=await this.vault.read(t),i=ZD.DateFormatter.getTodayStartTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_plannedStartTimestamp",i);await this.vault.modify(t,s)}isFile(e){return"basename"in e}};Pn.PlanningService=og;Pn.PlanningService=og=YD([(0,FS.injectable)(),XD(0,(0,FS.inject)(eR.DI_TOKENS.IVaultAdapter)),KD("design:paramtypes",[Object])],og)});var lg=v(Dn=>{"use strict";var tR=Dn&&Dn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},rR=Dn&&Dn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},nR=Dn&&Dn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Dn,"__esModule",{value:!0});Dn.AssetConversionService=void 0;var NS=Le(),LS=nr(),iR=Xi(),Jl=Ji(),sR=ct(),ug=class{static{o(this,"AssetConversionService")}constructor(e){this.vault=e,this.frontmatterService=new iR.FrontmatterService}async convertTaskToProject(e){try{let t=await this.vault.read(e),r=this.removeInstanceClassProperty(t);return r=this.frontmatterService.updateProperty(r,"exo__Instance_class",`["[[${LS.AssetClass.PROJECT}]]"]`),await this.vault.modify(e,r),Jl.LoggingService.info(`Converted Task to Project: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Task to Project: ${e.path}`;throw Jl.LoggingService.error(r,t instanceof Error?t:void 0),new Error(r)}}async convertProjectToTask(e){try{let t=await this.vault.read(e),r=this.removeInstanceClassProperty(t);return r=this.frontmatterService.updateProperty(r,"exo__Instance_class",`["[[${LS.AssetClass.TASK}]]"]`),await this.vault.modify(e,r),Jl.LoggingService.info(`Converted Project to Task: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Project to Task: ${e.path}`;throw Jl.LoggingService.error(r,t instanceof Error?t:void 0),new Error(r)}}removeInstanceClassProperty(e){let t=this.frontmatterService.parse(e);if(!t.exists)return e;let r=/^exo__Instance_class:.*$(\n -.*$)*/gm,i=t.content.replace(r,"").replace(/\n\n+/g,`
|
|
100
100
|
`).trim();return e.replace(/^---\n[\s\S]*?\n---/,`---
|
|
101
101
|
${i}
|
|
102
|
-
---`)}};Dn.AssetConversionService=cg;Dn.AssetConversionService=cg=JD([(0,RS.injectable)(),eR(0,(0,RS.inject)(rR.DI_TOKENS.IVaultAdapter)),ZD("design:paramtypes",[Object])],cg)});var fg=v(Rn=>{"use strict";var nR=Rn&&Rn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},iR=Rn&&Rn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},sR=Rn&&Rn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Rn,"__esModule",{value:!0});Rn.SessionEventService=void 0;var NS=Le(),aR=yr(),LS=nr(),oR=Ht(),cR=en(),uR=ct(),lg=class{static{o(this,"SessionEventService")}constructor(e){this.vault=e,this.folderPathCache=null,this.defaultOntologyAsset=null}setDefaultOntologyAsset(e){this.defaultOntologyAsset=e,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,LS.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,LS.AssetClass.SESSION_END_EVENT)}async getOntologyAssetFolder(){if(this.folderPathCache!==null)return this.folderPathCache;if(!this.defaultOntologyAsset){let r=this.vault.getDefaultNewFileParent();return this.folderPathCache=r?.path||"",this.folderPathCache}let e=this.vault.getAllFiles();for(let r of e)if(r.basename===this.defaultOntologyAsset){let i=r.parent?.path||"";return this.folderPathCache=i,this.folderPathCache}let t=this.vault.getDefaultNewFileParent();return this.folderPathCache=t?.path||"",this.folderPathCache}async createSessionEvent(e,t){let r=(0,aR.v4)(),i=oR.DateFormatter.toLocalTimestamp(new Date),s=this.defaultOntologyAsset?`"[[${this.defaultOntologyAsset}]]"`:'"[[!kitelev]]"',a={exo__Asset_uid:r,exo__Asset_createdAt:i,exo__Asset_isDefinedBy:s,exo__Instance_class:[`"[[${t}]]"`],ems__SessionEvent_timestamp:i,ems__Session_area:`"[[${e}]]"`},c=cR.MetadataHelpers.buildFileContent(a),u=await this.getOntologyAssetFolder();u&&!await this.vault.exists(u)&&await this.vault.createFolder(u);let l=u?`${u}/${r}.md`:`${r}.md`;return await this.vault.create(l,c)}};Rn.SessionEventService=lg;Rn.SessionEventService=lg=nR([(0,NS.injectable)(),sR(0,(0,NS.inject)(uR.DI_TOKENS.IVaultAdapter)),iR("design:paramtypes",[Object])],lg)});var dg=v(Fn=>{"use strict";var lR=Fn&&Fn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},fR=Fn&&Fn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},hR=Fn&&Fn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Fn,"__esModule",{value:!0});Fn.URIConstructionService=void 0;var kS=Le(),dR=ct(),hg=class{static{o(this,"URIConstructionService")}constructor(e){this.fileSystem=e,this.defaultOntologyURL="https://exocortex.my/default/",this.strictValidation=!0}configure(e){e?.defaultOntologyURL&&(this.defaultOntologyURL=e.defaultOntologyURL),e?.strictValidation!==void 0&&(this.strictValidation=e.strictValidation)}async constructAssetURI(e){let t=this.extractUID(e);if(!t){if(this.strictValidation)throw new Error(`Asset missing exo__Asset_uid: ${e.path}`);return console.warn(`Asset ${e.path} missing UID, using filename fallback`),this.constructFallbackURI(e)}let r=await this.resolveOntologyURL(e);if(!this.validateOntologyURL(r))throw new Error(`Invalid ontology URL: ${r}`);return`${r.endsWith("/")?r:`${r}/`}${t}`}validateOntologyURL(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}async resolveOntologyURL(e){let t=e.frontmatter?.exo__Asset_isDefinedBy;if(!t)return this.defaultOntologyURL;let r=this.extractWikiLink(t),i=r,s=await this.fileSystem.fileExists(r);return!s&&!r.endsWith(".md")&&(i=`${r}.md`,s=await this.fileSystem.fileExists(i)),s?(await this.fileSystem.getFileMetadata(i))?.exo__Ontology_url||this.defaultOntologyURL:(console.warn(`Ontology file not found: ${r}, using default`),this.defaultOntologyURL)}extractUID(e){return e.frontmatter?.exo__Asset_uid||null}extractWikiLink(e){return e.replace(/^\[\[|\]\]$/g,"")}constructFallbackURI(e){let t=e.path.split("/").pop()?.replace(".md","")||"unknown";return`${this.defaultOntologyURL}${t}`}};Fn.URIConstructionService=hg;Fn.URIConstructionService=hg=lR([(0,kS.injectable)(),hR(0,(0,kS.inject)(dR.DI_TOKENS.IFileSystemAdapter)),fR("design:paramtypes",[Object])],hg)});var MS=v(Qs=>{"use strict";var pR=Qs&&Qs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Qs,"__esModule",{value:!0});Qs.WebhookService=void 0;var mR=Le(),Fa=Ji(),pg=class{static{o(this,"WebhookService")}constructor(){this.webhooks=new Map,this.rateLimitStates=new Map,this.defaultRateLimitConfig={maxRequests:100,windowMs:6e4},this.dispatchHistory=[],this.maxHistorySize=100}registerWebhook(e){if(!e.id)throw new Error("Webhook ID is required");if(!e.url)throw new Error("Webhook URL is required");try{new URL(e.url)}catch{throw new Error(`Invalid webhook URL: ${e.url}`)}this.webhooks.set(e.id,{...e,timeout:e.timeout??3e4,retryCount:e.retryCount??3}),Fa.LoggingService.debug(`Registered webhook: ${e.name} (${e.id})`)}unregisterWebhook(e){let t=this.webhooks.delete(e);return this.rateLimitStates.delete(e),t&&Fa.LoggingService.debug(`Unregistered webhook: ${e}`),t}getWebhooks(){return Array.from(this.webhooks.values())}getWebhook(e){return this.webhooks.get(e)}updateWebhook(e,t){let r=this.webhooks.get(e);if(!r)return!1;if(t.url)try{new URL(t.url)}catch{throw new Error(`Invalid webhook URL: ${t.url}`)}return this.webhooks.set(e,{...r,...t,id:e}),Fa.LoggingService.debug(`Updated webhook: ${e}`),!0}getWebhooksForEvent(e){return Array.from(this.webhooks.values()).filter(t=>t.enabled&&(t.events.length===0||t.events.includes(e)))}isRateLimited(e){let t=this.rateLimitStates.get(e);if(!t)return!1;let r=Date.now(),{maxRequests:i,windowMs:s}=this.defaultRateLimitConfig;return r-t.windowStart>=s?(this.rateLimitStates.set(e,{requests:0,windowStart:r}),!1):t.requests>=i}recordRequest(e){let t=Date.now(),r=this.rateLimitStates.get(e),{windowMs:i}=this.defaultRateLimitConfig;!r||t-r.windowStart>=i?this.rateLimitStates.set(e,{requests:1,windowStart:t}):r.requests++}setRateLimitConfig(e){this.defaultRateLimitConfig=e}async dispatchEvent(e){let t=this.getWebhooksForEvent(e.event),r=[];for(let i of t){let s=await this.dispatchToWebhook(i,e);r.push(s),this.addToHistory(s)}return r}async dispatchToWebhook(e,t){let r=e.retryCount??3,i,s=0;for(;s<=r;){if(this.isRateLimited(e.id))return{webhookId:e.id,success:!1,error:"Rate limit exceeded",timestamp:new Date().toISOString(),retryCount:s};try{this.recordRequest(e.id);let a={"Content-Type":"application/json","User-Agent":"Exocortex-Webhook/1.0","X-Webhook-Event":t.event,"X-Webhook-Timestamp":t.timestamp,...e.headers},c=JSON.stringify(t);if(e.secret){let f=await this.createHmacSignature(c,e.secret);a["X-Webhook-Signature"]=f}let u=new AbortController,l=setTimeout(()=>u.abort(),e.timeout??3e4);try{let f=await fetch(e.url,{method:"POST",headers:a,body:c,signal:u.signal});if(clearTimeout(l),f.ok)return Fa.LoggingService.debug(`Webhook ${e.name} dispatched successfully: ${f.status}`),{webhookId:e.id,success:!0,statusCode:f.status,timestamp:new Date().toISOString(),retryCount:s};i=`HTTP ${f.status}: ${f.statusText}`,Fa.LoggingService.warn(`Webhook ${e.name} failed: ${i}`)}finally{clearTimeout(l)}}catch(a){i=a instanceof Error?a.message:"Unknown error",a instanceof Error&&a.name==="AbortError"&&(i="Request timeout"),Fa.LoggingService.warn(`Webhook ${e.name} error (attempt ${s+1}/${r+1}): ${i}`)}s++,s<=r&&await this.delay(Math.pow(2,s)*100)}return{webhookId:e.id,success:!1,error:i,timestamp:new Date().toISOString(),retryCount:s-1}}async createHmacSignature(e,t){let r=new TextEncoder,i=r.encode(t),s=r.encode(e),a=await crypto.subtle.importKey("raw",i,{name:"HMAC",hash:"SHA-256"},!1,["sign"]),c=await crypto.subtle.sign("HMAC",a,s);return"sha256="+Array.from(new Uint8Array(c)).map(l=>l.toString(16).padStart(2,"0")).join("")}delay(e){return new Promise(t=>setTimeout(t,e))}addToHistory(e){this.dispatchHistory.push(e),this.dispatchHistory.length>this.maxHistorySize&&this.dispatchHistory.shift()}getDispatchHistory(e=50){return this.dispatchHistory.slice(-e)}clearDispatchHistory(){this.dispatchHistory=[]}async testWebhook(e){let t=this.webhooks.get(e);if(!t)return{webhookId:e,success:!1,error:"Webhook not found",timestamp:new Date().toISOString(),retryCount:0};let r={event:"note.updated",timestamp:new Date().toISOString(),filePath:"/test/webhook-test.md",label:"Webhook Test",data:{test:!0,message:"This is a test webhook event from Exocortex"}},i=t.enabled;t.enabled=!0;let s=await this.dispatchToWebhook(t,r);return t.enabled=i,s}cleanup(){this.webhooks.clear(),this.rateLimitStates.clear(),this.dispatchHistory=[]}};Qs.WebhookService=pg;Qs.WebhookService=pg=pR([(0,mR.injectable)()],pg)});var gg=v(Nn=>{"use strict";var gR=Nn&&Nn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},yR=Nn&&Nn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},vR=Nn&&Nn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Nn,"__esModule",{value:!0});Nn.GenericAssetCreationService=void 0;var jS=Le(),SR=yr(),Ac=Ht(),_R=en(),bR=ct(),ti=jp(),mg=class{static{o(this,"GenericAssetCreationService")}constructor(e){this.vault=e}async createAsset(e,t){let r=(0,SR.v4)(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),a=_R.MetadataHelpers.buildFileContent(s),c=e.folderPath||this.getDefaultFolderPath(e);this.vault.getAbstractFileByPath(c)||await this.vault.createFolder(c);let l=c?`${c}/${i}`:i;return await this.vault.create(l,a)}generateFrontmatter(e,t,r){let i=new Date,s={},a=new Map;for(let c of t)a.set(c.name,c.fieldType);if(s.exo__Asset_uid=r,s.exo__Asset_createdAt=Ac.DateFormatter.toLocalTimestamp(i),s.exo__Instance_class=[this.formatWikilink(e.className)],e.label&&e.label.trim()!==""){let c=e.label.trim();s.exo__Asset_label=c,s.aliases=[c]}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(s,e),e.propertyValues)for(let[c,u]of Object.entries(e.propertyValues)){if(c==="exo__Asset_uid"||c==="exo__Asset_createdAt"||c==="exo__Instance_class"||c==="exo__Asset_label"||c==="aliases"||u==null)continue;let l=a.get(c);s[c]=this.formatValue(u,l)}return s}inheritParentContext(e,t){let r=t.parentMetadata||{},i=t.parentFile?.basename;if((t.className==="ems__Task"||t.className.startsWith("ems__Task"))&&(e.ems__Effort_parent=i?this.formatWikilink(i):null),t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=r.exo__Instance_class;this.isAreaClass(s)&&(e.ems__Project_area=i?this.formatWikilink(i):null)}r.exo__Asset_isDefinedBy&&(e.exo__Asset_isDefinedBy=r.exo__Asset_isDefinedBy)}isAreaClass(e){return e?(Array.isArray(e)?e:[e]).some(r=>String(r).includes("Area")||String(r).includes("ems__Area")):!1}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events",ims__Concept:"concepts"};if(t[e.className])return t[e.className];for(let[r,i]of Object.entries(t))if(e.className.startsWith(r))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case ti.PropertyFieldType.Text:return String(e);case ti.PropertyFieldType.Wikilink:case ti.PropertyFieldType.Reference:case ti.PropertyFieldType.StatusSelect:case ti.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case ti.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case ti.PropertyFieldType.Boolean:return this.formatBoolean(e);case ti.PropertyFieldType.Date:case ti.PropertyFieldType.DateTime:case ti.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Ac.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return Ac.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:Ac.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Ac.DateFormatter.toLocalTimestamp(t)}return String(e)}};Nn.GenericAssetCreationService=mg;Nn.GenericAssetCreationService=mg=gR([(0,jS.injectable)(),vR(0,(0,jS.inject)(bR.DI_TOKENS.IVaultAdapter)),yR("design:paramtypes",[Object])],mg)});var vg=v(tn=>{"use strict";var wR=tn&&tn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ER=tn&&tn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(tn,"__esModule",{value:!0});tn.EmbeddingService=tn.DEFAULT_EMBEDDING_CONFIG=void 0;var TR=Le(),$S=Ji();tn.DEFAULT_EMBEDDING_CONFIG={provider:"openai",model:"text-embedding-3-small",timeout:3e4,maxTextLength:8e3};var yg=class{static{o(this,"EmbeddingService")}constructor(e={}){this.requestCount=0,this.tokenCount=0,this.config={...tn.DEFAULT_EMBEDDING_CONFIG,...e}}setConfig(e){this.config={...this.config,...e},$S.LoggingService.debug(`EmbeddingService config updated: provider=${this.config.provider}, model=${this.config.model}`)}getConfig(){let{apiKey:e,...t}=this.config;return t}isConfigured(){return this.config.provider==="openai"?!!this.config.apiKey:!0}async generateEmbedding(e){if(!this.isConfigured())throw new Error("EmbeddingService is not properly configured");let t=this.truncateText(e);if(this.config.provider==="openai")return this.generateOpenAIEmbedding(t);throw new Error(`Unsupported embedding provider: ${this.config.provider}`)}async generateBatchEmbeddings(e){if(!this.isConfigured())throw new Error("EmbeddingService is not properly configured");if(e.length===0)return[];let t=[];if(this.config.provider==="openai"){let r=e.map(i=>this.truncateText(i.text));try{let i=await this.generateOpenAIBatchEmbeddings(r);for(let s=0;s<e.length;s++)t.push({id:e[s].id,result:i[s]??null})}catch(i){let s=i instanceof Error?i.message:"Unknown error";for(let a of e)t.push({id:a.id,result:null,error:s})}}else throw new Error(`Unsupported embedding provider: ${this.config.provider}`);return t}async generateOpenAIEmbedding(e){let t=await this.generateOpenAIBatchEmbeddings([e]);if(t.length===0||!t[0])throw new Error("Failed to generate embedding");return t[0]}async generateOpenAIBatchEmbeddings(e){let r=`${this.config.baseUrl||"https://api.openai.com/v1"}/embeddings`,i=new AbortController,s=setTimeout(()=>i.abort(),this.config.timeout??3e4);try{let a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model||"text-embedding-3-small",input:e}),signal:i.signal});if(clearTimeout(s),!a.ok){let u=await a.text();throw new Error(`OpenAI API error: ${a.status} - ${u}`)}let c=await a.json();return this.requestCount++,this.tokenCount+=c.usage?.total_tokens||0,c.data.map(u=>({embedding:u.embedding,tokenCount:Math.round((c.usage?.total_tokens||0)/e.length),model:c.model}))}catch(a){throw clearTimeout(s),a instanceof Error&&a.name==="AbortError"?new Error("OpenAI API request timeout"):a}}truncateText(e){let t=this.config.maxTextLength??8e3;return e.length<=t?e:($S.LoggingService.debug(`Truncating text from ${e.length} to ${t} characters`),e.slice(0,t))}prepareTextForEmbedding(e,t){let r=[];if(t){let s=t.exo__Asset_label;typeof s=="string"&&s&&r.push(`Title: ${s}`);let a=t.exo__Instance_class;if(a){let c=Array.isArray(a)?a[0]:a;typeof c=="string"&&r.push(`Type: ${this.cleanWikiLink(c)}`)}}let i=this.cleanMarkdownContent(e);return i&&r.push(i),r.join(`
|
|
102
|
+
---`)}};Dn.AssetConversionService=ug;Dn.AssetConversionService=ug=tR([(0,NS.injectable)(),nR(0,(0,NS.inject)(sR.DI_TOKENS.IVaultAdapter)),rR("design:paramtypes",[Object])],ug)});var hg=v(Rn=>{"use strict";var aR=Rn&&Rn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},oR=Rn&&Rn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},cR=Rn&&Rn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Rn,"__esModule",{value:!0});Rn.SessionEventService=void 0;var kS=Le(),uR=yr(),MS=nr(),lR=Ht(),fR=en(),hR=ct(),fg=class{static{o(this,"SessionEventService")}constructor(e){this.vault=e,this.folderPathCache=null,this.defaultOntologyAsset=null}setDefaultOntologyAsset(e){this.defaultOntologyAsset=e,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,MS.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,MS.AssetClass.SESSION_END_EVENT)}async getOntologyAssetFolder(){if(this.folderPathCache!==null)return this.folderPathCache;if(!this.defaultOntologyAsset){let r=this.vault.getDefaultNewFileParent();return this.folderPathCache=r?.path||"",this.folderPathCache}let e=this.vault.getAllFiles();for(let r of e)if(r.basename===this.defaultOntologyAsset){let i=r.parent?.path||"";return this.folderPathCache=i,this.folderPathCache}let t=this.vault.getDefaultNewFileParent();return this.folderPathCache=t?.path||"",this.folderPathCache}async createSessionEvent(e,t){let r=(0,uR.v4)(),i=lR.DateFormatter.toLocalTimestamp(new Date),s=this.defaultOntologyAsset?`"[[${this.defaultOntologyAsset}]]"`:'"[[!kitelev]]"',a={exo__Asset_uid:r,exo__Asset_createdAt:i,exo__Asset_isDefinedBy:s,exo__Instance_class:[`"[[${t}]]"`],ems__SessionEvent_timestamp:i,ems__Session_area:`"[[${e}]]"`},c=fR.MetadataHelpers.buildFileContent(a),u=await this.getOntologyAssetFolder();u&&!await this.vault.exists(u)&&await this.vault.createFolder(u);let l=u?`${u}/${r}.md`:`${r}.md`;return await this.vault.create(l,c)}};Rn.SessionEventService=fg;Rn.SessionEventService=fg=aR([(0,kS.injectable)(),cR(0,(0,kS.inject)(hR.DI_TOKENS.IVaultAdapter)),oR("design:paramtypes",[Object])],fg)});var pg=v(Fn=>{"use strict";var dR=Fn&&Fn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},pR=Fn&&Fn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},mR=Fn&&Fn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Fn,"__esModule",{value:!0});Fn.URIConstructionService=void 0;var jS=Le(),gR=ct(),dg=class{static{o(this,"URIConstructionService")}constructor(e){this.fileSystem=e,this.defaultOntologyURL="https://exocortex.my/default/",this.strictValidation=!0}configure(e){e?.defaultOntologyURL&&(this.defaultOntologyURL=e.defaultOntologyURL),e?.strictValidation!==void 0&&(this.strictValidation=e.strictValidation)}async constructAssetURI(e){let t=this.extractUID(e);if(!t){if(this.strictValidation)throw new Error(`Asset missing exo__Asset_uid: ${e.path}`);return console.warn(`Asset ${e.path} missing UID, using filename fallback`),this.constructFallbackURI(e)}let r=await this.resolveOntologyURL(e);if(!this.validateOntologyURL(r))throw new Error(`Invalid ontology URL: ${r}`);return`${r.endsWith("/")?r:`${r}/`}${t}`}validateOntologyURL(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}async resolveOntologyURL(e){let t=e.frontmatter?.exo__Asset_isDefinedBy;if(!t)return this.defaultOntologyURL;let r=this.extractWikiLink(t),i=r,s=await this.fileSystem.fileExists(r);return!s&&!r.endsWith(".md")&&(i=`${r}.md`,s=await this.fileSystem.fileExists(i)),s?(await this.fileSystem.getFileMetadata(i))?.exo__Ontology_url||this.defaultOntologyURL:(console.warn(`Ontology file not found: ${r}, using default`),this.defaultOntologyURL)}extractUID(e){return e.frontmatter?.exo__Asset_uid||null}extractWikiLink(e){return e.replace(/^\[\[|\]\]$/g,"")}constructFallbackURI(e){let t=e.path.split("/").pop()?.replace(".md","")||"unknown";return`${this.defaultOntologyURL}${t}`}};Fn.URIConstructionService=dg;Fn.URIConstructionService=dg=dR([(0,jS.injectable)(),mR(0,(0,jS.inject)(gR.DI_TOKENS.IFileSystemAdapter)),pR("design:paramtypes",[Object])],dg)});var $S=v(Qs=>{"use strict";var yR=Qs&&Qs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Qs,"__esModule",{value:!0});Qs.WebhookService=void 0;var vR=Le(),Fa=Ji(),mg=class{static{o(this,"WebhookService")}constructor(){this.webhooks=new Map,this.rateLimitStates=new Map,this.defaultRateLimitConfig={maxRequests:100,windowMs:6e4},this.dispatchHistory=[],this.maxHistorySize=100}registerWebhook(e){if(!e.id)throw new Error("Webhook ID is required");if(!e.url)throw new Error("Webhook URL is required");try{new URL(e.url)}catch{throw new Error(`Invalid webhook URL: ${e.url}`)}this.webhooks.set(e.id,{...e,timeout:e.timeout??3e4,retryCount:e.retryCount??3}),Fa.LoggingService.debug(`Registered webhook: ${e.name} (${e.id})`)}unregisterWebhook(e){let t=this.webhooks.delete(e);return this.rateLimitStates.delete(e),t&&Fa.LoggingService.debug(`Unregistered webhook: ${e}`),t}getWebhooks(){return Array.from(this.webhooks.values())}getWebhook(e){return this.webhooks.get(e)}updateWebhook(e,t){let r=this.webhooks.get(e);if(!r)return!1;if(t.url)try{new URL(t.url)}catch{throw new Error(`Invalid webhook URL: ${t.url}`)}return this.webhooks.set(e,{...r,...t,id:e}),Fa.LoggingService.debug(`Updated webhook: ${e}`),!0}getWebhooksForEvent(e){return Array.from(this.webhooks.values()).filter(t=>t.enabled&&(t.events.length===0||t.events.includes(e)))}isRateLimited(e){let t=this.rateLimitStates.get(e);if(!t)return!1;let r=Date.now(),{maxRequests:i,windowMs:s}=this.defaultRateLimitConfig;return r-t.windowStart>=s?(this.rateLimitStates.set(e,{requests:0,windowStart:r}),!1):t.requests>=i}recordRequest(e){let t=Date.now(),r=this.rateLimitStates.get(e),{windowMs:i}=this.defaultRateLimitConfig;!r||t-r.windowStart>=i?this.rateLimitStates.set(e,{requests:1,windowStart:t}):r.requests++}setRateLimitConfig(e){this.defaultRateLimitConfig=e}async dispatchEvent(e){let t=this.getWebhooksForEvent(e.event),r=[];for(let i of t){let s=await this.dispatchToWebhook(i,e);r.push(s),this.addToHistory(s)}return r}async dispatchToWebhook(e,t){let r=e.retryCount??3,i,s=0;for(;s<=r;){if(this.isRateLimited(e.id))return{webhookId:e.id,success:!1,error:"Rate limit exceeded",timestamp:new Date().toISOString(),retryCount:s};try{this.recordRequest(e.id);let a={"Content-Type":"application/json","User-Agent":"Exocortex-Webhook/1.0","X-Webhook-Event":t.event,"X-Webhook-Timestamp":t.timestamp,...e.headers},c=JSON.stringify(t);if(e.secret){let f=await this.createHmacSignature(c,e.secret);a["X-Webhook-Signature"]=f}let u=new AbortController,l=setTimeout(()=>u.abort(),e.timeout??3e4);try{let f=await fetch(e.url,{method:"POST",headers:a,body:c,signal:u.signal});if(clearTimeout(l),f.ok)return Fa.LoggingService.debug(`Webhook ${e.name} dispatched successfully: ${f.status}`),{webhookId:e.id,success:!0,statusCode:f.status,timestamp:new Date().toISOString(),retryCount:s};i=`HTTP ${f.status}: ${f.statusText}`,Fa.LoggingService.warn(`Webhook ${e.name} failed: ${i}`)}finally{clearTimeout(l)}}catch(a){i=a instanceof Error?a.message:"Unknown error",a instanceof Error&&a.name==="AbortError"&&(i="Request timeout"),Fa.LoggingService.warn(`Webhook ${e.name} error (attempt ${s+1}/${r+1}): ${i}`)}s++,s<=r&&await this.delay(Math.pow(2,s)*100)}return{webhookId:e.id,success:!1,error:i,timestamp:new Date().toISOString(),retryCount:s-1}}async createHmacSignature(e,t){let r=new TextEncoder,i=r.encode(t),s=r.encode(e),a=await crypto.subtle.importKey("raw",i,{name:"HMAC",hash:"SHA-256"},!1,["sign"]),c=await crypto.subtle.sign("HMAC",a,s);return"sha256="+Array.from(new Uint8Array(c)).map(l=>l.toString(16).padStart(2,"0")).join("")}delay(e){return new Promise(t=>setTimeout(t,e))}addToHistory(e){this.dispatchHistory.push(e),this.dispatchHistory.length>this.maxHistorySize&&this.dispatchHistory.shift()}getDispatchHistory(e=50){return this.dispatchHistory.slice(-e)}clearDispatchHistory(){this.dispatchHistory=[]}async testWebhook(e){let t=this.webhooks.get(e);if(!t)return{webhookId:e,success:!1,error:"Webhook not found",timestamp:new Date().toISOString(),retryCount:0};let r={event:"note.updated",timestamp:new Date().toISOString(),filePath:"/test/webhook-test.md",label:"Webhook Test",data:{test:!0,message:"This is a test webhook event from Exocortex"}},i=t.enabled;t.enabled=!0;let s=await this.dispatchToWebhook(t,r);return t.enabled=i,s}cleanup(){this.webhooks.clear(),this.rateLimitStates.clear(),this.dispatchHistory=[]}};Qs.WebhookService=mg;Qs.WebhookService=mg=yR([(0,vR.injectable)()],mg)});var yg=v(Nn=>{"use strict";var SR=Nn&&Nn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_R=Nn&&Nn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},bR=Nn&&Nn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Nn,"__esModule",{value:!0});Nn.GenericAssetCreationService=void 0;var VS=Le(),wR=yr(),Ac=Ht(),ER=en(),TR=ct(),ti=$p(),gg=class{static{o(this,"GenericAssetCreationService")}constructor(e){this.vault=e}async createAsset(e,t){let r=(0,wR.v4)(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),a=ER.MetadataHelpers.buildFileContent(s),c=e.folderPath||this.getDefaultFolderPath(e);this.vault.getAbstractFileByPath(c)||await this.vault.createFolder(c);let l=c?`${c}/${i}`:i;return await this.vault.create(l,a)}generateFrontmatter(e,t,r){let i=new Date,s={},a=new Map;for(let c of t)a.set(c.name,c.fieldType);if(s.exo__Asset_uid=r,s.exo__Asset_createdAt=Ac.DateFormatter.toLocalTimestamp(i),s.exo__Instance_class=[this.formatWikilink(e.className)],e.label&&e.label.trim()!==""){let c=e.label.trim();s.exo__Asset_label=c,s.aliases=[c]}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(s,e),e.propertyValues)for(let[c,u]of Object.entries(e.propertyValues)){if(c==="exo__Asset_uid"||c==="exo__Asset_createdAt"||c==="exo__Instance_class"||c==="exo__Asset_label"||c==="aliases"||u==null)continue;let l=a.get(c);s[c]=this.formatValue(u,l)}return s}inheritParentContext(e,t){let r=t.parentMetadata||{},i=t.parentFile?.basename;if((t.className==="ems__Task"||t.className.startsWith("ems__Task"))&&(e.ems__Effort_parent=i?this.formatWikilink(i):null),t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=r.exo__Instance_class;this.isAreaClass(s)&&(e.ems__Project_area=i?this.formatWikilink(i):null)}r.exo__Asset_isDefinedBy&&(e.exo__Asset_isDefinedBy=r.exo__Asset_isDefinedBy)}isAreaClass(e){return e?(Array.isArray(e)?e:[e]).some(r=>String(r).includes("Area")||String(r).includes("ems__Area")):!1}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events",ims__Concept:"concepts"};if(t[e.className])return t[e.className];for(let[r,i]of Object.entries(t))if(e.className.startsWith(r))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case ti.PropertyFieldType.Text:return String(e);case ti.PropertyFieldType.Wikilink:case ti.PropertyFieldType.Reference:case ti.PropertyFieldType.StatusSelect:case ti.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case ti.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case ti.PropertyFieldType.Boolean:return this.formatBoolean(e);case ti.PropertyFieldType.Date:case ti.PropertyFieldType.DateTime:case ti.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?Ac.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return Ac.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:Ac.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return Ac.DateFormatter.toLocalTimestamp(t)}return String(e)}};Nn.GenericAssetCreationService=gg;Nn.GenericAssetCreationService=gg=SR([(0,VS.injectable)(),bR(0,(0,VS.inject)(TR.DI_TOKENS.IVaultAdapter)),_R("design:paramtypes",[Object])],gg)});var Sg=v(tn=>{"use strict";var AR=tn&&tn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},xR=tn&&tn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(tn,"__esModule",{value:!0});tn.EmbeddingService=tn.DEFAULT_EMBEDDING_CONFIG=void 0;var CR=Le(),US=Ji();tn.DEFAULT_EMBEDDING_CONFIG={provider:"openai",model:"text-embedding-3-small",timeout:3e4,maxTextLength:8e3};var vg=class{static{o(this,"EmbeddingService")}constructor(e={}){this.requestCount=0,this.tokenCount=0,this.config={...tn.DEFAULT_EMBEDDING_CONFIG,...e}}setConfig(e){this.config={...this.config,...e},US.LoggingService.debug(`EmbeddingService config updated: provider=${this.config.provider}, model=${this.config.model}`)}getConfig(){let{apiKey:e,...t}=this.config;return t}isConfigured(){return this.config.provider==="openai"?!!this.config.apiKey:!0}async generateEmbedding(e){if(!this.isConfigured())throw new Error("EmbeddingService is not properly configured");let t=this.truncateText(e);if(this.config.provider==="openai")return this.generateOpenAIEmbedding(t);throw new Error(`Unsupported embedding provider: ${this.config.provider}`)}async generateBatchEmbeddings(e){if(!this.isConfigured())throw new Error("EmbeddingService is not properly configured");if(e.length===0)return[];let t=[];if(this.config.provider==="openai"){let r=e.map(i=>this.truncateText(i.text));try{let i=await this.generateOpenAIBatchEmbeddings(r);for(let s=0;s<e.length;s++)t.push({id:e[s].id,result:i[s]??null})}catch(i){let s=i instanceof Error?i.message:"Unknown error";for(let a of e)t.push({id:a.id,result:null,error:s})}}else throw new Error(`Unsupported embedding provider: ${this.config.provider}`);return t}async generateOpenAIEmbedding(e){let t=await this.generateOpenAIBatchEmbeddings([e]);if(t.length===0||!t[0])throw new Error("Failed to generate embedding");return t[0]}async generateOpenAIBatchEmbeddings(e){let r=`${this.config.baseUrl||"https://api.openai.com/v1"}/embeddings`,i=new AbortController,s=setTimeout(()=>i.abort(),this.config.timeout??3e4);try{let a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model||"text-embedding-3-small",input:e}),signal:i.signal});if(clearTimeout(s),!a.ok){let u=await a.text();throw new Error(`OpenAI API error: ${a.status} - ${u}`)}let c=await a.json();return this.requestCount++,this.tokenCount+=c.usage?.total_tokens||0,c.data.map(u=>({embedding:u.embedding,tokenCount:Math.round((c.usage?.total_tokens||0)/e.length),model:c.model}))}catch(a){throw clearTimeout(s),a instanceof Error&&a.name==="AbortError"?new Error("OpenAI API request timeout"):a}}truncateText(e){let t=this.config.maxTextLength??8e3;return e.length<=t?e:(US.LoggingService.debug(`Truncating text from ${e.length} to ${t} characters`),e.slice(0,t))}prepareTextForEmbedding(e,t){let r=[];if(t){let s=t.exo__Asset_label;typeof s=="string"&&s&&r.push(`Title: ${s}`);let a=t.exo__Instance_class;if(a){let c=Array.isArray(a)?a[0]:a;typeof c=="string"&&r.push(`Type: ${this.cleanWikiLink(c)}`)}}let i=this.cleanMarkdownContent(e);return i&&r.push(i),r.join(`
|
|
103
103
|
|
|
104
104
|
`)}cleanMarkdownContent(e){let t=e.replace(/^---[\s\S]*?---\n*/m,"").replace(/```[\s\S]*?```/g,r=>r.replace(/```\w*\n?|\n?```/g,"")).replace(/`([^`]+)`/g,"$1").replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(r,i,s)=>s||i).replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/^---+$/gm,"");return t=this.removeHtmlTags(t),t.replace(/\n{3,}/g,`
|
|
105
105
|
|
|
106
|
-
`).trim()}removeHtmlTags(e){let t=/<[^>]*>/g,r=e,i;do i=r,r=r.replace(t,"");while(r!==i);return r}cleanWikiLink(e){return e.replace(/^\[\[/,"").replace(/\]\]$/,"").replace(/^"/,"").replace(/"$/,"")}getStats(){return{requestCount:this.requestCount,tokenCount:this.tokenCount}}resetStats(){this.requestCount=0,this.tokenCount=0}};tn.EmbeddingService=yg;tn.EmbeddingService=yg=wR([(0,TR.injectable)(),ER("design:paramtypes",[Object])],yg)});var bg=v(rn=>{"use strict";var AR=rn&&rn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},xR=rn&&rn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(rn,"__esModule",{value:!0});rn.VectorStore=rn.DEFAULT_VECTOR_STORE_CONFIG=void 0;var CR=Le(),Sg=Ji();rn.DEFAULT_VECTOR_STORE_CONFIG={maxEntries:0,similarityThreshold:.7};var _g=class{static{o(this,"VectorStore")}constructor(e={}){this.entries=new Map,this.createdAt=new Date,this.updatedAt=new Date,this.config={...rn.DEFAULT_VECTOR_STORE_CONFIG,...e}}setConfig(e){this.config={...this.config,...e}}upsert(e){if(!e.vector||e.vector.length===0)throw new Error("Vector cannot be empty");let t=this.entries.values().next().value;if(t&&t.vector.length!==e.vector.length)throw new Error(`Vector dimension mismatch: expected ${t.vector.length}, got ${e.vector.length}`);if(this.config.maxEntries&&this.config.maxEntries>0&&!this.entries.has(e.id)&&this.entries.size>=this.config.maxEntries){let r=null,i=1/0;for(let[s,a]of this.entries)a.timestamp<i&&(i=a.timestamp,r=s);r&&(this.entries.delete(r),Sg.LoggingService.debug(`VectorStore: Evicted oldest entry ${r}`))}this.entries.set(e.id,e),this.updatedAt=new Date}remove(e){let t=this.entries.delete(e);return t&&(this.updatedAt=new Date),t}get(e){return this.entries.get(e)}has(e){return this.entries.has(e)}needsUpdate(e,t){let r=this.entries.get(e);return r?r.contentHash!==t:!0}getAllIds(){return Array.from(this.entries.keys())}size(){return this.entries.size}clear(){this.entries.clear(),this.updatedAt=new Date}search(e,t=10){if(this.entries.size===0)return[];let r=this.entries.values().next().value;if(r&&r.vector.length!==e.length)throw new Error(`Query vector dimension mismatch: expected ${r.vector.length}, got ${e.length}`);let i=[],s=this.config.similarityThreshold??.7;for(let a of this.entries.values()){let c=this.cosineSimilarity(e,a.vector);c>=s&&i.push({entry:a,score:c})}return i.sort((a,c)=>c.score-a.score),i.slice(0,t)}findSimilar(e,t=10){let r=this.entries.get(e);return r?this.search(r.vector,t+1).filter(s=>s.entry.id!==e).slice(0,t):[]}cosineSimilarity(e,t){if(e.length!==t.length)throw new Error("Vectors must have the same dimension");let r=0,i=0,s=0;for(let a=0;a<e.length;a++)r+=e[a]*t[a],i+=e[a]*e[a],s+=t[a]*t[a];return i=Math.sqrt(i),s=Math.sqrt(s),i===0||s===0?0:r/(i*s)}serialize(){return{version:1,entries:Array.from(this.entries.values()).map(e=>({id:e.id,vector:e.vector,metadata:e.metadata,timestamp:e.timestamp,contentHash:e.contentHash})),createdAt:this.createdAt.toISOString(),updatedAt:this.updatedAt.toISOString()}}deserialize(e){if(e.version!==1)throw new Error(`Unsupported VectorStore version: ${e.version}`);this.entries.clear();for(let t of e.entries)this.entries.set(t.id,{id:t.id,vector:t.vector,metadata:t.metadata,timestamp:t.timestamp,contentHash:t.contentHash});this.createdAt=new Date(e.createdAt),this.updatedAt=new Date(e.updatedAt),Sg.LoggingService.debug(`VectorStore: Loaded ${this.entries.size} entries from persistence`)}getStats(){let t=this.entries.values().next().value?.vector.length??null,i=(t?this.entries.size*t*8:0)/(1024*1024);return{entryCount:this.entries.size,dimension:t,createdAt:this.createdAt.toISOString(),updatedAt:this.updatedAt.toISOString(),estimatedMemoryMB:Math.round(i*100)/100}}pruneInvalidEntries(e){let t=[];for(let r of this.entries.keys())e.has(r)||t.push(r);for(let r of t)this.entries.delete(r);return t.length>0&&(this.updatedAt=new Date,Sg.LoggingService.debug(`VectorStore: Pruned ${t.length} invalid entries`)),t.length}};rn.VectorStore=_g;rn.VectorStore=_g=AR([(0,CR.injectable)(),xR("design:paramtypes",[Object])],_g)});var US=v(nn=>{"use strict";var IR=nn&&nn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},OR=nn&&nn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(nn,"__esModule",{value:!0});nn.SemanticSearchService=nn.DEFAULT_SEMANTIC_SEARCH_CONFIG=void 0;var PR=Le(),xc=Ji(),VS=vg(),DR=bg();nn.DEFAULT_SEMANTIC_SEARCH_CONFIG={embedding:VS.DEFAULT_EMBEDDING_CONFIG,maxResults:10,minSimilarity:.7,autoEmbed:!0,batchSize:20};var wg=class{static{o(this,"SemanticSearchService")}constructor(e={}){this.indexingStatus={isIndexing:!1,totalFiles:0,indexedFiles:0,failedFiles:0,progress:0},this.abortController=null,this.config={...nn.DEFAULT_SEMANTIC_SEARCH_CONFIG,...e},this.embeddingService=new VS.EmbeddingService(this.config.embedding),this.vectorStore=new DR.VectorStore({similarityThreshold:this.config.minSimilarity})}setConfig(e){this.config={...this.config,...e},e.embedding&&this.embeddingService.setConfig(e.embedding),e.minSimilarity!==void 0&&this.vectorStore.setConfig({similarityThreshold:e.minSimilarity})}getConfig(){return{...this.config,embedding:this.embeddingService.getConfig()}}isConfigured(){return this.embeddingService.isConfigured()}getIndexingStatus(){return{...this.indexingStatus}}async search(e,t){if(!this.isConfigured())throw new Error("SemanticSearchService is not properly configured");if(!e.trim())return[];let r=await this.embeddingService.generateEmbedding(e),i=t??this.config.maxResults;return this.vectorStore.search(r.embedding,i).map(a=>this.toSearchResult(a))}async findSimilar(e,t){let r=t??this.config.maxResults;return this.vectorStore.findSimilar(e,r).map(s=>this.toSearchResult(s))}toSearchResult(e){let t=e.entry.metadata??{};return{path:e.entry.id,score:e.score,label:t.exo__Asset_label,instanceClass:this.extractInstanceClass(t),metadata:t}}extractInstanceClass(e){let t=e.exo__Instance_class;if(t){if(Array.isArray(t)){let r=t[0];return typeof r=="string"?this.cleanWikiLink(r):void 0}return typeof t=="string"?this.cleanWikiLink(t):void 0}}cleanWikiLink(e){return e.replace(/^\[\[/,"").replace(/\]\]$/,"").replace(/^"/,"").replace(/"$/,"")}async indexFile(e,t,r){if(!this.isConfigured())return!1;try{let i=await this.hashContent(t);if(!this.vectorStore.needsUpdate(e,i))return!0;let s=this.embeddingService.prepareTextForEmbedding(t,r),a=await this.embeddingService.generateEmbedding(s);return this.vectorStore.upsert({id:e,vector:a.embedding,metadata:r,timestamp:Date.now(),contentHash:i}),xc.LoggingService.debug(`Indexed file: ${e}`),!0}catch(i){return xc.LoggingService.warn(`Failed to index file ${e}: ${i instanceof Error?i.message:"Unknown error"}`),!1}}removeFromIndex(e){return this.vectorStore.remove(e)}async indexBatch(e){if(!this.isConfigured())return{indexed:0,failed:e.length};let t=[],r=new Map;for(let c of e){let u=await this.hashContent(c.content);if(!this.vectorStore.needsUpdate(c.path,u))continue;let l=this.embeddingService.prepareTextForEmbedding(c.content,c.metadata);t.push({id:c.path,text:l}),r.set(c.path,{content:c.content,metadata:c.metadata,contentHash:u})}if(t.length===0)return{indexed:0,failed:0};let i=await this.embeddingService.generateBatchEmbeddings(t),s=0,a=0;for(let c of i){let u=r.get(c.id);u&&(c.result?(this.vectorStore.upsert({id:c.id,vector:c.result.embedding,metadata:u.metadata,timestamp:Date.now(),contentHash:u.contentHash}),s++):(a++,xc.LoggingService.warn(`Failed to embed ${c.id}: ${c.error||"Unknown error"}`)))}return{indexed:s,failed:a}}async indexAll(e,t,r){if(!this.isConfigured())throw new Error("SemanticSearchService is not properly configured");if(this.indexingStatus.isIndexing)throw new Error("Indexing is already in progress");this.abortController=new AbortController,this.indexingStatus={isIndexing:!0,totalFiles:e.length,indexedFiles:0,failedFiles:0,progress:0};let i=0,s=0,a=!1;try{for(let c=0;c<e.length;c+=this.config.batchSize){if(this.abortController.signal.aborted){a=!0;break}let u=e.slice(c,c+this.config.batchSize),l=[];for(let h of u){if(this.abortController.signal.aborted){a=!0;break}let d=await t(h);d?l.push({path:h,content:d.content,metadata:d.metadata}):s++}if(a)break;let f=await this.indexBatch(l);i+=f.indexed,s+=f.failed,this.indexingStatus.indexedFiles=c+u.length,this.indexingStatus.failedFiles=s,this.indexingStatus.progress=Math.round(this.indexingStatus.indexedFiles/e.length*100),r&&r({...this.indexingStatus})}}finally{this.indexingStatus.isIndexing=!1,this.abortController=null}return{indexed:i,failed:s,aborted:a}}abortIndexing(){this.abortController&&(this.abortController.abort(),xc.LoggingService.debug("Indexing aborted by user"))}isIndexed(e){return this.vectorStore.has(e)}getIndexedPaths(){return this.vectorStore.getAllIds()}getIndexedCount(){return this.vectorStore.size()}clearIndex(){this.vectorStore.clear(),xc.LoggingService.debug("Semantic search index cleared")}pruneDeletedFiles(e){return this.vectorStore.pruneInvalidEntries(e)}serializeIndex(){return this.vectorStore.serialize()}deserializeIndex(e){this.vectorStore.deserialize(e)}getStats(){return{indexStats:this.vectorStore.getStats(),embeddingStats:this.embeddingService.getStats()}}async hashContent(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}};nn.SemanticSearchService=wg;nn.SemanticSearchService=wg=IR([(0,PR.injectable)(),OR("design:paramtypes",[Object])],wg)});var BS=v(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.GraphQueryService=void 0;var Cc=Qe(),RR=lt(),Zi=Yr(),FR=Jd(),ri={INSTANCE_CLASS:Zi.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Zi.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Zi.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:Zi.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Zi.Namespace.EMS.term("Effort_parent"),REFERENCES:Zi.Namespace.EXO.term("references"),REFERENCED_BY:Zi.Namespace.EXO.term("referencedBy"),RDF_TYPE:Zi.Namespace.RDF.term("type")},Eg=class{static{o(this,"GraphQueryService")}constructor(e,t={}){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),r=await this.loadNodes(e),i=await this.loadEdges(r,e),s=this.computeStats(r,i),a=Date.now()-t;return a>100&&r.length>0&&console.debug(`GraphQueryService: loaded ${r.length} nodes in ${a}ms (${(a/r.length).toFixed(2)}ms/node)`),{nodes:r,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),r=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:r}),s=i.length>t,a=s?i.slice(0,t):i,c=await this.loadEdges(a,e);return{nodes:a,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(r+t):void 0}}async loadConnectedNodes(e,t={}){let r=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,a=[{id:e,currentDepth:0}],c=[];for(;a.length>0&&c.length<i;){let{id:l,currentDepth:f}=a.shift();if(s.has(l))continue;s.add(l);let h=await this.getNodeById(l,t);if(h&&(c.push(h),f<r)){let d=await this.getConnectedNodeIds(l);for(let p of d)s.has(p)||a.push({id:p,currentDepth:f+1})}}let u=await this.loadEdges(c,t);return{nodes:c,edges:u,hasMore:a.length>0,totalCount:s.size+a.length}}async getNodeById(e,t={}){let r=this.getCachedNode(e);if(r)return{...r};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let a=this.triplesToNode(e,s,t);return a&&this.cacheNode(a),a}subscribe(e){return this.subscribers.add(e),{unsubscribe:o(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(r){console.error("GraphQueryService: error in subscriber callback",r)}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,r=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,ri.INSTANCE_CLASS,void 0),a=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);a=s.filter(S=>{let b=this.getObjectValue(S.object);return b&&p.has(b)})}let c=new Set;for(let p of a)c.add(this.subjectToId(p.subject));let f=Array.from(c).slice(i,i+r).map(p=>this.getNodeById(p,e));return(await Promise.all(f)).filter(p=>!(!p||!t&&p.isArchived))}async loadEdges(e,t){let r=new Set(e.map(a=>a.id)),i=[],s=new Set;for(let a of e){let c=this.idToIRI(a.id),u=await this.tripleStore.match(c,void 0,void 0);for(let l of u){let f=this.tripleToEdge(a.id,l,r);f&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),r=[],i=await this.tripleStore.match(t,void 0,void 0);for(let a of i){let c=this.objectToId(a.object);c&&r.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let a of s)r.push(this.subjectToId(a.subject));return[...new Set(r)]}triplesToNode(e,t,r){let i={},s,a,c,u,l=!1;for(let d of t){let p=d.predicate.value,S=this.getObjectValue(d.object);if(p===ri.INSTANCE_CLASS.value)s=S;else if(p===ri.ASSET_LABEL.value)a=S;else if(p===ri.ASSET_PROTOTYPE.value)c=this.objectToId(d.object)??S;else if(p===ri.EFFORT_PARENT.value)u=this.objectToId(d.object)??S;else if(p===ri.ASSET_IS_ARCHIVED.value)l=S==="true"||S==="1";else{let b=this.predicateToPropertyName(p);b&&(i[b]=S)}}if(l&&!(r.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),h=a??this.pathToTitle(f);return{id:e,path:f,title:h,label:h,assetClass:s,isArchived:l,uri:e.startsWith("http")?e:void 0,prototype:c,parent:u,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,r){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!r.has(s)||s===e)return null;let a=this.predicateToEdgeType(i);if(!a)return null;let c=(0,FR.createEdgeId)(e,s,a,i),u=this.predicateToLabel(i);return{id:c,source:e,target:s,type:a,predicate:i,label:u}}predicateToEdgeType(e){return e===ri.EFFORT_PARENT.value?"hierarchy":e===ri.ASSET_PROTOTYPE.value?"prototype":e===ri.REFERENCES.value?"forward-link":e===ri.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),r=e.lastIndexOf("/"),i=Math.max(t,r);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let r={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let u=c.assetClass??"unknown";r[u]=(r[u]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,a=new Map;for(let c of t)a.set(c.source,(a.get(c.source)??0)+1),s.set(c.target,(s.get(c.target)??0)+1);for(let c of e)c.inDegree=s.get(c.id)??0,c.outDegree=a.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:r,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Cc.IRI(e):new Cc.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Cc.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Cc.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof RR.Literal||e instanceof Cc.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};Zl.GraphQueryService=Eg});var GS=v(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});ef.TypeRegistry=void 0;var ni=Qe(),qS=Ot(),NR=lt(),et=Zd(),Tg=class{static{o(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:et.DEFAULT_NODE_STYLE,defaultEdgeStyle:et.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let r=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:r,typeUri:e.uri,definition:e})}registerEdgeType(e){let r=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:r,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),r=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||r)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let r=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let{uri:a,currentDepth:c}=s.shift();if(i.has(a)||(i.add(a),c>=t))continue;let u=this.typeHierarchy.get(a)??[];for(let l of u)i.has(l)||(r.push(l),s.push({uri:l,currentDepth:c+1}))}return r}getChildTypes(e){let t=[];for(let[r,i]of this.typeHierarchy)i.includes(e)&&t.push(r);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],r="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),r=c,i="exo:Instance_class"}let s=e.properties?.[et.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),r==="unknown"&&(r=s,i="rdf:type"));for(let c of[...t]){let u=this.getParentTypes(c);for(let l of u)t.includes(l)||t.push(l)}let a=this.resolveNodeStyle(t);return{primaryType:r,types:t,resolvedStyle:a,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,r=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:r}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:r}=this.config.styleResolution,i={...r},s=[];for(let a of e){let c=this.nodeTypes.get(a);c&&s.push(c)}if(s.sort((a,c)=>a.priority-c.priority),t)for(let a of s)i=(0,et.mergeNodeStyles)(i,a.style);else if(s.length>0){let a=s[s.length-1];i=(0,et.mergeNodeStyles)(i,a.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,r={...t},i=this.edgeTypes.get(e);return i&&(r=(0,et.mergeEdgeStyles)(r,i.style)),r}filterNodes(e,t){return e.filter(r=>{let i=this.resolveNodeType(r);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(r=>{let i=r.predicate??r.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,r={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:a=0,maxGroups:c=20,customGroupFn:u}=r,l=new Map;for(let d of e){let p=this.resolveNodeType(d),S;if(u?S=u(p.types):s&&p.types.length>a?S=p.types[a]??p.primaryType:i?S=p.primaryType:S="all",!l.has(S)){let T=this.nodeTypes.get(S)?.label??(0,et.extractLocalName)(S);l.set(S,{nodeIds:new Set,label:T})}l.get(S).nodeIds.add(d.id)}let f=Array.from(l.entries()).map(([d,p])=>({id:d,label:p.label,nodeIds:Array.from(p.nodeIds)}));if(f.length>c){f.sort((S,b)=>b.nodeIds.length-S.nodeIds.length);let d=f.slice(0,c-1),p=f.slice(c-1).flatMap(S=>S.nodeIds);d.push({id:"other",label:"Other",nodeIds:p}),f=d}let h=new Map;for(let d of f)for(let p of d.nodeIds)h.set(p,d.id);return f.map((d,p)=>{let S=new Set(d.nodeIds),b=[],T=[];for(let L of t){let M=S.has(L.source),G=S.has(L.target);M&&G?L.id&&b.push(L.id):(M||G)&&L.id&&T.push(L.id)}let O=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:d.id,label:d.label,nodeIds:d.nodeIds,internalEdgeIds:b,externalEdgeIds:T,color:O,stats:{nodeCount:d.nodeIds.length,internalEdgeCount:b.length,externalEdgeCount:T.length}}})}validateTypes(e,t){let r=[],i=[];for(let s of e){let a=this.resolveNodeType(s);if(a.primaryType!=="unknown"){let c=this.nodeTypes.get(a.primaryType);!c&&a.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${a.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),c?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${a.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let a=s.predicate??s.type,c=this.edgeTypes.get(a);if(c?.domain&&c.domain.length>0){let u=e.find(l=>l.id===s.source);if(u){let l=this.resolveNodeType(u);c.domain.some(h=>l.types.includes(h))||r.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:c.domain,actual:l.types})}}if(c?.range&&c.range.length>0){let u=e.find(l=>l.id===s.target);if(u){let l=this.resolveNodeType(u);c.range.some(h=>l.types.includes(h))||r.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:l.types})}}}return{valid:r.length===0,errors:r,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new ni.IRI(et.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let r of e){let i=this.getObjectValue(r.object);if(i&&(0,et.isClassType)(i)){let s=this.getSubjectValue(r.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new ni.IRI(et.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let r of t){let i=this.getSubjectValue(r.subject),s=this.getObjectValue(r.object);if(i&&s){let a=this.typeHierarchy.get(i)??[];if(!a.includes(s)){a.push(s),this.typeHierarchy.set(i,a);let c=this.nodeTypes.get(i);c&&(c.parentTypes=a)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(et.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,et.extractLocalName)(e),source:"custom",style:(0,et.mergeNodeStyles)(et.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(et.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,et.extractLocalName)(e),source:"custom",style:(0,et.mergeEdgeStyles)(et.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new ni.IRI(e),new ni.IRI(et.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new ni.IRI(e),new ni.IRI(et.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,et.extractLocalName)(e):(0,et.extractLocalName)(e),s=r.length>0?this.getObjectValue(r[0].object):void 0,a="rdfs:Class",c=await this.tripleStore.match(new ni.IRI(e),new ni.IRI(et.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===et.RDF_TYPE_PREDICATES.OWL_CLASS){a="owl:Class";break}let u=et.BUILT_IN_NODE_STYLES[e]??et.BUILT_IN_NODE_STYLES[(0,et.extractLocalName)(e)],l={uri:e,label:i,description:s,source:a,style:(0,et.mergeNodeStyles)(et.DEFAULT_NODE_STYLE,u??{}),priority:1};this.registerNodeType(l)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof ni.IRI)return e.value;if(e instanceof qS.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof NR.Literal||e instanceof ni.IRI)return e.value;if(e instanceof qS.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let r of this.typeHierarchy.values())for(let i of r)e.add(i);let t=[];for(let r of this.nodeTypes.keys())(!this.typeHierarchy.has(r)||this.typeHierarchy.get(r).length===0)&&e.has(r)&&t.push(r);return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(r){console.error("TypeRegistry: error in subscriber callback",r)}}};ef.TypeRegistry=Tg});var Ag=v(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.SPARQL_TEMPLATES=B.KNOWN_PROTOTYPES=B.EFFORT_STATUSES=B.ASSET_CLASSES=B.PREDICATES=B.SPARQL_PREFIXES=void 0;B.getTemplateByName=LR;B.findMatchingTemplates=kR;B.fillTemplate=MR;B.validateParameters=jR;B.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
106
|
+
`).trim()}removeHtmlTags(e){let t=/<[^>]*>/g,r=e,i;do i=r,r=r.replace(t,"");while(r!==i);return r}cleanWikiLink(e){return e.replace(/^\[\[/,"").replace(/\]\]$/,"").replace(/^"/,"").replace(/"$/,"")}getStats(){return{requestCount:this.requestCount,tokenCount:this.tokenCount}}resetStats(){this.requestCount=0,this.tokenCount=0}};tn.EmbeddingService=vg;tn.EmbeddingService=vg=AR([(0,CR.injectable)(),xR("design:paramtypes",[Object])],vg)});var wg=v(rn=>{"use strict";var IR=rn&&rn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},OR=rn&&rn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(rn,"__esModule",{value:!0});rn.VectorStore=rn.DEFAULT_VECTOR_STORE_CONFIG=void 0;var PR=Le(),_g=Ji();rn.DEFAULT_VECTOR_STORE_CONFIG={maxEntries:0,similarityThreshold:.7};var bg=class{static{o(this,"VectorStore")}constructor(e={}){this.entries=new Map,this.createdAt=new Date,this.updatedAt=new Date,this.config={...rn.DEFAULT_VECTOR_STORE_CONFIG,...e}}setConfig(e){this.config={...this.config,...e}}upsert(e){if(!e.vector||e.vector.length===0)throw new Error("Vector cannot be empty");let t=this.entries.values().next().value;if(t&&t.vector.length!==e.vector.length)throw new Error(`Vector dimension mismatch: expected ${t.vector.length}, got ${e.vector.length}`);if(this.config.maxEntries&&this.config.maxEntries>0&&!this.entries.has(e.id)&&this.entries.size>=this.config.maxEntries){let r=null,i=1/0;for(let[s,a]of this.entries)a.timestamp<i&&(i=a.timestamp,r=s);r&&(this.entries.delete(r),_g.LoggingService.debug(`VectorStore: Evicted oldest entry ${r}`))}this.entries.set(e.id,e),this.updatedAt=new Date}remove(e){let t=this.entries.delete(e);return t&&(this.updatedAt=new Date),t}get(e){return this.entries.get(e)}has(e){return this.entries.has(e)}needsUpdate(e,t){let r=this.entries.get(e);return r?r.contentHash!==t:!0}getAllIds(){return Array.from(this.entries.keys())}size(){return this.entries.size}clear(){this.entries.clear(),this.updatedAt=new Date}search(e,t=10){if(this.entries.size===0)return[];let r=this.entries.values().next().value;if(r&&r.vector.length!==e.length)throw new Error(`Query vector dimension mismatch: expected ${r.vector.length}, got ${e.length}`);let i=[],s=this.config.similarityThreshold??.7;for(let a of this.entries.values()){let c=this.cosineSimilarity(e,a.vector);c>=s&&i.push({entry:a,score:c})}return i.sort((a,c)=>c.score-a.score),i.slice(0,t)}findSimilar(e,t=10){let r=this.entries.get(e);return r?this.search(r.vector,t+1).filter(s=>s.entry.id!==e).slice(0,t):[]}cosineSimilarity(e,t){if(e.length!==t.length)throw new Error("Vectors must have the same dimension");let r=0,i=0,s=0;for(let a=0;a<e.length;a++)r+=e[a]*t[a],i+=e[a]*e[a],s+=t[a]*t[a];return i=Math.sqrt(i),s=Math.sqrt(s),i===0||s===0?0:r/(i*s)}serialize(){return{version:1,entries:Array.from(this.entries.values()).map(e=>({id:e.id,vector:e.vector,metadata:e.metadata,timestamp:e.timestamp,contentHash:e.contentHash})),createdAt:this.createdAt.toISOString(),updatedAt:this.updatedAt.toISOString()}}deserialize(e){if(e.version!==1)throw new Error(`Unsupported VectorStore version: ${e.version}`);this.entries.clear();for(let t of e.entries)this.entries.set(t.id,{id:t.id,vector:t.vector,metadata:t.metadata,timestamp:t.timestamp,contentHash:t.contentHash});this.createdAt=new Date(e.createdAt),this.updatedAt=new Date(e.updatedAt),_g.LoggingService.debug(`VectorStore: Loaded ${this.entries.size} entries from persistence`)}getStats(){let t=this.entries.values().next().value?.vector.length??null,i=(t?this.entries.size*t*8:0)/(1024*1024);return{entryCount:this.entries.size,dimension:t,createdAt:this.createdAt.toISOString(),updatedAt:this.updatedAt.toISOString(),estimatedMemoryMB:Math.round(i*100)/100}}pruneInvalidEntries(e){let t=[];for(let r of this.entries.keys())e.has(r)||t.push(r);for(let r of t)this.entries.delete(r);return t.length>0&&(this.updatedAt=new Date,_g.LoggingService.debug(`VectorStore: Pruned ${t.length} invalid entries`)),t.length}};rn.VectorStore=bg;rn.VectorStore=bg=IR([(0,PR.injectable)(),OR("design:paramtypes",[Object])],bg)});var qS=v(nn=>{"use strict";var DR=nn&&nn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},RR=nn&&nn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(nn,"__esModule",{value:!0});nn.SemanticSearchService=nn.DEFAULT_SEMANTIC_SEARCH_CONFIG=void 0;var FR=Le(),xc=Ji(),BS=Sg(),NR=wg();nn.DEFAULT_SEMANTIC_SEARCH_CONFIG={embedding:BS.DEFAULT_EMBEDDING_CONFIG,maxResults:10,minSimilarity:.7,autoEmbed:!0,batchSize:20};var Eg=class{static{o(this,"SemanticSearchService")}constructor(e={}){this.indexingStatus={isIndexing:!1,totalFiles:0,indexedFiles:0,failedFiles:0,progress:0},this.abortController=null,this.config={...nn.DEFAULT_SEMANTIC_SEARCH_CONFIG,...e},this.embeddingService=new BS.EmbeddingService(this.config.embedding),this.vectorStore=new NR.VectorStore({similarityThreshold:this.config.minSimilarity})}setConfig(e){this.config={...this.config,...e},e.embedding&&this.embeddingService.setConfig(e.embedding),e.minSimilarity!==void 0&&this.vectorStore.setConfig({similarityThreshold:e.minSimilarity})}getConfig(){return{...this.config,embedding:this.embeddingService.getConfig()}}isConfigured(){return this.embeddingService.isConfigured()}getIndexingStatus(){return{...this.indexingStatus}}async search(e,t){if(!this.isConfigured())throw new Error("SemanticSearchService is not properly configured");if(!e.trim())return[];let r=await this.embeddingService.generateEmbedding(e),i=t??this.config.maxResults;return this.vectorStore.search(r.embedding,i).map(a=>this.toSearchResult(a))}async findSimilar(e,t){let r=t??this.config.maxResults;return this.vectorStore.findSimilar(e,r).map(s=>this.toSearchResult(s))}toSearchResult(e){let t=e.entry.metadata??{};return{path:e.entry.id,score:e.score,label:t.exo__Asset_label,instanceClass:this.extractInstanceClass(t),metadata:t}}extractInstanceClass(e){let t=e.exo__Instance_class;if(t){if(Array.isArray(t)){let r=t[0];return typeof r=="string"?this.cleanWikiLink(r):void 0}return typeof t=="string"?this.cleanWikiLink(t):void 0}}cleanWikiLink(e){return e.replace(/^\[\[/,"").replace(/\]\]$/,"").replace(/^"/,"").replace(/"$/,"")}async indexFile(e,t,r){if(!this.isConfigured())return!1;try{let i=await this.hashContent(t);if(!this.vectorStore.needsUpdate(e,i))return!0;let s=this.embeddingService.prepareTextForEmbedding(t,r),a=await this.embeddingService.generateEmbedding(s);return this.vectorStore.upsert({id:e,vector:a.embedding,metadata:r,timestamp:Date.now(),contentHash:i}),xc.LoggingService.debug(`Indexed file: ${e}`),!0}catch(i){return xc.LoggingService.warn(`Failed to index file ${e}: ${i instanceof Error?i.message:"Unknown error"}`),!1}}removeFromIndex(e){return this.vectorStore.remove(e)}async indexBatch(e){if(!this.isConfigured())return{indexed:0,failed:e.length};let t=[],r=new Map;for(let c of e){let u=await this.hashContent(c.content);if(!this.vectorStore.needsUpdate(c.path,u))continue;let l=this.embeddingService.prepareTextForEmbedding(c.content,c.metadata);t.push({id:c.path,text:l}),r.set(c.path,{content:c.content,metadata:c.metadata,contentHash:u})}if(t.length===0)return{indexed:0,failed:0};let i=await this.embeddingService.generateBatchEmbeddings(t),s=0,a=0;for(let c of i){let u=r.get(c.id);u&&(c.result?(this.vectorStore.upsert({id:c.id,vector:c.result.embedding,metadata:u.metadata,timestamp:Date.now(),contentHash:u.contentHash}),s++):(a++,xc.LoggingService.warn(`Failed to embed ${c.id}: ${c.error||"Unknown error"}`)))}return{indexed:s,failed:a}}async indexAll(e,t,r){if(!this.isConfigured())throw new Error("SemanticSearchService is not properly configured");if(this.indexingStatus.isIndexing)throw new Error("Indexing is already in progress");this.abortController=new AbortController,this.indexingStatus={isIndexing:!0,totalFiles:e.length,indexedFiles:0,failedFiles:0,progress:0};let i=0,s=0,a=!1;try{for(let c=0;c<e.length;c+=this.config.batchSize){if(this.abortController.signal.aborted){a=!0;break}let u=e.slice(c,c+this.config.batchSize),l=[];for(let h of u){if(this.abortController.signal.aborted){a=!0;break}let d=await t(h);d?l.push({path:h,content:d.content,metadata:d.metadata}):s++}if(a)break;let f=await this.indexBatch(l);i+=f.indexed,s+=f.failed,this.indexingStatus.indexedFiles=c+u.length,this.indexingStatus.failedFiles=s,this.indexingStatus.progress=Math.round(this.indexingStatus.indexedFiles/e.length*100),r&&r({...this.indexingStatus})}}finally{this.indexingStatus.isIndexing=!1,this.abortController=null}return{indexed:i,failed:s,aborted:a}}abortIndexing(){this.abortController&&(this.abortController.abort(),xc.LoggingService.debug("Indexing aborted by user"))}isIndexed(e){return this.vectorStore.has(e)}getIndexedPaths(){return this.vectorStore.getAllIds()}getIndexedCount(){return this.vectorStore.size()}clearIndex(){this.vectorStore.clear(),xc.LoggingService.debug("Semantic search index cleared")}pruneDeletedFiles(e){return this.vectorStore.pruneInvalidEntries(e)}serializeIndex(){return this.vectorStore.serialize()}deserializeIndex(e){this.vectorStore.deserialize(e)}getStats(){return{indexStats:this.vectorStore.getStats(),embeddingStats:this.embeddingService.getStats()}}async hashContent(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}};nn.SemanticSearchService=Eg;nn.SemanticSearchService=Eg=DR([(0,FR.injectable)(),RR("design:paramtypes",[Object])],Eg)});var GS=v(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.GraphQueryService=void 0;var Cc=Qe(),LR=lt(),Zi=Yr(),kR=Zd(),ri={INSTANCE_CLASS:Zi.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Zi.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Zi.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:Zi.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Zi.Namespace.EMS.term("Effort_parent"),REFERENCES:Zi.Namespace.EXO.term("references"),REFERENCED_BY:Zi.Namespace.EXO.term("referencedBy"),RDF_TYPE:Zi.Namespace.RDF.term("type")},Tg=class{static{o(this,"GraphQueryService")}constructor(e,t={}){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),r=await this.loadNodes(e),i=await this.loadEdges(r,e),s=this.computeStats(r,i),a=Date.now()-t;return a>100&&r.length>0&&console.debug(`GraphQueryService: loaded ${r.length} nodes in ${a}ms (${(a/r.length).toFixed(2)}ms/node)`),{nodes:r,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),r=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:r}),s=i.length>t,a=s?i.slice(0,t):i,c=await this.loadEdges(a,e);return{nodes:a,edges:c,hasMore:s,totalCount:void 0,cursor:s?String(r+t):void 0}}async loadConnectedNodes(e,t={}){let r=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,a=[{id:e,currentDepth:0}],c=[];for(;a.length>0&&c.length<i;){let{id:l,currentDepth:f}=a.shift();if(s.has(l))continue;s.add(l);let h=await this.getNodeById(l,t);if(h&&(c.push(h),f<r)){let d=await this.getConnectedNodeIds(l);for(let p of d)s.has(p)||a.push({id:p,currentDepth:f+1})}}let u=await this.loadEdges(c,t);return{nodes:c,edges:u,hasMore:a.length>0,totalCount:s.size+a.length}}async getNodeById(e,t={}){let r=this.getCachedNode(e);if(r)return{...r};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let a=this.triplesToNode(e,s,t);return a&&this.cacheNode(a),a}subscribe(e){return this.subscribers.add(e),{unsubscribe:o(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(r){console.error("GraphQueryService: error in subscriber callback",r)}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,r=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,ri.INSTANCE_CLASS,void 0),a=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);a=s.filter(S=>{let b=this.getObjectValue(S.object);return b&&p.has(b)})}let c=new Set;for(let p of a)c.add(this.subjectToId(p.subject));let f=Array.from(c).slice(i,i+r).map(p=>this.getNodeById(p,e));return(await Promise.all(f)).filter(p=>!(!p||!t&&p.isArchived))}async loadEdges(e,t){let r=new Set(e.map(a=>a.id)),i=[],s=new Set;for(let a of e){let c=this.idToIRI(a.id),u=await this.tripleStore.match(c,void 0,void 0);for(let l of u){let f=this.tripleToEdge(a.id,l,r);f&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),r=[],i=await this.tripleStore.match(t,void 0,void 0);for(let a of i){let c=this.objectToId(a.object);c&&r.push(c)}let s=await this.tripleStore.match(void 0,void 0,t);for(let a of s)r.push(this.subjectToId(a.subject));return[...new Set(r)]}triplesToNode(e,t,r){let i={},s,a,c,u,l=!1;for(let d of t){let p=d.predicate.value,S=this.getObjectValue(d.object);if(p===ri.INSTANCE_CLASS.value)s=S;else if(p===ri.ASSET_LABEL.value)a=S;else if(p===ri.ASSET_PROTOTYPE.value)c=this.objectToId(d.object)??S;else if(p===ri.EFFORT_PARENT.value)u=this.objectToId(d.object)??S;else if(p===ri.ASSET_IS_ARCHIVED.value)l=S==="true"||S==="1";else{let b=this.predicateToPropertyName(p);b&&(i[b]=S)}}if(l&&!(r.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),h=a??this.pathToTitle(f);return{id:e,path:f,title:h,label:h,assetClass:s,isArchived:l,uri:e.startsWith("http")?e:void 0,prototype:c,parent:u,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,r){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!r.has(s)||s===e)return null;let a=this.predicateToEdgeType(i);if(!a)return null;let c=(0,kR.createEdgeId)(e,s,a,i),u=this.predicateToLabel(i);return{id:c,source:e,target:s,type:a,predicate:i,label:u}}predicateToEdgeType(e){return e===ri.EFFORT_PARENT.value?"hierarchy":e===ri.ASSET_PROTOTYPE.value?"prototype":e===ri.REFERENCES.value?"forward-link":e===ri.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),r=e.lastIndexOf("/"),i=Math.max(t,r);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let r={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let c of e){let u=c.assetClass??"unknown";r[u]=(r[u]??0)+1}for(let c of t)i[c.type]=(i[c.type]??0)+1;let s=new Map,a=new Map;for(let c of t)a.set(c.source,(a.get(c.source)??0)+1),s.set(c.target,(s.get(c.target)??0)+1);for(let c of e)c.inDegree=s.get(c.id)??0,c.outDegree=a.get(c.id)??0,c.weight=c.inDegree+c.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:r,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new Cc.IRI(e):new Cc.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof Cc.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof Cc.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof LR.Literal||e instanceof Cc.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};Zl.GraphQueryService=Tg});var HS=v(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});ef.TypeRegistry=void 0;var ni=Qe(),WS=Ot(),MR=lt(),et=ep(),Ag=class{static{o(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:et.DEFAULT_NODE_STYLE,defaultEdgeStyle:et.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let r=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:r,typeUri:e.uri,definition:e})}registerEdgeType(e){let r=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:r,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),r=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||r)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let r=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let{uri:a,currentDepth:c}=s.shift();if(i.has(a)||(i.add(a),c>=t))continue;let u=this.typeHierarchy.get(a)??[];for(let l of u)i.has(l)||(r.push(l),s.push({uri:l,currentDepth:c+1}))}return r}getChildTypes(e){let t=[];for(let[r,i]of this.typeHierarchy)i.includes(e)&&t.push(r);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],r="unknown",i="custom";if(e.assetClass){let c=this.normalizeTypeUri(e.assetClass);t.push(c),r=c,i="exo:Instance_class"}let s=e.properties?.[et.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),r==="unknown"&&(r=s,i="rdf:type"));for(let c of[...t]){let u=this.getParentTypes(c);for(let l of u)t.includes(l)||t.push(l)}let a=this.resolveNodeStyle(t);return{primaryType:r,types:t,resolvedStyle:a,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,r=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:r}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:r}=this.config.styleResolution,i={...r},s=[];for(let a of e){let c=this.nodeTypes.get(a);c&&s.push(c)}if(s.sort((a,c)=>a.priority-c.priority),t)for(let a of s)i=(0,et.mergeNodeStyles)(i,a.style);else if(s.length>0){let a=s[s.length-1];i=(0,et.mergeNodeStyles)(i,a.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,r={...t},i=this.edgeTypes.get(e);return i&&(r=(0,et.mergeEdgeStyles)(r,i.style)),r}filterNodes(e,t){return e.filter(r=>{let i=this.resolveNodeType(r);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(a=>i.types.includes(a)||t.includeInferred&&this.isSubtypeOf(i.primaryType,a))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(r=>{let i=r.predicate??r.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,r={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:a=0,maxGroups:c=20,customGroupFn:u}=r,l=new Map;for(let d of e){let p=this.resolveNodeType(d),S;if(u?S=u(p.types):s&&p.types.length>a?S=p.types[a]??p.primaryType:i?S=p.primaryType:S="all",!l.has(S)){let T=this.nodeTypes.get(S)?.label??(0,et.extractLocalName)(S);l.set(S,{nodeIds:new Set,label:T})}l.get(S).nodeIds.add(d.id)}let f=Array.from(l.entries()).map(([d,p])=>({id:d,label:p.label,nodeIds:Array.from(p.nodeIds)}));if(f.length>c){f.sort((S,b)=>b.nodeIds.length-S.nodeIds.length);let d=f.slice(0,c-1),p=f.slice(c-1).flatMap(S=>S.nodeIds);d.push({id:"other",label:"Other",nodeIds:p}),f=d}let h=new Map;for(let d of f)for(let p of d.nodeIds)h.set(p,d.id);return f.map((d,p)=>{let S=new Set(d.nodeIds),b=[],T=[];for(let L of t){let M=S.has(L.source),G=S.has(L.target);M&&G?L.id&&b.push(L.id):(M||G)&&L.id&&T.push(L.id)}let O=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:d.id,label:d.label,nodeIds:d.nodeIds,internalEdgeIds:b,externalEdgeIds:T,color:O,stats:{nodeCount:d.nodeIds.length,internalEdgeCount:b.length,externalEdgeCount:T.length}}})}validateTypes(e,t){let r=[],i=[];for(let s of e){let a=this.resolveNodeType(s);if(a.primaryType!=="unknown"){let c=this.nodeTypes.get(a.primaryType);!c&&a.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${a.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),c?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${a.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let a=s.predicate??s.type,c=this.edgeTypes.get(a);if(c?.domain&&c.domain.length>0){let u=e.find(l=>l.id===s.source);if(u){let l=this.resolveNodeType(u);c.domain.some(h=>l.types.includes(h))||r.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:c.domain,actual:l.types})}}if(c?.range&&c.range.length>0){let u=e.find(l=>l.id===s.target);if(u){let l=this.resolveNodeType(u);c.range.some(h=>l.types.includes(h))||r.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:c.range,actual:l.types})}}}return{valid:r.length===0,errors:r,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new ni.IRI(et.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let r of e){let i=this.getObjectValue(r.object);if(i&&(0,et.isClassType)(i)){let s=this.getSubjectValue(r.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new ni.IRI(et.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let r of t){let i=this.getSubjectValue(r.subject),s=this.getObjectValue(r.object);if(i&&s){let a=this.typeHierarchy.get(i)??[];if(!a.includes(s)){a.push(s),this.typeHierarchy.set(i,a);let c=this.nodeTypes.get(i);c&&(c.parentTypes=a)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(et.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,et.extractLocalName)(e),source:"custom",style:(0,et.mergeNodeStyles)(et.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(et.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,et.extractLocalName)(e),source:"custom",style:(0,et.mergeEdgeStyles)(et.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new ni.IRI(e),new ni.IRI(et.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new ni.IRI(e),new ni.IRI(et.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,et.extractLocalName)(e):(0,et.extractLocalName)(e),s=r.length>0?this.getObjectValue(r[0].object):void 0,a="rdfs:Class",c=await this.tripleStore.match(new ni.IRI(e),new ni.IRI(et.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of c)if(this.getObjectValue(f.object)===et.RDF_TYPE_PREDICATES.OWL_CLASS){a="owl:Class";break}let u=et.BUILT_IN_NODE_STYLES[e]??et.BUILT_IN_NODE_STYLES[(0,et.extractLocalName)(e)],l={uri:e,label:i,description:s,source:a,style:(0,et.mergeNodeStyles)(et.DEFAULT_NODE_STYLE,u??{}),priority:1};this.registerNodeType(l)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof ni.IRI)return e.value;if(e instanceof WS.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof MR.Literal||e instanceof ni.IRI)return e.value;if(e instanceof WS.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let r of this.typeHierarchy.values())for(let i of r)e.add(i);let t=[];for(let r of this.nodeTypes.keys())(!this.typeHierarchy.has(r)||this.typeHierarchy.get(r).length===0)&&e.has(r)&&t.push(r);return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(r){console.error("TypeRegistry: error in subscriber callback",r)}}};ef.TypeRegistry=Ag});var xg=v(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.SPARQL_TEMPLATES=B.KNOWN_PROTOTYPES=B.EFFORT_STATUSES=B.ASSET_CLASSES=B.PREDICATES=B.SPARQL_PREFIXES=void 0;B.getTemplateByName=jR;B.findMatchingTemplates=$R;B.fillTemplate=VR;B.validateParameters=UR;B.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
|
|
107
107
|
PREFIX ems: <https://exocortex.my/ontology/ems#>
|
|
108
108
|
PREFIX ims: <https://exocortex.my/ontology/ims#>
|
|
109
109
|
PREFIX gtd: <https://exocortex.my/ontology/gtd#>
|
|
@@ -226,7 +226,7 @@ WHERE {
|
|
|
226
226
|
?person ${B.PREDICATES.INSTANCE_CLASS} "[[${B.ASSET_CLASSES.PERSON}]]" .
|
|
227
227
|
?person ${B.PREDICATES.ASSET_LABEL} ?label .
|
|
228
228
|
}
|
|
229
|
-
ORDER BY ?label`,parameters:[],examples:["\u0432\u0441\u0435 \u043B\u044E\u0434\u0438","\u043A\u043E\u043D\u0442\u0430\u043A\u0442\u044B","persons"],keywords:["\u043B\u044E\u0434\u0438","\u043A\u043E\u043D\u0442\u0430\u043A\u0442\u044B","persons","person"]}];function
|
|
229
|
+
ORDER BY ?label`,parameters:[],examples:["\u0432\u0441\u0435 \u043B\u044E\u0434\u0438","\u043A\u043E\u043D\u0442\u0430\u043A\u0442\u044B","persons"],keywords:["\u043B\u044E\u0434\u0438","\u043A\u043E\u043D\u0442\u0430\u043A\u0442\u044B","persons","person"]}];function jR(n){return B.SPARQL_TEMPLATES.find(e=>e.name===n)}o(jR,"getTemplateByName");function $R(n,e=3){let t=n.toLowerCase(),r=new Map;for(let i of B.SPARQL_TEMPLATES){let s=0;for(let a of i.keywords)t.includes(a.toLowerCase())&&(s+=2);for(let a of i.examples){let c=a.toLowerCase().split(/\s+/),u=t.split(/\s+/),l=c.filter(f=>u.some(h=>h.includes(f)||f.includes(h)));s+=l.length*.5}s>0&&r.set(i,s)}return Array.from(r.entries()).sort((i,s)=>s[1]-i[1]).slice(0,e).map(([i])=>i)}o($R,"findMatchingTemplates");function VR(n,e){let t=n.template;for(let r of n.parameters)!r.required&&!e[r.name]&&r.name==="limit"&&(e[r.name]="100");for(let[r,i]of Object.entries(e))t=t.replace(new RegExp(`\\{\\{${r}\\}\\}`,"g"),i);return t}o(VR,"fillTemplate");function UR(n,e){let t=[];for(let r of n.parameters)r.required&&!e[r.name]&&t.push(r.name);return{valid:t.length===0,missing:t}}o(UR,"validateParameters")});var zS=v(sn=>{"use strict";var BR=sn&&sn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},qR=sn&&sn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(sn,"__esModule",{value:!0});sn.NLToSPARQLService=sn.DEFAULT_NL_TO_SPARQL_CONFIG=void 0;var GR=Le(),WR=Ji(),St=xg();sn.DEFAULT_NL_TO_SPARQL_CONFIG={defaultLimit:100,includeExplanation:!0,confidenceThreshold:.3};var Cg=class{static{o(this,"NLToSPARQLService")}constructor(e={}){this.uuidPattern=/\b([0-9a-f]{8}[-]?[0-9a-f]{4}[-]?[0-9a-f]{4}[-]?[0-9a-f]{4}[-]?[0-9a-f]{12})\b/i,this.datePattern=/\b(20\d{2}[-]?\d{2}(?:[-]?\d{2})?)\b/,this.monthNames={\u044F\u043D\u0432\u0430\u0440:"01",\u0444\u0435\u0432\u0440\u0430\u043B:"02",\u043C\u0430\u0440\u0442:"03",\u0430\u043F\u0440\u0435\u043B:"04",\u043C\u0430\u0439:"05",\u0438\u044E\u043D:"06",\u0438\u044E\u043B:"07",\u0430\u0432\u0433\u0443\u0441\u0442:"08",\u0441\u0435\u043D\u0442\u044F\u0431\u0440:"09",\u043E\u043A\u0442\u044F\u0431\u0440:"10",\u043D\u043E\u044F\u0431\u0440:"11",\u0434\u0435\u043A\u0430\u0431\u0440:"12",january:"01",february:"02",march:"03",april:"04",may:"05",june:"06",july:"07",august:"08",september:"09",october:"10",november:"11",december:"12"},this.activityPatterns={\u0434\u0443\u0448:"\u0434\u0443\u0448","morning shower":"\u0434\u0443\u0448","\u0443\u0442\u0440\u0435\u043D\u043D\u0438\u0439 \u0434\u0443\u0448":"\u0434\u0443\u0448",\u0441\u043E\u043D:"\u041F\u043E\u0441\u043F\u0430\u0442\u044C",\u0441\u043F\u0430\u0442\u044C:"\u041F\u043E\u0441\u043F\u0430\u0442\u044C",\u043F\u043E\u0441\u043F\u0430\u0442\u044C:"\u041F\u043E\u0441\u043F\u0430\u0442\u044C",sleep:"\u041F\u043E\u0441\u043F\u0430\u0442\u044C",\u0439\u043E\u0433\u0430:"\u0439\u043E\u0433",yoga:"\u0439\u043E\u0433",\u043F\u0440\u0435\u0441\u0441:"\u041F\u0440\u0435\u0441\u0441","wim hof":"Wim Hof",\u043C\u043E\u0447\u0438:"\u041C\u041E\u0427\u0418"},this.prototypeMapping={\u0434\u0443\u0448:St.KNOWN_PROTOTYPES.MORNING_SHOWER,"\u0443\u0442\u0440\u0435\u043D\u043D\u0438\u0439 \u0434\u0443\u0448":St.KNOWN_PROTOTYPES.MORNING_SHOWER,"morning shower":St.KNOWN_PROTOTYPES.MORNING_SHOWER,\u043D\u043E\u0433\u0442\u0438:St.KNOWN_PROTOTYPES.CUT_NAILS,"\u043F\u043E\u0434\u0441\u0442\u0440\u0438\u0447\u044C \u043D\u043E\u0433\u0442\u0438":St.KNOWN_PROTOTYPES.CUT_NAILS},this.config={...sn.DEFAULT_NL_TO_SPARQL_CONFIG,...e}}convert(e){let t=e.trim().toLowerCase(),r=t.match(this.uuidPattern);if(r)return this.handleUuidQuery(t,r[1]);let i=(0,St.findMatchingTemplates)(t,3);if(i.length===0)return this.createFallbackQuery(t);let s=i[0],a=this.extractParameters(t,s),c=(0,St.validateParameters)(s,a);if(!c.valid){for(let d of c.missing){let p=this.inferParameter(t,d,s);p&&(a[d]=p)}let h=(0,St.validateParameters)(s,a);if(!h.valid)return this.createFallbackQuery(t,{template:s,missingParams:h.missing})}let u=(0,St.fillTemplate)(s,a),l=this.calculateConfidence(t,s,a),f=i.slice(1).map(h=>{let d=this.extractParameters(t,h);return(0,St.fillTemplate)(h,d)}).filter(h=>h!==u);return{query:u,templateName:s.name,parameters:a,confidence:l,explanation:this.generateExplanation(s,a),isFallback:!1,alternatives:f}}handleUuidQuery(e,t){if(e.includes("\u043F\u0440\u043E\u0442\u043E\u0442\u0438\u043F")||e.includes("prototype")||e.includes("\u0438\u043D\u0441\u0442\u0430\u043D\u0441")){let s=(0,St.getTemplateByName)("find_by_prototype_uuid");if(!s)throw new Error("Template find_by_prototype_uuid not found");let a={prototypeUuid:t,limit:"100"};return{query:(0,St.fillTemplate)(s,a),templateName:s.name,parameters:a,confidence:.9,explanation:`\u041F\u043E\u0438\u0441\u043A \u0438\u043D\u0441\u0442\u0430\u043D\u0441\u043E\u0432 \u043F\u0440\u043E\u0442\u043E\u0442\u0438\u043F\u0430 \u0441 UUID ${t}`,isFallback:!1,alternatives:[]}}let r=(0,St.getTemplateByName)("properties_by_uuid");if(!r)throw new Error("Template properties_by_uuid not found");let i={uuid:t};return{query:(0,St.fillTemplate)(r,i),templateName:r.name,parameters:i,confidence:.9,explanation:`\u041F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u0435 \u0441\u0432\u043E\u0439\u0441\u0442\u0432 \u0441\u0443\u0449\u043D\u043E\u0441\u0442\u0438 \u0441 UUID ${t}`,isFallback:!1,alternatives:[]}}extractParameters(e,t){let r={};for(let i of t.parameters)switch(i.name){case"keyword":case"pattern":case"taskLabel":case"entityLabel":r[i.name]=this.extractKeyword(e,t);break;case"prototypeUuid":r[i.name]=this.extractPrototypeUuid(e);break;case"yearMonth":r[i.name]=this.extractYearMonth(e);break;case"limit":r[i.name]=this.extractLimit(e);break;case"uuid":{let s=e.match(this.uuidPattern);s&&(r[i.name]=s[1]);break}}return r}extractKeyword(e,t){for(let[a,c]of Object.entries(this.activityPatterns))if(e.includes(a))return c;let r=e.match(/["'«»]([^"'«»]+)["'«»]/);if(r)return r[1];let i=e.replace(/^(найди|найти|покажи|покажешь|какие|какой|сколько|где|как|что|все|всех|мои|моих|за|в|по|для|который|которые)\s+/gi,"").replace(/\s+(за|в|по|для|с|на|от)\s+\d+.*$/gi,"").trim(),s=i.split(/\s+/);return s.length>0?s.slice(0,2).join(" "):i||e}extractPrototypeUuid(e){let t=e.match(this.uuidPattern);if(t)return t[1];for(let[r,i]of Object.entries(this.prototypeMapping))if(e.includes(r))return i;return""}extractYearMonth(e){let t=e.match(this.datePattern);if(t)return t[1].replace(/(\d{4})(\d{2})/,"$1-$2");for(let[r,i]of Object.entries(this.monthNames))if(e.includes(r)){let s=e.match(/\b(20\d{2})\b/);return`${s?s[1]:new Date().getFullYear()}-${i}`}return""}extractLimit(e){let t=e.match(/(?:первые|последние|топ|limit|лимит)\s*(\d+)/i);if(t)return t[1];let r=e.match(/\b(\d{1,3})\b/);return r&&parseInt(r[1])<=500?r[1]:String(this.config.defaultLimit)}inferParameter(e,t,r){switch(t){case"prototypeUuid":for(let[i,s]of Object.entries(this.prototypeMapping))if(e.includes(i))return s;break;case"keyword":case"pattern":for(let[i,s]of Object.entries(this.activityPatterns))if(e.includes(i))return s;break}return null}createFallbackQuery(e,t){let r=this.extractKeyword(e,St.SPARQL_TEMPLATES[0]),i=`${St.SPARQL_PREFIXES}
|
|
230
230
|
|
|
231
231
|
SELECT ?s ?label ?class WHERE {
|
|
232
232
|
?s ${St.PREDICATES.ASSET_LABEL} ?label .
|
|
@@ -234,26 +234,26 @@ SELECT ?s ?label ?class WHERE {
|
|
|
234
234
|
FILTER(CONTAINS(LCASE(?label), "${r.toLowerCase()}"))
|
|
235
235
|
}
|
|
236
236
|
ORDER BY ?label
|
|
237
|
-
LIMIT ${this.config.defaultLimit}`,s="\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0442\u043E\u0447\u043D\u043E \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0442\u0438\u043F \u0437\u0430\u043F\u0440\u043E\u0441\u0430. \u0412\u044B\u043F\u043E\u043B\u043D\u044F\u0435\u0442\u0441\u044F \u043F\u043E\u0438\u0441\u043A \u043F\u043E \u043A\u043B\u044E\u0447\u0435\u0432\u043E\u043C\u0443 \u0441\u043B\u043E\u0432\u0443.";return t?.template&&t?.missingParams&&(s+=` \u0414\u043B\u044F \u0448\u0430\u0431\u043B\u043E\u043D\u0430 "${t.template.name}" \u043D\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432: ${t.missingParams.join(", ")}.`),{query:i,templateName:null,parameters:{keyword:r},confidence:.3,explanation:s,isFallback:!0,alternatives:[]}}calculateConfidence(e,t,r){let i=.5;for(let c of t.keywords)e.includes(c.toLowerCase())&&(i+=.1);let s=t.parameters.filter(c=>c.required),a=s.filter(c=>r[c.name]&&r[c.name].length>0);s.length>0?i+=a.length/s.length*.2:i+=.2;for(let[c]of Object.entries(this.prototypeMapping))if(e.includes(c)){i+=.1;break}return Math.min(i,1)}generateExplanation(e,t){let r=e.description;return Object.keys(t).length>0&&(r+=". \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B: ",r+=Object.entries(t).filter(([,i])=>i&&i.length>0).map(([i,s])=>`${i}="${s}"`).join(", ")),r}getAvailableTemplates(){return[...St.SPARQL_TEMPLATES]}getTemplate(e){return(0,St.getTemplateByName)(e)}setConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}addTemplate(e){St.SPARQL_TEMPLATES.push(e),
|
|
238
|
-
`).filter(s=>s.trim()).map(s=>this.cleanWikiLink(s.replace(/^\s*-\s*/,"").trim()));let r=this.frontmatterService.getPropertyValue(e,"exo__Instance_class");return r?this.cleanWikiLink(r):null}cleanWikiLink(e){return e.replace(/^\[\[/,"").replace(/\]\]$/,"").replace(/^"/,"").replace(/"$/,"")}parseTimestamp(e){if(!e)return null;let t=e.replace(/^"/,"").replace(/"$/,""),r=new Date(t);return isNaN(r.getTime())?null:r}calculateDurationStats(e){let t=e.filter(f=>f.startTimestamp&&f.endTimestamp).map(f=>(f.endTimestamp.getTime()-f.startTimestamp.getTime())/6e4).filter(f=>f>0);if(t.length===0)return{count:0,totalMinutes:0,averageMinutes:0,minMinutes:0,maxMinutes:0,stdDevMinutes:0};let r=t.reduce((f,h)=>f+h,0),i=r/t.length,s=Math.min(...t),a=Math.max(...t),u=t.map(f=>Math.pow(f-i,2)).reduce((f,h)=>f+h,0)/t.length,l=Math.sqrt(u);return{count:t.length,totalMinutes:Math.round(r),averageMinutes:Math.round(i*10)/10,minMinutes:Math.round(s),maxMinutes:Math.round(a),stdDevMinutes:Math.round(l*10)/10}}calculateDailyAggregates(e){let t=new Map;for(let r of e){if(!r.startTimestamp)continue;let i=zR.DateFormatter.toDateString(r.startTimestamp);t.has(i)||t.set(i,{count:0,totalMinutes:0});let s=t.get(i);if(s.count++,r.endTimestamp){let a=r.endTimestamp.getTime()-r.startTimestamp.getTime();s.totalMinutes+=a/6e4}}return Array.from(t.entries()).map(([r,i])=>({date:r,count:i.count,totalMinutes:Math.round(i.totalMinutes),averageMinutes:i.count>0?Math.round(i.totalMinutes/i.count*10)/10:0})).sort((r,i)=>r.date.localeCompare(i.date))}calculateHourlyDistribution(e){let t=new Array(24).fill(0);for(let i of e){if(!i.startTimestamp)continue;let s=i.startTimestamp.getHours();t[s]++}let r=t.reduce((i,s)=>i+s,0);return t.map((i,s)=>({hour:s,count:i,percentage:r>0?Math.round(i/r*1e3)/10:0}))}calculateWeekdayDistribution(e){let t=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],r=new Array(7).fill(0);for(let s of e){if(!s.startTimestamp)continue;let a=s.startTimestamp.getDay();r[a]++}let i=r.reduce((s,a)=>s+a,0);return r.map((s,a)=>({dayOfWeek:a,dayName:t[a],count:s,percentage:i>0?Math.round(s/i*1e3)/10:0}))}async analyzeSleep(e=this.getDefaultPeriod()){let t=await this.getEffortsInPeriod(e,{labelContains:"\u041F\u043E\u0441\u043F\u0430\u0442\u044C"}),r=this.calculateDurationStats(t),i=this.calculateDailyAggregates(t),s=[],a=[];for(let h of t){if(h.startTimestamp){let d=h.startTimestamp.getHours()*60+h.startTimestamp.getMinutes();s.push(d<360?d+1440:d)}if(h.endTimestamp){let d=h.endTimestamp.getHours()*60+h.endTimestamp.getMinutes();a.push(d)}}let c=s.length>0?s.reduce((h,d)=>h+d,0)/s.length:0,u=a.length>0?a.reduce((h,d)=>h+d,0)/a.length:0,l=s.length>1?Math.sqrt(s.map(h=>Math.pow(h-c,2)).reduce((h,d)=>h+d,0)/s.length):0,f=a.length>1?Math.sqrt(a.map(h=>Math.pow(h-u,2)).reduce((h,d)=>h+d,0)/a.length):0;return{period:e,stats:r,dailyData:i,averageBedtime:this.minutesToTimeString(c%1440),averageWakeTime:this.minutesToTimeString(u),bedtimeVariabilityMinutes:Math.round(l),wakeTimeVariabilityMinutes:Math.round(f)}}minutesToTimeString(e){let t=Math.floor(e/60),r=Math.round(e%60);return`${String(t).padStart(2,"0")}:${String(r).padStart(2,"0")}`}async analyzeTaskCompletion(e=this.getDefaultPeriod()){let r=(await this.getEffortsInPeriod(e)).filter(l=>Array.isArray(l.instanceClass)?l.instanceClass.some(f=>f.includes("ems__Task")):l.instanceClass?.includes("ems__Task")??!1),i=r.filter(l=>l.status?.includes("ems__EffortStatusDone")),s=r.filter(l=>l.status?.includes("ems__EffortStatusTrashed")),a=i.filter(l=>l.startTimestamp&&l.endTimestamp).map(l=>(l.endTimestamp.getTime()-l.startTimestamp.getTime())/6e4),c=a.length>0?a.reduce((l,f)=>l+f,0)/a.length:0,u=this.calculateDailyAggregates(i);return{period:e,totalTasks:r.length,completedTasks:i.length,trashedTasks:s.length,completionRate:r.length>0?Math.round(i.length/r.length*1e3)/10:0,averageCompletionTimeMinutes:Math.round(c*10)/10,dailyCompletions:u}}async analyzeActivityFrequency(e,t=this.getDefaultPeriod()){let r=await this.getEffortsInPeriod(t,{labelContains:e}),i=this.calculateDurationStats(r),s=this.calculateDailyAggregates(r),a=this.calculateHourlyDistribution(r),c=this.calculateWeekdayDistribution(r);return{activityLabel:e,period:t,stats:i,dailyData:s,hourlyDistribution:a,weekdayDistribution:c}}async getActivitySummary(e=this.getDefaultPeriod()){let t=await this.getEffortsInPeriod(e),r=new Map;for(let s of t){let a=s.label.split(" ")[0];r.has(a)||r.set(a,[]),r.get(a).push(s)}let i=new Map;for(let[s,a]of r)i.set(s,this.calculateDurationStats(a));return i}};Ln.AnalyticsService=Cg;Ln.AnalyticsService=Cg=qR([(0,HS.injectable)(),WR(0,(0,HS.inject)(HR.DI_TOKENS.IVaultAdapter)),GR("design:paramtypes",[Object])],Cg)});var QS=v(Ys=>{"use strict";var YR=Ys&&Ys.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Ys,"__esModule",{value:!0});Ys.TrendDetectionService=void 0;var KR=Le(),Ig=class{static{o(this,"TrendDetectionService")}constructor(){this.TREND_THRESHOLD=.05,this.ANOMALY_THRESHOLD_STD=2,this.STRONG_CORRELATION_THRESHOLD=.7,this.MODERATE_CORRELATION_THRESHOLD=.4}analyzeTrend(e,t="averageMinutes"){if(e.length<3)return{direction:"stable",strength:"none",slope:0,rSquared:0,changePercentage:0,insight:"Insufficient data for trend analysis (need at least 3 data points)"};let r=e.map(d=>d[t]),{slope:i,rSquared:s}=this.linearRegression(r),a=r[0]||1,u=((r[r.length-1]||0)-a)/a*100,l;Math.abs(u)<this.TREND_THRESHOLD*100?l="stable":i>0?l="increasing":l="decreasing";let f;s>=.7?f="strong":s>=.4?f="moderate":s>=.2?f="weak":f="none";let h=this.generateTrendInsight(l,f,u);return{direction:l,strength:f,slope:Math.round(i*100)/100,rSquared:Math.round(s*100)/100,changePercentage:Math.round(u*10)/10,insight:h}}linearRegression(e){let t=e.length;if(t===0)return{slope:0,intercept:0,rSquared:0};let r=(t-1)/2,i=e.reduce((d,p)=>d+p,0)/t,s=0,a=0;for(let d=0;d<t;d++)s+=(d-r)*(e[d]-i),a+=Math.pow(d-r,2);let c=a!==0?s/a:0,u=i-c*r,l=0,f=0;for(let d=0;d<t;d++){let p=u+c*d;l+=Math.pow(e[d]-p,2),f+=Math.pow(e[d]-i,2)}let h=f!==0?1-l/f:0;return{slope:c,intercept:u,rSquared:Math.max(0,h)}}generateTrendInsight(e,t,r){if(t==="none"||e==="stable")return"Metric is relatively stable with no significant trend.";let i=t==="strong"?"clearly":t==="moderate"?"moderately":"slightly",s=e==="increasing"?"increasing":"decreasing",a=`${Math.abs(Math.round(r))}%`;return`Metric is ${i} ${s} (${a} change over the period).`}detectAnomalies(e,t="averageMinutes"){if(e.length<5)return[];let r=e.map(c=>c[t]),{mean:i,stdDev:s}=this.calculateStats(r),a=[];for(let c=0;c<e.length;c++){let u=r[c],l=(u-i)/(s||1);if(Math.abs(l)>=this.ANOMALY_THRESHOLD_STD){let f=this.determineAnomalySeverity(l),h=this.determineAnomalyType(l,u,i);a.push({date:e[c].date,value:u,expectedValue:Math.round(i*10)/10,deviation:Math.round(l*100)/100,severity:f,type:h,description:this.generateAnomalyDescription(h,f,l,u,i)})}}return a}calculateStats(e){if(e.length===0)return{mean:0,stdDev:0};let t=e.reduce((a,c)=>a+c,0)/e.length,i=e.map(a=>Math.pow(a-t,2)).reduce((a,c)=>a+c,0)/e.length,s=Math.sqrt(i);return{mean:t,stdDev:s}}determineAnomalySeverity(e){let t=Math.abs(e);return t>=3?"critical":t>=2.5?"warning":"info"}determineAnomalyType(e,t,r){return t>r&&e>0?"spike":t<r&&e<0?"drop":"outlier"}generateAnomalyDescription(e,t,r,i,s){let a=t==="critical"?"Significant":t==="warning"?"Notable":"Minor",c=e==="spike"?"spike":e==="drop"?"drop":"unusual value",u=Math.round((i-s)/s*100);return`${a} ${c} detected: ${Math.round(i)} (${u>0?"+":""}${u}% from average of ${Math.round(s)}, ${r.toFixed(1)}\u03C3 from mean).`}calculateCorrelation(e,t,r,i){let s=Math.min(e.length,t.length);if(s<5)return{metric1:r,metric2:i,coefficient:0,strength:"none",direction:"none",insight:"Insufficient data for correlation analysis."};let{mean:a,stdDev:c}=this.calculateStats(e.slice(0,s)),{mean:u,stdDev:l}=this.calculateStats(t.slice(0,s));if(c===0||l===0)return{metric1:r,metric2:i,coefficient:0,strength:"none",direction:"none",insight:"One or both metrics have no variation."};let f=0;for(let T=0;T<s;T++)f+=(e[T]-a)/c*((t[T]-u)/l);let h=f/s,d=Math.abs(h),p;d>=this.STRONG_CORRELATION_THRESHOLD?p="strong":d>=this.MODERATE_CORRELATION_THRESHOLD?p="moderate":d>=.2?p="weak":p="none";let S=p==="none"?"none":h>0?"positive":"negative",b=this.generateCorrelationInsight(r,i,h,p,S);return{metric1:r,metric2:i,coefficient:Math.round(h*100)/100,strength:p,direction:S,insight:b}}generateCorrelationInsight(e,t,r,i,s){if(i==="none")return`No significant correlation found between ${e} and ${t}.`;let a=i==="strong"?"strongly":i==="moderate"?"moderately":"weakly",c=s==="positive"?"When one increases, the other tends to increase":"When one increases, the other tends to decrease";return`${e} and ${t} are ${a} ${s}ly correlated (r=${r.toFixed(2)}). ${c}.`}analyzeWeeklyPattern(e,t="averageMinutes"){let r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i={};for(let u of e){let f=new Date(u.date).getDay();i[f]||(i[f]=[]),i[f].push(u[t])}let s=[],a=0,c=1/0;for(let u=0;u<7;u++){let l=i[u]||[],{mean:f,stdDev:h}=this.calculateStats(l);f>a&&(a=f),f<c&&l.length>0&&(c=f),s.push({dayOfWeek:u,dayName:r[u],averageValue:Math.round(f*10)/10,deviation:Math.round(h*10)/10,isHighPoint:!1,isLowPoint:!1})}for(let u of s)u.averageValue===a&&a>0&&(u.isHighPoint=!0),u.averageValue===c&&c!==1/0&&(u.isLowPoint=!0);return s}generateInsights(e,t,r,i,s){let a=[];t.strength!=="none"&&t.direction!=="stable"&&a.push({type:"trend",severity:t.direction==="decreasing"?"warning":"info",title:`${s} is ${t.direction}`,description:t.insight,metric:s,value:t.changePercentage,actionable:t.direction==="decreasing"});let c=r.filter(f=>f.severity==="critical");if(c.length>0)for(let f of c)a.push({type:"anomaly",severity:"critical",title:`Unusual ${f.type} detected on ${f.date}`,description:f.description,metric:s,value:f.value,actionable:!0});let u=i.filter(f=>f.isHighPoint).map(f=>f.dayName),l=i.filter(f=>f.isLowPoint).map(f=>f.dayName);return u.length>0&&l.length>0&&a.push({type:"pattern",severity:"info",title:"Weekly pattern detected",description:`${s} tends to be highest on ${u.join(", ")} and lowest on ${l.join(", ")}.`,metric:s,actionable:!1}),e.stdDevMinutes>e.averageMinutes*.5&&a.push({type:"recommendation",severity:"warning",title:"High variability detected",description:`${s} shows high variability (std dev: ${e.stdDevMinutes} min). Consider maintaining a more consistent schedule.`,metric:s,value:e.stdDevMinutes,actionable:!0}),a}detectSuddenChanges(e,t="averageMinutes",r=50){let i=[];for(let s=1;s<e.length;s++){let a=e[s-1][t],c=e[s][t];if(a===0)continue;let u=(c-a)/a*100;Math.abs(u)>=r&&i.push({date:e[s].date,previousValue:a,currentValue:c,changePercent:Math.round(u*10)/10})}return i}};Ys.TrendDetectionService=Ig;Ys.TrendDetectionService=Ig=YR([(0,KR.injectable)()],Ig)});var KS=v(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.AutocompleteService=Ks.DEFAULT_AUTOCOMPLETE_CONFIG=void 0;var tf=Yr(),Ic=Qe(),YS=lt();Ks.DEFAULT_AUTOCOMPLETE_CONFIG={limit:10,activeBoost:20,recencyBoost:10,recencyDays:7};var Og=class{static{o(this,"AutocompleteService")}constructor(e,t){this.tripleStore=e,this.config={...Ks.DEFAULT_AUTOCOMPLETE_CONFIG,...t}}async getSuggestions(e,t,r){let i={...this.config,...r},s=await this.getPropertyRange(e);if(s.length===0){let u=this.inferClassFromProperty(e);u&&s.push(u)}let a=[];for(let u of s){let l=await this.getAssetsOfClass(u);a.push(...l)}return a.map(u=>({...u,matchScore:this.calculateMatchScore(u,t,i)})).filter(u=>u.matchScore>0).sort((u,l)=>l.matchScore-u.matchScore).slice(0,i.limit)}async getSuggestionsByClass(e,t,r){let i={...this.config,...r},s=[];for(let c of e){let u=await this.getAssetsOfClass(c);s.push(...u)}return s.map(c=>({...c,matchScore:this.calculateMatchScore(c,t,i)})).filter(c=>c.matchScore>0).sort((c,u)=>u.matchScore-c.matchScore).slice(0,i.limit)}async getPropertyRange(e){let t=this.toFullIri(e),r=[],i=await this.tripleStore.match(new Ic.IRI(t),tf.Namespace.RDFS.term("range"),void 0);for(let s of i)if(s.object instanceof Ic.IRI){let a=this.toClassName(s.object.value);a&&r.push(a)}return r}async getAssetsOfClass(e){let t=this.toFullIri(e),r=[],i=await this.tripleStore.match(void 0,tf.Namespace.RDF.term("type"),new Ic.IRI(t));for(let s of i)if(s.subject instanceof Ic.IRI){let a=await this.buildSuggestion(s.subject,e);a&&r.push(a)}return r}async buildSuggestion(e,t){let r=await this.tripleStore.match(e,tf.Namespace.EXO.term("Asset_label"),void 0),i="";for(let c of r)if(c.object instanceof YS.Literal){i=c.object.value;break}if(i||(i=this.extractLabelFromUri(e.value)),!i)return null;let s=await this.checkIfActive(e),a=this.extractPathFromUri(e.value);return{label:i,uri:e.value,path:a,assetClass:t,isActive:s,matchScore:0}}async checkIfActive(e){let t=await this.tripleStore.match(e,tf.Namespace.EMS.term("Effort_status"),void 0);for(let r of t){let i=r.object instanceof YS.Literal||r.object instanceof Ic.IRI?r.object.value:"";if(i.includes("Active")||i.includes("EffortStatus_Active"))return!0}return!1}calculateMatchScore(e,t,r){if(!t||t.length===0)return e.isActive?100+r.activeBoost:100;let i=e.label.toLowerCase(),s=t.toLowerCase(),a=0;if(i===s)a=100;else if(i.startsWith(s))a=80;else if(i.includes(s))a=60;else if(this.fuzzyMatch(s,i))a=40;else return 0;if(e.isActive&&(a+=r.activeBoost),e.lastModified){let c=(Date.now()-e.lastModified)/864e5;c<=r.recencyDays&&(a+=r.recencyBoost*(1-c/r.recencyDays))}return a}fuzzyMatch(e,t){let r=0;for(let i=0;i<t.length&&r<e.length;i++)t[i]===e[r]&&r++;return r===e.length}inferClassFromProperty(e){let t=e.toLowerCase();return t.includes("project")?"ems__Project":t.includes("area")?"ems__Area":t.includes("task")?"ems__Task":t.includes("effort")?"ems__Effort":null}toFullIri(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=e.match(/^([a-z]+)__(.+)$/);if(t){let[,r,i]=t;switch(r){case"ems":return`https://exocortex.my/ontology/ems#${i}`;case"exo":return`https://exocortex.my/ontology/exo#${i}`;default:return`https://exocortex.my/ontology/${r}#${i}`}}return e}toClassName(e){let t=e.match(/https:\/\/exocortex\.my\/ontology\/([a-z]+)#(.+)$/);if(t){let[,r,i]=t;return`${r}__${i}`}return null}extractLabelFromUri(e){if(e.startsWith("obsidian://")){let r=decodeURIComponent(e),i=r.lastIndexOf("/");if(i>=0){let s=r.substring(i+1);return s.endsWith(".md")&&(s=s.substring(0,s.length-3)),s}}let t=e.lastIndexOf("/");if(t>=0){let r=e.substring(t+1);return r.endsWith(".md")&&(r=r.substring(0,r.length-3)),r}return""}extractPathFromUri(e){if(e.startsWith("obsidian://vault/")){let t=decodeURIComponent(e.substring(17)),r=t.indexOf("/");return r>=0?t.substring(r+1):t}return e}};Ks.AutocompleteService=Og});var JS=v(kn=>{"use strict";var XR=kn&&kn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},JR=kn&&kn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},ZR=kn&&kn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(kn,"__esModule",{value:!0});kn.DailyReviewService=void 0;var XS=Le(),eF=ct(),Na=Ht(),tF=Xi(),rF=yr(),Pg=class{static{o(this,"DailyReviewService")}constructor(e){this.vault=e,this.frontmatterService=new tF.FrontmatterService}async getPractices(){let e=this.vault.getAllFiles(),t=[],r=Na.DateFormatter.toDateString(new Date);for(let i of e)if(i.path.endsWith(".md"))try{let s=await this.vault.read(i),a=this.frontmatterService.parse(s);if(!a.exists)continue;let c=this.frontmatterService.getPropertyValue(a.content,"exo__Instance_class");if(!this.isTaskPrototype(c))continue;let u=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_uid");if(!u)continue;let l=u.replace(/"/g,""),f=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_label");if(!f)continue;let h=f.replace(/"/g,""),p=this.frontmatterService.getPropertyValue(a.content,"ems__Recurring_rule")?.replace(/"/g,"")||null,S=this.frontmatterService.getPropertyValue(a.content,"ems__Task_estimatedDuration"),b=null;if(S){let I=parseInt(S,10);isNaN(I)||(b=I)}let T=await this.findTodayInstance(l,r);t.push({uid:l,label:h,path:i.path,recurringRule:p,estimatedDuration:b,doneToday:T?.status==="done",inProgressToday:T?.status==="doing",todayInstancePath:T?.path||null})}catch{continue}return t.sort((i,s)=>i.label.localeCompare(s.label))}async getDailyReviewSummary(e){let t=e||new Date,r=Na.DateFormatter.toDateString(t),i=new Date(t);i.setHours(0,0,0,0);let s=new Date(t);s.setHours(23,59,59,999);let a=this.vault.getAllFiles(),c=0,u=0,l=0,f=0;for(let S of a)if(S.path.endsWith(".md"))try{let b=await this.vault.read(S),T=this.frontmatterService.parse(b);if(!T.exists)continue;let I=this.frontmatterService.getPropertyValue(T.content,"exo__Instance_class");if(!this.isTask(I))continue;let O=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_plannedStartTimestamp"),L=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_startTimestamp"),M=L?new Date(L):null,G=O?new Date(O):null;if(!(G&&G>=i&&G<=s||M&&M>=i&&M<=s))continue;c++;let je=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_status");if(this.isDoneStatus(je)){u++;let Me=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_endTimestamp");if(L&&Me){let q=this.calculateDurationMinutes(L,Me);f+=q}}else this.isDoingStatus(je)&&l++}catch{continue}let d=(await this.getPractices()).filter(S=>!S.doneToday&&S.recurringRule),p=c>0?Math.round(u/c*100):0;return{date:r,plannedCount:c,completedCount:u,inProgressCount:l,practicesDue:d,completionPercentage:p,totalTimeMinutes:Math.round(f)}}async quickCapture(e,t=!0,r){let i=(0,rF.v4)(),s=Na.DateFormatter.toISOTimestamp(new Date),a=`${i}.md`,c="03 Knowledge/kitelev",u=["---",`exo__Asset_uid: "${i}"`,`exo__Asset_label: "${e}"`,'exo__Instance_class: "[[ems__Task]]"'];if(r?.prototypeUid){let h=this.buildPrototypeUri(r.prototypeUid);u.push(`exo__Asset_prototype: "${h}"`)}if(r?.areaUid){let h=this.buildAssetUri(r.areaUid);u.push(`ems__Effort_area: "${h}"`)}if(r?.parentUid){let h=this.buildAssetUri(r.parentUid);u.push(`ems__Effort_parent: "${h}"`)}t?(u.push('ems__Effort_status: "[[ems__EffortStatusDoing]]"'),u.push(`ems__Effort_startTimestamp: ${s}`)):u.push('ems__Effort_status: "[[ems__EffortStatusBacklog]]"'),u.push("---","","");let l=u.join(`
|
|
239
|
-
`),f=`${c}/${a}`;return await this.vault.create(f,l),{path:f,uid:i,label:e,started:t}}async createFromPractice(e){let r=(await this.getPractices()).find(a=>a.uid===e.prototypeUid);if(!r)throw new Error(`Practice not found: ${e.prototypeUid}`);if(r.doneToday)throw new Error(`Practice "${r.label}" already completed today`);if(r.inProgressToday&&r.todayInstancePath)return{path:r.todayInstancePath,uid:e.prototypeUid,label:r.label,started:!0};let i=Na.DateFormatter.toDateString(new Date),s=e.label||`${r.label} ${i}`;return this.quickCapture(s,e.startImmediately??!0,{prototypeUid:e.prototypeUid,areaUid:e.areaUid,parentUid:e.parentUid})}async markPracticeDone(e){let r=(await this.getPractices()).find(l=>l.uid===e);if(!r)throw new Error(`Practice not found: ${e}`);if(r.doneToday)return;if(!r.todayInstancePath)throw new Error(`No active instance for practice "${r.label}" today`);let i=this.vault.getAbstractFileByPath(r.todayInstancePath);if(!i||!("basename"in i))throw new Error(`File not found: ${r.todayInstancePath}`);let s=i,a=await this.vault.read(s),c=Na.DateFormatter.toISOTimestamp(new Date),u=this.frontmatterService.updateProperty(a,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');u=this.frontmatterService.updateProperty(u,"ems__Effort_endTimestamp",c),u=this.frontmatterService.updateProperty(u,"ems__Effort_resolutionTimestamp",c),await this.vault.modify(s,u)}async findTodayInstance(e,t){let r=this.vault.getAllFiles();for(let i of r)if(i.path.endsWith(".md"))try{let s=await this.vault.read(i),a=this.frontmatterService.parse(s);if(!a.exists)continue;let c=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_prototype");if(!c||!c.includes(e))continue;let u=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_label"),l=this.frontmatterService.getPropertyValue(a.content,"ems__Effort_startTimestamp"),f=u?.includes(t),h=l?new Date(l):null,d=h&&Na.DateFormatter.toDateString(h)===t;if(!f&&!d)continue;let p=this.frontmatterService.getPropertyValue(a.content,"ems__Effort_status");return this.isDoneStatus(p)?{path:i.path,status:"done"}:this.isDoingStatus(p)?{path:i.path,status:"doing"}:{path:i.path,status:"other"}}catch{continue}return null}isTaskPrototype(e){return e?e.includes("ems__TaskPrototype")||e.includes("TaskPrototype"):!1}isTask(e){return e?(e.includes("ems__Task")||e.includes("[[ems__Task]]"))&&!e.includes("Prototype"):!1}isDoneStatus(e){return e?e.includes("Done")||e.includes("EffortStatusDone"):!1}isDoingStatus(e){return e?e.includes("Doing")||e.includes("EffortStatusDoing"):!1}calculateDurationMinutes(e,t){let r=new Date(e);return(new Date(t).getTime()-r.getTime())/1e3/60}buildPrototypeUri(e){return`obsidian://vault/03%20Knowledge%2Fkitelev%2F${e}.md`}buildAssetUri(e){return`obsidian://vault/03%20Knowledge%2Fkitelev%2F${e}.md`}};kn.DailyReviewService=
|
|
240
|
-
`;return e.length===0?"":e.map(i=>i.toString()).join(r)+r}serializeChunk(e,t){return e.length===0?"":e.map(r=>r.toString()).join(t)+t}};sf.NTriplesSerializer=
|
|
241
|
-
`,i=this.composePrefixes(t),s=this.serializePrefixes(i,r),a=this.nTriplesSerializer.serialize(e,{newline:r}).trimEnd();return s?a?`${s}${r}${r}${a}${r}`:`${s}${r}`:a?`${a}${r}`:""}serializePrefixes(e,t){let r=Object.entries(e);return r.length===0?"":r.map(([i,s])=>`@prefix ${i}: <${s}> .`).join(t)}composePrefixes(e){return e.includeDefaultPrefixes??!0?{...
|
|
242
|
-
`,i+=1;break;case"r":r+="\r",i+=1;break;case"f":r+="\f",i+=1;break;case'"':r+='"',i+=1;break;case"\\":r+="\\",i+=1;break;case"u":{let c=e.slice(i+2,i+6);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw new Error(`Invalid \\u escape at line ${t}`);r+=String.fromCharCode(parseInt(c,16)),i+=5;break}case"U":{let c=e.slice(i+2,i+10);if(c.length!==8||!/^[0-9a-fA-F]{8}$/.test(c))throw new Error(`Invalid \\U escape at line ${t}`);r+=String.fromCodePoint(parseInt(c,16)),i+=9;break}default:throw new Error(`Unknown escape sequence \\${a} at line ${t}`)}continue}if(s==='"'){let a=e.slice(i+1);return{value:r,rest:a}}r+=s}throw new Error(`Unterminated string literal at line ${t}`)}findClosingBracket(e,t,r){let i=0;for(let s=0;s<e.length;s++){let a=e[s];if(a===t){i++;continue}if(a===r&&(i--,i===0))return s}return-1}};cf.NTriplesParser=
|
|
243
|
-
`,
|
|
244
|
-
`),t}};lf.RDFSerializer=Ug});var Wg=v(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.TransactionError=es.TripleNotFoundError=es.TripleAlreadyExistsError=void 0;var Bg=class extends Error{static{o(this,"TripleAlreadyExistsError")}constructor(e){super(`Triple already exists: ${e.toString()}`),this.name="TripleAlreadyExistsError"}};es.TripleAlreadyExistsError=Bg;var qg=class extends Error{static{o(this,"TripleNotFoundError")}constructor(e){super(`Triple not found: ${e.toString()}`),this.name="TripleNotFoundError"}};es.TripleNotFoundError=qg;var Gg=class extends Error{static{o(this,"TransactionError")}constructor(e){super(e),this.name="TransactionError"}};es.TransactionError=Gg});var hf=v(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.LRUCache=void 0;var Hg=class{static{o(this,"LRUCache")}constructor(e){this.maxSize=e,this.cache=new Map}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};ff.LRUCache=Hg});var c_=v(pf=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});pf.InMemoryTripleStore=void 0;var ts=Wg(),df=Qe(),bF=Ot(),wF=lt(),EF=Yr(),TF=hf(),AF=EF.Namespace.XSD.term("string").value,xF=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,Va="__default__",zg=class n{static{o(this,"InMemoryTripleStore")}constructor(){this.triples=new Map,this.spo=new Map,this.sop=new Map,this.pso=new Map,this.pos=new Map,this.osp=new Map,this.ops=new Map,this.queryCache=new TF.LRUCache(1e3),this.uuidIndex=new Map,this.namedGraphs=new Map}async add(e){let t=this.getTripleKey(e);if(this.triples.has(t))return;this.triples.set(t,e);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);this.addToIndex(this.spo,r,i,s),this.addToIndex(this.sop,r,s,i),this.addToIndex(this.pso,i,r,s),this.addToIndex(this.pos,i,s,r),this.addToIndex(this.osp,s,r,i),this.addToIndex(this.ops,s,i,r),this.addToUUIDIndex(e.subject),this.queryCache.clear()}async remove(e){let t=this.getTripleKey(e);if(!this.triples.has(t))return!1;this.triples.delete(t);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);return this.removeFromIndex(this.spo,r,i,s),this.removeFromIndex(this.sop,r,s,i),this.removeFromIndex(this.pso,i,r,s),this.removeFromIndex(this.pos,i,s,r),this.removeFromIndex(this.osp,s,r,i),this.removeFromIndex(this.ops,s,i,r),this.queryCache.clear(),!0}async has(e){let t=this.getTripleKey(e);return this.triples.has(t)}async match(e,t,r){let i=this.getMatchCacheKey(e,t,r),s=this.queryCache.get(i);if(s!==void 0)return s;let a;return!e&&!t&&!r?a=Array.from(this.triples.values()):e&&t&&r?a=this.matchSPO(e,t,r):e&&t?a=this.matchSP(e,t):e&&r?a=this.matchSO(e,r):t&&r?a=this.matchPO(t,r):e?a=this.matchS(e):t?a=this.matchP(t):r?a=this.matchO(r):a=[],this.queryCache.set(i,a),a}async addAll(e){for(let t of e)await this.add(t)}async removeAll(e){let t=0;for(let r of e)await this.remove(r)&&t++;return t}async clear(){this.triples.clear(),this.spo.clear(),this.sop.clear(),this.pso.clear(),this.pos.clear(),this.osp.clear(),this.ops.clear(),this.uuidIndex.clear(),this.queryCache.clear()}async count(){return this.triples.size}async subjects(){let e=new Set;for(let t of this.triples.values())e.add(t.subject);return Array.from(e)}async predicates(){let e=new Set;for(let t of this.triples.values())e.add(t.predicate);return Array.from(e)}async objects(){let e=new Set;for(let t of this.triples.values())e.add(t.object);return Array.from(e)}async beginTransaction(){return new Qg(this)}async findSubjectsByUUID(e){return this.findSubjectsByUUIDSync(e)}findSubjectsByUUIDSync(e){let t=e.toLowerCase(),r=this.uuidIndex.get(t);if(!r||r.size===0)return[];let i=[];for(let s of r)this.spo.has(`i:${s}`)&&i.push(new df.IRI(s));return i}addToUUIDIndex(e){if(!(e instanceof df.IRI))return;let t=e.value,r=t.match(xF);if(r)for(let i of r){let s=i.toLowerCase();this.uuidIndex.has(s)||this.uuidIndex.set(s,new Set),this.uuidIndex.get(s).add(t)}}matchSPO(e,t,r){let i=this.getNodeKey(e),s=this.getNodeKey(t),a=this.getNodeKey(r),c=this.spo.get(i);if(!c)return[];let u=c.get(s);if(!u)return[];if(u.has(a)){let l=this.buildTripleKey(i,s,a),f=this.triples.get(l);return f?[f]:[]}return[]}matchSP(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.spo.get(r);if(!s)return[];let a=s.get(i);return a?this.getTriplesByKeys(Array.from(a).map(c=>this.buildTripleKey(r,i,c))):[]}matchSO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.sop.get(r);if(!s)return[];let a=s.get(i);return a?this.getTriplesByKeys(Array.from(a).map(c=>this.buildTripleKey(r,c,i))):[]}matchPO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.pos.get(r);if(!s)return[];let a=s.get(i);return a?this.getTriplesByKeys(Array.from(a).map(c=>this.buildTripleKey(c,r,i))):[]}matchS(e){let t=this.getNodeKey(e),r=this.spo.get(t);if(!r)return[];let i=[];for(let[s,a]of r.entries())for(let c of a)i.push(this.buildTripleKey(t,s,c));return this.getTriplesByKeys(i)}matchP(e){let t=this.getNodeKey(e),r=this.pso.get(t);if(!r)return[];let i=[];for(let[s,a]of r.entries())for(let c of a)i.push(this.buildTripleKey(s,t,c));return this.getTriplesByKeys(i)}matchO(e){let t=this.getNodeKey(e),r=this.osp.get(t);if(!r)return[];let i=[];for(let[s,a]of r.entries())for(let c of a)i.push(this.buildTripleKey(s,c,t));return this.getTriplesByKeys(i)}getTriplesByKeys(e){let t=[];for(let r of e){let i=this.triples.get(r);i&&t.push(i)}return t}addToIndex(e,t,r,i){e.has(t)||e.set(t,new Map);let s=e.get(t);s.has(r)||s.set(r,new Set),s.get(r).add(i)}removeFromIndex(e,t,r,i){let s=e.get(t);if(!s)return;let a=s.get(r);a&&(a.delete(i),a.size===0&&s.delete(r),s.size===0&&e.delete(t))}getTripleKey(e){let t=this.getNodeKey(e.subject),r=this.getNodeKey(e.predicate),i=this.getNodeKey(e.object);return this.buildTripleKey(t,r,i)}buildTripleKey(e,t,r){return`${e}|${t}|${r}`}getNodeKey(e){if(e instanceof df.IRI)return`i:${e.value}`;if(e instanceof bF.BlankNode)return`b:${e.id}`;if(e instanceof wF.Literal){let t=`l:${e.value}`;return e.datatype&&e.datatype.value!==AF?t+=`^^${e.datatype.value}`:e.language&&(t+=`@${e.language}`),t}return""}getMatchCacheKey(e,t,r){let i=e?this.getNodeKey(e):"?",s=t?this.getNodeKey(t):"?",a=r?this.getNodeKey(r):"?";return`${i}|${s}|${a}`}getGraphKey(e){return e?e.value:Va}getOrCreateGraphStore(e){let t=this.getGraphKey(e);return t===Va?this:(this.namedGraphs.has(t)||this.namedGraphs.set(t,new n),this.namedGraphs.get(t))}async addToGraph(e,t){await this.getOrCreateGraphStore(t).add(e)}async removeFromGraph(e,t){let r=this.getGraphKey(t);if(r===Va)return this.remove(e);let i=this.namedGraphs.get(r);return i?i.remove(e):!1}async matchInGraph(e,t,r,i){let s=this.getGraphKey(i);if(s===Va)return this.match(e,t,r);let a=this.namedGraphs.get(s);return a?a.match(e,t,r):[]}async getNamedGraphs(){return Array.from(this.namedGraphs.keys()).map(e=>new df.IRI(e))}async hasGraph(e){let t=this.namedGraphs.get(e.value);return t?await t.count()>0:!1}async clearGraph(e){let t=this.getGraphKey(e);if(t===Va){await this.clear();return}let r=this.namedGraphs.get(t);r&&(await r.clear(),this.namedGraphs.delete(t))}async countInGraph(e){let t=this.getGraphKey(e);if(t===Va)return this.count();let r=this.namedGraphs.get(t);return r?r.count():0}};pf.InMemoryTripleStore=zg;var Qg=class{static{o(this,"InMemoryTransaction")}constructor(e){this.store=e,this.operations=[],this.committed=!1,this.rolledBack=!1}async add(e){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");this.operations.push({type:"add",triple:e})}async remove(e){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");return this.operations.push({type:"remove",triple:e}),!0}async commit(){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");for(let e of this.operations)e.type==="add"?await this.store.add(e.triple):await this.store.remove(e.triple);this.committed=!0,this.operations=[]}async rollback(){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");this.operations=[],this.rolledBack=!0}}});var Kg=v(mf=>{"use strict";Object.defineProperty(mf,"__esModule",{value:!0});mf.RDFVocabularyMapper=void 0;var Br=xi(),u_=Qe(),ye=Yr(),Yg=class{static{o(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",ye.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",ye.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",ye.Namespace.RDFS.term("subClassOf")],["exo__Property_range",ye.Namespace.RDFS.term("range")],["exo__Property_domain",ye.Namespace.RDFS.term("domain")],["exo__Property_superProperty",ye.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Br.Triple(ye.Namespace.EXO.term("Asset"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.RDFS.term("Resource"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Class"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.RDFS.term("Class"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.RDF.term("Property"))),e.push(new Br.Triple(ye.Namespace.EMS.term("Task"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.EXO.term("Asset"))),e.push(new Br.Triple(ye.Namespace.EMS.term("Project"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.EXO.term("Asset"))),e.push(new Br.Triple(ye.Namespace.EMS.term("Area"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Br.Triple(ye.Namespace.EXO.term("Instance_class"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDF.term("type"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Asset_isDefinedBy"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("isDefinedBy"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Class_superClass"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("subClassOf"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property_range"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("range"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property_domain"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("domain"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property_superProperty"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof u_.IRI)s=r;else{let a=r.match(/^(ems|exo)__(.+)$/);if(a){let[,c,u]=a;s=(c==="ems"?ye.Namespace.EMS:ye.Namespace.EXO).term(u)}else s=new u_.IRI(r)}return new Br.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};mf.RDFVocabularyMapper=Yg});var Jg=v(Mn=>{"use strict";var CF=Mn&&Mn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},IF=Mn&&Mn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},OF=Mn&&Mn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NoteToRDFConverter=void 0;var l_=Le(),Nr=xi(),Oc=Qe(),an=lt(),f_=Ot(),Sr=Yr(),PF=ct(),DF=Kg(),Lr=Np(),Xg=class{static{o(this,"NoteToRDFConverter")}constructor(e){this.vault=e,this.OBSIDIAN_VAULT_SCHEME="obsidian://vault/",this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.uuidIndex=null,this.vocabularyMapper=new DF.RDFVocabularyMapper}setUuidIndex(e){this.uuidIndex=e}clearUuidIndex(){this.uuidIndex=null}async convertNote(e){let t=this.vault.getFrontmatter(e);return t?Lr.Exo003Parser.isExo003Format(t)?this.convertExo003Note(e,t):this.convertLegacyNote(e,t):[]}async convertLegacyNote(e,t){let r=[],i=this.notePathToIRI(e.path),s=Sr.Namespace.EXO.term("Asset_fileName");r.push(new Nr.Triple(i,s,new an.Literal(e.basename)));for(let[c,u]of Object.entries(t)){if(!this.isExocortexProperty(c))continue;let l=this.propertyKeyToIRI(c),f=Array.isArray(u)?u:[u];for(let h of f)if(c==="exo__Instance_class"){let d=this.valueToClassURI(h);r.push(new Nr.Triple(i,l,d))}else{let d=await this.valueToRDFObject(h,e);if(r.push(new Nr.Triple(i,l,d)),this.vocabularyMapper.hasMappingFor(c)&&d instanceof Oc.IRI){let p=this.vocabularyMapper.generateMappedTriple(i,c,d);p&&r.push(p)}}if(c==="exo__Instance_class")for(let h of f){let d=this.expandClassValue(h);if(d){let p=Sr.Namespace.RDF.term("type");r.push(new Nr.Triple(i,p,d))}}}let a=await this.convertBodyWikilinks(e,i);return r.push(...a),r}async convertExo003Note(e,t){let r=Lr.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Lr.Exo003MetadataType.Namespace:break;case Lr.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Lr.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Lr.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Lr.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new Oc.IRI(t.uri);return[new Nr.Triple(r,Sr.Namespace.OWL.term("sameAs"),i),new Nr.Triple(i,Sr.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new Nr.Triple(r,Sr.Namespace.OWL.term("sameAs"),new f_.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Lr.Exo003Parser.toTriple(t,i);r.push(s);let a=this.notePathToIRI(e.path);r.push(new Nr.Triple(a,Sr.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.createExo003ReferenceResolver(e),c=a(t.subject),u=a(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(u.type!=="iri")throw new Error("Body predicate must be an IRI");let l=c.type==="iri"?new Oc.IRI(c.value):new f_.BlankNode(c.value),f=new Oc.IRI(u.value),h=Lr.Exo003Parser.toLiteral(t,s.trim());r.push(new Nr.Triple(l,f,h));let d=this.notePathToIRI(e.path);r.push(new Nr.Triple(d,Sr.Namespace.RDF.term("value"),l))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t;if(this.uuidIndex){let a=this.uuidIndex.get(i);if(a)return{type:a.type,value:a.uri}}if(!r&&t.includes("://"))return{type:"iri",value:t};let s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let a=this.vault.getFrontmatter(s);if(a&&Lr.Exo003Parser.isExo003Format(a)){let c=Lr.Exo003Parser.parse(a);if(c.success&&c.metadata){let u=c.metadata;if(u.metadata===Lr.Exo003MetadataType.Anchor||u.metadata===Lr.Exo003MetadataType.Namespace)return{type:"iri",value:u.uri};if(u.metadata===Lr.Exo003MetadataType.BlankNode)return{type:"blank",value:u.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return{type:"literal",value:t}}}async convertVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e)try{let i=await this.convertNote(r);t.push(...i)}catch(i){console.warn(`\u26A0\uFE0F Skipping file with invalid IRI: ${r.path}`),console.warn(` Reason: ${i instanceof Error?i.message:String(i)}`);continue}return t}notePathToIRI(e){let t=encodeURI(e);return new Oc.IRI(`${this.OBSIDIAN_VAULT_SCHEME}${t}`)}isExocortexProperty(e){return e.startsWith("exo__")||e.startsWith("ems__")}propertyKeyToIRI(e){if(e.startsWith("exo__")){let t=e.substring(5);return Sr.Namespace.EXO.term(t)}if(e.startsWith("ems__")){let t=e.substring(5);return Sr.Namespace.EMS.term(t)}throw new Error(`Invalid property key: ${e}`)}async valueToRDFObject(e,t){if(typeof e=="string"){let r=this.removeQuotes(e),i=this.extractWikilink(r);if(i){let s=this.vault.getFirstLinkpathDest(i,t.path);if(s)return this.notePathToIRI(s.path);if(this.isClassReference(i)){let a=this.expandClassValue(i);if(a)return a}return new an.Literal(r)}if(this.isClassReference(r)){let s=this.expandClassValue(r);if(s)return s}return this.isISO8601DateTime(r)?new an.Literal(r,Sr.Namespace.XSD.term("dateTime")):new an.Literal(r)}return typeof e=="boolean"?new an.Literal(e.toString()):typeof e=="number"?new an.Literal(e.toString(),Sr.Namespace.XSD.term("decimal")):e instanceof Date?new an.Literal(e.toISOString(),Sr.Namespace.XSD.term("dateTime")):new an.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(/^\[\[([^\]|]+)(?:\|[^\]]+)?\]\]$/);return t?t[1]:null}valueToClassURI(e){if(typeof e!="string")return new an.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);return s||new an.Literal(t)}isClassReference(e){return(e.startsWith("ems__")||e.startsWith("exo__"))&&!/\s/.test(e)}expandClassValue(e){let t=this.removeQuotes(e);if(t.startsWith("ems__")){let r=t.substring(5);return Sr.Namespace.EMS.term(r)}if(t.startsWith("exo__")){let r=t.substring(5);return Sr.Namespace.EXO.term(r)}return null}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.extractBodyWikilinks(s),c=Sr.Namespace.EXO.term("Asset_bodyLink");for(let u of a){let l=this.vault.getFirstLinkpathDest(u,e.path);if(l){let f=this.notePathToIRI(l.path);r.push(new Nr.Triple(t,c,f))}else if(this.isClassReference(u)){let f=this.expandClassValue(u);f?r.push(new Nr.Triple(t,c,f)):r.push(new Nr.Triple(t,c,new an.Literal(u)))}else r.push(new Nr.Triple(t,c,new an.Literal(u)))}}catch{}return r}};Mn.NoteToRDFConverter=Xg;Mn.NoteToRDFConverter=Xg=CF([(0,l_.injectable)(),OF(0,(0,l_.inject)(PF.DI_TOKENS.IVaultAdapter)),IF("design:paramtypes",[Object])],Xg)});var Zg=v((cq,h_)=>{var Ua=class{static{o(this,"Wildcard")}constructor(){return RF||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(Ua.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(Ua.prototype,"termType",{enumerable:!0,value:"Wildcard"});var RF=new Ua;h_.exports.Wildcard=Ua});var p_=v((lq,d_)=>{var FF=(function(){var n=o(function(x,A,P,F){for(P=P||{},F=x.length;F--;P[x[F]]=A);return P},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],r=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],a=[1,27],c=[13,16,45,197,224,229,308],u=[28,29,53],l=[28,53],f=[1,42],h=[1,45],d=[1,41],p=[1,44],S=[123,126],b=[1,67],T=[39,45,87],I=[13,16,45,197,224,308],O=[1,87],L=[2,281],M=[1,86],G=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Ee=[6,28,29,53,63,70,73,81,83,85],je=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],Me=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],q=[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],ie=[13,16,308],Se=[112,132,327,334],nt=[13,16,112,132,308],Ke=[1,111],at=[1,117],Ue=[112,132,327,328,334],Be=[13,16,112,132,308,328],ke=[28,29,45,53,87],Q=[1,138],k=[1,151],qe=[1,128],Xe=[1,127],V=[1,129],me=[1,140],Ie=[1,141],z=[1,142],Oe=[1,143],Pe=[1,144],Te=[1,145],De=[1,147],he=[1,148],Ae=[2,457],ge=[1,158],xe=[1,159],Re=[1,160],Z=[1,152],se=[1,153],ae=[1,156],ee=[1,171],te=[1,172],re=[1,173],ne=[1,174],oe=[1,175],ce=[1,176],ue=[1,167],le=[1,168],X=[1,169],fe=[1,170],$e=[1,157],Fe=[1,166],be=[1,161],w=[1,162],E=[1,163],_=[1,164],C=[1,165],W=[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],it=[1,195],ut=[6,31,73,81,83,85],we=[2,285],j=[1,199],$=[1,201],U=[6,31,70,73,81,83,85],H=[2,283],ve=[1,207],Ge=[1,218],We=[1,223],Ut=[1,219],Or=[1,225],$r=[1,226],hr=[1,224],D1=[6,63,70,73,81,83,85],R1=[1,236],F1=[2,334],N1=[1,243],L1=[1,241],Bt=[6,193],xu=[2,349],k1=[2,339],Bi=[28,128],M1=[47,48,193,272],Cu=[47,48,193,242,272],Sa=[47,48,193,242,246,272],_a=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Nt=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],j1=[1,271],$1=[1,270],Et=[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],V1=[1,281],U1=[1,280],dr=[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],zo=[45,89],Iu=[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],Ou=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Pu=[31,89],Du=[48,87],ws=[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],Qn=[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],B1=[1,313],ba=[6,85],fd=[6,31,81,83,85],q1=[2,361],yi=[2,353],Es=[1,343],Qo=[31,112,335],vi=[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],hd=[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],G1=[6,109,193],Ts=[31,112],Tt=[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],dd=[1,390],pd=[1,391],qi=[13,16,87,197,308,314],W1=[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],Ru=[1,417],Fu=[1,418],H1=[13,16,48,197,229,308],Gi=[6,31,85],z1=[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],md=[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],As=[29,31,85,112,159,160,161,163,164],Nu=[1,443],Lu=[1,444],Q1=[1,449],xs=[31,112,193,232,318,335],ku=[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],Y1=[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],gd=[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],Yo=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Ko=[31,45],K1=[1,507],X1=[1,508],J1=[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],Mu=[29,31,85,112,159,160,161,163,164,335],Cs=[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],Z1=[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],e2=[2,352],yd=[13,16,197,308,314],t2=[1,565],wa=[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],r2=[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],Si=[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],n2=[13,16,87,308],_i=[2,364],Ea=[29,31,85,112,159,160,161,163,164,193,232,318,335],ju=[31,112,193,232,272,318,335],bi=[2,359],i2=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],$u=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],s2=[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],a2=[2,347],vd={trace:o(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:o(function(A,P,F,Y,_e,m,mr){var g=m.length-1;switch(_e){case 1:if(m[g-1]=m[g-1]||{},Ce.base&&(m[g-1].base=Ce.base),Ce.base="",m[g-1].prefixes=Ce.prefixes,Ce.prefixes=null,Ce.pathOnly){if(m[g-1].type==="path"||"termType"in m[g-1])return m[g-1];throw new Error("Received full SPARQL query in path only mode")}else if(m[g-1].type==="path"||"termType"in m[g-1])throw new Error("Received only path in full SPARQL mode");if(m[g-1].type==="update"){let st={};for(let dt of m[g-1].updates)if(dt.updateType==="insert"){let He={};for(let Ze of dt.insert)if(Ze.type==="bgp"||Ze.type==="graph")for(let Pr of Ze.triples)Pr.subject.termType==="BlankNode"&&(He[Pr.subject.value]=!0),Pr.predicate.termType==="BlankNode"&&(He[Pr.predicate.value]=!0),Pr.object.termType==="BlankNode"&&(He[Pr.object.value]=!0);for(let Ze of Object.keys(He)){if(st[Ze])throw new Error("Detected reuse blank node across different INSERT DATA clauses");st[Ze]=!0}}}return m[g-1];case 2:this.$={...m[g-1],...m[g],type:"query"};break;case 4:Ce.base=Xo(m[g]);break;case 5:Ce.prefixes||(Ce.prefixes={}),m[g-1]=m[g-1].substr(0,m[g-1].length-1),m[g]=Xo(m[g]),Ce.prefixes[m[g-1]]=m[g];break;case 6:this.$={...m[g-3],...Ps(m[g-2]),...m[g-1],...m[g]};break;case 7:if(!Ce.skipValidation&&(xd(m[g-3].variables.map(dt=>Ad(dt.expression))).some(dt=>dt.aggregation==="count"&&!(dt.expression instanceof Vu))||m[g].group)){for(let dt of m[g-3].variables)if(dt.termType==="Variable"){if(!m[g].group||!m[g].group.map(He=>Ca(He)).includes(Ca(dt)))throw Error("Projection of ungrouped variable (?"+Ca(dt)+")")}else if(Ad(dt.expression).length===0){let He=_A(dt.expression);for(let Ze of He)if(!m[g].group||!m[g].group.map||!m[g].group.map(Pr=>Ca(Pr)).includes(Ca(Ze)))throw Error("Use of ungrouped variable in projection of operation (?"+Ca(Ze)+")")}}let Jn=m[g-1].where.filter(st=>st.type==="query");if(Jn.length>0){let st=m[g-3].variables.filter(He=>He.variable&&He.variable.value).map(He=>He.variable.value),dt=xd(Jn.map(He=>He.variables)).map(He=>He.value||He.variable.value);for(let He of st)if(dt.indexOf(He)>=0)throw Error("Target id of 'AS' (?"+He+") already used in subquery")}this.$=yt(m[g-3],Ps(m[g-2]),m[g-1],m[g]);break;case 8:this.$=yt({queryType:"CONSTRUCT",template:m[g-3]},Ps(m[g-2]),m[g-1],m[g]);break;case 9:this.$=yt({queryType:"CONSTRUCT",template:m[g-2]=m[g-2]?m[g-2].triples:[]},Ps(m[g-5]),{where:[{type:"bgp",triples:Os([],m[g-2])}]},m[g]);break;case 10:this.$=yt({queryType:"DESCRIBE",variables:m[g-3]==="*"?[new Vu]:m[g-3]},Ps(m[g-2]),m[g-1],m[g]);break;case 11:this.$=yt({queryType:"ASK"},Ps(m[g-2]),m[g-1],m[g]);break;case 12:this.$=yt(m[g-1],{variables:[new Vu]});break;case 13:let rc=m[g].map(st=>st.value||st.variable.value),Ia=bA(rc);if(Ia.length>0)throw Error("Two or more of the resulting columns have the same name (?"+Ia[0]+")");this.$=yt(m[g-1],{variables:m[g]});break;case 14:this.$=yt({queryType:"SELECT"},m[g]&&(m[g-1]=pr(m[g]),m[g]={},m[g][m[g-1]]=!0,m[g]));break;case 16:case 27:this.$=Ta(m[g-3],{variable:m[g-1]});break;case 17:case 18:this.$=yt(m[g-3],m[g-2],m[g-1],m[g],{type:"query"});break;case 19:case 58:this.$={iri:m[g],named:!!m[g-1]};break;case 20:this.$={where:m[g].patterns};break;case 21:this.$=yt(m[g-1],m[g]);break;case 22:this.$=yt(m[g-2],m[g-1],m[g]);break;case 23:this.$={group:m[g]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Ta(m[g]);break;case 26:this.$=Ta(m[g-1]);break;case 29:this.$={having:m[g]};break;case 30:this.$={order:m[g]};break;case 32:this.$=Ta(m[g],{descending:!0});break;case 35:this.$={limit:xa(m[g])};break;case 36:this.$={offset:xa(m[g])};break;case 37:this.$={limit:xa(m[g-2]),offset:xa(m[g])};break;case 38:this.$={limit:xa(m[g]),offset:xa(m[g-2])};break;case 39:case 43:this.$={type:"values",values:m[g]};break;case 40:case 84:this.$=m[g-1].map(st=>({[m[g-3]]:st}));break;case 41:case 85:this.$=m[g-1].map(()=>({}));break;case 42:case 86:var Xn=m[g-4].length;m[g-4]=m[g-4].map(Sd),this.$=m[g-1].map(function(st){if(st.length!==Xn)throw Error("Inconsistent VALUES length");for(var dt={},He=0;He<Xn;He++)dt["?"+m[g-4][He].value]=st[He];return dt});break;case 44:case 65:case 100:case 126:case 175:this.$=m[g-1];break;case 45:this.$={type:"update",updates:wi(m[g-2],m[g-1])};break;case 46:this.$=yt({type:"load",silent:!!m[g-2],source:m[g-1]},m[g]&&{destination:m[g]});break;case 47:this.$={type:pr(m[g-2]),silent:!!m[g-1],graph:m[g]};break;case 48:this.$={type:pr(m[g-4]),silent:!!m[g-3],source:m[g-2],destination:m[g]};break;case 49:this.$={type:"create",silent:!!m[g-2],graph:{type:"graph",name:m[g]}};break;case 50:this.$={updateType:"insert",insert:y2(m[g])};break;case 51:this.$={updateType:"delete",delete:Od(y2(m[g]))};break;case 52:this.$={updateType:"deletewhere",delete:Od(m[g])};break;case 53:this.$={updateType:"insertdelete",...m[g-4],...m[g-3],...Ps(m[g-2],"using"),where:m[g].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=m[g];break;case 55:this.$={delete:Od(m[g-1]),insert:m[g]||[]};break;case 56:this.$={delete:[],insert:m[g]};break;case 59:this.$={graph:m[g]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:m[g]};break;case 64:this.$={[pr(m[g])]:!0};break;case 66:this.$=m[g-1]?Yn(m[g],[m[g-1]]):Yn(m[g]);break;case 67:var ec=yt(m[g-3]||{triples:[]},{type:"graph",name:m[g-5]});this.$=m[g]?[ec,m[g]]:[ec];break;case 68:case 73:this.$={type:"bgp",triples:Yn(m[g-2],[m[g-1]])};break;case 69:this.$={type:"group",patterns:[m[g-1]]};break;case 70:for(let st of m[g-1].filter(dt=>dt.type==="bind")){let dt=m[g-1].indexOf(st),He=new Set;for(let Ze of m[g-1].slice(0,dt))(Ze.type==="group"||Ze.type==="bgp")&&m2(Ze).forEach(Pr=>He.add(Pr));if(He.has(st.variable.value))throw Error("Variable used to bind is already bound (?"+st.variable.value+")")}this.$={type:"group",patterns:m[g-1]};break;case 71:this.$=m[g-1]?Yn([m[g-1]],m[g]):Yn(m[g]);break;case 72:this.$=m[g]?[m[g-2],m[g]]:m[g-2];break;case 75:this.$=yt(m[g],{type:"optional"});break;case 76:this.$=yt(m[g],{type:"minus"});break;case 77:this.$=yt(m[g],{type:"graph",name:m[g-1]});break;case 78:this.$=yt(m[g],{type:"service",name:m[g-1],silent:!!m[g-2]});break;case 79:this.$={type:"filter",expression:m[g]};break;case 80:this.$={type:"bind",variable:m[g-1],expression:m[g-3]};break;case 89:this.$=Zo(m[g]);break;case 90:this.$=void 0;break;case 91:this.$=m[g-1].length?{type:"union",patterns:Yn(m[g-1].map(bd),[bd(m[g])])}:m[g];break;case 95:this.$={...m[g],function:m[g-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:wi(m[g-2],m[g-1]),distinct:!!m[g-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.$=wi(m[g-2],m[g-1]);break;case 101:this.$=Yn(m[g-2],[m[g-1]]);break;case 102:case 112:this.$=Id(m[g].map(st=>yt(Ei(m[g-1]),st)));break;case 103:this.$=Id(Os(m[g].map(st=>yt(Ei(m[g-1].entity),st)),m[g-1].triples));break;case 105:this.$=Yn([m[g-1]],m[g]);break;case 106:this.$=Yn(m[g]);break;case 107:this.$=Td(m[g-1],m[g]);break;case 109:case 237:this.$=Ce.factory.namedNode(lA);break;case 110:case 118:this.$=wi(m[g-1],m[g]);break;case 111:this.$=m[g]?{annotation:m[g],object:m[g-1]}:m[g-1];break;case 113:this.$=m[g]?Id(Os(m[g].map(st=>yt(Ei(m[g-1].entity),st)),m[g-1].triples)):m[g-1].triples;break;case 114:this.$=Td(...m[g-1],m[g]);break;case 116:this.$=Td(...m[g]);break;case 117:case 159:case 163:this.$=[m[g-1],m[g]];break;case 119:this.$=m[g]?{object:m[g-1],annotation:m[g]}:m[g-1];break;case 120:this.$=m[g-1].length?Aa("|",wi(m[g-1],m[g])):m[g];break;case 121:this.$=m[g-1].length?Aa("/",wi(m[g-1],m[g])):m[g];break;case 122:this.$=m[g]?Aa(m[g],[m[g-1]]):m[g-1];break;case 123:this.$=m[g-1]?Aa(m[g-1],[m[g]]):m[g];break;case 125:case 131:this.$=Aa(m[g-1],[m[g]]);break;case 129:this.$=Aa("|",wi(m[g-2],m[g-1]));break;case 132:case 134:this.$=vA(m[g-1]);break;case 133:case 135:this.$=SA(m[g-1]);break;case 140:this.$={entity:m[g],triples:[]};break;case 145:this.$=Sd(m[g]);break;case 149:this.$=Ce.factory.namedNode(o2);break;case 151:case 153:case 158:case 162:this.$=_d(m[g-1],m[g]);break;case 152:this.$=["||",m[g]];break;case 154:this.$=["&&",m[g]];break;case 156:this.$=qt(m[g-1],[m[g-2],m[g]]);break;case 157:this.$=qt(m[g-2]?"notin":"in",[m[g-3],m[g]]);break;case 160:this.$=["+",_d(m[g-1],m[g])];break;case 161:var qu=Kn(m[g-1].value.replace("-",""),m[g-1].datatype);this.$=["-",_d(qu,m[g])];break;case 164:this.$=qt("UPLUS",[m[g]]);break;case 165:this.$=qt(m[g-1],[m[g]]);break;case 166:this.$=qt("UMINUS",[m[g]]);break;case 177:this.$=qt(pr(m[g-1]));break;case 178:this.$=qt(pr(m[g-3]),[m[g-1]]);break;case 179:this.$=Zo(qt(pr(m[g-3]),[m[g-1]]));break;case 180:this.$=qt(pr(m[g-5]),[m[g-3],m[g-1]]);break;case 181:this.$=qt(pr(m[g-7]),[m[g-5],m[g-3],m[g-1]]);break;case 182:this.$=Zo(qt(pr(m[g-7]),[m[g-5],m[g-3],m[g-1]]));break;case 183:this.$=qt(pr(m[g-1]),m[g]);break;case 184:this.$=qt("bound",[Sd(m[g-1])]);break;case 185:this.$=qt(m[g-1],[]);break;case 186:this.$=qt(m[g-3],[m[g-1]]);break;case 187:this.$=qt(m[g-2]?"notexists":"exists",[bd(m[g])]);break;case 188:case 189:this.$=Ta(m[g-1],{type:"aggregate",aggregation:pr(m[g-4]),distinct:!!m[g-2]});break;case 190:this.$=Ta(m[g-2],{type:"aggregate",aggregation:pr(m[g-5]),distinct:!!m[g-3],separator:typeof m[g-1]=="string"?m[g-1]:" "});break;case 192:this.$=Kn(m[g]);break;case 193:this.$=pA(m[g-1],pr(m[g].substr(1)));break;case 194:this.$=Kn(m[g-2],m[g]);break;case 195:case 204:this.$=Kn(m[g],c2);break;case 196:case 205:this.$=Kn(m[g],u2);break;case 197:case 206:this.$=Kn(pr(m[g]),l2);break;case 200:this.$=Kn(m[g].toLowerCase(),dA);break;case 201:this.$=Kn(m[g].substr(1),c2);break;case 202:this.$=Kn(m[g].substr(1),u2);break;case 203:this.$=Kn(m[g].substr(1).toLowerCase(),l2);break;case 207:case 208:this.$=p2(m[g],1);break;case 209:case 210:this.$=p2(m[g],3);break;case 211:this.$=Ce.factory.namedNode(Xo(m[g]));break;case 213:var Gu=m[g].indexOf(":"),tc=m[g].substr(0,Gu),Wu=Ce.prefixes[tc];if(!Wu)throw new Error("Unknown prefix: "+tc);var mt=Xo(Wu+m[g].substr(Gu+1));this.$=Ce.factory.namedNode(mt);break;case 214:if(m[g]=m[g].substr(0,m[g].length-1),!(m[g]in Ce.prefixes))throw new Error("Unknown prefix: "+m[g]);var mt=Xo(Ce.prefixes[m[g]]);this.$=Ce.factory.namedNode(mt);break;case 215:this.$=Jo(m[g].replace(/^(_:)/,""));break;case 216:this.$=Jo();break;case 217:case 218:case 232:this.$=Zo(wd(m[g-3],m[g-2],m[g-1]));break;case 230:case 231:this.$=Zo(m[g-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:m[g-1].push(m[g]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[m[g]];break;case 308:m[g-3].push(m[g-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:m[g-2].push(m[g-1]);break}},"anonymous"),table:[n(e,t,{3:1,4:2,10:3}),{1:[3]},n(r,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),n([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:a},{6:[2,239]},n(c,[2,411],{216:28,217:29}),n(u,[2,249],{18:30}),n(u,[2,251],{22:31}),n(l,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:h,33:35,39:[1,37],44:39,55:40,87:d,139:38,307:43,308:p,323:36},n(u,[2,267],{37:46}),n(S,[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:b,87:d},n(T,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),n(e,[2,248]),n(e,[2,245]),n(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),n(I,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:O,29:L,52:84,53:M,56:85},{19:88,28:O,29:L,52:89,53:M,56:85},n(u,[2,253],{26:90}),{28:[1,91],52:92,53:M},n(G,[2,385],{181:93,182:94,183:95,31:[2,383]}),n(Ee,[2,263],{34:96}),n(Ee,[2,261],{44:39,55:40,307:43,139:97,13:f,16:h,87:d,308:p}),n(Ee,[2,262]),n(je,[2,259]),n(Me,[2,143]),n(Me,[2,144]),n([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),n(q,[2,211]),n(q,[2,212]),n(q,[2,213]),n(q,[2,214]),{19:98,28:O,29:L,52:99,53:M,56:85},{6:[2,309],99:100,193:[1,101]},n(ie,[2,311],{101:102,328:[1,103]}),n(Se,[2,317],{104:104,328:[1,105]}),n(nt,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:Ke,114:110},{29:Ke,114:112},{29:Ke,114:113},{118:114,123:[1,115],125:116,126:at},n(Ue,[2,315]),n(Ue,[2,316]),n(Be,[2,319]),n(Be,[2,320]),n(Be,[2,321]),n(S,[2,327]),{13:f,16:h,55:118,307:43,308:p},n(u,[2,12]),n(u,[2,13],{44:66,43:119,45:b,87:d}),n(ke,[2,269]),n(ke,[2,15]),{13:f,16:h,44:136,45:Q,46:120,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(T,[2,14]),n(T,[2,274]),n(T,[2,271]),n(T,[2,272]),n(e,[2,4]),{13:[1,177]},n(W,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},n(c,[2,410]),n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:h,45:[1,193],55:194,197:it,219:189,220:190,223:191,224:[1,192],307:43,308:p},n(I,[2,419]),n(ut,we,{20:196,59:197,69:198,70:j}),n(u,[2,250]),{29:$,57:200},n(ie,[2,279],{54:202,327:[1,203]}),{29:[2,282]},n(U,H,{23:204,58:205,62:206,63:ve}),n(u,[2,252]),{19:208,28:O,29:L,52:209,53:M,56:85},{29:[1,210]},n(l,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,145:212,172:221,185:213,187:214,231:Ut,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(D1,[2,265],{56:85,35:227,52:228,19:229,28:O,29:L,53:M}),n(je,[2,260]),n(U,H,{58:205,62:206,23:230,63:ve}),n(u,[2,268]),{6:[2,45]},n(e,t,{10:3,4:231}),{13:f,16:h,55:232,307:43,308:p},n(ie,[2,312]),{105:233,112:R1,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},n(Se,[2,318]),n(ie,F1,{108:240,133:242,112:N1,132:L1}),n(nt,[2,323]),{112:[1,244]},{112:[2,325]},n(Bt,[2,50]),n(G,xu,{135:245,136:246,143:247,144:248,31:k1,112:k1}),n(Bt,[2,51]),n(Bt,[2,52]),n(Bi,[2,328],{119:249}),{29:Ke,114:250},n(Bi,[2,56]),{29:Ke,114:251},n(S,[2,59]),n(ke,[2,270]),{47:[1,252]},n(M1,[2,150]),n(Cu,[2,428],{240:253}),n(Sa,[2,430],{244:254}),n(Sa,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),n(_a,[2,440],{252:264}),n(Nt,[2,448],{260:265}),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,255:154,257:155,264:266,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,255:154,257:155,264:267,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,255:154,257:155,264:268,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Nt,[2,167]),n(Nt,[2,168]),n(Nt,[2,169]),n(Nt,[2,170],{176:269,45:j1,89:$1}),n(Nt,[2,171]),n(Nt,[2,172]),n(Nt,[2,173]),n(Nt,[2,174]),{13:f,16:h,44:136,45:Q,46:272,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:V1,89:U1,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},n(dr,[2,192],{292:[1,286],293:[1,287]}),n(dr,[2,195]),n(dr,[2,196]),n(dr,[2,197]),n(dr,[2,198]),n(dr,[2,199]),n(dr,[2,200]),{13:f,16:h,44:39,55:40,82:k,87:d,139:289,172:291,255:154,257:155,266:290,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},n(zo,[2,452]),n(zo,[2,453]),n(zo,[2,454]),n(zo,[2,455]),n(zo,[2,456]),{279:[2,458]},n(Iu,[2,207]),n(Iu,[2,208]),n(Iu,[2,209]),n(Iu,[2,210]),n(dr,[2,201]),n(dr,[2,202]),n(dr,[2,203]),n(dr,[2,204]),n(dr,[2,205]),n(dr,[2,206]),n(e,[2,5]),n(Ou,[2,297],{88:295}),n(Pu,[2,299],{90:296}),{48:[1,297],87:[1,298]},n(Du,[2,301]),n(W,[2,43]),n(W,[2,82]),n(W,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},n(c,[2,412]),n(ws,[2,123]),n(ws,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),n(Qn,[2,124]),{13:f,16:h,45:[1,311],55:194,89:[1,310],197:it,223:312,225:308,226:309,229:B1,307:43,308:p},n(c,i,{215:10,214:314}),n(Qn,[2,236]),n(Qn,[2,237]),n(ba,[2,6]),n(fd,[2,287],{60:315,72:316,73:[1,317]}),n(ut,[2,286]),{13:f,16:h,45:Q,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},n([6,31,63,70,73,81,83,85],[2,20]),n(G,q1,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:yi,31:yi,85:yi,112:yi,159:yi,160:yi,161:yi,163:yi,164:yi,41:s}),{13:f,16:h,55:331,307:43,308:p},n(ie,[2,280]),n(ba,[2,7]),n(ut,we,{59:197,69:198,20:332,70:j}),n(U,[2,284]),{64:[1,333]},n(U,H,{58:205,62:206,23:334,63:ve}),n(u,[2,254]),n(G,xu,{144:248,30:335,143:336,31:[2,257]}),n(u,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:h,44:39,55:40,87:d,139:342,186:339,190:340,195:341,197:Es,307:43,308:p},n(Qo,[2,389],{44:39,55:40,307:43,190:340,195:341,139:342,188:344,189:345,186:346,13:f,16:h,87:d,197:Es,308:p}),n(vi,[2,227]),n(vi,[2,228]),n(vi,[2,229]),{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,172:221,185:351,187:350,200:348,230:347,231:Ut,234:349,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},{13:f,16:h,44:39,55:40,87:d,139:342,186:352,190:340,195:341,197:Es,307:43,308:p},n(vi,[2,146]),n(vi,[2,147]),n(vi,[2,148]),n(vi,[2,149]),{13:f,16:h,44:354,55:355,82:k,87:d,172:357,237:356,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:358,312:hr,313:353},n(hd,[2,215]),n(hd,[2,216]),n(U,H,{58:205,62:206,23:359,63:ve}),n(Ee,[2,264]),n(D1,[2,266]),n(ba,[2,11]),n(r,[2,308],{6:[2,310]}),n(Bt,[2,313],{102:360,120:361,121:[1,362]}),n(Bt,[2,47]),n(Bt,[2,63]),n(Bt,[2,64]),{13:f,16:h,55:363,307:43,308:p},n(Bt,[2,336]),n(Bt,[2,337]),n(Bt,[2,338]),{109:[1,364]},n(G1,[2,60]),{13:f,16:h,55:365,307:43,308:p},n(ie,[2,335]),{13:f,16:h,55:366,307:43,308:p},{31:[1,367]},n(Ts,[2,341],{137:368}),n(Ts,[2,340]),{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,145:369,172:221,185:213,187:214,231:Ut,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},{28:[1,370],127:371,128:[1,372]},n(Bi,[2,330],{124:373,125:374,126:at}),n(Bi,[2,57]),{44:375,87:d},n(M1,[2,151],{241:376,242:[1,377]}),n(Cu,[2,153],{245:378,246:[1,379]}),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,247:380,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{250:[1,381]},n(Tt,[2,432]),n(Tt,[2,433]),n(Tt,[2,434]),n(Tt,[2,435]),n(Tt,[2,436]),n(Tt,[2,437]),{250:[2,439]},n([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:ee,298:te,299:re,300:ne,301:oe,302:ce}),n(_a,[2,162],{261:388,262:389,39:dd,338:pd}),n(Nt,[2,164]),n(Nt,[2,165]),n(Nt,[2,166]),n(Et,[2,95]),n(Et,[2,96]),n(Tt,[2,377],{177:392,325:[1,393]}),{48:[1,394]},n(Et,[2,177]),{13:f,16:h,44:136,45:Q,46:395,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:396,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:397,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:398,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:399,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,183]),n(Et,[2,98]),n(Tt,[2,381],{180:400}),{87:[1,401]},n(Et,[2,185]),{13:f,16:h,44:136,45:Q,46:402,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{29:$,57:403},n(dr,[2,193]),{13:f,16:h,55:404,307:43,308:p},{13:f,16:h,44:39,55:40,87:d,139:342,195:405,197:Es,307:43,308:p},n(qi,[2,233]),n(qi,[2,234]),n(qi,[2,235]),n(W1,[2,459],{281:406,325:[1,407]}),n(Tt,[2,463],{284:408,325:[1,409]}),n(Tt,[2,465],{286:410,325:[1,411]}),{13:f,16:h,31:[1,412],55:414,82:k,171:413,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},{31:[1,419],89:[1,420]},{29:[1,421]},n(Du,[2,302]),n(Ou,[2,367],{167:422}),n(Pu,[2,369],{168:423}),{48:[1,424],87:[1,425]},n(Du,[2,371]),n(ws,[2,122]),n(ws,[2,417]),n(ws,[2,413]),n(ws,[2,414]),n(ws,[2,415]),n(Qn,[2,125]),n(Qn,[2,127]),n(Qn,[2,128]),n(H1,[2,420],{227:426}),n(Qn,[2,130]),{13:f,16:h,55:194,197:it,223:427,307:43,308:p},{48:[1,428]},n(Gi,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),n(fd,[2,288]),{64:[1,433]},n(ut,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:f,16:h,45:Q,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,276:De,277:he,279:Ae,280:ge,283:xe,285:Re,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C}),n(z1,[2,293]),n(md,[2,92]),n(md,[2,93]),n(md,[2,94]),{45:j1,89:$1,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:O,29:L,56:85},{19:438,28:O,29:L,56:85},n(As,[2,355],{149:439}),n(As,[2,354]),{13:f,16:h,44:215,45:Nu,55:220,82:k,87:d,89:We,156:440,172:221,185:441,203:442,231:Lu,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(Ee,[2,19]),n(Gi,[2,21]),{13:f,16:h,44:450,45:Q1,55:323,65:445,66:446,67:447,68:448,87:d,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},n(ba,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},n(G,[2,386],{31:[2,388]}),n(Qo,[2,102]),n(xs,[2,391],{191:452}),n(G,[2,395],{196:453,198:454}),n(G,[2,108]),n(G,[2,109]),n(Qo,[2,103]),n(Qo,[2,104]),n(Qo,[2,390]),{13:f,16:h,44:215,45:Ge,48:[1,455],55:220,82:k,87:d,89:We,172:221,185:351,187:350,200:456,231:Ut,234:349,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(ku,[2,424]),n(Y1,[2,136]),n(Y1,[2,137]),n(gd,[2,140]),{232:[1,457]},{13:f,16:h,44:39,55:40,87:d,139:342,195:458,197:Es,307:43,308:p},n(qi,[2,219]),n(qi,[2,220]),n(qi,[2,221]),n(qi,[2,222]),n(qi,[2,223]),n(ba,[2,10]),n(Bt,[2,46]),n(Bt,[2,314]),{112:R1,122:459},n(Bt,[2,62]),n(ie,F1,{133:242,108:460,112:N1,132:L1}),n(G1,[2,61]),n(Bt,[2,49]),n([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},n(Ts,[2,351],{146:463,335:[1,464]}),{29:$,57:465},n(Bi,[2,329]),n(ie,[2,332],{129:466,327:[1,467]}),n(Bi,[2,55]),n(Bi,[2,331]),{48:[1,468]},n(Cu,[2,429]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Sa,[2,431]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,243:470,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Sa,[2,156]),{45:V1,89:U1,179:471},n(_a,[2,441]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,251:472,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Nt,[2,444],{256:473}),n(Nt,[2,446],{258:474}),n(Tt,[2,442]),n(Tt,[2,443]),n(Nt,[2,449]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,255:154,257:155,259:475,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Tt,[2,450]),n(Tt,[2,451]),n(Tt,[2,379],{178:476}),n(Tt,[2,378]),n([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:h,44:136,45:Q,46:482,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{48:[1,483]},{48:[1,484]},n(Et,[2,187]),n(dr,[2,194]),{13:f,16:h,44:39,55:40,82:k,87:d,139:289,172:291,255:154,257:155,266:290,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,320:485},{13:f,16:h,39:[1,487],44:136,45:Q,46:488,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,282:486,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(W1,[2,460]),{13:f,16:h,44:136,45:Q,46:489,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Tt,[2,464]),{13:f,16:h,44:136,45:Q,46:490,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Tt,[2,466]),n(W,[2,40]),n(Ou,[2,298]),n(Yo,[2,87]),n(Yo,[2,88]),n(Yo,[2,89]),n(Yo,[2,90]),{13:f,16:h,55:492,82:k,172:493,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,311:494,312:hr,315:491},n(W,[2,41]),n(Pu,[2,300]),n(Ko,[2,303],{92:495}),{13:f,16:h,31:[1,496],55:414,82:k,171:497,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},{31:[1,498],89:[1,499]},{29:[1,500]},n(Du,[2,372]),{13:f,16:h,48:[2,422],55:194,197:it,223:312,226:502,228:501,229:B1,307:43,308:p},n(Qn,[2,131]),n(Qn,[2,126]),n(Gi,[2,22]),n(Gi,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:h,44:510,45:Q,55:323,67:321,68:322,74:505,75:506,76:K1,77:320,78:X1,79:509,87:d,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},n(z1,[2,294]),n(J1,[2,69]),n(J1,[2,70]),n(ut,we,{59:197,69:198,20:511,70:j}),n(U,H,{58:205,62:206,23:512,63:ve}),{29:[2,375],31:[2,71],84:522,85:a,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},n(As,[2,363],{157:524,335:[1,525]}),n(c,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:d}),n(Mu,[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:d}),{13:f,16:h,44:215,45:Nu,55:220,82:k,87:d,89:We,172:221,185:351,203:536,212:534,231:Lu,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(c,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:d}),n(U,[2,23],{307:43,267:139,275:146,278:149,55:323,67:447,68:448,44:450,66:538,13:f,16:h,45:Q1,87:d,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,276:De,277:he,279:Ae,280:ge,283:xe,285:Re,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C}),n(Cs,[2,291]),n(Cs,[2,24]),n(Cs,[2,25]),{13:f,16:h,44:136,45:Q,46:539,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Cs,[2,28]),n(U,H,{58:205,62:206,23:540,63:ve}),n([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),n(xs,[2,107]),{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,172:221,185:351,187:350,199:543,200:544,231:Ut,234:349,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(Z1,[2,132]),n(ku,[2,425]),n(Z1,[2,133]),{13:f,16:h,44:354,55:355,82:k,87:d,172:357,237:356,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:358,312:hr,313:545},n(Bt,[2,54]),n(Bt,[2,48]),n(Ts,[2,342]),{13:f,16:h,44:39,55:40,87:d,139:546,307:43,308:p},n(Ts,[2,68]),n(G,[2,350],{31:e2,112:e2}),n(Bt,[2,53]),{13:f,16:h,55:547,307:43,308:p},n(ie,[2,333]),n(ke,[2,16]),n(Cu,[2,152]),n(Sa,[2,154]),n(Sa,[2,157]),n(_a,[2,159]),n(_a,[2,160],{262:389,261:548,39:dd,338:pd}),n(_a,[2,161],{262:389,261:549,39:dd,338:pd}),n(Nt,[2,163]),{13:f,16:h,44:136,45:Q,46:550,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,178]),n(Et,[2,179]),{13:f,16:h,44:136,45:Q,46:551,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:552,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:553,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{48:[1,554],272:[1,555]},n(Et,[2,184]),n(Et,[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:h,55:194,197:it,223:562,307:43,308:p},n(yd,[2,224]),n(yd,[2,225]),n(yd,[2,226]),{31:[1,563],45:t2,94:564},n(W,[2,84]),n(Ou,[2,368]),n(W,[2,85]),n(Pu,[2,370]),n(Ko,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},n(Gi,[2,35],{83:[1,569]}),n(Gi,[2,36],{81:[1,570]}),n(fd,[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:h,45:Q,76:K1,78:X1,87:d,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,276:De,277:he,279:Ae,280:ge,283:xe,285:Re,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C}),n(wa,[2,295]),{45:Q,77:572},{45:Q,77:573},n(wa,[2,33]),n(wa,[2,34]),{31:[2,275],50:574,84:575,85:a},{31:[2,277],51:576,84:577,85:a},n(As,[2,356]),n(r2,[2,357],{152:578,335:[1,579]}),n(Si,[2,74]),{29:$,57:580},{29:$,57:581},{13:f,16:h,44:39,55:40,87:d,139:582,307:43,308:p},n(n2,[2,365],{162:583,328:[1,584]}),{13:f,16:h,45:Q,55:323,67:321,68:322,77:320,79:585,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},{45:[1,586]},n(Si,[2,81]),{29:$,57:587},n(As,[2,73]),n(G,[2,362],{29:_i,31:_i,85:_i,112:_i,159:_i,160:_i,161:_i,163:_i,164:_i}),n(Mu,[2,112]),n(Ea,[2,401],{206:588}),n(G,[2,405],{209:589,210:590}),n(G,[2,403]),n(G,[2,404]),n(Mu,[2,113]),n(Mu,[2,400]),{13:f,16:h,44:215,45:Nu,48:[1,591],55:220,82:k,87:d,89:We,172:221,185:351,203:536,212:592,231:Lu,234:535,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(ku,[2,426]),n(gd,[2,138]),n(gd,[2,139]),{232:[1,593]},n(Cs,[2,292]),{47:[1,595],48:[1,594]},n(ba,[2,9]),n(xs,[2,392]),n(xs,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:h,87:d,197:Es,308:p}),n(xs,[2,110],{272:[1,598]}),n(ju,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},n(Bi,[2,58]),n(Nt,[2,445]),n(Nt,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},n(Et,[2,99]),n(Tt,[2,382]),n([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),n(Et,[2,188]),n(Et,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:h,55:492,82:k,172:493,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,311:494,312:hr,315:611},n(W,[2,42]),n(Ko,[2,304]),{13:f,16:h,55:414,82:k,95:612,171:613,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},{31:[1,614],45:t2,94:615},n(Qn,[2,129]),n(H1,[2,421]),{82:[1,616]},{82:[1,617]},n(wa,[2,296]),n(wa,[2,31]),n(wa,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},n(G,q1,{155:330,153:618,154:619,29:bi,31:bi,85:bi,112:bi,159:bi,160:bi,161:bi,163:bi,164:bi}),n(r2,[2,358]),n(Si,[2,75]),n(Si,[2,76]),{29:$,57:620},{13:f,16:h,44:39,55:40,87:d,139:621,307:43,308:p},n(n2,[2,366]),n(Si,[2,79]),{13:f,16:h,44:136,45:Q,46:622,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Si,[2,91],{336:[1,623]}),n([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),n(Ea,[2,117]),{13:f,16:h,44:215,45:Nu,55:220,82:k,87:d,89:We,172:221,185:351,203:536,211:626,212:627,231:Lu,234:535,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(vi,[2,134]),n(ku,[2,427]),n(vi,[2,135]),n(Cs,[2,26]),{44:628,87:d},n(xs,[2,106]),n(xs,[2,394]),n(G,[2,396]),n(ju,[2,111]),n(ju,[2,398]),{13:f,16:h,44:39,55:40,87:d,139:342,186:629,190:340,195:341,197:Es,307:43,308:p},n(hd,[2,217]),n(G,xu,{144:248,140:630,143:631,31:[2,343]}),n(Et,[2,97]),n(Tt,[2,380]),n(Et,[2,180]),{13:f,16:h,44:136,45:Q,46:632,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:633,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:h,48:[1,636],55:414,82:k,171:637,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},n(i2,[2,305]),n(W,[2,86]),n(Ko,[2,374]),n(Gi,[2,37]),n(Gi,[2,38]),n(As,[2,72]),n(As,[2,360]),n(Si,[2,77]),{29:$,57:638},{47:[1,639]},{29:[2,376]},n(Ea,[2,402]),n(Ea,[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:d}),n(Ea,[2,118],{272:[1,641]}),n($u,[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:ue,304:le,305:X,306:fe},n(Yo,[2,218]),n(Ko,[2,44]),n(i2,[2,306]),n(Si,[2,78]),{44:651,87:d},n(Ea,[2,116]),n(G,[2,406]),n($u,[2,119]),n($u,[2,408]),n(c,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:d}),n(Cs,[2,27]),n(ju,[2,230]),n(s2,[2,345],{141:653,335:[1,654]}),n(Et,[2,181]),n(Et,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},n(G,xu,{144:248,142:657,143:658,31:a2,112:a2}),n(s2,[2,346]),n(Si,[2,80]),n($u,[2,231]),n(Ts,[2,67]),n(Ts,[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:o(function(A,P){if(P.recoverable)this.trace(A);else{var F=new Error(A);throw F.hash=P,F}},"parseError"),parse:o(function(A){var P=this,F=[0],Y=[],_e=[null],m=[],mr=this.table,g="",Xn=0,ec=0,qu=0,Gu=2,tc=1,Wu=m.slice.call(arguments,1),mt=Object.create(this.lexer),Jn={yy:{}};for(var rc in this.yy)Object.prototype.hasOwnProperty.call(this.yy,rc)&&(Jn.yy[rc]=this.yy[rc]);mt.setInput(A,Jn.yy),Jn.yy.lexer=mt,Jn.yy.parser=this,typeof mt.yylloc>"u"&&(mt.yylloc={});var Ia=mt.yylloc;m.push(Ia);var st=mt.options&&mt.options.ranges;typeof Jn.yy.parseError=="function"?this.parseError=Jn.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function dt(Zn){F.length=F.length-2*Zn,_e.length=_e.length-Zn,m.length=m.length-Zn}o(dt,"popStack");for(var He=o(function(){var Zn;return Zn=mt.lex()||tc,typeof Zn!="number"&&(Zn=P.symbols_[Zn]||Zn),Zn},"lex"),Ze,Pr,Ds,zr,JM,Pd,Oa={},Hu,Ti,v2,zu;;){if(Ds=F[F.length-1],this.defaultActions[Ds]?zr=this.defaultActions[Ds]:((Ze===null||typeof Ze>"u")&&(Ze=He()),zr=mr[Ds]&&mr[Ds][Ze]),typeof zr>"u"||!zr.length||!zr[0]){var Dd="";zu=[];for(Hu in mr[Ds])this.terminals_[Hu]&&Hu>Gu&&zu.push("'"+this.terminals_[Hu]+"'");mt.showPosition?Dd="Parse error on line "+(Xn+1)+`:
|
|
237
|
+
LIMIT ${this.config.defaultLimit}`,s="\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0442\u043E\u0447\u043D\u043E \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0442\u0438\u043F \u0437\u0430\u043F\u0440\u043E\u0441\u0430. \u0412\u044B\u043F\u043E\u043B\u043D\u044F\u0435\u0442\u0441\u044F \u043F\u043E\u0438\u0441\u043A \u043F\u043E \u043A\u043B\u044E\u0447\u0435\u0432\u043E\u043C\u0443 \u0441\u043B\u043E\u0432\u0443.";return t?.template&&t?.missingParams&&(s+=` \u0414\u043B\u044F \u0448\u0430\u0431\u043B\u043E\u043D\u0430 "${t.template.name}" \u043D\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432: ${t.missingParams.join(", ")}.`),{query:i,templateName:null,parameters:{keyword:r},confidence:.3,explanation:s,isFallback:!0,alternatives:[]}}calculateConfidence(e,t,r){let i=.5;for(let c of t.keywords)e.includes(c.toLowerCase())&&(i+=.1);let s=t.parameters.filter(c=>c.required),a=s.filter(c=>r[c.name]&&r[c.name].length>0);s.length>0?i+=a.length/s.length*.2:i+=.2;for(let[c]of Object.entries(this.prototypeMapping))if(e.includes(c)){i+=.1;break}return Math.min(i,1)}generateExplanation(e,t){let r=e.description;return Object.keys(t).length>0&&(r+=". \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B: ",r+=Object.entries(t).filter(([,i])=>i&&i.length>0).map(([i,s])=>`${i}="${s}"`).join(", ")),r}getAvailableTemplates(){return[...St.SPARQL_TEMPLATES]}getTemplate(e){return(0,St.getTemplateByName)(e)}setConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}addTemplate(e){St.SPARQL_TEMPLATES.push(e),WR.LoggingService.debug(`Added custom template: ${e.name}`)}getSuggestions(e){let t=[];return(e.includes("\u0441\u043A\u043E\u043B\u044C\u043A\u043E")||e.includes("\u0441\u0440\u0435\u0434\u043D")||e.includes("\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A"))&&!e.match(/\b20\d{2}\b/)&&!this.containsMonth(e)&&t.push("\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043F\u0435\u0440\u0438\u043E\u0434 \u0432\u0440\u0435\u043C\u0435\u043D\u0438 (\u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440: '\u0437\u0430 \u0434\u0435\u043A\u0430\u0431\u0440\u044C' \u0438\u043B\u0438 '\u0437\u0430 2025-12')"),(e.includes("\u0437\u0430\u0434\u0430\u0447")||e.includes("\u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0441\u0442"))&&t.push("\u0414\u043B\u044F \u0442\u043E\u0447\u043D\u043E\u0433\u043E \u043F\u043E\u0438\u0441\u043A\u0430 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 UUID \u043F\u0440\u043E\u0442\u043E\u0442\u0438\u043F\u0430 \u0432\u043C\u0435\u0441\u0442\u043E \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F"),e.length<10&&t.push("\u0423\u0442\u043E\u0447\u043D\u0438\u0442\u0435 \u0437\u0430\u043F\u0440\u043E\u0441: \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0441\u0442\u0438 \u0438\u043B\u0438 \u0442\u0438\u043F \u0434\u0430\u043D\u043D\u044B\u0445"),t}containsMonth(e){return Object.keys(this.monthNames).some(t=>e.includes(t))}};sn.NLToSPARQLService=Cg;sn.NLToSPARQLService=Cg=BR([(0,GR.injectable)(),qR("design:paramtypes",[Object])],Cg)});var YS=v(Ln=>{"use strict";var HR=Ln&&Ln.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},zR=Ln&&Ln.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},QR=Ln&&Ln.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.AnalyticsService=void 0;var QS=Le(),YR=ct(),KR=Ht(),XR=Xi(),Ig=class{static{o(this,"AnalyticsService")}constructor(e){this.vault=e,this.frontmatterService=new XR.FrontmatterService}getDefaultPeriod(){let e=new Date,t=new Date;return t.setDate(t.getDate()-30),{startDate:t,endDate:e}}async getEffortsInPeriod(e,t){let i=this.vault.getAllFiles().filter(a=>a.path.endsWith(".md")),s=[];for(let a of i)try{let c=await this.vault.read(a),u=this.extractEffortData(a,c);if(!u)continue;if(u.startTimestamp){if(u.startTimestamp<e.startDate||u.startTimestamp>e.endDate)continue}else continue;if(t?.prototypeUri&&u.prototypeUri!==t.prototypeUri||t?.labelContains&&!u.label.toLowerCase().includes(t.labelContains.toLowerCase())||t?.status&&u.status&&!t.status.includes(u.status))continue;s.push(u)}catch{continue}return s}extractEffortData(e,t){let r=this.frontmatterService.parse(t);if(!r.exists)return null;let i=this.frontmatterService.getPropertyValue(r.content,"exo__Asset_label");if(!i)return null;let s=this.frontmatterService.getPropertyValue(r.content,"ems__Effort_status"),a=this.frontmatterService.getPropertyValue(r.content,"ems__Effort_startTimestamp"),c=this.frontmatterService.getPropertyValue(r.content,"ems__Effort_endTimestamp"),u=this.frontmatterService.getPropertyValue(r.content,"exo__Asset_prototype"),l=this.extractInstanceClass(r.content);return{path:e.path,label:this.cleanWikiLink(i),status:s?this.cleanWikiLink(s):null,startTimestamp:a?this.parseTimestamp(a):null,endTimestamp:c?this.parseTimestamp(c):null,prototypeUri:u?this.cleanWikiLink(u):null,instanceClass:l}}extractInstanceClass(e){let t=e.match(/exo__Instance_class:\s*\n((?:\s*-\s*.*\n?)+)/);if(t)return t[1].split(`
|
|
238
|
+
`).filter(s=>s.trim()).map(s=>this.cleanWikiLink(s.replace(/^\s*-\s*/,"").trim()));let r=this.frontmatterService.getPropertyValue(e,"exo__Instance_class");return r?this.cleanWikiLink(r):null}cleanWikiLink(e){return e.replace(/^\[\[/,"").replace(/\]\]$/,"").replace(/^"/,"").replace(/"$/,"")}parseTimestamp(e){if(!e)return null;let t=e.replace(/^"/,"").replace(/"$/,""),r=new Date(t);return isNaN(r.getTime())?null:r}calculateDurationStats(e){let t=e.filter(f=>f.startTimestamp&&f.endTimestamp).map(f=>(f.endTimestamp.getTime()-f.startTimestamp.getTime())/6e4).filter(f=>f>0);if(t.length===0)return{count:0,totalMinutes:0,averageMinutes:0,minMinutes:0,maxMinutes:0,stdDevMinutes:0};let r=t.reduce((f,h)=>f+h,0),i=r/t.length,s=Math.min(...t),a=Math.max(...t),u=t.map(f=>Math.pow(f-i,2)).reduce((f,h)=>f+h,0)/t.length,l=Math.sqrt(u);return{count:t.length,totalMinutes:Math.round(r),averageMinutes:Math.round(i*10)/10,minMinutes:Math.round(s),maxMinutes:Math.round(a),stdDevMinutes:Math.round(l*10)/10}}calculateDailyAggregates(e){let t=new Map;for(let r of e){if(!r.startTimestamp)continue;let i=KR.DateFormatter.toDateString(r.startTimestamp);t.has(i)||t.set(i,{count:0,totalMinutes:0});let s=t.get(i);if(s.count++,r.endTimestamp){let a=r.endTimestamp.getTime()-r.startTimestamp.getTime();s.totalMinutes+=a/6e4}}return Array.from(t.entries()).map(([r,i])=>({date:r,count:i.count,totalMinutes:Math.round(i.totalMinutes),averageMinutes:i.count>0?Math.round(i.totalMinutes/i.count*10)/10:0})).sort((r,i)=>r.date.localeCompare(i.date))}calculateHourlyDistribution(e){let t=new Array(24).fill(0);for(let i of e){if(!i.startTimestamp)continue;let s=i.startTimestamp.getHours();t[s]++}let r=t.reduce((i,s)=>i+s,0);return t.map((i,s)=>({hour:s,count:i,percentage:r>0?Math.round(i/r*1e3)/10:0}))}calculateWeekdayDistribution(e){let t=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],r=new Array(7).fill(0);for(let s of e){if(!s.startTimestamp)continue;let a=s.startTimestamp.getDay();r[a]++}let i=r.reduce((s,a)=>s+a,0);return r.map((s,a)=>({dayOfWeek:a,dayName:t[a],count:s,percentage:i>0?Math.round(s/i*1e3)/10:0}))}async analyzeSleep(e=this.getDefaultPeriod()){let t=await this.getEffortsInPeriod(e,{labelContains:"\u041F\u043E\u0441\u043F\u0430\u0442\u044C"}),r=this.calculateDurationStats(t),i=this.calculateDailyAggregates(t),s=[],a=[];for(let h of t){if(h.startTimestamp){let d=h.startTimestamp.getHours()*60+h.startTimestamp.getMinutes();s.push(d<360?d+1440:d)}if(h.endTimestamp){let d=h.endTimestamp.getHours()*60+h.endTimestamp.getMinutes();a.push(d)}}let c=s.length>0?s.reduce((h,d)=>h+d,0)/s.length:0,u=a.length>0?a.reduce((h,d)=>h+d,0)/a.length:0,l=s.length>1?Math.sqrt(s.map(h=>Math.pow(h-c,2)).reduce((h,d)=>h+d,0)/s.length):0,f=a.length>1?Math.sqrt(a.map(h=>Math.pow(h-u,2)).reduce((h,d)=>h+d,0)/a.length):0;return{period:e,stats:r,dailyData:i,averageBedtime:this.minutesToTimeString(c%1440),averageWakeTime:this.minutesToTimeString(u),bedtimeVariabilityMinutes:Math.round(l),wakeTimeVariabilityMinutes:Math.round(f)}}minutesToTimeString(e){let t=Math.floor(e/60),r=Math.round(e%60);return`${String(t).padStart(2,"0")}:${String(r).padStart(2,"0")}`}async analyzeTaskCompletion(e=this.getDefaultPeriod()){let r=(await this.getEffortsInPeriod(e)).filter(l=>Array.isArray(l.instanceClass)?l.instanceClass.some(f=>f.includes("ems__Task")):l.instanceClass?.includes("ems__Task")??!1),i=r.filter(l=>l.status?.includes("ems__EffortStatusDone")),s=r.filter(l=>l.status?.includes("ems__EffortStatusTrashed")),a=i.filter(l=>l.startTimestamp&&l.endTimestamp).map(l=>(l.endTimestamp.getTime()-l.startTimestamp.getTime())/6e4),c=a.length>0?a.reduce((l,f)=>l+f,0)/a.length:0,u=this.calculateDailyAggregates(i);return{period:e,totalTasks:r.length,completedTasks:i.length,trashedTasks:s.length,completionRate:r.length>0?Math.round(i.length/r.length*1e3)/10:0,averageCompletionTimeMinutes:Math.round(c*10)/10,dailyCompletions:u}}async analyzeActivityFrequency(e,t=this.getDefaultPeriod()){let r=await this.getEffortsInPeriod(t,{labelContains:e}),i=this.calculateDurationStats(r),s=this.calculateDailyAggregates(r),a=this.calculateHourlyDistribution(r),c=this.calculateWeekdayDistribution(r);return{activityLabel:e,period:t,stats:i,dailyData:s,hourlyDistribution:a,weekdayDistribution:c}}async getActivitySummary(e=this.getDefaultPeriod()){let t=await this.getEffortsInPeriod(e),r=new Map;for(let s of t){let a=s.label.split(" ")[0];r.has(a)||r.set(a,[]),r.get(a).push(s)}let i=new Map;for(let[s,a]of r)i.set(s,this.calculateDurationStats(a));return i}};Ln.AnalyticsService=Ig;Ln.AnalyticsService=Ig=HR([(0,QS.injectable)(),QR(0,(0,QS.inject)(YR.DI_TOKENS.IVaultAdapter)),zR("design:paramtypes",[Object])],Ig)});var KS=v(Ys=>{"use strict";var JR=Ys&&Ys.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Ys,"__esModule",{value:!0});Ys.TrendDetectionService=void 0;var ZR=Le(),Og=class{static{o(this,"TrendDetectionService")}constructor(){this.TREND_THRESHOLD=.05,this.ANOMALY_THRESHOLD_STD=2,this.STRONG_CORRELATION_THRESHOLD=.7,this.MODERATE_CORRELATION_THRESHOLD=.4}analyzeTrend(e,t="averageMinutes"){if(e.length<3)return{direction:"stable",strength:"none",slope:0,rSquared:0,changePercentage:0,insight:"Insufficient data for trend analysis (need at least 3 data points)"};let r=e.map(d=>d[t]),{slope:i,rSquared:s}=this.linearRegression(r),a=r[0]||1,u=((r[r.length-1]||0)-a)/a*100,l;Math.abs(u)<this.TREND_THRESHOLD*100?l="stable":i>0?l="increasing":l="decreasing";let f;s>=.7?f="strong":s>=.4?f="moderate":s>=.2?f="weak":f="none";let h=this.generateTrendInsight(l,f,u);return{direction:l,strength:f,slope:Math.round(i*100)/100,rSquared:Math.round(s*100)/100,changePercentage:Math.round(u*10)/10,insight:h}}linearRegression(e){let t=e.length;if(t===0)return{slope:0,intercept:0,rSquared:0};let r=(t-1)/2,i=e.reduce((d,p)=>d+p,0)/t,s=0,a=0;for(let d=0;d<t;d++)s+=(d-r)*(e[d]-i),a+=Math.pow(d-r,2);let c=a!==0?s/a:0,u=i-c*r,l=0,f=0;for(let d=0;d<t;d++){let p=u+c*d;l+=Math.pow(e[d]-p,2),f+=Math.pow(e[d]-i,2)}let h=f!==0?1-l/f:0;return{slope:c,intercept:u,rSquared:Math.max(0,h)}}generateTrendInsight(e,t,r){if(t==="none"||e==="stable")return"Metric is relatively stable with no significant trend.";let i=t==="strong"?"clearly":t==="moderate"?"moderately":"slightly",s=e==="increasing"?"increasing":"decreasing",a=`${Math.abs(Math.round(r))}%`;return`Metric is ${i} ${s} (${a} change over the period).`}detectAnomalies(e,t="averageMinutes"){if(e.length<5)return[];let r=e.map(c=>c[t]),{mean:i,stdDev:s}=this.calculateStats(r),a=[];for(let c=0;c<e.length;c++){let u=r[c],l=(u-i)/(s||1);if(Math.abs(l)>=this.ANOMALY_THRESHOLD_STD){let f=this.determineAnomalySeverity(l),h=this.determineAnomalyType(l,u,i);a.push({date:e[c].date,value:u,expectedValue:Math.round(i*10)/10,deviation:Math.round(l*100)/100,severity:f,type:h,description:this.generateAnomalyDescription(h,f,l,u,i)})}}return a}calculateStats(e){if(e.length===0)return{mean:0,stdDev:0};let t=e.reduce((a,c)=>a+c,0)/e.length,i=e.map(a=>Math.pow(a-t,2)).reduce((a,c)=>a+c,0)/e.length,s=Math.sqrt(i);return{mean:t,stdDev:s}}determineAnomalySeverity(e){let t=Math.abs(e);return t>=3?"critical":t>=2.5?"warning":"info"}determineAnomalyType(e,t,r){return t>r&&e>0?"spike":t<r&&e<0?"drop":"outlier"}generateAnomalyDescription(e,t,r,i,s){let a=t==="critical"?"Significant":t==="warning"?"Notable":"Minor",c=e==="spike"?"spike":e==="drop"?"drop":"unusual value",u=Math.round((i-s)/s*100);return`${a} ${c} detected: ${Math.round(i)} (${u>0?"+":""}${u}% from average of ${Math.round(s)}, ${r.toFixed(1)}\u03C3 from mean).`}calculateCorrelation(e,t,r,i){let s=Math.min(e.length,t.length);if(s<5)return{metric1:r,metric2:i,coefficient:0,strength:"none",direction:"none",insight:"Insufficient data for correlation analysis."};let{mean:a,stdDev:c}=this.calculateStats(e.slice(0,s)),{mean:u,stdDev:l}=this.calculateStats(t.slice(0,s));if(c===0||l===0)return{metric1:r,metric2:i,coefficient:0,strength:"none",direction:"none",insight:"One or both metrics have no variation."};let f=0;for(let T=0;T<s;T++)f+=(e[T]-a)/c*((t[T]-u)/l);let h=f/s,d=Math.abs(h),p;d>=this.STRONG_CORRELATION_THRESHOLD?p="strong":d>=this.MODERATE_CORRELATION_THRESHOLD?p="moderate":d>=.2?p="weak":p="none";let S=p==="none"?"none":h>0?"positive":"negative",b=this.generateCorrelationInsight(r,i,h,p,S);return{metric1:r,metric2:i,coefficient:Math.round(h*100)/100,strength:p,direction:S,insight:b}}generateCorrelationInsight(e,t,r,i,s){if(i==="none")return`No significant correlation found between ${e} and ${t}.`;let a=i==="strong"?"strongly":i==="moderate"?"moderately":"weakly",c=s==="positive"?"When one increases, the other tends to increase":"When one increases, the other tends to decrease";return`${e} and ${t} are ${a} ${s}ly correlated (r=${r.toFixed(2)}). ${c}.`}analyzeWeeklyPattern(e,t="averageMinutes"){let r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i={};for(let u of e){let f=new Date(u.date).getDay();i[f]||(i[f]=[]),i[f].push(u[t])}let s=[],a=0,c=1/0;for(let u=0;u<7;u++){let l=i[u]||[],{mean:f,stdDev:h}=this.calculateStats(l);f>a&&(a=f),f<c&&l.length>0&&(c=f),s.push({dayOfWeek:u,dayName:r[u],averageValue:Math.round(f*10)/10,deviation:Math.round(h*10)/10,isHighPoint:!1,isLowPoint:!1})}for(let u of s)u.averageValue===a&&a>0&&(u.isHighPoint=!0),u.averageValue===c&&c!==1/0&&(u.isLowPoint=!0);return s}generateInsights(e,t,r,i,s){let a=[];t.strength!=="none"&&t.direction!=="stable"&&a.push({type:"trend",severity:t.direction==="decreasing"?"warning":"info",title:`${s} is ${t.direction}`,description:t.insight,metric:s,value:t.changePercentage,actionable:t.direction==="decreasing"});let c=r.filter(f=>f.severity==="critical");if(c.length>0)for(let f of c)a.push({type:"anomaly",severity:"critical",title:`Unusual ${f.type} detected on ${f.date}`,description:f.description,metric:s,value:f.value,actionable:!0});let u=i.filter(f=>f.isHighPoint).map(f=>f.dayName),l=i.filter(f=>f.isLowPoint).map(f=>f.dayName);return u.length>0&&l.length>0&&a.push({type:"pattern",severity:"info",title:"Weekly pattern detected",description:`${s} tends to be highest on ${u.join(", ")} and lowest on ${l.join(", ")}.`,metric:s,actionable:!1}),e.stdDevMinutes>e.averageMinutes*.5&&a.push({type:"recommendation",severity:"warning",title:"High variability detected",description:`${s} shows high variability (std dev: ${e.stdDevMinutes} min). Consider maintaining a more consistent schedule.`,metric:s,value:e.stdDevMinutes,actionable:!0}),a}detectSuddenChanges(e,t="averageMinutes",r=50){let i=[];for(let s=1;s<e.length;s++){let a=e[s-1][t],c=e[s][t];if(a===0)continue;let u=(c-a)/a*100;Math.abs(u)>=r&&i.push({date:e[s].date,previousValue:a,currentValue:c,changePercent:Math.round(u*10)/10})}return i}};Ys.TrendDetectionService=Og;Ys.TrendDetectionService=Og=JR([(0,ZR.injectable)()],Og)});var JS=v(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.AutocompleteService=Ks.DEFAULT_AUTOCOMPLETE_CONFIG=void 0;var tf=Yr(),Ic=Qe(),XS=lt();Ks.DEFAULT_AUTOCOMPLETE_CONFIG={limit:10,activeBoost:20,recencyBoost:10,recencyDays:7};var Pg=class{static{o(this,"AutocompleteService")}constructor(e,t){this.tripleStore=e,this.config={...Ks.DEFAULT_AUTOCOMPLETE_CONFIG,...t}}async getSuggestions(e,t,r){let i={...this.config,...r},s=await this.getPropertyRange(e);if(s.length===0){let u=this.inferClassFromProperty(e);u&&s.push(u)}let a=[];for(let u of s){let l=await this.getAssetsOfClass(u);a.push(...l)}return a.map(u=>({...u,matchScore:this.calculateMatchScore(u,t,i)})).filter(u=>u.matchScore>0).sort((u,l)=>l.matchScore-u.matchScore).slice(0,i.limit)}async getSuggestionsByClass(e,t,r){let i={...this.config,...r},s=[];for(let c of e){let u=await this.getAssetsOfClass(c);s.push(...u)}return s.map(c=>({...c,matchScore:this.calculateMatchScore(c,t,i)})).filter(c=>c.matchScore>0).sort((c,u)=>u.matchScore-c.matchScore).slice(0,i.limit)}async getPropertyRange(e){let t=this.toFullIri(e),r=[],i=await this.tripleStore.match(new Ic.IRI(t),tf.Namespace.RDFS.term("range"),void 0);for(let s of i)if(s.object instanceof Ic.IRI){let a=this.toClassName(s.object.value);a&&r.push(a)}return r}async getAssetsOfClass(e){let t=this.toFullIri(e),r=[],i=await this.tripleStore.match(void 0,tf.Namespace.RDF.term("type"),new Ic.IRI(t));for(let s of i)if(s.subject instanceof Ic.IRI){let a=await this.buildSuggestion(s.subject,e);a&&r.push(a)}return r}async buildSuggestion(e,t){let r=await this.tripleStore.match(e,tf.Namespace.EXO.term("Asset_label"),void 0),i="";for(let c of r)if(c.object instanceof XS.Literal){i=c.object.value;break}if(i||(i=this.extractLabelFromUri(e.value)),!i)return null;let s=await this.checkIfActive(e),a=this.extractPathFromUri(e.value);return{label:i,uri:e.value,path:a,assetClass:t,isActive:s,matchScore:0}}async checkIfActive(e){let t=await this.tripleStore.match(e,tf.Namespace.EMS.term("Effort_status"),void 0);for(let r of t){let i=r.object instanceof XS.Literal||r.object instanceof Ic.IRI?r.object.value:"";if(i.includes("Active")||i.includes("EffortStatus_Active"))return!0}return!1}calculateMatchScore(e,t,r){if(!t||t.length===0)return e.isActive?100+r.activeBoost:100;let i=e.label.toLowerCase(),s=t.toLowerCase(),a=0;if(i===s)a=100;else if(i.startsWith(s))a=80;else if(i.includes(s))a=60;else if(this.fuzzyMatch(s,i))a=40;else return 0;if(e.isActive&&(a+=r.activeBoost),e.lastModified){let c=(Date.now()-e.lastModified)/864e5;c<=r.recencyDays&&(a+=r.recencyBoost*(1-c/r.recencyDays))}return a}fuzzyMatch(e,t){let r=0;for(let i=0;i<t.length&&r<e.length;i++)t[i]===e[r]&&r++;return r===e.length}inferClassFromProperty(e){let t=e.toLowerCase();return t.includes("project")?"ems__Project":t.includes("area")?"ems__Area":t.includes("task")?"ems__Task":t.includes("effort")?"ems__Effort":null}toFullIri(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=e.match(/^([a-z]+)__(.+)$/);if(t){let[,r,i]=t;switch(r){case"ems":return`https://exocortex.my/ontology/ems#${i}`;case"exo":return`https://exocortex.my/ontology/exo#${i}`;default:return`https://exocortex.my/ontology/${r}#${i}`}}return e}toClassName(e){let t=e.match(/https:\/\/exocortex\.my\/ontology\/([a-z]+)#(.+)$/);if(t){let[,r,i]=t;return`${r}__${i}`}return null}extractLabelFromUri(e){if(e.startsWith("obsidian://")){let r=decodeURIComponent(e),i=r.lastIndexOf("/");if(i>=0){let s=r.substring(i+1);return s.endsWith(".md")&&(s=s.substring(0,s.length-3)),s}}let t=e.lastIndexOf("/");if(t>=0){let r=e.substring(t+1);return r.endsWith(".md")&&(r=r.substring(0,r.length-3)),r}return""}extractPathFromUri(e){if(e.startsWith("obsidian://vault/")){let t=decodeURIComponent(e.substring(17)),r=t.indexOf("/");return r>=0?t.substring(r+1):t}return e}};Ks.AutocompleteService=Pg});var e_=v(kn=>{"use strict";var eF=kn&&kn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},tF=kn&&kn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},rF=kn&&kn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(kn,"__esModule",{value:!0});kn.DailyReviewService=void 0;var ZS=Le(),nF=ct(),Na=Ht(),iF=Xi(),sF=yr(),Dg=class{static{o(this,"DailyReviewService")}constructor(e){this.vault=e,this.frontmatterService=new iF.FrontmatterService}async getPractices(){let e=this.vault.getAllFiles(),t=[],r=Na.DateFormatter.toDateString(new Date);for(let i of e)if(i.path.endsWith(".md"))try{let s=await this.vault.read(i),a=this.frontmatterService.parse(s);if(!a.exists)continue;let c=this.frontmatterService.getPropertyValue(a.content,"exo__Instance_class");if(!this.isTaskPrototype(c))continue;let u=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_uid");if(!u)continue;let l=u.replace(/"/g,""),f=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_label");if(!f)continue;let h=f.replace(/"/g,""),p=this.frontmatterService.getPropertyValue(a.content,"ems__Recurring_rule")?.replace(/"/g,"")||null,S=this.frontmatterService.getPropertyValue(a.content,"ems__Task_estimatedDuration"),b=null;if(S){let I=parseInt(S,10);isNaN(I)||(b=I)}let T=await this.findTodayInstance(l,r);t.push({uid:l,label:h,path:i.path,recurringRule:p,estimatedDuration:b,doneToday:T?.status==="done",inProgressToday:T?.status==="doing",todayInstancePath:T?.path||null})}catch{continue}return t.sort((i,s)=>i.label.localeCompare(s.label))}async getDailyReviewSummary(e){let t=e||new Date,r=Na.DateFormatter.toDateString(t),i=new Date(t);i.setHours(0,0,0,0);let s=new Date(t);s.setHours(23,59,59,999);let a=this.vault.getAllFiles(),c=0,u=0,l=0,f=0;for(let S of a)if(S.path.endsWith(".md"))try{let b=await this.vault.read(S),T=this.frontmatterService.parse(b);if(!T.exists)continue;let I=this.frontmatterService.getPropertyValue(T.content,"exo__Instance_class");if(!this.isTask(I))continue;let O=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_plannedStartTimestamp"),L=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_startTimestamp"),M=L?new Date(L):null,G=O?new Date(O):null;if(!(G&&G>=i&&G<=s||M&&M>=i&&M<=s))continue;c++;let je=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_status");if(this.isDoneStatus(je)){u++;let Me=this.frontmatterService.getPropertyValue(T.content,"ems__Effort_endTimestamp");if(L&&Me){let q=this.calculateDurationMinutes(L,Me);f+=q}}else this.isDoingStatus(je)&&l++}catch{continue}let d=(await this.getPractices()).filter(S=>!S.doneToday&&S.recurringRule),p=c>0?Math.round(u/c*100):0;return{date:r,plannedCount:c,completedCount:u,inProgressCount:l,practicesDue:d,completionPercentage:p,totalTimeMinutes:Math.round(f)}}async quickCapture(e,t=!0,r){let i=(0,sF.v4)(),s=Na.DateFormatter.toISOTimestamp(new Date),a=`${i}.md`,c="03 Knowledge/kitelev",u=["---",`exo__Asset_uid: "${i}"`,`exo__Asset_label: "${e}"`,'exo__Instance_class: "[[ems__Task]]"'];if(r?.prototypeUid){let h=this.buildPrototypeUri(r.prototypeUid);u.push(`exo__Asset_prototype: "${h}"`)}if(r?.areaUid){let h=this.buildAssetUri(r.areaUid);u.push(`ems__Effort_area: "${h}"`)}if(r?.parentUid){let h=this.buildAssetUri(r.parentUid);u.push(`ems__Effort_parent: "${h}"`)}t?(u.push('ems__Effort_status: "[[ems__EffortStatusDoing]]"'),u.push(`ems__Effort_startTimestamp: ${s}`)):u.push('ems__Effort_status: "[[ems__EffortStatusBacklog]]"'),u.push("---","","");let l=u.join(`
|
|
239
|
+
`),f=`${c}/${a}`;return await this.vault.create(f,l),{path:f,uid:i,label:e,started:t}}async createFromPractice(e){let r=(await this.getPractices()).find(a=>a.uid===e.prototypeUid);if(!r)throw new Error(`Practice not found: ${e.prototypeUid}`);if(r.doneToday)throw new Error(`Practice "${r.label}" already completed today`);if(r.inProgressToday&&r.todayInstancePath)return{path:r.todayInstancePath,uid:e.prototypeUid,label:r.label,started:!0};let i=Na.DateFormatter.toDateString(new Date),s=e.label||`${r.label} ${i}`;return this.quickCapture(s,e.startImmediately??!0,{prototypeUid:e.prototypeUid,areaUid:e.areaUid,parentUid:e.parentUid})}async markPracticeDone(e){let r=(await this.getPractices()).find(l=>l.uid===e);if(!r)throw new Error(`Practice not found: ${e}`);if(r.doneToday)return;if(!r.todayInstancePath)throw new Error(`No active instance for practice "${r.label}" today`);let i=this.vault.getAbstractFileByPath(r.todayInstancePath);if(!i||!("basename"in i))throw new Error(`File not found: ${r.todayInstancePath}`);let s=i,a=await this.vault.read(s),c=Na.DateFormatter.toISOTimestamp(new Date),u=this.frontmatterService.updateProperty(a,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');u=this.frontmatterService.updateProperty(u,"ems__Effort_endTimestamp",c),u=this.frontmatterService.updateProperty(u,"ems__Effort_resolutionTimestamp",c),await this.vault.modify(s,u)}async findTodayInstance(e,t){let r=this.vault.getAllFiles();for(let i of r)if(i.path.endsWith(".md"))try{let s=await this.vault.read(i),a=this.frontmatterService.parse(s);if(!a.exists)continue;let c=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_prototype");if(!c||!c.includes(e))continue;let u=this.frontmatterService.getPropertyValue(a.content,"exo__Asset_label"),l=this.frontmatterService.getPropertyValue(a.content,"ems__Effort_startTimestamp"),f=u?.includes(t),h=l?new Date(l):null,d=h&&Na.DateFormatter.toDateString(h)===t;if(!f&&!d)continue;let p=this.frontmatterService.getPropertyValue(a.content,"ems__Effort_status");return this.isDoneStatus(p)?{path:i.path,status:"done"}:this.isDoingStatus(p)?{path:i.path,status:"doing"}:{path:i.path,status:"other"}}catch{continue}return null}isTaskPrototype(e){return e?e.includes("ems__TaskPrototype")||e.includes("TaskPrototype"):!1}isTask(e){return e?(e.includes("ems__Task")||e.includes("[[ems__Task]]"))&&!e.includes("Prototype"):!1}isDoneStatus(e){return e?e.includes("Done")||e.includes("EffortStatusDone"):!1}isDoingStatus(e){return e?e.includes("Doing")||e.includes("EffortStatusDoing"):!1}calculateDurationMinutes(e,t){let r=new Date(e);return(new Date(t).getTime()-r.getTime())/1e3/60}buildPrototypeUri(e){return`obsidian://vault/03%20Knowledge%2Fkitelev%2F${e}.md`}buildAssetUri(e){return`obsidian://vault/03%20Knowledge%2Fkitelev%2F${e}.md`}};kn.DailyReviewService=Dg;kn.DailyReviewService=Dg=eF([(0,ZS.injectable)(),rF(0,(0,ZS.inject)(nF.DI_TOKENS.IVaultAdapter)),tF("design:paramtypes",[Object])],Dg)});var t_=v(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.EffortSortingHelpers=void 0;var Rg=class n{static{o(this,"EffortSortingHelpers")}static getTimeFromTimestamp(e){if(!e)return"00:00:00";let t=new Date(e);if(isNaN(t.getTime()))return"00:00:00";let r=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),s=String(t.getSeconds()).padStart(2,"0");return`${r}:${i}:${s}`}static sortByStartTime(e,t){let r=n.getTimeFromTimestamp(e.startTimestamp),i=n.getTimeFromTimestamp(t.startTimestamp),s=r==="00:00:00",a=i==="00:00:00";return s&&!a?1:!s&&a?-1:r.localeCompare(i)}static sortByPriority(e,t){if(e.isTrashed!==t.isTrashed)return e.isTrashed?1:-1;if(e.isDone!==t.isDone)return e.isDone?1:-1;let r=typeof e.metadata.ems__Effort_votes=="number"?e.metadata.ems__Effort_votes:0,i=typeof t.metadata.ems__Effort_votes=="number"?t.metadata.ems__Effort_votes:0;return r!==i?i-r:e.startTime&&t.startTime?e.startTime.localeCompare(t.startTime):e.startTime?-1:t.startTime?1:0}};rf.EffortSortingHelpers=Rg});var r_=v(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.FilenameValidator=void 0;var Xs=class{static{o(this,"FilenameValidator")}static validate(e,t={}){let{maxLength:r=this.DEFAULT_MAX_LENGTH,replacementChar:i=this.DEFAULT_REPLACEMENT,allowEmpty:s=!1}=t,a=[];if(!e||e.trim().length===0)return s||a.push("Filename cannot be empty"),{valid:a.length===0,sanitized:"",errors:a};e.endsWith(" ")&&a.push("Filename should not end with a space");let c=e.trim();this.INVALID_CHARS_PATTERN.test(c)&&a.push('Filename contains invalid characters: / \\ : * ? " < > |');let u=this.getBaseName(c);this.RESERVED_NAMES.has(u.toUpperCase())&&a.push(`"${u}" is a reserved filename on Windows`),c.length>r&&a.push(`Filename exceeds maximum length of ${r} characters`),c.startsWith(".")&&a.push("Filename should not start with a dot"),c.endsWith(".")&&a.push("Filename should not end with a dot");let l=this.sanitize(e,{maxLength:r,replacementChar:i});return{valid:a.length===0,sanitized:l,errors:a}}static sanitize(e,t={}){let{maxLength:r=this.DEFAULT_MAX_LENGTH,replacementChar:i=this.DEFAULT_REPLACEMENT}=t;if(!e||e.trim().length===0)return"";let s=e.trim();for(s=s.replace(this.INVALID_CHARS_PATTERN,i);s.startsWith(".")&&s.length>1;)s=s.substring(1);for(;s.length>0&&(s.endsWith(".")||s.endsWith(" "));)s=s.slice(0,-1);for(s.includes(i)&&(s=s.split(i).filter(l=>l!=="").join(i));s.startsWith(i);)s=s.slice(i.length);for(;s.endsWith(i);)s=s.slice(0,-i.length);let a=this.getBaseName(s);if(this.RESERVED_NAMES.has(a.toUpperCase())){let c=this.getExtension(s);s=a+i+c}if(s.length>r)for(s=s.slice(0,r);s.endsWith(i);)s=s.slice(0,-i.length);return s}static hasInvalidChars(e){return this.INVALID_CHARS_PATTERN.test(e)}static getInvalidChars(e){let t=e.match(this.INVALID_CHARS_PATTERN);return t?[...new Set(t)]:[]}static getBaseName(e){let t=e.lastIndexOf(".");return t===-1||t===0?e:e.substring(0,t)}static getExtension(e){let t=e.lastIndexOf(".");return t===-1||t===0?"":e.substring(t)}};nf.FilenameValidator=Xs;Xs.INVALID_CHARS_PATTERN=/[/\\:*?"<>|\x00-\x1F]/g;Xs.RESERVED_NAMES=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]);Xs.DEFAULT_MAX_LENGTH=200;Xs.DEFAULT_REPLACEMENT="_"});var Ng=v(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.NTriplesSerializer=void 0;var Fg=class{static{o(this,"NTriplesSerializer")}serialize(e,t={}){let r=t.newline??`
|
|
240
|
+
`;return e.length===0?"":e.map(i=>i.toString()).join(r)+r}serializeChunk(e,t){return e.length===0?"":e.map(r=>r.toString()).join(t)+t}};sf.NTriplesSerializer=Fg});var n_=v(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0});af.TurtleSerializer=void 0;var La=Yr(),aF=Ng(),oF={rdf:La.Namespace.RDF.iri.value,rdfs:La.Namespace.RDFS.iri.value,owl:La.Namespace.OWL.iri.value,xsd:La.Namespace.XSD.iri.value,exo:La.Namespace.EXO.iri.value,ems:La.Namespace.EMS.iri.value},Lg=class{static{o(this,"TurtleSerializer")}constructor(){this.nTriplesSerializer=new aF.NTriplesSerializer}serialize(e,t={}){let r=t.newline??`
|
|
241
|
+
`,i=this.composePrefixes(t),s=this.serializePrefixes(i,r),a=this.nTriplesSerializer.serialize(e,{newline:r}).trimEnd();return s?a?`${s}${r}${r}${a}${r}`:`${s}${r}`:a?`${a}${r}`:""}serializePrefixes(e,t){let r=Object.entries(e);return r.length===0?"":r.map(([i,s])=>`@prefix ${i}: <${s}> .`).join(t)}composePrefixes(e){return e.includeDefaultPrefixes??!0?{...oF,...e.prefixes??{}}:{...e.prefixes??{}}}serializeTriplesOnly(e,t){return this.nTriplesSerializer.serializeChunk(e,t).trimEnd()}};af.TurtleSerializer=Lg});var a_=v(of=>{"use strict";Object.defineProperty(of,"__esModule",{value:!0});of.JSONLDSerializer=void 0;var i_=Qe(),s_=Ot(),cF=lt(),ka=Yr(),uF={rdf:ka.Namespace.RDF.iri.value,rdfs:ka.Namespace.RDFS.iri.value,owl:ka.Namespace.OWL.iri.value,xsd:ka.Namespace.XSD.iri.value,exo:ka.Namespace.EXO.iri.value,ems:ka.Namespace.EMS.iri.value},kg=class{static{o(this,"JSONLDSerializer")}toDocument(e,t={}){let r={...uF,...t.context??{}},i=new Map;for(let s of e){let a=this.subjectToId(s.subject),c=this.compactIri(s.predicate.value,r),u=this.objectToJSONLD(s.object,r),l=i.get(a)??{"@id":a},f=l[c];f===void 0?l[c]=u:Array.isArray(f)?f.push(u):l[c]=[f,u],i.set(a,l)}return{"@context":r,"@graph":Array.from(i.values())}}serialize(e,t={}){let r=this.toDocument(e,t),i=t.pretty?t.indent??2:void 0;return JSON.stringify(r,null,i)}subjectToId(e){return e instanceof i_.IRI?e.value:e instanceof s_.BlankNode?`_:${e.id}`:String(e)}compactIri(e,t){for(let[r,i]of Object.entries(t))if(e.startsWith(i)){let s=e.slice(i.length);if(s.length>0)return`${r}:${s}`}return e}objectToJSONLD(e,t){if(e instanceof i_.IRI)return{"@id":e.value};if(e instanceof s_.BlankNode)return{"@id":`_:${e.id}`};if(e instanceof cF.Literal){let r={"@value":e.value};return e.datatype?r["@type"]=this.compactIri(e.datatype.value,t):e.language&&(r["@language"]=e.language,e.hasDirection()&&e.direction&&(r["@direction"]=e.direction)),r}return e}};of.JSONLDSerializer=kg});var $g=v(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});cf.NTriplesParser=void 0;var lF=xi(),o_=Qe(),Mg=lt(),fF=Ot(),Ma=Yr(),hF={rdf:Ma.Namespace.RDF.iri.value,rdfs:Ma.Namespace.RDFS.iri.value,owl:Ma.Namespace.OWL.iri.value,xsd:Ma.Namespace.XSD.iri.value,exo:Ma.Namespace.EXO.iri.value,ems:Ma.Namespace.EMS.iri.value},jg=class{static{o(this,"NTriplesParser")}parse(e,t={}){let r={prefixes:{...hF,...t.prefixes??{}},strict:t.strict??!1},i=[];return e.split(/\r?\n/).forEach((a,c)=>{let u=a.trim();!u||u.startsWith("#")||i.push(this.parseLine(u,c+1,r))}),i}parseLine(e,t,r){if(!e.endsWith("."))throw new Error(`Invalid RDF statement at line ${t}: missing '.' terminator`);let s=e.slice(0,-1).trim(),a=this.parseSubject(s,t,r);s=a.rest.trim();let c=this.parsePredicate(s,t,r);s=c.rest.trim();let u=this.parseObject(s,t,r);if(s=u.rest.trim(),s.length>0)throw new Error(`Unexpected tokens after object at line ${t}`);return new lF.Triple(a.node,c.node,u.node)}parseSubject(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):e.startsWith("_:")?this.consumeBlankNode(e,t):this.consumePrefixedName(e,t,r)}parsePredicate(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):this.consumePrefixedName(e,t,r)}parseObject(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):e.startsWith("_:")?this.consumeBlankNode(e,t):e.startsWith('"')?this.consumeLiteral(e,t,r):this.consumePrefixedName(e,t,r)}consumePrefixedName(e,t,r){let i=e.match(/^([a-zA-Z_][\w-]*):([^\s]+)(?:\s+(.*))?$/);if(!i)throw new Error(`Invalid token at line ${t}: ${e}`);let[,s,a,c]=i,u=r.prefixes[s];if(!u)throw new Error(`Unknown prefix "${s}" at line ${t}`);return{node:new o_.IRI(`${u}${a}`),rest:(c??"").trimStart()}}consumeIRI(e,t,r){let i=this.findClosingBracket(e,"<",">");if(i===-1)throw new Error(`Invalid IRI at line ${t}`);let s=e.slice(1,i),a=new o_.IRI(s),c=e.slice(i+1).trimStart();return{node:a,rest:c}}consumeBlankNode(e,t){let r=e.match(/^_:(\w+)(?:\s+(.*))?$/);if(!r)throw new Error(`Invalid blank node identifier at line ${t}`);let[,i,s]=r;return{node:new fF.BlankNode(i),rest:(s??"").trimStart()}}consumeLiteral(e,t,r){let{value:i,rest:s}=this.consumeQuotedString(e,t),a=s.trimStart();if(a.startsWith("^^")){a=a.slice(2).trimStart();let c=a.startsWith("<")?this.consumeIRI(a,t,r):this.consumePrefixedName(a,t,r);return{node:new Mg.Literal(i,c.node),rest:c.rest}}if(a.startsWith("@")){let c=a.match(/^@([a-zA-Z-]+)(?:\s+(.*))?$/);if(!c)throw new Error(`Invalid language tag at line ${t}`);let[,u,l]=c;return{node:new Mg.Literal(i,void 0,u),rest:(l??"").trimStart()}}return{node:new Mg.Literal(i),rest:a}}consumeQuotedString(e,t){if(!e.startsWith('"'))throw new Error(`Expected quoted string at line ${t}`);let r="";for(let i=1;i<e.length;i++){let s=e[i];if(s==="\\"){if(i+1>=e.length)throw new Error(`Invalid escape sequence at line ${t}`);let a=e[i+1];switch(a){case"t":r+=" ",i+=1;break;case"b":r+="\b",i+=1;break;case"n":r+=`
|
|
242
|
+
`,i+=1;break;case"r":r+="\r",i+=1;break;case"f":r+="\f",i+=1;break;case'"':r+='"',i+=1;break;case"\\":r+="\\",i+=1;break;case"u":{let c=e.slice(i+2,i+6);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw new Error(`Invalid \\u escape at line ${t}`);r+=String.fromCharCode(parseInt(c,16)),i+=5;break}case"U":{let c=e.slice(i+2,i+10);if(c.length!==8||!/^[0-9a-fA-F]{8}$/.test(c))throw new Error(`Invalid \\U escape at line ${t}`);r+=String.fromCodePoint(parseInt(c,16)),i+=9;break}default:throw new Error(`Unknown escape sequence \\${a} at line ${t}`)}continue}if(s==='"'){let a=e.slice(i+1);return{value:r,rest:a}}r+=s}throw new Error(`Unterminated string literal at line ${t}`)}findClosingBracket(e,t,r){let i=0;for(let s=0;s<e.length;s++){let a=e[s];if(a===t){i++;continue}if(a===r&&(i--,i===0))return s}return-1}};cf.NTriplesParser=jg});var c_=v(uf=>{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});uf.TurtleParser=void 0;var ja=Yr(),dF=$g(),pF={rdf:ja.Namespace.RDF.iri.value,rdfs:ja.Namespace.RDFS.iri.value,owl:ja.Namespace.OWL.iri.value,xsd:ja.Namespace.XSD.iri.value,exo:ja.Namespace.EXO.iri.value,ems:ja.Namespace.EMS.iri.value},mF=/^@prefix\s+([a-zA-Z_][\w-]*):\s*<([^>]+)>\s*\.$/,Vg=class{static{o(this,"TurtleParser")}constructor(){this.nTriplesParser=new dF.NTriplesParser}parse(e,t={}){let r={...pF,...t.prefixes??{}},i=this.collectStatements(e),s=[];return i.forEach(({statement:a,lineNumber:c})=>{if(this.isPrefixStatement(a)){let l=a.match(mF);if(!l)throw new Error(`Invalid prefix declaration at line ${c}`);let[,f,h]=l;r[f]=h;return}if(a.includes(";")||a.includes(","))throw new Error(`Complex Turtle statements with ';' or ',' are not supported (line ${c})`);let u=this.normalizeShortcuts(a);s.push(this.nTriplesParser.parseLine(u,c,{prefixes:r,strict:!1}))}),s}collectStatements(e){let t=e.split(/\r?\n/),r=[],i="",s=0;if(t.forEach((a,c)=>{let u=a.trim();!u||u.startsWith("#")||(i||(s=c+1),i=i?`${i} ${u}`:u,u.endsWith(".")&&(r.push({statement:i,lineNumber:s}),i=""))}),i)throw new Error(`Unterminated Turtle statement near line ${s}`);return r}isPrefixStatement(e){return e.startsWith("@prefix")}normalizeShortcuts(e){return e.includes(" a ")?e.replace(/\sa\s/g," rdf:type "):e}};uf.TurtleParser=Vg});var u_=v(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});lf.RDFSerializer=void 0;var $a=xi(),Js=Qe(),Zs=lt(),Ug=Ot(),ii=Yr(),gF=n_(),yF=Ng(),vF=a_(),SF=c_(),_F=$g(),bF=1024,wF=`
|
|
243
|
+
`,EF={rdf:ii.Namespace.RDF.iri.value,rdfs:ii.Namespace.RDFS.iri.value,owl:ii.Namespace.OWL.iri.value,xsd:ii.Namespace.XSD.iri.value,exo:ii.Namespace.EXO.iri.value,ems:ii.Namespace.EMS.iri.value},Bg=class{static{o(this,"RDFSerializer")}constructor(e){this.store=e,this.turtleSerializer=new gF.TurtleSerializer,this.nTriplesSerializer=new yF.NTriplesSerializer,this.jsonldSerializer=new vF.JSONLDSerializer,this.turtleParser=new SF.TurtleParser,this.nTriplesParser=new _F.NTriplesParser}async serialize(e,t={}){let r=await this.store.match();return this.serializeTriples(r,e,t)}serializeTriples(e,t,r={}){switch(t){case"turtle":return this.turtleSerializer.serialize(e,{prefixes:r.prefixes,includeDefaultPrefixes:r.includeDefaultPrefixes,newline:r.newline});case"n-triples":return this.nTriplesSerializer.serialize(e,{newline:r.newline});case"json-ld":return this.jsonldSerializer.serialize(e,{context:r.prefixes,pretty:r.pretty,indent:r.indent});default:throw new Error(`Unsupported serialization format: ${t}`)}}stream(e,t={}){let r=t.newline??wF,i=t.batchSize??bF,s=t.includeDefaultPrefixes,a=t.prefixes,c=this,u=!1,l=[],f=[],h=0,d=o(async()=>{if(!u){if(f=await c.store.match(),e==="json-ld"){let S=c.jsonldSerializer.toDocument(f,{context:a,pretty:!1});l.push(...c.buildJsonLdChunks(S))}else if(e==="turtle"){let S=c.turtleSerializer.serializePrefixes(c.composePrefixes(a,s),r);S&&l.push(`${S}${r}${r}`)}u=!0}},"ensureInitialized");return{async next(){if(await d(),l.length>0)return{value:l.shift(),done:!1};if(e==="json-ld")return{value:void 0,done:!0};if(h>=f.length)return{value:void 0,done:!0};let S=f.slice(h,h+i);h+=S.length;let b="";if(e==="turtle"){let T=c.turtleSerializer.serializeTriplesOnly(S,r);T&&(b=`${T}${r}`)}else e==="n-triples"&&(b=c.nTriplesSerializer.serializeChunk(S,r));return b?{value:b,done:!1}:this.next()},async return(){return l=[],f=[],h=0,{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}async load(e,t,r={}){let i=this.parse(e,t,r);return r.mode!=="append"&&await this.store.clear(),await this.store.addAll(i),i.length}parse(e,t,r={}){switch(t){case"turtle":return this.turtleParser.parse(e,this.buildTurtleParseOptions(r));case"n-triples":return this.nTriplesParser.parse(e,this.buildNTriplesParseOptions(r));case"json-ld":return this.parseJsonLd(e,r);default:throw new Error(`Unsupported serialization format: ${t}`)}}buildTurtleParseOptions(e){return{prefixes:this.composePrefixes(e.prefixes,!0),strict:e.strict}}buildNTriplesParseOptions(e){return{prefixes:this.composePrefixes(e.prefixes,!0),strict:e.strict}}composePrefixes(e,t){return t??!0?{...EF,...e??{}}:{...e??{}}}parseJsonLd(e,t){let r;try{r=JSON.parse(e)}catch(l){throw new Error(`Invalid JSON-LD document: ${l.message}`)}let i=this.composePrefixes(t.prefixes,!0),s=this.extractContext(r),a={...i,...s},c=this.extractGraph(r),u=[];return c.forEach((l,f)=>{if(!l||typeof l!="object"||Array.isArray(l))throw new Error(`Invalid JSON-LD node at index ${f}`);let h=this.parseSubjectFromNode(l,a,f),d=Object.entries(l);for(let[p,S]of d){if(p==="@id"||p==="@context")continue;if(p==="@type"){this.collectTypeTriples(h,S,u,a);continue}let b=this.expandTerm(p,a),T=new Js.IRI(b);this.collectTriplesForValue(h,T,S,u,a)}}),u}extractContext(e){if(!e||typeof e!="object"||Array.isArray(e))return{};let t=e["@context"];if(!t||typeof t!="object"||Array.isArray(t))return{};let r={};return Object.entries(t).forEach(([i,s])=>{typeof s=="string"&&(r[i]=s)}),r}extractGraph(e){if(Array.isArray(e))return e;if(!e||typeof e!="object")return[];let t=e["@graph"];return Array.isArray(t)?t:[e]}parseSubjectFromNode(e,t,r){let i=e["@id"];if(typeof i=="string"){if(i.startsWith("_:"))return new Ug.BlankNode(i.slice(2));if(this.isAbsoluteIri(i))return new Js.IRI(i);let s=this.expandTerm(i,t);return new Js.IRI(s)}return new Ug.BlankNode(`jsonld_${r}`)}collectTypeTriples(e,t,r,i){let s=ii.Namespace.RDF.term("type");(Array.isArray(t)?t:[t]).forEach(c=>{if(typeof c!="string")throw new Error("Invalid @type value in JSON-LD node");let u=this.expandTerm(c,i);r.push(new $a.Triple(e,s,new Js.IRI(u)))})}collectTriplesForValue(e,t,r,i,s){if(r!=null){if(Array.isArray(r)){r.forEach(a=>this.collectTriplesForValue(e,t,a,i,s));return}if(typeof r=="object"){let a=r;if(typeof a["@id"]=="string"){let c=this.parseIdNode(a["@id"],s);i.push(new $a.Triple(e,t,c));return}if(a["@value"]!==void 0){let c=this.parseLiteralObject(a,s);i.push(new $a.Triple(e,t,c));return}}if(typeof r=="string"){i.push(new $a.Triple(e,t,new Zs.Literal(r)));return}if(typeof r=="number"){let a=Number.isInteger(r)?ii.Namespace.XSD.term("integer"):ii.Namespace.XSD.term("decimal");i.push(new $a.Triple(e,t,new Zs.Literal(r.toString(),a)));return}if(typeof r=="boolean"){let a=ii.Namespace.XSD.term("boolean");i.push(new $a.Triple(e,t,new Zs.Literal(r.toString(),a)));return}throw new Error("Unsupported JSON-LD value encountered")}}parseIdNode(e,t){if(e.startsWith("_:"))return new Ug.BlankNode(e.slice(2));if(this.isAbsoluteIri(e))return new Js.IRI(e);let r=this.expandTerm(e,t);return new Js.IRI(r)}parseLiteralObject(e,t){let r=e["@value"];if(typeof r!="string")throw new Error("JSON-LD literal values must be strings");if(typeof e["@language"]=="string"){let i=e["@direction"];return i==="ltr"||i==="rtl"?new Zs.Literal(r,void 0,e["@language"],i):new Zs.Literal(r,void 0,e["@language"])}if(typeof e["@type"]=="string"){let i=this.expandTerm(e["@type"],t);return new Zs.Literal(r,new Js.IRI(i))}return new Zs.Literal(r)}expandTerm(e,t){if(this.isAbsoluteIri(e))return e;let r=e.indexOf(":");if(r>0){let s=e.slice(0,r),a=e.slice(r+1),c=t[s];if(!c)throw new Error(`Unknown prefix "${s}" in JSON-LD document`);return`${c}${a}`}let i=t["@vocab"];if(i)return`${i}${e}`;throw new Error(`Unable to expand JSON-LD term "${e}"`)}isAbsoluteIri(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)}buildJsonLdChunks(e){let t=[],r=JSON.stringify(e["@context"]);return t.push(`{"@context":${r},"@graph":[`),e["@graph"].forEach((i,s)=>{let a=JSON.stringify(i);s>0?t.push(`,${a}`):t.push(a)}),t.push(`]}
|
|
244
|
+
`),t}};lf.RDFSerializer=Bg});var Hg=v(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.TransactionError=es.TripleNotFoundError=es.TripleAlreadyExistsError=void 0;var qg=class extends Error{static{o(this,"TripleAlreadyExistsError")}constructor(e){super(`Triple already exists: ${e.toString()}`),this.name="TripleAlreadyExistsError"}};es.TripleAlreadyExistsError=qg;var Gg=class extends Error{static{o(this,"TripleNotFoundError")}constructor(e){super(`Triple not found: ${e.toString()}`),this.name="TripleNotFoundError"}};es.TripleNotFoundError=Gg;var Wg=class extends Error{static{o(this,"TransactionError")}constructor(e){super(e),this.name="TransactionError"}};es.TransactionError=Wg});var hf=v(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.LRUCache=void 0;var zg=class{static{o(this,"LRUCache")}constructor(e){this.maxSize=e,this.cache=new Map}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};ff.LRUCache=zg});var l_=v(pf=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});pf.InMemoryTripleStore=void 0;var ts=Hg(),df=Qe(),TF=Ot(),AF=lt(),xF=Yr(),CF=hf(),IF=xF.Namespace.XSD.term("string").value,OF=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,Va="__default__",Qg=class n{static{o(this,"InMemoryTripleStore")}constructor(){this.triples=new Map,this.spo=new Map,this.sop=new Map,this.pso=new Map,this.pos=new Map,this.osp=new Map,this.ops=new Map,this.queryCache=new CF.LRUCache(1e3),this.uuidIndex=new Map,this.namedGraphs=new Map}async add(e){let t=this.getTripleKey(e);if(this.triples.has(t))return;this.triples.set(t,e);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);this.addToIndex(this.spo,r,i,s),this.addToIndex(this.sop,r,s,i),this.addToIndex(this.pso,i,r,s),this.addToIndex(this.pos,i,s,r),this.addToIndex(this.osp,s,r,i),this.addToIndex(this.ops,s,i,r),this.addToUUIDIndex(e.subject),this.queryCache.clear()}async remove(e){let t=this.getTripleKey(e);if(!this.triples.has(t))return!1;this.triples.delete(t);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);return this.removeFromIndex(this.spo,r,i,s),this.removeFromIndex(this.sop,r,s,i),this.removeFromIndex(this.pso,i,r,s),this.removeFromIndex(this.pos,i,s,r),this.removeFromIndex(this.osp,s,r,i),this.removeFromIndex(this.ops,s,i,r),this.queryCache.clear(),!0}async has(e){let t=this.getTripleKey(e);return this.triples.has(t)}async match(e,t,r){let i=this.getMatchCacheKey(e,t,r),s=this.queryCache.get(i);if(s!==void 0)return s;let a;return!e&&!t&&!r?a=Array.from(this.triples.values()):e&&t&&r?a=this.matchSPO(e,t,r):e&&t?a=this.matchSP(e,t):e&&r?a=this.matchSO(e,r):t&&r?a=this.matchPO(t,r):e?a=this.matchS(e):t?a=this.matchP(t):r?a=this.matchO(r):a=[],this.queryCache.set(i,a),a}async addAll(e){for(let t of e)await this.add(t)}async removeAll(e){let t=0;for(let r of e)await this.remove(r)&&t++;return t}async clear(){this.triples.clear(),this.spo.clear(),this.sop.clear(),this.pso.clear(),this.pos.clear(),this.osp.clear(),this.ops.clear(),this.uuidIndex.clear(),this.queryCache.clear()}async count(){return this.triples.size}async subjects(){let e=new Set;for(let t of this.triples.values())e.add(t.subject);return Array.from(e)}async predicates(){let e=new Set;for(let t of this.triples.values())e.add(t.predicate);return Array.from(e)}async objects(){let e=new Set;for(let t of this.triples.values())e.add(t.object);return Array.from(e)}async beginTransaction(){return new Yg(this)}async findSubjectsByUUID(e){return this.findSubjectsByUUIDSync(e)}findSubjectsByUUIDSync(e){let t=e.toLowerCase(),r=this.uuidIndex.get(t);if(!r||r.size===0)return[];let i=[];for(let s of r)this.spo.has(`i:${s}`)&&i.push(new df.IRI(s));return i}addToUUIDIndex(e){if(!(e instanceof df.IRI))return;let t=e.value,r=t.match(OF);if(r)for(let i of r){let s=i.toLowerCase();this.uuidIndex.has(s)||this.uuidIndex.set(s,new Set),this.uuidIndex.get(s).add(t)}}matchSPO(e,t,r){let i=this.getNodeKey(e),s=this.getNodeKey(t),a=this.getNodeKey(r),c=this.spo.get(i);if(!c)return[];let u=c.get(s);if(!u)return[];if(u.has(a)){let l=this.buildTripleKey(i,s,a),f=this.triples.get(l);return f?[f]:[]}return[]}matchSP(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.spo.get(r);if(!s)return[];let a=s.get(i);return a?this.getTriplesByKeys(Array.from(a).map(c=>this.buildTripleKey(r,i,c))):[]}matchSO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.sop.get(r);if(!s)return[];let a=s.get(i);return a?this.getTriplesByKeys(Array.from(a).map(c=>this.buildTripleKey(r,c,i))):[]}matchPO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.pos.get(r);if(!s)return[];let a=s.get(i);return a?this.getTriplesByKeys(Array.from(a).map(c=>this.buildTripleKey(c,r,i))):[]}matchS(e){let t=this.getNodeKey(e),r=this.spo.get(t);if(!r)return[];let i=[];for(let[s,a]of r.entries())for(let c of a)i.push(this.buildTripleKey(t,s,c));return this.getTriplesByKeys(i)}matchP(e){let t=this.getNodeKey(e),r=this.pso.get(t);if(!r)return[];let i=[];for(let[s,a]of r.entries())for(let c of a)i.push(this.buildTripleKey(s,t,c));return this.getTriplesByKeys(i)}matchO(e){let t=this.getNodeKey(e),r=this.osp.get(t);if(!r)return[];let i=[];for(let[s,a]of r.entries())for(let c of a)i.push(this.buildTripleKey(s,c,t));return this.getTriplesByKeys(i)}getTriplesByKeys(e){let t=[];for(let r of e){let i=this.triples.get(r);i&&t.push(i)}return t}addToIndex(e,t,r,i){e.has(t)||e.set(t,new Map);let s=e.get(t);s.has(r)||s.set(r,new Set),s.get(r).add(i)}removeFromIndex(e,t,r,i){let s=e.get(t);if(!s)return;let a=s.get(r);a&&(a.delete(i),a.size===0&&s.delete(r),s.size===0&&e.delete(t))}getTripleKey(e){let t=this.getNodeKey(e.subject),r=this.getNodeKey(e.predicate),i=this.getNodeKey(e.object);return this.buildTripleKey(t,r,i)}buildTripleKey(e,t,r){return`${e}|${t}|${r}`}getNodeKey(e){if(e instanceof df.IRI)return`i:${e.value}`;if(e instanceof TF.BlankNode)return`b:${e.id}`;if(e instanceof AF.Literal){let t=`l:${e.value}`;return e.datatype&&e.datatype.value!==IF?t+=`^^${e.datatype.value}`:e.language&&(t+=`@${e.language}`),t}return""}getMatchCacheKey(e,t,r){let i=e?this.getNodeKey(e):"?",s=t?this.getNodeKey(t):"?",a=r?this.getNodeKey(r):"?";return`${i}|${s}|${a}`}getGraphKey(e){return e?e.value:Va}getOrCreateGraphStore(e){let t=this.getGraphKey(e);return t===Va?this:(this.namedGraphs.has(t)||this.namedGraphs.set(t,new n),this.namedGraphs.get(t))}async addToGraph(e,t){await this.getOrCreateGraphStore(t).add(e)}async removeFromGraph(e,t){let r=this.getGraphKey(t);if(r===Va)return this.remove(e);let i=this.namedGraphs.get(r);return i?i.remove(e):!1}async matchInGraph(e,t,r,i){let s=this.getGraphKey(i);if(s===Va)return this.match(e,t,r);let a=this.namedGraphs.get(s);return a?a.match(e,t,r):[]}async getNamedGraphs(){return Array.from(this.namedGraphs.keys()).map(e=>new df.IRI(e))}async hasGraph(e){let t=this.namedGraphs.get(e.value);return t?await t.count()>0:!1}async clearGraph(e){let t=this.getGraphKey(e);if(t===Va){await this.clear();return}let r=this.namedGraphs.get(t);r&&(await r.clear(),this.namedGraphs.delete(t))}async countInGraph(e){let t=this.getGraphKey(e);if(t===Va)return this.count();let r=this.namedGraphs.get(t);return r?r.count():0}};pf.InMemoryTripleStore=Qg;var Yg=class{static{o(this,"InMemoryTransaction")}constructor(e){this.store=e,this.operations=[],this.committed=!1,this.rolledBack=!1}async add(e){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");this.operations.push({type:"add",triple:e})}async remove(e){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");return this.operations.push({type:"remove",triple:e}),!0}async commit(){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");for(let e of this.operations)e.type==="add"?await this.store.add(e.triple):await this.store.remove(e.triple);this.committed=!0,this.operations=[]}async rollback(){if(this.committed)throw new ts.TransactionError("Transaction already committed");if(this.rolledBack)throw new ts.TransactionError("Transaction already rolled back");this.operations=[],this.rolledBack=!0}}});var Xg=v(mf=>{"use strict";Object.defineProperty(mf,"__esModule",{value:!0});mf.RDFVocabularyMapper=void 0;var Br=xi(),f_=Qe(),ye=Yr(),Kg=class{static{o(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",ye.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",ye.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",ye.Namespace.RDFS.term("subClassOf")],["exo__Property_range",ye.Namespace.RDFS.term("range")],["exo__Property_domain",ye.Namespace.RDFS.term("domain")],["exo__Property_superProperty",ye.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Br.Triple(ye.Namespace.EXO.term("Asset"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.RDFS.term("Resource"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Class"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.RDFS.term("Class"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.RDF.term("Property"))),e.push(new Br.Triple(ye.Namespace.EMS.term("Task"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.EXO.term("Asset"))),e.push(new Br.Triple(ye.Namespace.EMS.term("Project"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.EXO.term("Asset"))),e.push(new Br.Triple(ye.Namespace.EMS.term("Area"),ye.Namespace.RDFS.term("subClassOf"),ye.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Br.Triple(ye.Namespace.EXO.term("Instance_class"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDF.term("type"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Asset_isDefinedBy"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("isDefinedBy"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Class_superClass"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("subClassOf"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property_range"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("range"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property_domain"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("domain"))),e.push(new Br.Triple(ye.Namespace.EXO.term("Property_superProperty"),ye.Namespace.RDFS.term("subPropertyOf"),ye.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof f_.IRI)s=r;else{let a=r.match(/^(ems|exo)__(.+)$/);if(a){let[,c,u]=a;s=(c==="ems"?ye.Namespace.EMS:ye.Namespace.EXO).term(u)}else s=new f_.IRI(r)}return new Br.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};mf.RDFVocabularyMapper=Kg});var Zg=v(Mn=>{"use strict";var PF=Mn&&Mn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},DF=Mn&&Mn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},RF=Mn&&Mn.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NoteToRDFConverter=void 0;var h_=Le(),Nr=xi(),Oc=Qe(),an=lt(),d_=Ot(),Sr=Yr(),FF=ct(),NF=Xg(),Lr=Lp(),Jg=class{static{o(this,"NoteToRDFConverter")}constructor(e){this.vault=e,this.OBSIDIAN_VAULT_SCHEME="obsidian://vault/",this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.uuidIndex=null,this.vocabularyMapper=new NF.RDFVocabularyMapper}setUuidIndex(e){this.uuidIndex=e}clearUuidIndex(){this.uuidIndex=null}async convertNote(e){let t=this.vault.getFrontmatter(e);return t?Lr.Exo003Parser.isExo003Format(t)?this.convertExo003Note(e,t):this.convertLegacyNote(e,t):[]}async convertLegacyNote(e,t){let r=[],i=this.notePathToIRI(e.path),s=Sr.Namespace.EXO.term("Asset_fileName");r.push(new Nr.Triple(i,s,new an.Literal(e.basename)));for(let[c,u]of Object.entries(t)){if(!this.isExocortexProperty(c))continue;let l=this.propertyKeyToIRI(c),f=Array.isArray(u)?u:[u];for(let h of f)if(c==="exo__Instance_class"){let d=this.valueToClassURI(h);r.push(new Nr.Triple(i,l,d))}else{let d=await this.valueToRDFObject(h,e);if(r.push(new Nr.Triple(i,l,d)),this.vocabularyMapper.hasMappingFor(c)&&d instanceof Oc.IRI){let p=this.vocabularyMapper.generateMappedTriple(i,c,d);p&&r.push(p)}}if(c==="exo__Instance_class")for(let h of f){let d=this.expandClassValue(h);if(d){let p=Sr.Namespace.RDF.term("type");r.push(new Nr.Triple(i,p,d))}}}let a=await this.convertBodyWikilinks(e,i);return r.push(...a),r}async convertExo003Note(e,t){let r=Lr.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Lr.Exo003MetadataType.Namespace:break;case Lr.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Lr.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Lr.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Lr.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new Oc.IRI(t.uri);return[new Nr.Triple(r,Sr.Namespace.OWL.term("sameAs"),i),new Nr.Triple(i,Sr.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new Nr.Triple(r,Sr.Namespace.OWL.term("sameAs"),new d_.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Lr.Exo003Parser.toTriple(t,i);r.push(s);let a=this.notePathToIRI(e.path);r.push(new Nr.Triple(a,Sr.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.createExo003ReferenceResolver(e),c=a(t.subject),u=a(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(u.type!=="iri")throw new Error("Body predicate must be an IRI");let l=c.type==="iri"?new Oc.IRI(c.value):new d_.BlankNode(c.value),f=new Oc.IRI(u.value),h=Lr.Exo003Parser.toLiteral(t,s.trim());r.push(new Nr.Triple(l,f,h));let d=this.notePathToIRI(e.path);r.push(new Nr.Triple(d,Sr.Namespace.RDF.term("value"),l))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t;if(this.uuidIndex){let a=this.uuidIndex.get(i);if(a)return{type:a.type,value:a.uri}}if(!r&&t.includes("://"))return{type:"iri",value:t};let s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let a=this.vault.getFrontmatter(s);if(a&&Lr.Exo003Parser.isExo003Format(a)){let c=Lr.Exo003Parser.parse(a);if(c.success&&c.metadata){let u=c.metadata;if(u.metadata===Lr.Exo003MetadataType.Anchor||u.metadata===Lr.Exo003MetadataType.Namespace)return{type:"iri",value:u.uri};if(u.metadata===Lr.Exo003MetadataType.BlankNode)return{type:"blank",value:u.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return{type:"literal",value:t}}}async convertVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e)try{let i=await this.convertNote(r);t.push(...i)}catch(i){console.warn(`\u26A0\uFE0F Skipping file with invalid IRI: ${r.path}`),console.warn(` Reason: ${i instanceof Error?i.message:String(i)}`);continue}return t}notePathToIRI(e){let t=encodeURI(e);return new Oc.IRI(`${this.OBSIDIAN_VAULT_SCHEME}${t}`)}isExocortexProperty(e){return e.startsWith("exo__")||e.startsWith("ems__")}propertyKeyToIRI(e){if(e.startsWith("exo__")){let t=e.substring(5);return Sr.Namespace.EXO.term(t)}if(e.startsWith("ems__")){let t=e.substring(5);return Sr.Namespace.EMS.term(t)}throw new Error(`Invalid property key: ${e}`)}async valueToRDFObject(e,t){if(typeof e=="string"){let r=this.removeQuotes(e),i=this.extractWikilink(r);if(i){let s=this.vault.getFirstLinkpathDest(i,t.path);if(s)return this.notePathToIRI(s.path);if(this.isClassReference(i)){let a=this.expandClassValue(i);if(a)return a}return new an.Literal(r)}if(this.isClassReference(r)){let s=this.expandClassValue(r);if(s)return s}return this.isISO8601DateTime(r)?new an.Literal(r,Sr.Namespace.XSD.term("dateTime")):new an.Literal(r)}return typeof e=="boolean"?new an.Literal(e.toString()):typeof e=="number"?new an.Literal(e.toString(),Sr.Namespace.XSD.term("decimal")):e instanceof Date?new an.Literal(e.toISOString(),Sr.Namespace.XSD.term("dateTime")):new an.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(/^\[\[([^\]|]+)(?:\|[^\]]+)?\]\]$/);return t?t[1]:null}valueToClassURI(e){if(typeof e!="string")return new an.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);return s||new an.Literal(t)}isClassReference(e){return(e.startsWith("ems__")||e.startsWith("exo__"))&&!/\s/.test(e)}expandClassValue(e){let t=this.removeQuotes(e);if(t.startsWith("ems__")){let r=t.substring(5);return Sr.Namespace.EMS.term(r)}if(t.startsWith("exo__")){let r=t.substring(5);return Sr.Namespace.EXO.term(r)}return null}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.extractBodyWikilinks(s),c=Sr.Namespace.EXO.term("Asset_bodyLink");for(let u of a){let l=this.vault.getFirstLinkpathDest(u,e.path);if(l){let f=this.notePathToIRI(l.path);r.push(new Nr.Triple(t,c,f))}else if(this.isClassReference(u)){let f=this.expandClassValue(u);f?r.push(new Nr.Triple(t,c,f)):r.push(new Nr.Triple(t,c,new an.Literal(u)))}else r.push(new Nr.Triple(t,c,new an.Literal(u)))}}catch{}return r}};Mn.NoteToRDFConverter=Jg;Mn.NoteToRDFConverter=Jg=PF([(0,h_.injectable)(),RF(0,(0,h_.inject)(FF.DI_TOKENS.IVaultAdapter)),DF("design:paramtypes",[Object])],Jg)});var ey=v((hq,p_)=>{var Ua=class{static{o(this,"Wildcard")}constructor(){return LF||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(Ua.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(Ua.prototype,"termType",{enumerable:!0,value:"Wildcard"});var LF=new Ua;p_.exports.Wildcard=Ua});var g_=v((pq,m_)=>{var kF=(function(){var n=o(function(x,A,P,F){for(P=P||{},F=x.length;F--;P[x[F]]=A);return P},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],r=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],a=[1,27],c=[13,16,45,197,224,229,308],u=[28,29,53],l=[28,53],f=[1,42],h=[1,45],d=[1,41],p=[1,44],S=[123,126],b=[1,67],T=[39,45,87],I=[13,16,45,197,224,308],O=[1,87],L=[2,281],M=[1,86],G=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Ee=[6,28,29,53,63,70,73,81,83,85],je=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],Me=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],q=[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],ie=[13,16,308],Se=[112,132,327,334],nt=[13,16,112,132,308],Ke=[1,111],at=[1,117],Ue=[112,132,327,328,334],Be=[13,16,112,132,308,328],ke=[28,29,45,53,87],Q=[1,138],k=[1,151],qe=[1,128],Xe=[1,127],V=[1,129],me=[1,140],Ie=[1,141],z=[1,142],Oe=[1,143],Pe=[1,144],Te=[1,145],De=[1,147],he=[1,148],Ae=[2,457],ge=[1,158],xe=[1,159],Re=[1,160],Z=[1,152],se=[1,153],ae=[1,156],ee=[1,171],te=[1,172],re=[1,173],ne=[1,174],oe=[1,175],ce=[1,176],ue=[1,167],le=[1,168],X=[1,169],fe=[1,170],$e=[1,157],Fe=[1,166],be=[1,161],w=[1,162],E=[1,163],_=[1,164],C=[1,165],W=[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],it=[1,195],ut=[6,31,73,81,83,85],we=[2,285],j=[1,199],$=[1,201],U=[6,31,70,73,81,83,85],H=[2,283],ve=[1,207],Ge=[1,218],We=[1,223],Ut=[1,219],Or=[1,225],$r=[1,226],hr=[1,224],F1=[6,63,70,73,81,83,85],N1=[1,236],L1=[2,334],k1=[1,243],M1=[1,241],Bt=[6,193],xu=[2,349],j1=[2,339],Bi=[28,128],$1=[47,48,193,272],Cu=[47,48,193,242,272],Sa=[47,48,193,242,246,272],_a=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Nt=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],V1=[1,271],U1=[1,270],Et=[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],B1=[1,281],q1=[1,280],dr=[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],zo=[45,89],Iu=[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],Ou=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Pu=[31,89],Du=[48,87],ws=[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],Qn=[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],G1=[1,313],ba=[6,85],hd=[6,31,81,83,85],W1=[2,361],yi=[2,353],Es=[1,343],Qo=[31,112,335],vi=[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],dd=[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],H1=[6,109,193],Ts=[31,112],Tt=[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],pd=[1,390],md=[1,391],qi=[13,16,87,197,308,314],z1=[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],Ru=[1,417],Fu=[1,418],Q1=[13,16,48,197,229,308],Gi=[6,31,85],Y1=[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],gd=[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],As=[29,31,85,112,159,160,161,163,164],Nu=[1,443],Lu=[1,444],K1=[1,449],xs=[31,112,193,232,318,335],ku=[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],X1=[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],yd=[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],Yo=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Ko=[31,45],J1=[1,507],Z1=[1,508],e2=[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],Mu=[29,31,85,112,159,160,161,163,164,335],Cs=[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],t2=[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],r2=[2,352],vd=[13,16,197,308,314],n2=[1,565],wa=[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],i2=[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],Si=[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],s2=[13,16,87,308],_i=[2,364],Ea=[29,31,85,112,159,160,161,163,164,193,232,318,335],ju=[31,112,193,232,272,318,335],bi=[2,359],a2=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],$u=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],o2=[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],c2=[2,347],Sd={trace:o(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:o(function(A,P,F,Y,_e,m,mr){var g=m.length-1;switch(_e){case 1:if(m[g-1]=m[g-1]||{},Ce.base&&(m[g-1].base=Ce.base),Ce.base="",m[g-1].prefixes=Ce.prefixes,Ce.prefixes=null,Ce.pathOnly){if(m[g-1].type==="path"||"termType"in m[g-1])return m[g-1];throw new Error("Received full SPARQL query in path only mode")}else if(m[g-1].type==="path"||"termType"in m[g-1])throw new Error("Received only path in full SPARQL mode");if(m[g-1].type==="update"){let st={};for(let dt of m[g-1].updates)if(dt.updateType==="insert"){let He={};for(let Ze of dt.insert)if(Ze.type==="bgp"||Ze.type==="graph")for(let Pr of Ze.triples)Pr.subject.termType==="BlankNode"&&(He[Pr.subject.value]=!0),Pr.predicate.termType==="BlankNode"&&(He[Pr.predicate.value]=!0),Pr.object.termType==="BlankNode"&&(He[Pr.object.value]=!0);for(let Ze of Object.keys(He)){if(st[Ze])throw new Error("Detected reuse blank node across different INSERT DATA clauses");st[Ze]=!0}}}return m[g-1];case 2:this.$={...m[g-1],...m[g],type:"query"};break;case 4:Ce.base=Xo(m[g]);break;case 5:Ce.prefixes||(Ce.prefixes={}),m[g-1]=m[g-1].substr(0,m[g-1].length-1),m[g]=Xo(m[g]),Ce.prefixes[m[g-1]]=m[g];break;case 6:this.$={...m[g-3],...Ps(m[g-2]),...m[g-1],...m[g]};break;case 7:if(!Ce.skipValidation&&(Cd(m[g-3].variables.map(dt=>xd(dt.expression))).some(dt=>dt.aggregation==="count"&&!(dt.expression instanceof Vu))||m[g].group)){for(let dt of m[g-3].variables)if(dt.termType==="Variable"){if(!m[g].group||!m[g].group.map(He=>Ca(He)).includes(Ca(dt)))throw Error("Projection of ungrouped variable (?"+Ca(dt)+")")}else if(xd(dt.expression).length===0){let He=EA(dt.expression);for(let Ze of He)if(!m[g].group||!m[g].group.map||!m[g].group.map(Pr=>Ca(Pr)).includes(Ca(Ze)))throw Error("Use of ungrouped variable in projection of operation (?"+Ca(Ze)+")")}}let Jn=m[g-1].where.filter(st=>st.type==="query");if(Jn.length>0){let st=m[g-3].variables.filter(He=>He.variable&&He.variable.value).map(He=>He.variable.value),dt=Cd(Jn.map(He=>He.variables)).map(He=>He.value||He.variable.value);for(let He of st)if(dt.indexOf(He)>=0)throw Error("Target id of 'AS' (?"+He+") already used in subquery")}this.$=yt(m[g-3],Ps(m[g-2]),m[g-1],m[g]);break;case 8:this.$=yt({queryType:"CONSTRUCT",template:m[g-3]},Ps(m[g-2]),m[g-1],m[g]);break;case 9:this.$=yt({queryType:"CONSTRUCT",template:m[g-2]=m[g-2]?m[g-2].triples:[]},Ps(m[g-5]),{where:[{type:"bgp",triples:Os([],m[g-2])}]},m[g]);break;case 10:this.$=yt({queryType:"DESCRIBE",variables:m[g-3]==="*"?[new Vu]:m[g-3]},Ps(m[g-2]),m[g-1],m[g]);break;case 11:this.$=yt({queryType:"ASK"},Ps(m[g-2]),m[g-1],m[g]);break;case 12:this.$=yt(m[g-1],{variables:[new Vu]});break;case 13:let rc=m[g].map(st=>st.value||st.variable.value),Ia=TA(rc);if(Ia.length>0)throw Error("Two or more of the resulting columns have the same name (?"+Ia[0]+")");this.$=yt(m[g-1],{variables:m[g]});break;case 14:this.$=yt({queryType:"SELECT"},m[g]&&(m[g-1]=pr(m[g]),m[g]={},m[g][m[g-1]]=!0,m[g]));break;case 16:case 27:this.$=Ta(m[g-3],{variable:m[g-1]});break;case 17:case 18:this.$=yt(m[g-3],m[g-2],m[g-1],m[g],{type:"query"});break;case 19:case 58:this.$={iri:m[g],named:!!m[g-1]};break;case 20:this.$={where:m[g].patterns};break;case 21:this.$=yt(m[g-1],m[g]);break;case 22:this.$=yt(m[g-2],m[g-1],m[g]);break;case 23:this.$={group:m[g]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Ta(m[g]);break;case 26:this.$=Ta(m[g-1]);break;case 29:this.$={having:m[g]};break;case 30:this.$={order:m[g]};break;case 32:this.$=Ta(m[g],{descending:!0});break;case 35:this.$={limit:xa(m[g])};break;case 36:this.$={offset:xa(m[g])};break;case 37:this.$={limit:xa(m[g-2]),offset:xa(m[g])};break;case 38:this.$={limit:xa(m[g]),offset:xa(m[g-2])};break;case 39:case 43:this.$={type:"values",values:m[g]};break;case 40:case 84:this.$=m[g-1].map(st=>({[m[g-3]]:st}));break;case 41:case 85:this.$=m[g-1].map(()=>({}));break;case 42:case 86:var Xn=m[g-4].length;m[g-4]=m[g-4].map(_d),this.$=m[g-1].map(function(st){if(st.length!==Xn)throw Error("Inconsistent VALUES length");for(var dt={},He=0;He<Xn;He++)dt["?"+m[g-4][He].value]=st[He];return dt});break;case 44:case 65:case 100:case 126:case 175:this.$=m[g-1];break;case 45:this.$={type:"update",updates:wi(m[g-2],m[g-1])};break;case 46:this.$=yt({type:"load",silent:!!m[g-2],source:m[g-1]},m[g]&&{destination:m[g]});break;case 47:this.$={type:pr(m[g-2]),silent:!!m[g-1],graph:m[g]};break;case 48:this.$={type:pr(m[g-4]),silent:!!m[g-3],source:m[g-2],destination:m[g]};break;case 49:this.$={type:"create",silent:!!m[g-2],graph:{type:"graph",name:m[g]}};break;case 50:this.$={updateType:"insert",insert:S2(m[g])};break;case 51:this.$={updateType:"delete",delete:Pd(S2(m[g]))};break;case 52:this.$={updateType:"deletewhere",delete:Pd(m[g])};break;case 53:this.$={updateType:"insertdelete",...m[g-4],...m[g-3],...Ps(m[g-2],"using"),where:m[g].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=m[g];break;case 55:this.$={delete:Pd(m[g-1]),insert:m[g]||[]};break;case 56:this.$={delete:[],insert:m[g]};break;case 59:this.$={graph:m[g]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:m[g]};break;case 64:this.$={[pr(m[g])]:!0};break;case 66:this.$=m[g-1]?Yn(m[g],[m[g-1]]):Yn(m[g]);break;case 67:var ec=yt(m[g-3]||{triples:[]},{type:"graph",name:m[g-5]});this.$=m[g]?[ec,m[g]]:[ec];break;case 68:case 73:this.$={type:"bgp",triples:Yn(m[g-2],[m[g-1]])};break;case 69:this.$={type:"group",patterns:[m[g-1]]};break;case 70:for(let st of m[g-1].filter(dt=>dt.type==="bind")){let dt=m[g-1].indexOf(st),He=new Set;for(let Ze of m[g-1].slice(0,dt))(Ze.type==="group"||Ze.type==="bgp")&&y2(Ze).forEach(Pr=>He.add(Pr));if(He.has(st.variable.value))throw Error("Variable used to bind is already bound (?"+st.variable.value+")")}this.$={type:"group",patterns:m[g-1]};break;case 71:this.$=m[g-1]?Yn([m[g-1]],m[g]):Yn(m[g]);break;case 72:this.$=m[g]?[m[g-2],m[g]]:m[g-2];break;case 75:this.$=yt(m[g],{type:"optional"});break;case 76:this.$=yt(m[g],{type:"minus"});break;case 77:this.$=yt(m[g],{type:"graph",name:m[g-1]});break;case 78:this.$=yt(m[g],{type:"service",name:m[g-1],silent:!!m[g-2]});break;case 79:this.$={type:"filter",expression:m[g]};break;case 80:this.$={type:"bind",variable:m[g-1],expression:m[g-3]};break;case 89:this.$=Zo(m[g]);break;case 90:this.$=void 0;break;case 91:this.$=m[g-1].length?{type:"union",patterns:Yn(m[g-1].map(wd),[wd(m[g])])}:m[g];break;case 95:this.$={...m[g],function:m[g-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:wi(m[g-2],m[g-1]),distinct:!!m[g-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.$=wi(m[g-2],m[g-1]);break;case 101:this.$=Yn(m[g-2],[m[g-1]]);break;case 102:case 112:this.$=Od(m[g].map(st=>yt(Ei(m[g-1]),st)));break;case 103:this.$=Od(Os(m[g].map(st=>yt(Ei(m[g-1].entity),st)),m[g-1].triples));break;case 105:this.$=Yn([m[g-1]],m[g]);break;case 106:this.$=Yn(m[g]);break;case 107:this.$=Ad(m[g-1],m[g]);break;case 109:case 237:this.$=Ce.factory.namedNode(dA);break;case 110:case 118:this.$=wi(m[g-1],m[g]);break;case 111:this.$=m[g]?{annotation:m[g],object:m[g-1]}:m[g-1];break;case 113:this.$=m[g]?Od(Os(m[g].map(st=>yt(Ei(m[g-1].entity),st)),m[g-1].triples)):m[g-1].triples;break;case 114:this.$=Ad(...m[g-1],m[g]);break;case 116:this.$=Ad(...m[g]);break;case 117:case 159:case 163:this.$=[m[g-1],m[g]];break;case 119:this.$=m[g]?{object:m[g-1],annotation:m[g]}:m[g-1];break;case 120:this.$=m[g-1].length?Aa("|",wi(m[g-1],m[g])):m[g];break;case 121:this.$=m[g-1].length?Aa("/",wi(m[g-1],m[g])):m[g];break;case 122:this.$=m[g]?Aa(m[g],[m[g-1]]):m[g-1];break;case 123:this.$=m[g-1]?Aa(m[g-1],[m[g]]):m[g];break;case 125:case 131:this.$=Aa(m[g-1],[m[g]]);break;case 129:this.$=Aa("|",wi(m[g-2],m[g-1]));break;case 132:case 134:this.$=bA(m[g-1]);break;case 133:case 135:this.$=wA(m[g-1]);break;case 140:this.$={entity:m[g],triples:[]};break;case 145:this.$=_d(m[g]);break;case 149:this.$=Ce.factory.namedNode(u2);break;case 151:case 153:case 158:case 162:this.$=bd(m[g-1],m[g]);break;case 152:this.$=["||",m[g]];break;case 154:this.$=["&&",m[g]];break;case 156:this.$=qt(m[g-1],[m[g-2],m[g]]);break;case 157:this.$=qt(m[g-2]?"notin":"in",[m[g-3],m[g]]);break;case 160:this.$=["+",bd(m[g-1],m[g])];break;case 161:var qu=Kn(m[g-1].value.replace("-",""),m[g-1].datatype);this.$=["-",bd(qu,m[g])];break;case 164:this.$=qt("UPLUS",[m[g]]);break;case 165:this.$=qt(m[g-1],[m[g]]);break;case 166:this.$=qt("UMINUS",[m[g]]);break;case 177:this.$=qt(pr(m[g-1]));break;case 178:this.$=qt(pr(m[g-3]),[m[g-1]]);break;case 179:this.$=Zo(qt(pr(m[g-3]),[m[g-1]]));break;case 180:this.$=qt(pr(m[g-5]),[m[g-3],m[g-1]]);break;case 181:this.$=qt(pr(m[g-7]),[m[g-5],m[g-3],m[g-1]]);break;case 182:this.$=Zo(qt(pr(m[g-7]),[m[g-5],m[g-3],m[g-1]]));break;case 183:this.$=qt(pr(m[g-1]),m[g]);break;case 184:this.$=qt("bound",[_d(m[g-1])]);break;case 185:this.$=qt(m[g-1],[]);break;case 186:this.$=qt(m[g-3],[m[g-1]]);break;case 187:this.$=qt(m[g-2]?"notexists":"exists",[wd(m[g])]);break;case 188:case 189:this.$=Ta(m[g-1],{type:"aggregate",aggregation:pr(m[g-4]),distinct:!!m[g-2]});break;case 190:this.$=Ta(m[g-2],{type:"aggregate",aggregation:pr(m[g-5]),distinct:!!m[g-3],separator:typeof m[g-1]=="string"?m[g-1]:" "});break;case 192:this.$=Kn(m[g]);break;case 193:this.$=yA(m[g-1],pr(m[g].substr(1)));break;case 194:this.$=Kn(m[g-2],m[g]);break;case 195:case 204:this.$=Kn(m[g],l2);break;case 196:case 205:this.$=Kn(m[g],f2);break;case 197:case 206:this.$=Kn(pr(m[g]),h2);break;case 200:this.$=Kn(m[g].toLowerCase(),gA);break;case 201:this.$=Kn(m[g].substr(1),l2);break;case 202:this.$=Kn(m[g].substr(1),f2);break;case 203:this.$=Kn(m[g].substr(1).toLowerCase(),h2);break;case 207:case 208:this.$=g2(m[g],1);break;case 209:case 210:this.$=g2(m[g],3);break;case 211:this.$=Ce.factory.namedNode(Xo(m[g]));break;case 213:var Gu=m[g].indexOf(":"),tc=m[g].substr(0,Gu),Wu=Ce.prefixes[tc];if(!Wu)throw new Error("Unknown prefix: "+tc);var mt=Xo(Wu+m[g].substr(Gu+1));this.$=Ce.factory.namedNode(mt);break;case 214:if(m[g]=m[g].substr(0,m[g].length-1),!(m[g]in Ce.prefixes))throw new Error("Unknown prefix: "+m[g]);var mt=Xo(Ce.prefixes[m[g]]);this.$=Ce.factory.namedNode(mt);break;case 215:this.$=Jo(m[g].replace(/^(_:)/,""));break;case 216:this.$=Jo();break;case 217:case 218:case 232:this.$=Zo(Ed(m[g-3],m[g-2],m[g-1]));break;case 230:case 231:this.$=Zo(m[g-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:m[g-1].push(m[g]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[m[g]];break;case 308:m[g-3].push(m[g-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:m[g-2].push(m[g-1]);break}},"anonymous"),table:[n(e,t,{3:1,4:2,10:3}),{1:[3]},n(r,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),n([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:a},{6:[2,239]},n(c,[2,411],{216:28,217:29}),n(u,[2,249],{18:30}),n(u,[2,251],{22:31}),n(l,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:h,33:35,39:[1,37],44:39,55:40,87:d,139:38,307:43,308:p,323:36},n(u,[2,267],{37:46}),n(S,[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:b,87:d},n(T,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),n(e,[2,248]),n(e,[2,245]),n(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),n(I,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:O,29:L,52:84,53:M,56:85},{19:88,28:O,29:L,52:89,53:M,56:85},n(u,[2,253],{26:90}),{28:[1,91],52:92,53:M},n(G,[2,385],{181:93,182:94,183:95,31:[2,383]}),n(Ee,[2,263],{34:96}),n(Ee,[2,261],{44:39,55:40,307:43,139:97,13:f,16:h,87:d,308:p}),n(Ee,[2,262]),n(je,[2,259]),n(Me,[2,143]),n(Me,[2,144]),n([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),n(q,[2,211]),n(q,[2,212]),n(q,[2,213]),n(q,[2,214]),{19:98,28:O,29:L,52:99,53:M,56:85},{6:[2,309],99:100,193:[1,101]},n(ie,[2,311],{101:102,328:[1,103]}),n(Se,[2,317],{104:104,328:[1,105]}),n(nt,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:Ke,114:110},{29:Ke,114:112},{29:Ke,114:113},{118:114,123:[1,115],125:116,126:at},n(Ue,[2,315]),n(Ue,[2,316]),n(Be,[2,319]),n(Be,[2,320]),n(Be,[2,321]),n(S,[2,327]),{13:f,16:h,55:118,307:43,308:p},n(u,[2,12]),n(u,[2,13],{44:66,43:119,45:b,87:d}),n(ke,[2,269]),n(ke,[2,15]),{13:f,16:h,44:136,45:Q,46:120,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(T,[2,14]),n(T,[2,274]),n(T,[2,271]),n(T,[2,272]),n(e,[2,4]),{13:[1,177]},n(W,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},n(c,[2,410]),n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:h,45:[1,193],55:194,197:it,219:189,220:190,223:191,224:[1,192],307:43,308:p},n(I,[2,419]),n(ut,we,{20:196,59:197,69:198,70:j}),n(u,[2,250]),{29:$,57:200},n(ie,[2,279],{54:202,327:[1,203]}),{29:[2,282]},n(U,H,{23:204,58:205,62:206,63:ve}),n(u,[2,252]),{19:208,28:O,29:L,52:209,53:M,56:85},{29:[1,210]},n(l,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,145:212,172:221,185:213,187:214,231:Ut,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(F1,[2,265],{56:85,35:227,52:228,19:229,28:O,29:L,53:M}),n(je,[2,260]),n(U,H,{58:205,62:206,23:230,63:ve}),n(u,[2,268]),{6:[2,45]},n(e,t,{10:3,4:231}),{13:f,16:h,55:232,307:43,308:p},n(ie,[2,312]),{105:233,112:N1,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},n(Se,[2,318]),n(ie,L1,{108:240,133:242,112:k1,132:M1}),n(nt,[2,323]),{112:[1,244]},{112:[2,325]},n(Bt,[2,50]),n(G,xu,{135:245,136:246,143:247,144:248,31:j1,112:j1}),n(Bt,[2,51]),n(Bt,[2,52]),n(Bi,[2,328],{119:249}),{29:Ke,114:250},n(Bi,[2,56]),{29:Ke,114:251},n(S,[2,59]),n(ke,[2,270]),{47:[1,252]},n($1,[2,150]),n(Cu,[2,428],{240:253}),n(Sa,[2,430],{244:254}),n(Sa,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),n(_a,[2,440],{252:264}),n(Nt,[2,448],{260:265}),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,255:154,257:155,264:266,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,255:154,257:155,264:267,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,255:154,257:155,264:268,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Nt,[2,167]),n(Nt,[2,168]),n(Nt,[2,169]),n(Nt,[2,170],{176:269,45:V1,89:U1}),n(Nt,[2,171]),n(Nt,[2,172]),n(Nt,[2,173]),n(Nt,[2,174]),{13:f,16:h,44:136,45:Q,46:272,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:B1,89:q1,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},n(dr,[2,192],{292:[1,286],293:[1,287]}),n(dr,[2,195]),n(dr,[2,196]),n(dr,[2,197]),n(dr,[2,198]),n(dr,[2,199]),n(dr,[2,200]),{13:f,16:h,44:39,55:40,82:k,87:d,139:289,172:291,255:154,257:155,266:290,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},n(zo,[2,452]),n(zo,[2,453]),n(zo,[2,454]),n(zo,[2,455]),n(zo,[2,456]),{279:[2,458]},n(Iu,[2,207]),n(Iu,[2,208]),n(Iu,[2,209]),n(Iu,[2,210]),n(dr,[2,201]),n(dr,[2,202]),n(dr,[2,203]),n(dr,[2,204]),n(dr,[2,205]),n(dr,[2,206]),n(e,[2,5]),n(Ou,[2,297],{88:295}),n(Pu,[2,299],{90:296}),{48:[1,297],87:[1,298]},n(Du,[2,301]),n(W,[2,43]),n(W,[2,82]),n(W,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},n(c,[2,412]),n(ws,[2,123]),n(ws,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),n(Qn,[2,124]),{13:f,16:h,45:[1,311],55:194,89:[1,310],197:it,223:312,225:308,226:309,229:G1,307:43,308:p},n(c,i,{215:10,214:314}),n(Qn,[2,236]),n(Qn,[2,237]),n(ba,[2,6]),n(hd,[2,287],{60:315,72:316,73:[1,317]}),n(ut,[2,286]),{13:f,16:h,45:Q,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},n([6,31,63,70,73,81,83,85],[2,20]),n(G,W1,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:yi,31:yi,85:yi,112:yi,159:yi,160:yi,161:yi,163:yi,164:yi,41:s}),{13:f,16:h,55:331,307:43,308:p},n(ie,[2,280]),n(ba,[2,7]),n(ut,we,{59:197,69:198,20:332,70:j}),n(U,[2,284]),{64:[1,333]},n(U,H,{58:205,62:206,23:334,63:ve}),n(u,[2,254]),n(G,xu,{144:248,30:335,143:336,31:[2,257]}),n(u,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:h,44:39,55:40,87:d,139:342,186:339,190:340,195:341,197:Es,307:43,308:p},n(Qo,[2,389],{44:39,55:40,307:43,190:340,195:341,139:342,188:344,189:345,186:346,13:f,16:h,87:d,197:Es,308:p}),n(vi,[2,227]),n(vi,[2,228]),n(vi,[2,229]),{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,172:221,185:351,187:350,200:348,230:347,231:Ut,234:349,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},{13:f,16:h,44:39,55:40,87:d,139:342,186:352,190:340,195:341,197:Es,307:43,308:p},n(vi,[2,146]),n(vi,[2,147]),n(vi,[2,148]),n(vi,[2,149]),{13:f,16:h,44:354,55:355,82:k,87:d,172:357,237:356,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:358,312:hr,313:353},n(dd,[2,215]),n(dd,[2,216]),n(U,H,{58:205,62:206,23:359,63:ve}),n(Ee,[2,264]),n(F1,[2,266]),n(ba,[2,11]),n(r,[2,308],{6:[2,310]}),n(Bt,[2,313],{102:360,120:361,121:[1,362]}),n(Bt,[2,47]),n(Bt,[2,63]),n(Bt,[2,64]),{13:f,16:h,55:363,307:43,308:p},n(Bt,[2,336]),n(Bt,[2,337]),n(Bt,[2,338]),{109:[1,364]},n(H1,[2,60]),{13:f,16:h,55:365,307:43,308:p},n(ie,[2,335]),{13:f,16:h,55:366,307:43,308:p},{31:[1,367]},n(Ts,[2,341],{137:368}),n(Ts,[2,340]),{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,145:369,172:221,185:213,187:214,231:Ut,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},{28:[1,370],127:371,128:[1,372]},n(Bi,[2,330],{124:373,125:374,126:at}),n(Bi,[2,57]),{44:375,87:d},n($1,[2,151],{241:376,242:[1,377]}),n(Cu,[2,153],{245:378,246:[1,379]}),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,247:380,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{250:[1,381]},n(Tt,[2,432]),n(Tt,[2,433]),n(Tt,[2,434]),n(Tt,[2,435]),n(Tt,[2,436]),n(Tt,[2,437]),{250:[2,439]},n([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:ee,298:te,299:re,300:ne,301:oe,302:ce}),n(_a,[2,162],{261:388,262:389,39:pd,338:md}),n(Nt,[2,164]),n(Nt,[2,165]),n(Nt,[2,166]),n(Et,[2,95]),n(Et,[2,96]),n(Tt,[2,377],{177:392,325:[1,393]}),{48:[1,394]},n(Et,[2,177]),{13:f,16:h,44:136,45:Q,46:395,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:396,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:397,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:398,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:399,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,183]),n(Et,[2,98]),n(Tt,[2,381],{180:400}),{87:[1,401]},n(Et,[2,185]),{13:f,16:h,44:136,45:Q,46:402,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{29:$,57:403},n(dr,[2,193]),{13:f,16:h,55:404,307:43,308:p},{13:f,16:h,44:39,55:40,87:d,139:342,195:405,197:Es,307:43,308:p},n(qi,[2,233]),n(qi,[2,234]),n(qi,[2,235]),n(z1,[2,459],{281:406,325:[1,407]}),n(Tt,[2,463],{284:408,325:[1,409]}),n(Tt,[2,465],{286:410,325:[1,411]}),{13:f,16:h,31:[1,412],55:414,82:k,171:413,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},{31:[1,419],89:[1,420]},{29:[1,421]},n(Du,[2,302]),n(Ou,[2,367],{167:422}),n(Pu,[2,369],{168:423}),{48:[1,424],87:[1,425]},n(Du,[2,371]),n(ws,[2,122]),n(ws,[2,417]),n(ws,[2,413]),n(ws,[2,414]),n(ws,[2,415]),n(Qn,[2,125]),n(Qn,[2,127]),n(Qn,[2,128]),n(Q1,[2,420],{227:426}),n(Qn,[2,130]),{13:f,16:h,55:194,197:it,223:427,307:43,308:p},{48:[1,428]},n(Gi,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),n(hd,[2,288]),{64:[1,433]},n(ut,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:f,16:h,45:Q,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,276:De,277:he,279:Ae,280:ge,283:xe,285:Re,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C}),n(Y1,[2,293]),n(gd,[2,92]),n(gd,[2,93]),n(gd,[2,94]),{45:V1,89:U1,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:O,29:L,56:85},{19:438,28:O,29:L,56:85},n(As,[2,355],{149:439}),n(As,[2,354]),{13:f,16:h,44:215,45:Nu,55:220,82:k,87:d,89:We,156:440,172:221,185:441,203:442,231:Lu,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(Ee,[2,19]),n(Gi,[2,21]),{13:f,16:h,44:450,45:K1,55:323,65:445,66:446,67:447,68:448,87:d,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},n(ba,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},n(G,[2,386],{31:[2,388]}),n(Qo,[2,102]),n(xs,[2,391],{191:452}),n(G,[2,395],{196:453,198:454}),n(G,[2,108]),n(G,[2,109]),n(Qo,[2,103]),n(Qo,[2,104]),n(Qo,[2,390]),{13:f,16:h,44:215,45:Ge,48:[1,455],55:220,82:k,87:d,89:We,172:221,185:351,187:350,200:456,231:Ut,234:349,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(ku,[2,424]),n(X1,[2,136]),n(X1,[2,137]),n(yd,[2,140]),{232:[1,457]},{13:f,16:h,44:39,55:40,87:d,139:342,195:458,197:Es,307:43,308:p},n(qi,[2,219]),n(qi,[2,220]),n(qi,[2,221]),n(qi,[2,222]),n(qi,[2,223]),n(ba,[2,10]),n(Bt,[2,46]),n(Bt,[2,314]),{112:N1,122:459},n(Bt,[2,62]),n(ie,L1,{133:242,108:460,112:k1,132:M1}),n(H1,[2,61]),n(Bt,[2,49]),n([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},n(Ts,[2,351],{146:463,335:[1,464]}),{29:$,57:465},n(Bi,[2,329]),n(ie,[2,332],{129:466,327:[1,467]}),n(Bi,[2,55]),n(Bi,[2,331]),{48:[1,468]},n(Cu,[2,429]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Sa,[2,431]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,243:470,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Sa,[2,156]),{45:B1,89:q1,179:471},n(_a,[2,441]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,251:472,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Nt,[2,444],{256:473}),n(Nt,[2,446],{258:474}),n(Tt,[2,442]),n(Tt,[2,443]),n(Nt,[2,449]),{13:f,16:h,44:136,45:Q,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,255:154,257:155,259:475,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Tt,[2,450]),n(Tt,[2,451]),n(Tt,[2,379],{178:476}),n(Tt,[2,378]),n([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:h,44:136,45:Q,46:482,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{48:[1,483]},{48:[1,484]},n(Et,[2,187]),n(dr,[2,194]),{13:f,16:h,44:39,55:40,82:k,87:d,139:289,172:291,255:154,257:155,266:290,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,320:485},{13:f,16:h,39:[1,487],44:136,45:Q,46:488,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,282:486,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(z1,[2,460]),{13:f,16:h,44:136,45:Q,46:489,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Tt,[2,464]),{13:f,16:h,44:136,45:Q,46:490,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Tt,[2,466]),n(W,[2,40]),n(Ou,[2,298]),n(Yo,[2,87]),n(Yo,[2,88]),n(Yo,[2,89]),n(Yo,[2,90]),{13:f,16:h,55:492,82:k,172:493,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,311:494,312:hr,315:491},n(W,[2,41]),n(Pu,[2,300]),n(Ko,[2,303],{92:495}),{13:f,16:h,31:[1,496],55:414,82:k,171:497,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},{31:[1,498],89:[1,499]},{29:[1,500]},n(Du,[2,372]),{13:f,16:h,48:[2,422],55:194,197:it,223:312,226:502,228:501,229:G1,307:43,308:p},n(Qn,[2,131]),n(Qn,[2,126]),n(Gi,[2,22]),n(Gi,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:h,44:510,45:Q,55:323,67:321,68:322,74:505,75:506,76:J1,77:320,78:Z1,79:509,87:d,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Y1,[2,294]),n(e2,[2,69]),n(e2,[2,70]),n(ut,we,{59:197,69:198,20:511,70:j}),n(U,H,{58:205,62:206,23:512,63:ve}),{29:[2,375],31:[2,71],84:522,85:a,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},n(As,[2,363],{157:524,335:[1,525]}),n(c,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:d}),n(Mu,[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:d}),{13:f,16:h,44:215,45:Nu,55:220,82:k,87:d,89:We,172:221,185:351,203:536,212:534,231:Lu,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(c,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:d}),n(U,[2,23],{307:43,267:139,275:146,278:149,55:323,67:447,68:448,44:450,66:538,13:f,16:h,45:K1,87:d,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,276:De,277:he,279:Ae,280:ge,283:xe,285:Re,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C}),n(Cs,[2,291]),n(Cs,[2,24]),n(Cs,[2,25]),{13:f,16:h,44:136,45:Q,46:539,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Cs,[2,28]),n(U,H,{58:205,62:206,23:540,63:ve}),n([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),n(xs,[2,107]),{13:f,16:h,44:215,45:Ge,55:220,82:k,87:d,89:We,172:221,185:351,187:350,199:543,200:544,231:Ut,234:349,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(t2,[2,132]),n(ku,[2,425]),n(t2,[2,133]),{13:f,16:h,44:354,55:355,82:k,87:d,172:357,237:356,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:358,312:hr,313:545},n(Bt,[2,54]),n(Bt,[2,48]),n(Ts,[2,342]),{13:f,16:h,44:39,55:40,87:d,139:546,307:43,308:p},n(Ts,[2,68]),n(G,[2,350],{31:r2,112:r2}),n(Bt,[2,53]),{13:f,16:h,55:547,307:43,308:p},n(ie,[2,333]),n(ke,[2,16]),n(Cu,[2,152]),n(Sa,[2,154]),n(Sa,[2,157]),n(_a,[2,159]),n(_a,[2,160],{262:389,261:548,39:pd,338:md}),n(_a,[2,161],{262:389,261:549,39:pd,338:md}),n(Nt,[2,163]),{13:f,16:h,44:136,45:Q,46:550,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,178]),n(Et,[2,179]),{13:f,16:h,44:136,45:Q,46:551,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:552,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:553,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{48:[1,554],272:[1,555]},n(Et,[2,184]),n(Et,[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:h,55:194,197:it,223:562,307:43,308:p},n(vd,[2,224]),n(vd,[2,225]),n(vd,[2,226]),{31:[1,563],45:n2,94:564},n(W,[2,84]),n(Ou,[2,368]),n(W,[2,85]),n(Pu,[2,370]),n(Ko,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},n(Gi,[2,35],{83:[1,569]}),n(Gi,[2,36],{81:[1,570]}),n(hd,[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:h,45:Q,76:J1,78:Z1,87:d,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,276:De,277:he,279:Ae,280:ge,283:xe,285:Re,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C}),n(wa,[2,295]),{45:Q,77:572},{45:Q,77:573},n(wa,[2,33]),n(wa,[2,34]),{31:[2,275],50:574,84:575,85:a},{31:[2,277],51:576,84:577,85:a},n(As,[2,356]),n(i2,[2,357],{152:578,335:[1,579]}),n(Si,[2,74]),{29:$,57:580},{29:$,57:581},{13:f,16:h,44:39,55:40,87:d,139:582,307:43,308:p},n(s2,[2,365],{162:583,328:[1,584]}),{13:f,16:h,45:Q,55:323,67:321,68:322,77:320,79:585,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,307:43,308:p,346:Fe,347:be,348:w,349:E,350:_,351:C},{45:[1,586]},n(Si,[2,81]),{29:$,57:587},n(As,[2,73]),n(G,[2,362],{29:_i,31:_i,85:_i,112:_i,159:_i,160:_i,161:_i,163:_i,164:_i}),n(Mu,[2,112]),n(Ea,[2,401],{206:588}),n(G,[2,405],{209:589,210:590}),n(G,[2,403]),n(G,[2,404]),n(Mu,[2,113]),n(Mu,[2,400]),{13:f,16:h,44:215,45:Nu,48:[1,591],55:220,82:k,87:d,89:We,172:221,185:351,203:536,212:592,231:Lu,234:535,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(ku,[2,426]),n(yd,[2,138]),n(yd,[2,139]),{232:[1,593]},n(Cs,[2,292]),{47:[1,595],48:[1,594]},n(ba,[2,9]),n(xs,[2,392]),n(xs,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:h,87:d,197:Es,308:p}),n(xs,[2,110],{272:[1,598]}),n(ju,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},n(Bi,[2,58]),n(Nt,[2,445]),n(Nt,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},n(Et,[2,99]),n(Tt,[2,382]),n([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),n(Et,[2,188]),n(Et,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:h,55:492,82:k,172:493,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,311:494,312:hr,315:611},n(W,[2,42]),n(Ko,[2,304]),{13:f,16:h,55:414,82:k,95:612,171:613,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},{31:[1,614],45:n2,94:615},n(Qn,[2,129]),n(Q1,[2,421]),{82:[1,616]},{82:[1,617]},n(wa,[2,296]),n(wa,[2,31]),n(wa,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},n(G,W1,{155:330,153:618,154:619,29:bi,31:bi,85:bi,112:bi,159:bi,160:bi,161:bi,163:bi,164:bi}),n(i2,[2,358]),n(Si,[2,75]),n(Si,[2,76]),{29:$,57:620},{13:f,16:h,44:39,55:40,87:d,139:621,307:43,308:p},n(s2,[2,366]),n(Si,[2,79]),{13:f,16:h,44:136,45:Q,46:622,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Si,[2,91],{336:[1,623]}),n([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),n(Ea,[2,117]),{13:f,16:h,44:215,45:Nu,55:220,82:k,87:d,89:We,172:221,185:351,203:536,211:626,212:627,231:Lu,234:535,236:216,237:222,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,309:Or,310:$r,311:217,312:hr},n(vi,[2,134]),n(ku,[2,427]),n(vi,[2,135]),n(Cs,[2,26]),{44:628,87:d},n(xs,[2,106]),n(xs,[2,394]),n(G,[2,396]),n(ju,[2,111]),n(ju,[2,398]),{13:f,16:h,44:39,55:40,87:d,139:342,186:629,190:340,195:341,197:Es,307:43,308:p},n(dd,[2,217]),n(G,xu,{144:248,140:630,143:631,31:[2,343]}),n(Et,[2,97]),n(Tt,[2,380]),n(Et,[2,180]),{13:f,16:h,44:136,45:Q,46:632,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},{13:f,16:h,44:136,45:Q,46:633,55:133,67:132,68:134,77:131,82:k,87:d,172:135,224:qe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Xe,264:130,265:V,266:137,267:139,268:me,269:Ie,270:z,271:Oe,273:Pe,274:Te,275:146,276:De,277:he,278:149,279:Ae,280:ge,283:xe,285:Re,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:$e,346:Fe,347:be,348:w,349:E,350:_,351:C},n(Et,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:h,48:[1,636],55:414,82:k,171:637,172:415,173:416,174:Ru,255:154,257:155,291:150,294:Z,295:se,296:ae,297:ee,298:te,299:re,300:ne,301:oe,302:ce,303:ue,304:le,305:X,306:fe,307:43,308:p,312:Fu},n(a2,[2,305]),n(W,[2,86]),n(Ko,[2,374]),n(Gi,[2,37]),n(Gi,[2,38]),n(As,[2,72]),n(As,[2,360]),n(Si,[2,77]),{29:$,57:638},{47:[1,639]},{29:[2,376]},n(Ea,[2,402]),n(Ea,[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:d}),n(Ea,[2,118],{272:[1,641]}),n($u,[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:ue,304:le,305:X,306:fe},n(Yo,[2,218]),n(Ko,[2,44]),n(a2,[2,306]),n(Si,[2,78]),{44:651,87:d},n(Ea,[2,116]),n(G,[2,406]),n($u,[2,119]),n($u,[2,408]),n(c,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:d}),n(Cs,[2,27]),n(ju,[2,230]),n(o2,[2,345],{141:653,335:[1,654]}),n(Et,[2,181]),n(Et,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},n(G,xu,{144:248,142:657,143:658,31:c2,112:c2}),n(o2,[2,346]),n(Si,[2,80]),n($u,[2,231]),n(Ts,[2,67]),n(Ts,[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:o(function(A,P){if(P.recoverable)this.trace(A);else{var F=new Error(A);throw F.hash=P,F}},"parseError"),parse:o(function(A){var P=this,F=[0],Y=[],_e=[null],m=[],mr=this.table,g="",Xn=0,ec=0,qu=0,Gu=2,tc=1,Wu=m.slice.call(arguments,1),mt=Object.create(this.lexer),Jn={yy:{}};for(var rc in this.yy)Object.prototype.hasOwnProperty.call(this.yy,rc)&&(Jn.yy[rc]=this.yy[rc]);mt.setInput(A,Jn.yy),Jn.yy.lexer=mt,Jn.yy.parser=this,typeof mt.yylloc>"u"&&(mt.yylloc={});var Ia=mt.yylloc;m.push(Ia);var st=mt.options&&mt.options.ranges;typeof Jn.yy.parseError=="function"?this.parseError=Jn.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function dt(Zn){F.length=F.length-2*Zn,_e.length=_e.length-Zn,m.length=m.length-Zn}o(dt,"popStack");for(var He=o(function(){var Zn;return Zn=mt.lex()||tc,typeof Zn!="number"&&(Zn=P.symbols_[Zn]||Zn),Zn},"lex"),Ze,Pr,Ds,zr,rj,Dd,Oa={},Hu,Ti,_2,zu;;){if(Ds=F[F.length-1],this.defaultActions[Ds]?zr=this.defaultActions[Ds]:((Ze===null||typeof Ze>"u")&&(Ze=He()),zr=mr[Ds]&&mr[Ds][Ze]),typeof zr>"u"||!zr.length||!zr[0]){var Rd="";zu=[];for(Hu in mr[Ds])this.terminals_[Hu]&&Hu>Gu&&zu.push("'"+this.terminals_[Hu]+"'");mt.showPosition?Rd="Parse error on line "+(Xn+1)+`:
|
|
245
245
|
`+mt.showPosition()+`
|
|
246
|
-
Expecting `+zu.join(", ")+", got '"+(this.terminals_[Ze]||Ze)+"'":
|
|
247
|
-
`,r:"\r",f:"\f"},
|
|
246
|
+
Expecting `+zu.join(", ")+", got '"+(this.terminals_[Ze]||Ze)+"'":Rd="Parse error on line "+(Xn+1)+": Unexpected "+(Ze==tc?"end of input":"'"+(this.terminals_[Ze]||Ze)+"'"),this.parseError(Rd,{text:mt.match,token:this.terminals_[Ze]||Ze,line:mt.yylineno,loc:Ia,expected:zu})}if(zr[0]instanceof Array&&zr.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Ds+", token: "+Ze);switch(zr[0]){case 1:F.push(Ze),_e.push(mt.yytext),m.push(mt.yylloc),F.push(zr[1]),Ze=null,Pr?(Ze=Pr,Pr=null):(ec=mt.yyleng,g=mt.yytext,Xn=mt.yylineno,Ia=mt.yylloc,qu>0&&qu--);break;case 2:if(Ti=this.productions_[zr[1]][1],Oa.$=_e[_e.length-Ti],Oa._$={first_line:m[m.length-(Ti||1)].first_line,last_line:m[m.length-1].last_line,first_column:m[m.length-(Ti||1)].first_column,last_column:m[m.length-1].last_column},st&&(Oa._$.range=[m[m.length-(Ti||1)].range[0],m[m.length-1].range[1]]),Dd=this.performAction.apply(Oa,[g,ec,Xn,Jn.yy,zr[1],_e,m].concat(Wu)),typeof Dd<"u")return Dd;Ti&&(F=F.slice(0,-1*Ti*2),_e=_e.slice(0,-1*Ti),m=m.slice(0,-1*Ti)),F.push(this.productions_[zr[1]][0]),_e.push(Oa.$),m.push(Oa._$),_2=mr[F[F.length-2]][F[F.length-1]],F.push(_2);break;case 3:return!0}}return!0},"parse")},Vu=ey().Wildcard,Uu="http://www.w3.org/1999/02/22-rdf-syntax-ns#",dA=Uu+"type",pA=Uu+"first",mA=Uu+"rest",u2=Uu+"nil",Bu="http://www.w3.org/2001/XMLSchema#",l2=Bu+"integer",f2=Bu+"decimal",h2=Bu+"double",gA=Bu+"boolean",Is="",d2="",p2="";function pr(x){return x.toLowerCase()}o(pr,"lowercase");function wi(x,A){return x.push(A),x}o(wi,"appendTo");function Os(x,A){return x.push.apply(x,A),x}o(Os,"appendAllTo");function yt(x){x||(x={});for(var A=1,P=arguments.length,F;A<P&&(F=arguments[A]||{});A++)for(var Y in F)x[Y]=F[Y];return x}o(yt,"extend");function Yn(){for(var x=[],A=0,P=arguments.length;A<P;A++)x=x.concat.apply(x,arguments[A]);return x}o(Yn,"unionAll");function Xo(x){if(x[0]==="<"&&(x=x.substring(1,x.length-1)),/^[a-z][a-z0-9.+-]*:/i.test(x))return x;if(!Ce.base)throw new Error("Cannot resolve relative IRI "+x+" because no base IRI was set.");switch(Is!==Ce.base&&(Is=Ce.base,d2=Is.replace(/[^\/:]*$/,""),p2=Is.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),x[0]){case void 0:return Is;case"#":return Is+x;case"?":return Is.replace(/(?:\?.*)?$/,x);case"/":return p2+x;default:return d2+x}}o(Xo,"resolveIRI");function _d(x){if(x){var A=x[0];if(A==="?"||A==="$")return Ce.factory.variable(x.substr(1))}return x}o(_d,"toVar");function qt(x,A){return{type:"operation",operator:x,args:A||[]}}o(qt,"operation");function Ta(x,A){var P={expression:x==="*"?new Vu:x};if(A)for(var F in A)P[F]=A[F];return P}o(Ta,"expression");function Aa(x,A){return{type:"path",pathType:x,items:A}}o(Aa,"path");function bd(x,A){for(var P=0,F=A.length,Y;P<F&&(Y=A[P]);P++)x=qt(Y[0],[x,Y[1]]);return x}o(bd,"createOperationTree");function Ps(x,A){var P=[],F=[],Y=x.length,_e,m={};if(!Y)return null;for(var mr=0;mr<Y&&(_e=x[mr]);mr++)(_e.named?F:P).push(_e.iri);return m[A||"from"]={default:P,named:F},m}o(Ps,"groupDatasets");function xa(x){return parseInt(x,10)}o(xa,"toInt");function wd(x){return x.type==="group"&&x.patterns.length===1?x.patterns[0]:x}o(wd,"degroupSingle");function Kn(x,A){return A&&A.termType!=="NamedNode"&&(A=Ce.factory.namedNode(A)),Ce.factory.literal(x,A)}o(Kn,"createTypedLiteral");function yA(x,A){return Ce.factory.literal(x,A)}o(yA,"createLangLiteral");function Ed(x,A,P){if(!("termType"in A))throw new Error("Nested triples cannot contain paths");return Ce.factory.quad(x,A,P)}o(Ed,"nestedTriple");function Ei(x,A,P,F){var Y={};return x!=null&&(Y.subject=x),A!=null&&(Y.predicate=A),P!=null&&(Y.object=P),F!=null&&(Y.annotations=F),Y}o(Ei,"triple");function Jo(x){return typeof x=="string"?x.startsWith("e_")?Ce.factory.blankNode(x):Ce.factory.blankNode("e_"+x):Ce.factory.blankNode("g_"+m2++)}o(Jo,"blank");var m2=0;Ce._resetBlanks=function(){m2=0};var vA=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,SA={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
|
|
247
|
+
`,r:"\r",f:"\f"},_A=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,Td=String.fromCharCode;function g2(x,A){x=x.substring(A,x.length-A);try{x=x.replace(vA,function(P,F,Y,_e){var m;if(F){if(m=parseInt(F,16),isNaN(m))throw new Error;return Td(m)}else if(Y){if(m=parseInt(Y,16),isNaN(m))throw new Error;return m<65535?Td(m):Td(55296+((m-=65536)>>10),56320+(m&1023))}else{var mr=SA[_e];if(!mr)throw new Error;return mr}})}catch{return""}if(_A.exec(x))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+x);return x}o(g2,"unescapeString");function bA(x){var A=Jo(),P=A,F=[],Y,_e=[];x.forEach(function(Xn){F.push(Xn.entity),Os(_e,Xn.triples)});for(var m=0,mr=0,g=F.length,Y=Array(g*2);m<g;)Y[mr++]=Ei(P,Ce.factory.namedNode(pA),F[m]),Y[mr++]=Ei(P,Ce.factory.namedNode(mA),P=++m<g?Jo():Ce.factory.namedNode(u2));return{entity:A,triples:Os(Y,_e)}}o(bA,"createList");function wA(x){var A=Jo();return{entity:A,triples:x.map(function(P){return yt(Ei(A),P)})}}o(wA,"createAnonymousObject");function Ad(x,A,P){var F=[],Y=[];return A.forEach(function(_e){let m=null;_e.annotation&&(m=_e.annotation,_e=_e.object),F.push(Ei(null,x,_e.entity,m)),Os(Y,_e.triples)}),Yn(F,P||[],Y)}o(Ad,"objectListToTriples");function ej(x){for(var A=[],P,F=0,Y;Y=x[F];F++)switch(Y.type){case"bgp":Y.triples.length&&(P?Os(P.triples,Y.triples):wi(A,P=Y));break;default:(!Y.patterns||Y.patterns.length>0)&&(wi(A,Y),P=null)}return A}o(ej,"mergeAdjacentBGPs");function Ca(x){return x.variable?x.variable.value:x.value||x.expression.value}o(Ca,"getExpressionId");function xd(x){if(!x)return[];if(x.type==="aggregate")return[x];if(x.type==="operation"){let A=[];for(let P of x.args)A.push(...xd(P));return A}return[]}o(xd,"getAggregatesOfExpression");function EA(x){let A=new Set,P=o(function(F){F&&(F.termType==="Variable"?A.add(F):F.type==="operation"&&F.args.forEach(P))},"visitExpression");return P(x),A}o(EA,"getVariablesFromExpression");function Cd(x,A=1,P=[]){for(let F of x)A>0&&F instanceof Array?Cd(F,A-1,P):P.push(F);return P}o(Cd,"flatten");function Id(x){return x.termType==="Variable"}o(Id,"isVariable");function y2(x){if(x.triples){let A=[];for(let P of x.triples)Id(P.subject)&&A.push(P.subject.value),Id(P.predicate)&&A.push(P.predicate.value),Id(P.object)&&A.push(P.object.value);return A}else if(x.patterns){let A=[];for(let P of x.patterns)A.push(...y2(P));return A}return[]}o(y2,"getBoundVarsFromGroupGraphPattern");function TA(x){let A=x.slice().sort(),P=[];for(let F=0;F<A.length-1;F++)A[F+1]==A[F]&&P.push(A[F]);return P}o(TA,"getDuplicatesInArray");function Zo(x){if(!Ce.sparqlStar)throw new Error("SPARQL-star support is not enabled");return x}o(Zo,"ensureSparqlStar");function v2(x,A,P){for(let F of A){let Y=Ei("subject"in F?F.subject:x,F.predicate,F.object);P.push(Y),F.annotations&&v2(Ed(x,F.predicate,F.object),F.annotations,P)}}o(v2,"_applyAnnotations");function Od(x){if(Ce.sparqlStar){let A=[];return x.forEach(P=>{let F=Ei(P.subject,P.predicate,P.object);A.push(F),P.annotations&&v2(Ed(P.subject,P.predicate,P.object),P.annotations,A)}),A}return x}o(Od,"applyAnnotations");function tj(x){if(!Ce.sparqlStarNestedQuads)throw new Error("Lenient SPARQL-star support with nested quads is not enabled");return x}o(tj,"ensureSparqlStarNestedQuads");function S2(x){for(let A of x){if(A.type==="graph"&&A.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(A.type==="bgp"||A.type==="graph"){for(let P of A.triples)if(P.subject.termType==="Variable"||P.predicate.termType==="Variable"||P.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return x}o(S2,"ensureNoVariables");function Pd(x){for(let A of x)if(A.type==="bgp"){for(let P of A.triples)if(P.subject.termType==="BlankNode"||P.predicate.termType==="BlankNode"||P.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return x}o(Pd,"ensureNoBnodes");var AA=(function(){var x={EOF:1,parseError:o(function(P,F){if(this.yy.parser)this.yy.parser.parseError(P,F);else throw new Error(P)},"parseError"),setInput:o(function(A,P){return this.yy=P||this.yy||{},this._input=A,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:o(function(){var A=this._input[0];this.yytext+=A,this.yyleng++,this.offset++,this.match+=A,this.matched+=A;var P=A.match(/(?:\r\n?|\n).*/g);return P?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),A},"input"),unput:o(function(A){var P=A.length,F=A.split(/(?:\r\n?|\n)/g);this._input=A+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-P),this.offset-=P;var Y=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),F.length-1&&(this.yylineno-=F.length-1);var _e=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:F?(F.length===Y.length?this.yylloc.first_column:0)+Y[Y.length-F.length].length-F[0].length:this.yylloc.first_column-P},this.options.ranges&&(this.yylloc.range=[_e[0],_e[0]+this.yyleng-P]),this.yyleng=this.yytext.length,this},"unput"),more:o(function(){return this._more=!0,this},"more"),reject:o(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).
|
|
248
248
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:o(function(A){this.unput(this.match.slice(A))},"less"),pastInput:o(function(){var A=this.matched.substr(0,this.matched.length-this.match.length);return(A.length>20?"...":"")+A.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:o(function(){var A=this.match;return A.length<20&&(A+=this._input.substr(0,20-A.length)),(A.substr(0,20)+(A.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:o(function(){var A=this.pastInput(),P=new Array(A.length+1).join("-");return A+this.upcomingInput()+`
|
|
249
249
|
`+P+"^"},"showPosition"),test_match:o(function(A,P){var F,Y,_e;if(this.options.backtrack_lexer&&(_e={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(_e.yylloc.range=this.yylloc.range.slice(0))),Y=A[0].match(/(?:\r\n?|\n).*/g),Y&&(this.yylineno+=Y.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:Y?Y[Y.length-1].length-Y[Y.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+A[0].length},this.yytext+=A[0],this.match+=A[0],this.matches=A,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(A[0].length),this.matched+=A[0],F=this.performAction.call(this,this.yy,this,P,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),F)return F;if(this._backtrack){for(var m in _e)this[m]=_e[m];return!1}return!1},"test_match"),next:o(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var A,P,F,Y;this._more||(this.yytext="",this.match="");for(var _e=this._currentRules(),m=0;m<_e.length;m++)if(F=this._input.match(this.rules[_e[m]]),F&&(!P||F[0].length>P[0].length)){if(P=F,Y=m,this.options.backtrack_lexer){if(A=this.test_match(F,_e[m]),A!==!1)return A;if(this._backtrack){P=!1;continue}else return!1}else if(!this.options.flex)break}return P?(A=this.test_match(P,_e[Y]),A!==!1?A:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
250
|
-
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:o(function(){var P=this.next();return P||this.lex()},"lex"),begin:o(function(P){this.conditionStack.push(P)},"begin"),popState:o(function(){var P=this.conditionStack.length-1;return P>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:o(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:o(function(P){return P=this.conditionStack.length-1-Math.abs(P||0),P>=0?this.conditionStack[P]:"INITIAL"},"topState"),pushState:o(function(P){this.begin(P)},"pushState"),stateStackSize:o(function(){return this.conditionStack.length},"stateStackSize"),options:{flex:!0,"case-insensitive":!0},performAction:o(function(P,F,Y,_e){var m=_e;switch(Y){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(F.yytext);break}},"anonymous"),rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};return x})();vd.lexer=wA;function Ce(){this.yy={}}return o(Ce,"Parser"),Ce.prototype=vd,vd.Parser=Ce,new Ce})();d_.exports=FF});var v_=v((hq,y_)=>{var NF="http://www.w3.org/2001/XMLSchema#integer",LF="http://www.w3.org/2001/XMLSchema#string";function ft(n){this._options=n=n||{};var e=n.prefixes||{};this._prefixByIri={};var t=[];for(var r in e){var i=e[r];Pc(i)&&(this._prefixByIri[i]=r,t.push(i))}var s=t.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=n.sparqlStar,this._indent=Pc(n.indent)?n.indent:" ",this._newline=Pc(n.newline)?n.newline:`
|
|
251
|
-
`,this._explicitDatatype=!!n.explicitDatatype}o(ft,"Generator");ft.prototype.toQuery=function(n){var e="";return n.queryType&&(e+=n.queryType.toUpperCase()+" "),n.reduced&&(e+="REDUCED "),n.distinct&&(e+="DISTINCT "),n.variables?e+=qr(n.variables,void 0,function(t){return/^[?$]/.test(t)?t:rs(t)?this.toEntity(t):"("+this.toExpression(t.expression)+" AS "+gf(t.variable)+")"},this)+" ":n.template&&(e+=this.group(n.template,!0)+this._newline),n.from&&(e+=this.graphs("FROM ",n.from.default)+this.graphs("FROM NAMED ",n.from.named)),n.where&&(e+="WHERE "+this.group(n.where,!0)+this._newline),n.updates&&(e+=qr(n.updates,";"+this._newline,this.toUpdate,this)),n.group&&(e+="GROUP BY "+qr(n.group,void 0,function(t){var r=rs(t.expression)?this.toEntity(t.expression):"("+this.toExpression(t.expression)+")";return t.variable?"("+r+" AS "+gf(t.variable)+")":r},this)+this._newline),n.having&&(e+="HAVING ("+qr(n.having,void 0,this.toExpression,this)+")"+this._newline),n.order&&(e+="ORDER BY "+qr(n.order,void 0,function(t){var r="("+this.toExpression(t.expression)+")";return t.descending?"DESC "+r:r},this)+this._newline),n.offset&&(e+="OFFSET "+n.offset+this._newline),n.limit&&(e+="LIMIT "+n.limit+this._newline),n.values&&(e+=this.values(n)),e=this.baseAndPrefixes(n)+e,e.trim()};ft.prototype.baseAndPrefixes=function(n){var e=n.base?"BASE <"+n.base+">"+this._newline:"",t="";for(var r in n.prefixes)(this._options.allPrefixes||this._usedPrefixes[r])&&(t+="PREFIX "+r+": <"+n.prefixes[r]+">"+this._newline);return e+t};ft.prototype.toPattern=function(n){var e=n.type||n instanceof Array&&"array"||(n.subject&&n.predicate&&n.object?"triple":"");if(!(e in this))throw new Error("Unknown entry type: "+e);return this[e](n)};ft.prototype.triple=function(n){return this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+"."};ft.prototype.array=function(n){return qr(n,this._newline,this.toPattern,this)};ft.prototype.bgp=function(n){return this.encodeTriples(n.triples)};ft.prototype.encodeTriples=function(n){if(!n.length)return"";for(var e=[],t=void 0,r=void 0,i=0;i<n.length;i++){var s=n[i];ea(s.subject,t)?ea(s.predicate,r)?e.push(","):(r=s.predicate,e.push(";"+this._newline,this._indent,this.toEntity(r))):(t&&e.push("."+this._newline),t=s.subject,r=s.predicate,e.push(this.toEntity(t)," ",this.toEntity(r))),e.push(" ",this.toEntity(s.object))}return e.push("."),e.join("")};ft.prototype.graph=function(n){return"GRAPH "+this.toEntity(n.name)+" "+this.group(n)};ft.prototype.graphs=function(n,e){return!e||e.length===0?"":qr(e,"",function(t){return n+this.toEntity(t)+this._newline},this)};ft.prototype.group=function(n,e){return n=e!==!0?this.array(n.patterns||n.triples):this.toPattern(n.type!=="group"?n:n.patterns),n.indexOf(this._newline)===-1?"{ "+n+" }":"{"+this._newline+this.indent(n)+this._newline+"}"};ft.prototype.query=function(n){return this.toQuery(n)};ft.prototype.filter=function(n){return"FILTER("+this.toExpression(n.expression)+")"};ft.prototype.bind=function(n){return"BIND("+this.toExpression(n.expression)+" AS "+gf(n.variable)+")"};ft.prototype.optional=function(n){return"OPTIONAL "+this.group(n)};ft.prototype.union=function(n){return qr(n.patterns,this._newline+"UNION"+this._newline,function(e){return this.group(e,!0)},this)};ft.prototype.minus=function(n){return"MINUS "+this.group(n)};ft.prototype.values=function(n){var e=Object.keys(n.values.reduce(function(i,s){for(var a in s)i[a]=!0;return i},{})),t,r;return e.length===1?t=r="":(t="(",r=")"),"VALUES "+t+e.join(" ")+r+" {"+this._newline+qr(n.values,this._newline,function(i){return" "+t+qr(e,void 0,function(s){return i[s]?this.toEntity(i[s]):"UNDEF"},this)+r},this)+this._newline+"}"};ft.prototype.service=function(n){return"SERVICE "+(n.silent?"SILENT ":"")+this.toEntity(n.name)+" "+this.group(n)};ft.prototype.toExpression=function(n){if(rs(n))return this.toEntity(n);switch(n.type.toLowerCase()){case"aggregate":return n.aggregation.toUpperCase()+"("+(n.distinct?"DISTINCT ":"")+this.toExpression(n.expression)+(typeof n.separator=="string"?'; SEPARATOR = "'+n.separator.replace(m_,g_)+'"':"")+")";case"functioncall":return this.toEntity(n.function)+"("+qr(n.args,", ",this.toExpression,this)+")";case"operation":var e=n.operator.toUpperCase(),t=n.args||[];switch(n.operator.toLowerCase()){case"<":case">":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(rs(t[0])?this.toEntity(t[0]):"("+this.toExpression(t[0])+")")+" "+e+" "+(rs(t[1])?this.toEntity(t[1]):"("+this.toExpression(t[1])+")");case"!":return"!("+this.toExpression(t[0])+")";case"uplus":return"+("+this.toExpression(t[0])+")";case"uminus":return"-("+this.toExpression(t[0])+")";case"notin":e="NOT IN";case"in":return this.toExpression(t[0])+" "+e+"("+(Pc(t[1])?t[1]:qr(t[1],", ",this.toExpression,this))+")";case"notexists":e="NOT EXISTS";case"exists":return e+" "+this.group(t[0],!0);default:return e+"("+qr(t,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+n.type)}};ft.prototype.toEntity=function(n){if(rs(n))switch(n.termType){case"Wildcard":return"*";case"Variable":return gf(n);case"BlankNode":return"_:"+n.value;case"Literal":var e=n.value||"",t=n.language||"",r=n.datatype;if(n='"'+e.replace(m_,g_)+'"',t)n+="@"+t;else if(r){if(!this._explicitDatatype)switch(r.value){case LF:return n;case NF:if(/^\d+$/.test(e))return e+" "}n+="^^"+this.encodeIRI(r.value)}return n;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return n.graph&&n.graph.termType!=="DefaultGraph"?"<< GRAPH "+this.toEntity(n.graph)+" { "+this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+" } >>":"<< "+this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+" >>";default:return this.encodeIRI(n.value)}else{var i=n.items.map(this.toEntity,this),s=n.pathType;switch(s){case"^":case"!":return s+i[0];case"*":case"+":case"?":return"("+i[0]+s+")";default:return"("+i.join(s)+")"}}};var m_=/["\\\t\n\r\b\f]/g,g_=o(function(n){return kF[n]},"escapeReplacer"),kF={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};ft.prototype.encodeIRI=function(n){var e=this._prefixRegex.exec(n);if(e){var t=this._prefixByIri[e[1]];return this._usedPrefixes[t]=!0,t+":"+e[2]}return"<"+n+">"};ft.prototype.toUpdate=function(n){switch(n.type||n.updateType){case"load":return"LOAD"+(n.source?" "+this.toEntity(n.source):"")+(n.destination?" INTO GRAPH "+this.toEntity(n.destination):"");case"insert":return"INSERT DATA "+this.group(n.insert,!0);case"delete":return"DELETE DATA "+this.group(n.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(n.delete,!0);case"insertdelete":return(n.graph?"WITH "+this.toEntity(n.graph)+this._newline:"")+(n.delete.length?"DELETE "+this.group(n.delete,!0)+this._newline:"")+(n.insert.length?"INSERT "+this.group(n.insert,!0)+this._newline:"")+(n.using?this.graphs("USING ",n.using.default):"")+(n.using?this.graphs("USING NAMED ",n.using.named):"")+"WHERE "+this.group(n.where,!0);case"add":case"copy":case"move":return n.type.toUpperCase()+" "+(n.silent?"SILENT ":"")+(n.source.default?"DEFAULT":this.toEntity(n.source.name))+" TO "+this.toEntity(n.destination.name);case"create":case"clear":case"drop":return n.type.toUpperCase()+(n.silent?" SILENT ":" ")+(n.graph.default?"DEFAULT":n.graph.named?"NAMED":n.graph.all?"ALL":"GRAPH "+this.toEntity(n.graph.name));default:throw new Error("Unknown update query type: "+n.type)}};ft.prototype.indent=function(n){return n.replace(/^/gm,this._indent)};function gf(n){return"?"+n.value}o(gf,"variableToString");function Pc(n){return typeof n=="string"}o(Pc,"isString");function rs(n){return typeof n.termType=="string"}o(rs,"isTerm");function ea(n,e){if(!n||!rs(n)||!e||!rs(e)||n.termType!==e.termType)return!1;switch(n.termType){case"Literal":return n.value===e.value&&n.language===e.language&&ea(n.datatype,e.datatype);case"Quad":return ea(n.subject,e.subject)&&ea(n.predicate,e.predicate)&&ea(n.object,e.object)&&ea(n.graph,e.graph);default:return n.value===e.value}}o(ea,"equalTerms");function qr(n,e,t,r){return n.map(t,r).join(Pc(e)?e:" ")}o(qr,"mapJoin");function MF(n={}){return{stringify:o(function(e){var t=Object.create(n);return t.prefixes=e.prefixes,new ft(t).toQuery(e)},"stringify"),createGenerator:o(function(){return new ft(n)},"createGenerator")}}o(MF,"_Generator");y_.exports={Generator:MF}});var ty=v(yf=>{"use strict";Object.defineProperty(yf,"__esModule",{value:!0});yf.BlankNode=void 0;var ey=class{static{o(this,"BlankNode")}constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&e.termType==="BlankNode"&&e.value===this.value}};yf.BlankNode=ey});var ry=v(vf=>{"use strict";Object.defineProperty(vf,"__esModule",{value:!0});vf.DefaultGraph=void 0;var Dc=class{static{o(this,"DefaultGraph")}constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&e.termType==="DefaultGraph"}};vf.DefaultGraph=Dc;Dc.INSTANCE=new Dc});var _f=v(Sf=>{"use strict";Object.defineProperty(Sf,"__esModule",{value:!0});Sf.NamedNode=void 0;var ny=class{static{o(this,"NamedNode")}constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&e.termType==="NamedNode"&&e.value===this.value}};Sf.NamedNode=ny});var iy=v(bf=>{"use strict";Object.defineProperty(bf,"__esModule",{value:!0});bf.Literal=void 0;var S_=_f(),Rc=class n{static{o(this,"Literal")}constructor(e,t){this.termType="Literal",this.value=e,typeof t=="string"?(this.language=t,this.datatype=n.RDF_LANGUAGE_STRING):t?(this.language="",this.datatype=t):(this.language="",this.datatype=n.XSD_STRING)}equals(e){return!!e&&e.termType==="Literal"&&e.value===this.value&&e.language===this.language&&this.datatype.equals(e.datatype)}};bf.Literal=Rc;Rc.RDF_LANGUAGE_STRING=new S_.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");Rc.XSD_STRING=new S_.NamedNode("http://www.w3.org/2001/XMLSchema#string")});var ay=v(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});wf.Quad=void 0;var sy=class{static{o(this,"Quad")}constructor(e,t,r,i){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=i}equals(e){return!!e&&(e.termType==="Quad"||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}};wf.Quad=sy});var cy=v(Ef=>{"use strict";Object.defineProperty(Ef,"__esModule",{value:!0});Ef.Variable=void 0;var oy=class{static{o(this,"Variable")}constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&e.termType==="Variable"&&e.value===this.value}};Ef.Variable=oy});var b_=v(Tf=>{"use strict";Object.defineProperty(Tf,"__esModule",{value:!0});Tf.DataFactory=void 0;var jF=ty(),$F=ry(),__=iy(),VF=_f(),UF=ay(),BF=cy(),qF=0,uy=class{static{o(this,"DataFactory")}constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${qF++}_`}namedNode(e){return new VF.NamedNode(e)}blankNode(e){return new jF.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new __.Literal(e,t)}variable(e){return new BF.Variable(e)}defaultGraph(){return $F.DefaultGraph.INSTANCE}quad(e,t,r,i){return new UF.Quad(e,t,r,i||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(__.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}};Tf.DataFactory=uy});var w_=v(Gr=>{"use strict";var GF=Gr&&Gr.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),ta=Gr&&Gr.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&GF(e,n,t)};Object.defineProperty(Gr,"__esModule",{value:!0});ta(ty(),Gr);ta(b_(),Gr);ta(ry(),Gr);ta(iy(),Gr);ta(_f(),Gr);ta(ay(),Gr);ta(cy(),Gr)});var T_=v((Pq,E_)=>{var{Parser:Ri}=p_(),{Generator:WF}=v_(),{Wildcard:HF}=Zg(),{DataFactory:zF}=w_();function QF({prefixes:n,baseIRI:e,factory:t,pathOnly:r,sparqlStar:i,skipValidation:s,skipUngroupedVariableCheck:a}={}){let c={};for(let l in n??{})c[l]=n[l];let u=new Ri;return u.parse=function(){return Ri.base=e||"",Ri.prefixes=Object.create(c),Ri.factory=t||new zF,Ri.sparqlStar=!!i,Ri.pathOnly=!!r,Ri.skipValidation=!!s||!!a,Ri.prototype.parse.apply(u,arguments)},u._resetBlanks=Ri._resetBlanks,u}o(QF,"_Parser");E_.exports={Parser:QF,Generator:WF,Wildcard:HF}});var fy=v(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.CaseWhenTransformerError=Ba.CaseWhenTransformer=void 0;var ly=class{static{o(this,"CaseWhenTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new Fi("Too many nested CASE expressions (max 100 iterations)");while(t!==r);return t}transformSinglePass(e){let t=this.findCasePositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],a=this.extractCaseExpression(r,s);if(a){let c=this.convertCaseToIf(a.content);r=r.substring(0,s)+c+r.substring(s+a.length)}}return r}findCasePositions(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(r.substring(i,i+4)==="CASE"&&this.isWordBoundary(e,i,4)){t.push(i),i+=4;continue}i++}return t}extractCaseExpression(e,t){let r=1,i=t+4,s=e.toUpperCase();for(;i<e.length&&r>0;){if(e[i]==="'"||e[i]==='"'){let a=e[i];for(i++;i<e.length&&e[i]!==a;)e[i]==="\\"&&i++,i++;i++;continue}if(s.substring(i,i+4)==="CASE"&&this.isWordBoundary(e,i,4)){r++,i+=4;continue}if(s.substring(i,i+3)==="END"&&this.isWordBoundary(e,i,3)){if(r--,r===0){let a=e.substring(t,i+3);return{content:a,length:a.length}}i+=3;continue}i++}if(r>0)throw new Fi(`Unclosed CASE expression at position ${t}`);return null}isWordBoundary(e,t,r){let i=t>0?e[t-1]:"",s=t===0||!/[a-zA-Z0-9_?$]/.test(i),a=t+r<e.length?e[t+r]:"",c=t+r>=e.length||!/[a-zA-Z0-9_]/.test(a);return s&&c}convertCaseToIf(e){let t=this.extractWhenClauses(e),r=this.extractElseClause(e);if(t.length===0)throw new Fi("CASE expression must have at least one WHEN clause");let i=r!==null?r:'""';for(let s=t.length-1;s>=0;s--){let{condition:a,result:c}=t[s];i=`IF(${a}, ${c}, ${i})`}return i}extractWhenClauses(e){let t=[],r=e.replace(/^\s*CASE\s+/i,"").replace(/\s*END\s*$/i,""),i=this.findKeywordPositions(r,"WHEN"),s=this.findKeywordPositions(r,"ELSE"),a=s.length>0?s[0]:r.length;for(let c=0;c<i.length;c++){let u=i[c]+4,l=c+1<i.length?i[c+1]:a,f=r.substring(u,l).trim(),h=this.parseWhenClause(f);h&&t.push(h)}return t}findKeywordPositions(e,t){let r=[],i=e.toUpperCase(),s=0,a=0;for(;s<e.length;){let c=e[s];if(c==="'"||c==='"'){let u=c;for(s++;s<e.length&&e[s]!==u;)e[s]==="\\"&&s++,s++;s++;continue}if(c==="("){a++,s++;continue}if(c===")"){a--,s++;continue}if(a===0&&i.substring(s,s+t.length)===t&&this.isWordBoundary(e,s,t.length)){r.push(s),s+=t.length;continue}s++}return r}parseWhenClause(e){let t=this.findKeywordPositions(e,"THEN");if(t.length===0)throw new Fi(`WHEN clause missing THEN keyword: ${e.substring(0,50)}...`);let r=t[0],i=e.substring(0,r).trim(),s=e.substring(r+4).trim();if(!i)throw new Fi("WHEN clause has empty condition");if(!s)throw new Fi("WHEN clause has empty result");return{condition:i,result:s}}extractElseClause(e){let t=e.replace(/^\s*CASE\s+/i,"").replace(/\s*END\s*$/i,""),r=this.findKeywordPositions(t,"ELSE");if(r.length>0){let i=r[0];return t.substring(i+4).trim()}return null}};Ba.CaseWhenTransformer=ly;var Fi=class extends Error{static{o(this,"CaseWhenTransformerError")}constructor(e){super(`CASE WHEN transformation error: ${e}`),this.name="CaseWhenTransformerError"}};Ba.CaseWhenTransformerError=Fi});var hy=v(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.LateralTransformerError=qa.LateralTransformer=void 0;var Af=class n{static{o(this,"LateralTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new ns("Too many nested LATERAL joins (max 100 iterations)");while(t!==r);return t}hasLateral(e){return this.findLateralPositions(e).length>0}static isLateralJoin(e){if(e.type==="group"&&e.patterns){for(let t of e.patterns)if(t.type==="query"&&t.queryType==="SELECT"&&t.variables&&Array.isArray(t.variables)){for(let r of t.variables)if(r.termType==="Variable"&&r.value===n.LATERAL_MARKER)return!0}}if(e.type==="query"&&e.queryType==="SELECT"&&e.variables&&Array.isArray(e.variables)){for(let t of e.variables)if(t.termType==="Variable"&&t.value===n.LATERAL_MARKER)return!0}return!1}transformSinglePass(e){let t=this.findLateralPositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],a=this.extractLateralExpression(r,s);if(a){let c=this.transformLateral(a.content);r=r.substring(0,s)+c+r.substring(s+a.length)}}return r}findLateralPositions(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(e[i]==="#"){for(;i<e.length&&e[i]!==`
|
|
250
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:o(function(){var P=this.next();return P||this.lex()},"lex"),begin:o(function(P){this.conditionStack.push(P)},"begin"),popState:o(function(){var P=this.conditionStack.length-1;return P>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:o(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:o(function(P){return P=this.conditionStack.length-1-Math.abs(P||0),P>=0?this.conditionStack[P]:"INITIAL"},"topState"),pushState:o(function(P){this.begin(P)},"pushState"),stateStackSize:o(function(){return this.conditionStack.length},"stateStackSize"),options:{flex:!0,"case-insensitive":!0},performAction:o(function(P,F,Y,_e){var m=_e;switch(Y){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(F.yytext);break}},"anonymous"),rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};return x})();Sd.lexer=AA;function Ce(){this.yy={}}return o(Ce,"Parser"),Ce.prototype=Sd,Sd.Parser=Ce,new Ce})();m_.exports=kF});var __=v((gq,S_)=>{var MF="http://www.w3.org/2001/XMLSchema#integer",jF="http://www.w3.org/2001/XMLSchema#string";function ft(n){this._options=n=n||{};var e=n.prefixes||{};this._prefixByIri={};var t=[];for(var r in e){var i=e[r];Pc(i)&&(this._prefixByIri[i]=r,t.push(i))}var s=t.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=n.sparqlStar,this._indent=Pc(n.indent)?n.indent:" ",this._newline=Pc(n.newline)?n.newline:`
|
|
251
|
+
`,this._explicitDatatype=!!n.explicitDatatype}o(ft,"Generator");ft.prototype.toQuery=function(n){var e="";return n.queryType&&(e+=n.queryType.toUpperCase()+" "),n.reduced&&(e+="REDUCED "),n.distinct&&(e+="DISTINCT "),n.variables?e+=qr(n.variables,void 0,function(t){return/^[?$]/.test(t)?t:rs(t)?this.toEntity(t):"("+this.toExpression(t.expression)+" AS "+gf(t.variable)+")"},this)+" ":n.template&&(e+=this.group(n.template,!0)+this._newline),n.from&&(e+=this.graphs("FROM ",n.from.default)+this.graphs("FROM NAMED ",n.from.named)),n.where&&(e+="WHERE "+this.group(n.where,!0)+this._newline),n.updates&&(e+=qr(n.updates,";"+this._newline,this.toUpdate,this)),n.group&&(e+="GROUP BY "+qr(n.group,void 0,function(t){var r=rs(t.expression)?this.toEntity(t.expression):"("+this.toExpression(t.expression)+")";return t.variable?"("+r+" AS "+gf(t.variable)+")":r},this)+this._newline),n.having&&(e+="HAVING ("+qr(n.having,void 0,this.toExpression,this)+")"+this._newline),n.order&&(e+="ORDER BY "+qr(n.order,void 0,function(t){var r="("+this.toExpression(t.expression)+")";return t.descending?"DESC "+r:r},this)+this._newline),n.offset&&(e+="OFFSET "+n.offset+this._newline),n.limit&&(e+="LIMIT "+n.limit+this._newline),n.values&&(e+=this.values(n)),e=this.baseAndPrefixes(n)+e,e.trim()};ft.prototype.baseAndPrefixes=function(n){var e=n.base?"BASE <"+n.base+">"+this._newline:"",t="";for(var r in n.prefixes)(this._options.allPrefixes||this._usedPrefixes[r])&&(t+="PREFIX "+r+": <"+n.prefixes[r]+">"+this._newline);return e+t};ft.prototype.toPattern=function(n){var e=n.type||n instanceof Array&&"array"||(n.subject&&n.predicate&&n.object?"triple":"");if(!(e in this))throw new Error("Unknown entry type: "+e);return this[e](n)};ft.prototype.triple=function(n){return this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+"."};ft.prototype.array=function(n){return qr(n,this._newline,this.toPattern,this)};ft.prototype.bgp=function(n){return this.encodeTriples(n.triples)};ft.prototype.encodeTriples=function(n){if(!n.length)return"";for(var e=[],t=void 0,r=void 0,i=0;i<n.length;i++){var s=n[i];ea(s.subject,t)?ea(s.predicate,r)?e.push(","):(r=s.predicate,e.push(";"+this._newline,this._indent,this.toEntity(r))):(t&&e.push("."+this._newline),t=s.subject,r=s.predicate,e.push(this.toEntity(t)," ",this.toEntity(r))),e.push(" ",this.toEntity(s.object))}return e.push("."),e.join("")};ft.prototype.graph=function(n){return"GRAPH "+this.toEntity(n.name)+" "+this.group(n)};ft.prototype.graphs=function(n,e){return!e||e.length===0?"":qr(e,"",function(t){return n+this.toEntity(t)+this._newline},this)};ft.prototype.group=function(n,e){return n=e!==!0?this.array(n.patterns||n.triples):this.toPattern(n.type!=="group"?n:n.patterns),n.indexOf(this._newline)===-1?"{ "+n+" }":"{"+this._newline+this.indent(n)+this._newline+"}"};ft.prototype.query=function(n){return this.toQuery(n)};ft.prototype.filter=function(n){return"FILTER("+this.toExpression(n.expression)+")"};ft.prototype.bind=function(n){return"BIND("+this.toExpression(n.expression)+" AS "+gf(n.variable)+")"};ft.prototype.optional=function(n){return"OPTIONAL "+this.group(n)};ft.prototype.union=function(n){return qr(n.patterns,this._newline+"UNION"+this._newline,function(e){return this.group(e,!0)},this)};ft.prototype.minus=function(n){return"MINUS "+this.group(n)};ft.prototype.values=function(n){var e=Object.keys(n.values.reduce(function(i,s){for(var a in s)i[a]=!0;return i},{})),t,r;return e.length===1?t=r="":(t="(",r=")"),"VALUES "+t+e.join(" ")+r+" {"+this._newline+qr(n.values,this._newline,function(i){return" "+t+qr(e,void 0,function(s){return i[s]?this.toEntity(i[s]):"UNDEF"},this)+r},this)+this._newline+"}"};ft.prototype.service=function(n){return"SERVICE "+(n.silent?"SILENT ":"")+this.toEntity(n.name)+" "+this.group(n)};ft.prototype.toExpression=function(n){if(rs(n))return this.toEntity(n);switch(n.type.toLowerCase()){case"aggregate":return n.aggregation.toUpperCase()+"("+(n.distinct?"DISTINCT ":"")+this.toExpression(n.expression)+(typeof n.separator=="string"?'; SEPARATOR = "'+n.separator.replace(y_,v_)+'"':"")+")";case"functioncall":return this.toEntity(n.function)+"("+qr(n.args,", ",this.toExpression,this)+")";case"operation":var e=n.operator.toUpperCase(),t=n.args||[];switch(n.operator.toLowerCase()){case"<":case">":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(rs(t[0])?this.toEntity(t[0]):"("+this.toExpression(t[0])+")")+" "+e+" "+(rs(t[1])?this.toEntity(t[1]):"("+this.toExpression(t[1])+")");case"!":return"!("+this.toExpression(t[0])+")";case"uplus":return"+("+this.toExpression(t[0])+")";case"uminus":return"-("+this.toExpression(t[0])+")";case"notin":e="NOT IN";case"in":return this.toExpression(t[0])+" "+e+"("+(Pc(t[1])?t[1]:qr(t[1],", ",this.toExpression,this))+")";case"notexists":e="NOT EXISTS";case"exists":return e+" "+this.group(t[0],!0);default:return e+"("+qr(t,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+n.type)}};ft.prototype.toEntity=function(n){if(rs(n))switch(n.termType){case"Wildcard":return"*";case"Variable":return gf(n);case"BlankNode":return"_:"+n.value;case"Literal":var e=n.value||"",t=n.language||"",r=n.datatype;if(n='"'+e.replace(y_,v_)+'"',t)n+="@"+t;else if(r){if(!this._explicitDatatype)switch(r.value){case jF:return n;case MF:if(/^\d+$/.test(e))return e+" "}n+="^^"+this.encodeIRI(r.value)}return n;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return n.graph&&n.graph.termType!=="DefaultGraph"?"<< GRAPH "+this.toEntity(n.graph)+" { "+this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+" } >>":"<< "+this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+" >>";default:return this.encodeIRI(n.value)}else{var i=n.items.map(this.toEntity,this),s=n.pathType;switch(s){case"^":case"!":return s+i[0];case"*":case"+":case"?":return"("+i[0]+s+")";default:return"("+i.join(s)+")"}}};var y_=/["\\\t\n\r\b\f]/g,v_=o(function(n){return $F[n]},"escapeReplacer"),$F={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};ft.prototype.encodeIRI=function(n){var e=this._prefixRegex.exec(n);if(e){var t=this._prefixByIri[e[1]];return this._usedPrefixes[t]=!0,t+":"+e[2]}return"<"+n+">"};ft.prototype.toUpdate=function(n){switch(n.type||n.updateType){case"load":return"LOAD"+(n.source?" "+this.toEntity(n.source):"")+(n.destination?" INTO GRAPH "+this.toEntity(n.destination):"");case"insert":return"INSERT DATA "+this.group(n.insert,!0);case"delete":return"DELETE DATA "+this.group(n.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(n.delete,!0);case"insertdelete":return(n.graph?"WITH "+this.toEntity(n.graph)+this._newline:"")+(n.delete.length?"DELETE "+this.group(n.delete,!0)+this._newline:"")+(n.insert.length?"INSERT "+this.group(n.insert,!0)+this._newline:"")+(n.using?this.graphs("USING ",n.using.default):"")+(n.using?this.graphs("USING NAMED ",n.using.named):"")+"WHERE "+this.group(n.where,!0);case"add":case"copy":case"move":return n.type.toUpperCase()+" "+(n.silent?"SILENT ":"")+(n.source.default?"DEFAULT":this.toEntity(n.source.name))+" TO "+this.toEntity(n.destination.name);case"create":case"clear":case"drop":return n.type.toUpperCase()+(n.silent?" SILENT ":" ")+(n.graph.default?"DEFAULT":n.graph.named?"NAMED":n.graph.all?"ALL":"GRAPH "+this.toEntity(n.graph.name));default:throw new Error("Unknown update query type: "+n.type)}};ft.prototype.indent=function(n){return n.replace(/^/gm,this._indent)};function gf(n){return"?"+n.value}o(gf,"variableToString");function Pc(n){return typeof n=="string"}o(Pc,"isString");function rs(n){return typeof n.termType=="string"}o(rs,"isTerm");function ea(n,e){if(!n||!rs(n)||!e||!rs(e)||n.termType!==e.termType)return!1;switch(n.termType){case"Literal":return n.value===e.value&&n.language===e.language&&ea(n.datatype,e.datatype);case"Quad":return ea(n.subject,e.subject)&&ea(n.predicate,e.predicate)&&ea(n.object,e.object)&&ea(n.graph,e.graph);default:return n.value===e.value}}o(ea,"equalTerms");function qr(n,e,t,r){return n.map(t,r).join(Pc(e)?e:" ")}o(qr,"mapJoin");function VF(n={}){return{stringify:o(function(e){var t=Object.create(n);return t.prefixes=e.prefixes,new ft(t).toQuery(e)},"stringify"),createGenerator:o(function(){return new ft(n)},"createGenerator")}}o(VF,"_Generator");S_.exports={Generator:VF}});var ry=v(yf=>{"use strict";Object.defineProperty(yf,"__esModule",{value:!0});yf.BlankNode=void 0;var ty=class{static{o(this,"BlankNode")}constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&e.termType==="BlankNode"&&e.value===this.value}};yf.BlankNode=ty});var ny=v(vf=>{"use strict";Object.defineProperty(vf,"__esModule",{value:!0});vf.DefaultGraph=void 0;var Dc=class{static{o(this,"DefaultGraph")}constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&e.termType==="DefaultGraph"}};vf.DefaultGraph=Dc;Dc.INSTANCE=new Dc});var _f=v(Sf=>{"use strict";Object.defineProperty(Sf,"__esModule",{value:!0});Sf.NamedNode=void 0;var iy=class{static{o(this,"NamedNode")}constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&e.termType==="NamedNode"&&e.value===this.value}};Sf.NamedNode=iy});var sy=v(bf=>{"use strict";Object.defineProperty(bf,"__esModule",{value:!0});bf.Literal=void 0;var b_=_f(),Rc=class n{static{o(this,"Literal")}constructor(e,t){this.termType="Literal",this.value=e,typeof t=="string"?(this.language=t,this.datatype=n.RDF_LANGUAGE_STRING):t?(this.language="",this.datatype=t):(this.language="",this.datatype=n.XSD_STRING)}equals(e){return!!e&&e.termType==="Literal"&&e.value===this.value&&e.language===this.language&&this.datatype.equals(e.datatype)}};bf.Literal=Rc;Rc.RDF_LANGUAGE_STRING=new b_.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");Rc.XSD_STRING=new b_.NamedNode("http://www.w3.org/2001/XMLSchema#string")});var oy=v(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});wf.Quad=void 0;var ay=class{static{o(this,"Quad")}constructor(e,t,r,i){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=i}equals(e){return!!e&&(e.termType==="Quad"||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}};wf.Quad=ay});var uy=v(Ef=>{"use strict";Object.defineProperty(Ef,"__esModule",{value:!0});Ef.Variable=void 0;var cy=class{static{o(this,"Variable")}constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&e.termType==="Variable"&&e.value===this.value}};Ef.Variable=cy});var E_=v(Tf=>{"use strict";Object.defineProperty(Tf,"__esModule",{value:!0});Tf.DataFactory=void 0;var UF=ry(),BF=ny(),w_=sy(),qF=_f(),GF=oy(),WF=uy(),HF=0,ly=class{static{o(this,"DataFactory")}constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${HF++}_`}namedNode(e){return new qF.NamedNode(e)}blankNode(e){return new UF.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new w_.Literal(e,t)}variable(e){return new WF.Variable(e)}defaultGraph(){return BF.DefaultGraph.INSTANCE}quad(e,t,r,i){return new GF.Quad(e,t,r,i||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(w_.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}};Tf.DataFactory=ly});var T_=v(Gr=>{"use strict";var zF=Gr&&Gr.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),ta=Gr&&Gr.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&zF(e,n,t)};Object.defineProperty(Gr,"__esModule",{value:!0});ta(ry(),Gr);ta(E_(),Gr);ta(ny(),Gr);ta(sy(),Gr);ta(_f(),Gr);ta(oy(),Gr);ta(uy(),Gr)});var x_=v((Nq,A_)=>{var{Parser:Ri}=g_(),{Generator:QF}=__(),{Wildcard:YF}=ey(),{DataFactory:KF}=T_();function XF({prefixes:n,baseIRI:e,factory:t,pathOnly:r,sparqlStar:i,skipValidation:s,skipUngroupedVariableCheck:a}={}){let c={};for(let l in n??{})c[l]=n[l];let u=new Ri;return u.parse=function(){return Ri.base=e||"",Ri.prefixes=Object.create(c),Ri.factory=t||new KF,Ri.sparqlStar=!!i,Ri.pathOnly=!!r,Ri.skipValidation=!!s||!!a,Ri.prototype.parse.apply(u,arguments)},u._resetBlanks=Ri._resetBlanks,u}o(XF,"_Parser");A_.exports={Parser:XF,Generator:QF,Wildcard:YF}});var hy=v(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.CaseWhenTransformerError=Ba.CaseWhenTransformer=void 0;var fy=class{static{o(this,"CaseWhenTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new Fi("Too many nested CASE expressions (max 100 iterations)");while(t!==r);return t}transformSinglePass(e){let t=this.findCasePositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],a=this.extractCaseExpression(r,s);if(a){let c=this.convertCaseToIf(a.content);r=r.substring(0,s)+c+r.substring(s+a.length)}}return r}findCasePositions(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(r.substring(i,i+4)==="CASE"&&this.isWordBoundary(e,i,4)){t.push(i),i+=4;continue}i++}return t}extractCaseExpression(e,t){let r=1,i=t+4,s=e.toUpperCase();for(;i<e.length&&r>0;){if(e[i]==="'"||e[i]==='"'){let a=e[i];for(i++;i<e.length&&e[i]!==a;)e[i]==="\\"&&i++,i++;i++;continue}if(s.substring(i,i+4)==="CASE"&&this.isWordBoundary(e,i,4)){r++,i+=4;continue}if(s.substring(i,i+3)==="END"&&this.isWordBoundary(e,i,3)){if(r--,r===0){let a=e.substring(t,i+3);return{content:a,length:a.length}}i+=3;continue}i++}if(r>0)throw new Fi(`Unclosed CASE expression at position ${t}`);return null}isWordBoundary(e,t,r){let i=t>0?e[t-1]:"",s=t===0||!/[a-zA-Z0-9_?$]/.test(i),a=t+r<e.length?e[t+r]:"",c=t+r>=e.length||!/[a-zA-Z0-9_]/.test(a);return s&&c}convertCaseToIf(e){let t=this.extractWhenClauses(e),r=this.extractElseClause(e);if(t.length===0)throw new Fi("CASE expression must have at least one WHEN clause");let i=r!==null?r:'""';for(let s=t.length-1;s>=0;s--){let{condition:a,result:c}=t[s];i=`IF(${a}, ${c}, ${i})`}return i}extractWhenClauses(e){let t=[],r=e.replace(/^\s*CASE\s+/i,"").replace(/\s*END\s*$/i,""),i=this.findKeywordPositions(r,"WHEN"),s=this.findKeywordPositions(r,"ELSE"),a=s.length>0?s[0]:r.length;for(let c=0;c<i.length;c++){let u=i[c]+4,l=c+1<i.length?i[c+1]:a,f=r.substring(u,l).trim(),h=this.parseWhenClause(f);h&&t.push(h)}return t}findKeywordPositions(e,t){let r=[],i=e.toUpperCase(),s=0,a=0;for(;s<e.length;){let c=e[s];if(c==="'"||c==='"'){let u=c;for(s++;s<e.length&&e[s]!==u;)e[s]==="\\"&&s++,s++;s++;continue}if(c==="("){a++,s++;continue}if(c===")"){a--,s++;continue}if(a===0&&i.substring(s,s+t.length)===t&&this.isWordBoundary(e,s,t.length)){r.push(s),s+=t.length;continue}s++}return r}parseWhenClause(e){let t=this.findKeywordPositions(e,"THEN");if(t.length===0)throw new Fi(`WHEN clause missing THEN keyword: ${e.substring(0,50)}...`);let r=t[0],i=e.substring(0,r).trim(),s=e.substring(r+4).trim();if(!i)throw new Fi("WHEN clause has empty condition");if(!s)throw new Fi("WHEN clause has empty result");return{condition:i,result:s}}extractElseClause(e){let t=e.replace(/^\s*CASE\s+/i,"").replace(/\s*END\s*$/i,""),r=this.findKeywordPositions(t,"ELSE");if(r.length>0){let i=r[0];return t.substring(i+4).trim()}return null}};Ba.CaseWhenTransformer=fy;var Fi=class extends Error{static{o(this,"CaseWhenTransformerError")}constructor(e){super(`CASE WHEN transformation error: ${e}`),this.name="CaseWhenTransformerError"}};Ba.CaseWhenTransformerError=Fi});var dy=v(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.LateralTransformerError=qa.LateralTransformer=void 0;var Af=class n{static{o(this,"LateralTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new ns("Too many nested LATERAL joins (max 100 iterations)");while(t!==r);return t}hasLateral(e){return this.findLateralPositions(e).length>0}static isLateralJoin(e){if(e.type==="group"&&e.patterns){for(let t of e.patterns)if(t.type==="query"&&t.queryType==="SELECT"&&t.variables&&Array.isArray(t.variables)){for(let r of t.variables)if(r.termType==="Variable"&&r.value===n.LATERAL_MARKER)return!0}}if(e.type==="query"&&e.queryType==="SELECT"&&e.variables&&Array.isArray(e.variables)){for(let t of e.variables)if(t.termType==="Variable"&&t.value===n.LATERAL_MARKER)return!0}return!1}transformSinglePass(e){let t=this.findLateralPositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],a=this.extractLateralExpression(r,s);if(a){let c=this.transformLateral(a.content);r=r.substring(0,s)+c+r.substring(s+a.length)}}return r}findLateralPositions(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(e[i]==="#"){for(;i<e.length&&e[i]!==`
|
|
252
252
|
`;)i++;continue}if(r.substring(i,i+7)==="LATERAL"&&this.isWordBoundary(e,i,7)){t.push(i),i+=7;continue}i++}return t}extractLateralExpression(e,t){let r=t+7;for(;r<e.length&&/\s/.test(e[r]);)r++;if(e[r]!=="{")throw new ns(`Expected '{' after LATERAL keyword at position ${t}`);let i=1;for(r++;r<e.length&&i>0;){if(e[r]==="'"||e[r]==='"'){let s=e[r];for(r++;r<e.length&&e[r]!==s;)e[r]==="\\"&&r++,r++;r++;continue}if(e[r]==="#"){for(;r<e.length&&e[r]!==`
|
|
253
|
-
`;)r++;continue}if(e[r]==="{"){i++,r++;continue}if(e[r]==="}"){if(i--,i===0){let s=e.substring(t,r+1);return{content:s,length:s.length}}r++;continue}r++}if(i>0)throw new ns(`Unclosed LATERAL block at position ${t}`);return null}transformLateral(e){let t=e.indexOf("{");if(t===-1)throw new ns("LATERAL expression missing opening brace");let r=e.substring(t+1,e.length-1).trim();if(!r.toUpperCase().trim().startsWith("SELECT"))throw new ns("LATERAL block must contain a SELECT subquery");let a=r.toUpperCase().indexOf("SELECT")+6;for(;a<r.length&&/\s/.test(r[a]);)a++;let c=r.substring(a).toUpperCase();return c.startsWith("DISTINCT")?a+=8:c.startsWith("REDUCED")&&(a+=7),`{ ${r.substring(0,a)+` ?${n.LATERAL_MARKER}`+r.substring(a)} }`}isWordBoundary(e,t,r){let i=t>0?e[t-1]:"",s=t===0||!/[a-zA-Z0-9_]/.test(i),a=t+r<e.length?e[t+r]:"",c=t+r>=e.length||!/[a-zA-Z0-9_]/.test(a);return s&&c}};qa.LateralTransformer=Af;Af.LATERAL_MARKER="__LATERAL_JOIN__";var ns=class extends Error{static{o(this,"LateralTransformerError")}constructor(e){super(`LATERAL transformation error: ${e}`),this.name="LateralTransformerError"}};qa.LateralTransformerError=ns});var
|
|
253
|
+
`;)r++;continue}if(e[r]==="{"){i++,r++;continue}if(e[r]==="}"){if(i--,i===0){let s=e.substring(t,r+1);return{content:s,length:s.length}}r++;continue}r++}if(i>0)throw new ns(`Unclosed LATERAL block at position ${t}`);return null}transformLateral(e){let t=e.indexOf("{");if(t===-1)throw new ns("LATERAL expression missing opening brace");let r=e.substring(t+1,e.length-1).trim();if(!r.toUpperCase().trim().startsWith("SELECT"))throw new ns("LATERAL block must contain a SELECT subquery");let a=r.toUpperCase().indexOf("SELECT")+6;for(;a<r.length&&/\s/.test(r[a]);)a++;let c=r.substring(a).toUpperCase();return c.startsWith("DISTINCT")?a+=8:c.startsWith("REDUCED")&&(a+=7),`{ ${r.substring(0,a)+` ?${n.LATERAL_MARKER}`+r.substring(a)} }`}isWordBoundary(e,t,r){let i=t>0?e[t-1]:"",s=t===0||!/[a-zA-Z0-9_]/.test(i),a=t+r<e.length?e[t+r]:"",c=t+r>=e.length||!/[a-zA-Z0-9_]/.test(a);return s&&c}};qa.LateralTransformer=Af;Af.LATERAL_MARKER="__LATERAL_JOIN__";var ns=class extends Error{static{o(this,"LateralTransformerError")}constructor(e){super(`LATERAL transformation error: ${e}`),this.name="LateralTransformerError"}};qa.LateralTransformerError=ns});var C_=v(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.PrefixStarTransformerError=is.PrefixStarTransformer=is.WellKnownPrefixResolver=void 0;var xf=class{static{o(this,"WellKnownPrefixResolver")}constructor(){this.wellKnownPrefixes=new Map;let e=new Map;e.set("schema","http://schema.org/"),this.wellKnownPrefixes.set("http://schema.org/",e);let t=new Map;t.set("foaf","http://xmlns.com/foaf/0.1/"),this.wellKnownPrefixes.set("http://xmlns.com/foaf/0.1/",t);let r=new Map;r.set("dc","http://purl.org/dc/elements/1.1/"),r.set("dcterms","http://purl.org/dc/terms/"),this.wellKnownPrefixes.set("http://purl.org/dc/elements/1.1/",r),this.wellKnownPrefixes.set("http://purl.org/dc/terms/",r);let i=new Map;i.set("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"),i.set("rdfs","http://www.w3.org/2000/01/rdf-schema#"),this.wellKnownPrefixes.set("http://www.w3.org/1999/02/22-rdf-syntax-ns#",i),this.wellKnownPrefixes.set("http://www.w3.org/2000/01/rdf-schema#",i);let s=new Map;s.set("owl","http://www.w3.org/2002/07/owl#"),this.wellKnownPrefixes.set("http://www.w3.org/2002/07/owl#",s);let a=new Map;a.set("xsd","http://www.w3.org/2001/XMLSchema#"),this.wellKnownPrefixes.set("http://www.w3.org/2001/XMLSchema#",a);let c=new Map;c.set("skos","http://www.w3.org/2004/02/skos/core#"),this.wellKnownPrefixes.set("http://www.w3.org/2004/02/skos/core#",c);let u=new Map;u.set("prov","http://www.w3.org/ns/prov#"),this.wellKnownPrefixes.set("http://www.w3.org/ns/prov#",u);let l=new Map;l.set("geo","http://www.w3.org/2003/01/geo/wgs84_pos#"),this.wellKnownPrefixes.set("http://www.w3.org/2003/01/geo/wgs84_pos#",l);let f=new Map;f.set("dcat","http://www.w3.org/ns/dcat#"),this.wellKnownPrefixes.set("http://www.w3.org/ns/dcat#",f)}async resolve(e){let t=e.endsWith("#")||e.endsWith("/")?e:e+(e.includes("#")?"":"/"),r=this.wellKnownPrefixes.get(t);if(r)return r;let i=t.slice(0,-1),s=this.wellKnownPrefixes.get(i);return s||new Map}addVocabulary(e,t){this.wellKnownPrefixes.set(e,t)}};is.WellKnownPrefixResolver=xf;var py=class{static{o(this,"PrefixStarTransformer")}constructor(e){this.resolver=e??new xf}async transform(e){let t=this.findPrefixStarDeclarations(e);if(t.length===0)return e;let r=[],i=[];for(let a of t)try{let c=await this.resolver.resolve(a.uri);for(let[u,l]of c)r.push(`PREFIX ${u}: <${l}>`);if(c.size===0){let u=this.extractPrefixFromUri(a.uri);u&&r.push(`PREFIX ${u}: <${a.uri}>`)}}catch(c){let u=c instanceof Error?c.message:String(c);i.push(`Failed to resolve vocabulary ${a.uri}: ${u}`)}if(r.length===0&&i.length>0)throw new Ga(i.join("; "));let s=e;for(let a=t.length-1;a>=0;a--){let c=t[a];s=s.substring(0,c.startPos)+s.substring(c.endPos)}return r.length>0&&(s=r.join(`
|
|
254
254
|
`)+`
|
|
255
255
|
`+s.trimStart()),s}findPrefixStarDeclarations(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(r.substring(i,i+6)==="PREFIX"){let s=i;for(i+=6;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]==="*"){for(i++;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]==="<"){i++;let a=i;for(;i<e.length&&e[i]!==">";)i++;if(e[i]===">"){let c=e.substring(a,i);i++;let u=this.findDeclarationEnd(e,i);t.push({uri:c,startPos:s,endPos:u}),i=u;continue}else throw new Ga(`Unclosed IRI in PREFIX* declaration at position ${a}`)}else throw new Ga(`Expected IRI after PREFIX* at position ${i}`)}else continue}i++}return t}findDeclarationEnd(e,t){let r=t;for(;r<e.length;){let i=e[r];if(i===`
|
|
256
|
-
`)return r+1;let s=e.substring(r).toUpperCase();if(s.startsWith("PREFIX")||s.startsWith("BASE")||s.startsWith("SELECT")||s.startsWith("CONSTRUCT")||s.startsWith("DESCRIBE")||s.startsWith("ASK"))return r;if(/\s/.test(i)){r++;continue}break}return r}extractPrefixFromUri(e){let t=e.replace(/^https?:\/\//,"");t=t.replace(/\/$/,"").replace(/#$/,"");let r=t.split(/[/.#]+/).filter(Boolean);if(r.length===0)return null;let i=r[r.length-1];return/^(ontology|vocab|schema|ns|core)$/i.test(i)&&r.length>1?r[r.length-2].toLowerCase():i.toLowerCase().replace(/[^a-z0-9]/g,"")}};is.PrefixStarTransformer=dy;var Ga=class extends Error{static{o(this,"PrefixStarTransformerError")}constructor(e){super(`PREFIX* transformation error: ${e}`),this.name="PrefixStarTransformerError"}};is.PrefixStarTransformerError=Ga});var py=v(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.DescribeOptionsTransformer=Ha.DescribeOptionsTransformerError=void 0;var Cf=class extends Error{static{o(this,"DescribeOptionsTransformerError")}constructor(e){super(e),this.name="DescribeOptionsTransformerError"}};Ha.DescribeOptionsTransformerError=Cf;var Wa=class n{static{o(this,"DescribeOptionsTransformer")}transform(e){if(!n.DESCRIBE_QUERY_PATTERN.test(e))return{query:e};let t=e,r={},i=!1,s=n.DEPTH_PATTERN.exec(e);if(s){let a=parseInt(s[1],10);if(a<0)throw new Cf(`DESCRIBE DEPTH must be a non-negative integer, got: ${a}`);r.depth=a,i=!0,n.DEPTH_PATTERN.lastIndex=0,t=t.replace(n.DEPTH_PATTERN,"")}return n.DEPTH_PATTERN.lastIndex=0,n.SYMMETRIC_PATTERN.test(e)&&(r.symmetric=!0,i=!0,n.SYMMETRIC_PATTERN.lastIndex=0,t=t.replace(n.SYMMETRIC_PATTERN,"")),n.SYMMETRIC_PATTERN.lastIndex=0,t=t.replace(/\s{2,}/g," ").trim(),{query:t,options:i?r:void 0}}hasDescribeOptions(e){let t=n.DEPTH_PATTERN.test(e);n.DEPTH_PATTERN.lastIndex=0;let r=n.SYMMETRIC_PATTERN.test(e);return n.SYMMETRIC_PATTERN.lastIndex=0,t||r}};Ha.DescribeOptionsTransformer=Wa;Wa.DEPTH_PATTERN=/\bDEPTH\s+(\d+)/gi;Wa.SYMMETRIC_PATTERN=/\bSYMMETRIC\b/gi;Wa.DESCRIBE_QUERY_PATTERN=/\bDESCRIBE\b/i});var x_=v(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.DirectionalLangTagTransformerError=za.DirectionalLangTagTransformer=void 0;var If=class n{static{o(this,"DirectionalLangTagTransformer")}constructor(){this.directionMappings=new Map}transform(e){return this.directionMappings.clear(),e.replace(n.DIRECTIONAL_TAG_REGEX,(t,r,i,s,a)=>{let c=s.toLowerCase();return this.directionMappings.set(c,a),`${r}${i}${r}@${s}`})}getDirection(e){return this.directionMappings.get(e.toLowerCase())}getAllMappings(){return new Map(this.directionMappings)}hasDirectionalTags(e){return n.DIRECTIONAL_TAG_REGEX.lastIndex=0,n.DIRECTIONAL_TAG_REGEX.test(e)}clearMappings(){this.directionMappings.clear()}};za.DirectionalLangTagTransformer=If;If.DIRECTIONAL_TAG_REGEX=/(["'])((?:[^\\]|\\.)*?)\1@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)--(ltr|rtl)/g;var my=class extends Error{static{o(this,"DirectionalLangTagTransformerError")}constructor(e){super(`Directional language tag transformation error: ${e}`),this.name="DirectionalLangTagTransformerError"}};za.DirectionalLangTagTransformerError=my});var C_=v(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.TripleTermTransformerError=Ya.TripleTermTransformer=void 0;var gy=class{static{o(this,"TripleTermTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new Qa("Too many nested triple terms (max 100 iterations)");while(t!==r);return t}hasTripleTermSyntax(e){return this.findTripleTermPositions(e).length>0}transformSinglePass(e){let t=this.findTripleTermPositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],a=this.extractTripleTerm(r,s);if(a){let c=this.convertToStandardSyntax(a.content);r=r.substring(0,s)+c+r.substring(s+a.length)}}return r}findTripleTermPositions(e){let t=[],r=0;for(;r<e.length;){if(e[r]==="'"){r=this.skipStringLiteral(e,r,"'");continue}if(e[r]==='"'){r=this.skipStringLiteral(e,r,'"');continue}if(e.substring(r,r+2)==="<<"&&this.isParenthesizedTripleTerm(e,r)){t.push(r),r+=2;continue}r++}return t}skipStringLiteral(e,t,r){let i=r.repeat(3);if(e.substring(t,t+3)===i){for(t+=3;t<e.length;){if(e.substring(t,t+3)===i)return t+3;e[t]==="\\"&&t++,t++}return t}for(t++;t<e.length&&e[t]!==r;)e[t]==="\\"&&t++,t++;return t+1}isParenthesizedTripleTerm(e,t){let r=t+2;for(;r<e.length&&/\s/.test(e[r]);)r++;return e[r]==="("}extractTripleTerm(e,t){let r=t+2;for(;r<e.length&&/\s/.test(e[r]);)r++;if(e[r]!=="(")return null;r++;let i=1;for(;r<e.length&&i>0;){if(e[r]==="'"||e[r]==='"'){r=this.skipStringLiteral(e,r,e[r]);continue}if(e.substring(r,r+2)==="<<"&&this.isParenthesizedTripleTerm(e,r)){for(r+=2;r<e.length&&/\s/.test(e[r]);)r++;e[r]==="("&&(i++,r++);continue}if(e.substring(r,r+2)==="<<"){r+=2;let s=1;for(;r<e.length&&s>0;){if(e[r]==="'"||e[r]==='"'){r=this.skipStringLiteral(e,r,e[r]);continue}if(e.substring(r,r+2)==="<<"){s++,r+=2;continue}if(e.substring(r,r+2)===">>"){s--,r+=2;continue}r++}continue}if(e[r]==="("){i++,r++;continue}if(e[r]===")"){let s=r+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(e.substring(s,s+2)===">>"){if(i--,i===0){let a=e.substring(t,s+2);return{content:a,length:a.length}}r=s+2;continue}r++;continue}r++}if(i>0)throw new Qa(`Unclosed triple term at position ${t}: missing )>>`);return null}convertToStandardSyntax(e){let t=e.match(/^<<\s*\(\s*([\s\S]*?)\s*\)\s*>>$/);if(!t)throw new Qa(`Invalid triple term syntax: ${e.substring(0,50)}...`);return`<< ${t[1]} >>`}};Ya.TripleTermTransformer=gy;var Qa=class extends Error{static{o(this,"TripleTermTransformerError")}constructor(e){super(`Triple term transformation error: ${e}`),this.name="TripleTermTransformerError"}};Ya.TripleTermTransformerError=Qa});var P_=v(on=>{"use strict";var YF=on&&on.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),KF=on&&on.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),XF=on&&on.__importStar||(function(){var n=o(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&YF(t,e,r[i]);return KF(t,e),t}})();Object.defineProperty(on,"__esModule",{value:!0});on.SPARQLParser=on.SPARQLParseError=void 0;var I_=XF(T_()),yy=fy(),vy=hy(),O_=A_(),Sy=py(),JF=x_(),_y=C_(),Pt=class extends Error{static{o(this,"SPARQLParseError")}constructor(e,t,r,i){super(e,i?{cause:i}:void 0),this.name="SPARQLParseError",this.line=t,this.column=r}};on.SPARQLParseError=Pt;var by=class{static{o(this,"SPARQLParser")}constructor(e){this.lastDirectionMappings=new Map,this.parser=new I_.Parser({sparqlStar:!0}),this.generator=new I_.Generator({sparqlStar:!0}),this.caseWhenTransformer=new yy.CaseWhenTransformer,this.lateralTransformer=new vy.LateralTransformer,this.prefixStarTransformer=new O_.PrefixStarTransformer(e?.vocabularyResolver),this.describeOptionsTransformer=new Sy.DescribeOptionsTransformer,this.directionalLangTagTransformer=new JF.DirectionalLangTagTransformer,this.tripleTermTransformer=new _y.TripleTermTransformer}parse(e){try{let t=this.describeOptionsTransformer.transform(e);this.lastDescribeOptions=t.options;let r=t.query;r=this.directionalLangTagTransformer.transform(r),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),r=this.lateralTransformer.transform(r),r=this.caseWhenTransformer.transform(r),r=this.tripleTermTransformer.transform(r);let i=this.parser.parse(r);return this.validateQuery(i),this.lastDescribeOptions&&this.isDescribeQuery(i)&&(i.describeOptions=this.lastDescribeOptions),i}catch(t){if(t instanceof Sy.DescribeOptionsTransformerError)throw new Pt(t.message);if(t instanceof vy.LateralTransformerError)throw new Pt(t.message);if(t instanceof yy.CaseWhenTransformerError)throw new Pt(t.message);if(t instanceof _y.TripleTermTransformerError)throw new Pt(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new Pt(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}parseWithOptions(e){return{query:this.parse(e),describeOptions:this.lastDescribeOptions}}getLastDescribeOptions(){return this.lastDescribeOptions}async parseAsync(e){try{let t=this.describeOptionsTransformer.transform(e);this.lastDescribeOptions=t.options;let r=t.query;r=this.directionalLangTagTransformer.transform(r),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),r=await this.prefixStarTransformer.transform(r),r=this.lateralTransformer.transform(r),r=this.caseWhenTransformer.transform(r),r=this.tripleTermTransformer.transform(r);let i=this.parser.parse(r);return this.validateQuery(i),this.lastDescribeOptions&&this.isDescribeQuery(i)&&(i.describeOptions=this.lastDescribeOptions),i}catch(t){if(t instanceof Sy.DescribeOptionsTransformerError)throw new Pt(t.message);if(t instanceof O_.PrefixStarTransformerError)throw new Pt(t.message);if(t instanceof vy.LateralTransformerError)throw new Pt(t.message);if(t instanceof yy.CaseWhenTransformerError)throw new Pt(t.message);if(t instanceof _y.TripleTermTransformerError)throw new Pt(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new Pt(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}async parseAsyncWithOptions(e){return{query:await this.parseAsync(e),describeOptions:this.lastDescribeOptions}}hasPrefixStar(e){return/PREFIX\s*\*/i.test(e)}hasLateral(e){return this.lateralTransformer.hasLateral(e)}hasDescribeOptions(e){return this.describeOptionsTransformer.hasDescribeOptions(e)}hasDirectionalLangTags(e){return this.directionalLangTagTransformer.hasDirectionalTags(e)}hasTripleTermSyntax(e){return this.tripleTermTransformer.hasTripleTermSyntax(e)}getLastDirectionMappings(){return new Map(this.lastDirectionMappings)}getDirectionForLanguage(e){return this.lastDirectionMappings.get(e.toLowerCase())}toString(e){try{return this.generator.stringify(e)}catch(t){throw t instanceof Error?new Pt(`Failed to serialize SPARQL query: ${t.message}`,void 0,void 0,t):t}}getQueryType(e){if("queryType"in e&&e.type==="query")return e.queryType;throw new Pt("Query does not have a valid queryType property")}isSelectQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="SELECT"}isConstructQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="CONSTRUCT"}isAskQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="ASK"}isDescribeQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="DESCRIBE"}isUpdateQuery(e){return e.type==="update"}isInsertDataOperation(e){return"updateType"in e&&e.updateType==="insert"}isDeleteDataOperation(e){return"updateType"in e&&e.updateType==="delete"}validateQuery(e){if(!e||typeof e!="object")throw new Pt("Invalid query: not an object");if(e.type!=="query"&&e.type!=="update")throw new Pt(`Invalid type: expected "query" or "update", got "${e.type}"`);if(e.type==="query"){let t=["SELECT","CONSTRUCT","ASK","DESCRIBE"];if(!t.includes(e.queryType))throw new Pt(`Invalid query type: expected one of ${t.join(", ")}, got "${e.queryType}"`)}}};on.SPARQLParser=by});var R_=v(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.AlgebraTranslator=Ka.AlgebraTranslatorError=void 0;var D_=hy(),de=class extends Error{static{o(this,"AlgebraTranslatorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AlgebraTranslatorError"}};Ka.AlgebraTranslatorError=de;var wy=class{static{o(this,"AlgebraTranslator")}constructor(){this.directionMappings=new Map,this.aggregateCounter=0}setDirectionMappings(e){this.directionMappings=e}translate(e){if(e.type!=="query")throw new de("Only query operations are supported (not updates)");if(e.queryType==="SELECT")return this.translateSelect(e);if(e.queryType==="CONSTRUCT")return this.translateConstruct(e);if(e.queryType==="ASK")return this.translateAsk(e);if(e.queryType==="DESCRIBE")return this.translateDescribe(e);throw new de(`Query type ${e.queryType} not yet supported`)}translateSelect(e){let t;if(!e.where||e.where.length===0)throw new de("SELECT query must have WHERE clause");t=this.translateWhere(e.where),this.aggregateCounter=0;let r=new Map,i=this.extractAggregatesWithMapping(e.variables,r),s=this.extractGroupVariables(e.group);if((i.length>0||s.length>0)&&(t={type:"group",variables:s,aggregates:i,input:t}),e.variables&&e.variables.length>0){for(let c of e.variables){let u=c;if(u.expression&&u.variable){if(u.expression.type==="aggregate")continue;let l=this.transformExpressionWithAggregateVars(u.expression,r);t={type:"extend",variable:u.variable.value,expression:l,input:t}}}let a=e.variables.filter(c=>c.termType==="Variable"||c.variable).map(c=>c.termType==="Variable"?c.value:c.variable.value);a.length>0&&(t={type:"project",variables:a,input:t})}return e.distinct&&(t={type:"distinct",input:t}),e.reduced&&(t={type:"reduced",input:t}),e.order&&e.order.length>0&&(t={type:"orderby",comparators:e.order.map(a=>this.translateOrderComparator(a)),input:t}),(e.limit!==void 0||e.offset!==void 0)&&(t={type:"slice",limit:e.limit,offset:e.offset,input:t}),t}translateConstruct(e){let t=this.translateConstructTemplate(e.template??[]);if(!e.where||e.where.length===0)throw new de("CONSTRUCT query must have WHERE clause");let r=this.translateWhere(e.where);return{type:"construct",template:t,where:r}}translateConstructTemplate(e){return!e||!Array.isArray(e)?[]:e.map(t=>this.translateTriple(t))}translateAsk(e){return{type:"ask",where:e.where&&e.where.length>0?this.translateWhere(e.where):{type:"bgp",triples:[]}}}extractAggregatesWithMapping(e,t){if(!e)return[];let r=[];for(let i of e)!i.expression||!i.variable||(i.expression.type==="aggregate"?(r.push({variable:i.variable.value,expression:this.translateAggregateExpression(i.expression)}),t.set(i.expression,i.variable.value)):this.collectNestedAggregates(i.expression,r,t));return r}collectNestedAggregates(e,t,r){if(e){if(e.type==="aggregate"){let i=`__agg${this.aggregateCounter++}`;t.push({variable:i,expression:this.translateAggregateExpression(e)}),r.set(e,i)}else if(e.type==="operation"&&e.args)for(let i of e.args)this.collectNestedAggregates(i,t,r)}}transformExpressionWithAggregateVars(e,t){if(t.has(e))return{type:"variable",name:t.get(e)};if(e.type==="operation"&&e.args){let r=e.args.map(c=>this.transformExpressionWithAggregateVars(c,t)),i=["=","!=","<",">","<=",">="],s=["&&","||","!"],a=["+","-","*","/"];return i.includes(e.operator)?{type:"comparison",operator:e.operator,left:r[0],right:r[1]}:s.includes(e.operator)?{type:"logical",operator:e.operator,operands:r}:a.includes(e.operator)?{type:"arithmetic",operator:e.operator,left:r[0],right:r[1]}:{type:"function",function:e.operator,args:r}}return this.translateExpression(e)}extractGroupVariables(e){return e?e.filter(t=>t.expression&&t.expression.termType==="Variable").map(t=>t.expression.value):[]}translateAggregateExpression(e){let t=e.aggregation;if(typeof t=="string"){let r=t.toLowerCase();return["count","sum","avg","min","max","group_concat","sample"].includes(r)?{type:"aggregate",aggregation:r,expression:e.expression?this.translateExpression(e.expression):void 0,distinct:e.distinct||!1,separator:e.separator}:{type:"aggregate",aggregation:{type:"custom",iri:t},expression:e.expression?this.translateExpression(e.expression):void 0,distinct:e.distinct||!1,separator:e.separator}}if(t&&typeof t=="object"){let r;if(t.termType==="NamedNode"&&t.value)r=t.value;else if("value"in t)r=String(t.value);else throw new de(`Invalid custom aggregate: expected IRI but got ${JSON.stringify(t)}`);return{type:"aggregate",aggregation:{type:"custom",iri:r},expression:e.expression?this.translateExpression(e.expression):void 0,distinct:e.distinct||!1,separator:e.separator}}throw new de(`Unknown aggregate format: ${JSON.stringify(t)}`)}isLateralPattern(e){if(e.type==="query"&&this.isLateralSubquery(e))return!0;if(e.type==="group"&&e.patterns?.length===1){let t=e.patterns[0];if(t.type==="query"&&this.isLateralSubquery(t))return!0}return!1}extractLateralSubquery(e){if(e.type==="query")return e;if(e.type==="group"&&e.patterns?.length===1)return e.patterns[0];throw new de("Invalid lateral pattern structure")}translateWhere(e){if(e.length===0)throw new de("Empty WHERE clause");let t=e.filter(a=>a.type==="filter"),r=e.filter(a=>a.type==="bind"),i=e.filter(a=>a.type!=="filter"&&a.type!=="bind"),s;if(i.length===0)s={type:"bgp",triples:[]};else if(i.length===1)s=this.translatePattern(i[0]);else{s=this.translatePattern(i[0]);for(let a=1;a<i.length;a++){let c=i[a];if(this.isLateralPattern(c)){let u=this.extractLateralSubquery(c),l=this.removeLateralMarker(u),f=this.translateSelect(l);s={type:"lateraljoin",left:s,right:f}}else{let u=this.translatePattern(c);s={type:"join",left:s,right:u}}}}for(let a of r)s=this.translateBind(a,s);for(let a of t)s={type:"filter",expression:this.translateExpression(a.expression),input:s};return s}translatePattern(e){if(!e||!e.type)throw new de("Invalid pattern: missing type");switch(e.type){case"bgp":return this.translateBGP(e);case"filter":return this.translateFilter(e);case"optional":return this.translateOptional(e);case"union":return this.translateUnion(e);case"minus":return this.translateMinus(e);case"values":return this.translateValues(e);case"group":return this.translateWhere(e.patterns);case"query":return this.translateSubquery(e);case"service":return this.translateService(e);case"graph":return this.translateGraph(e);default:throw new de(`Unsupported pattern type: ${e.type}`)}}translateBGP(e){if(!e.triples||!Array.isArray(e.triples))throw new de("BGP pattern must have triples array");return{type:"bgp",triples:e.triples.map(t=>this.translateTriple(t))}}translateTriple(e){if(!e.subject||!e.predicate||!e.object)throw new de("Triple must have subject, predicate, and object");return{subject:this.translateTripleElement(e.subject),predicate:this.translatePredicate(e.predicate),object:this.translateTripleElement(e.object)}}translatePredicate(e){return e.type==="path"?this.translatePropertyPath(e):this.translateTripleElement(e)}translatePropertyPath(e){if(!e.pathType)throw new de("Property path must have pathType");if(!e.items||!Array.isArray(e.items))throw new de("Property path must have items array");let t=e.items.map(r=>this.translatePathItem(r));switch(e.pathType){case"/":return{type:"path",pathType:"/",items:t};case"|":return{type:"path",pathType:"|",items:t};case"^":if(t.length!==1)throw new de("Inverse path must have exactly one item");return{type:"path",pathType:"^",items:[t[0]]};case"+":if(t.length!==1)throw new de("OneOrMore path must have exactly one item");return{type:"path",pathType:"+",items:[t[0]]};case"*":if(t.length!==1)throw new de("ZeroOrMore path must have exactly one item");return{type:"path",pathType:"*",items:[t[0]]};case"?":if(t.length!==1)throw new de("ZeroOrOne path must have exactly one item");return{type:"path",pathType:"?",items:[t[0]]};default:throw new de(`Unsupported property path type: ${e.pathType}`)}}translatePathItem(e){if(e.type==="path")return this.translatePropertyPath(e);if(e.termType==="NamedNode")return{type:"iri",value:e.value};throw new de(`Unsupported path item type: ${e.type||e.termType}`)}translateTripleElement(e){if(!e||!e.termType)throw new de("Triple element must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};case"Literal":{let t={type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language};if(e.language){let r=this.directionMappings.get(e.language.toLowerCase());r&&(t.direction=r)}return t}case"BlankNode":return{type:"blank",value:e.value};case"Quad":return this.translateQuotedTriple(e);default:throw new de(`Unsupported term type: ${e.termType}`)}}translateQuotedTriple(e){if(!e.subject||!e.predicate||!e.object)throw new de("Quoted triple must have subject, predicate, and object");let t=this.translateTripleElement(e.subject),r=this.translateQuotedTriplePredicate(e.predicate),i=this.translateTripleElement(e.object);return{type:"quoted",subject:t,predicate:r,object:i}}translateQuotedTriplePredicate(e){if(!e||!e.termType)throw new de("Quoted triple predicate must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};default:throw new de(`Quoted triple predicate must be IRI or Variable, got: ${e.termType}`)}}translateFilter(e){if(!e.expression)throw new de("Filter pattern must have expression");let t=e.patterns?this.translateWhere(e.patterns):{type:"bgp",triples:[]};return{type:"filter",expression:this.translateExpression(e.expression),input:t}}translateExpression(e){if(!e)throw new de("Expression cannot be null or undefined");if(e.type==="operation")return this.translateOperationExpression(e);if(e.type==="functioncall"||e.type==="functionCall")return{type:"functionCall",function:e.function,args:e.args.map(t=>this.translateExpression(t))};if(e.termType)return this.translateTermExpression(e);throw new de(`Unsupported expression structure: ${JSON.stringify(e)}`)}translateOperationExpression(e){let t=["=","!=","<",">","<=",">="],r=["&&","||","!"],i=["+","-","*","/"];return t.includes(e.operator)?{type:"comparison",operator:e.operator,left:this.translateExpression(e.args[0]),right:this.translateExpression(e.args[1])}:r.includes(e.operator)?{type:"logical",operator:e.operator,operands:e.args.map(s=>this.translateExpression(s))}:i.includes(e.operator)?{type:"arithmetic",operator:e.operator,left:this.translateExpression(e.args[0]),right:this.translateExpression(e.args[1])}:e.operator==="exists"||e.operator==="notexists"?this.translateExistsExpression(e):e.operator==="in"||e.operator==="notin"?this.translateInExpression(e):{type:"function",function:e.operator,args:e.args.map(s=>this.translateExpression(s))}}translateExistsExpression(e){if(!e.args||e.args.length!==1)throw new de("EXISTS/NOT EXISTS must have exactly one pattern argument");let t=e.args[0],r;return t.type==="group"&&t.patterns?r=this.translateWhere(t.patterns):t.type==="bgp"?r=this.translateBGP(t):r=this.translatePattern(t),{type:"exists",negated:e.operator==="notexists",pattern:r}}translateInExpression(e){if(!e.args||e.args.length!==2)throw new de("IN/NOT IN must have exactly 2 arguments (expression and list)");let t=e.args[0],r=e.args[1];if(!Array.isArray(r))throw new de("IN/NOT IN second argument must be an array of values");return{type:"in",expression:this.translateExpression(t),list:r.map(i=>this.translateExpression(i)),negated:e.operator==="notin"}}translateTermExpression(e){if(e.termType==="Variable")return{type:"variable",name:e.value};if(e.termType==="Literal"){let t=e.value;return e.datatype&&(e.datatype.value.includes("#integer")||e.datatype.value.includes("#decimal")?t=parseFloat(e.value):e.datatype.value.includes("#boolean")&&(t=e.value==="true")),{type:"literal",value:t,datatype:e.datatype?.value}}return{type:"literal",value:String(e.value||e)}}translateOptional(e){if(!e.patterns||e.patterns.length===0)throw new de("OPTIONAL pattern must have patterns");return{type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns),expression:e.expression?this.translateExpression(e.expression):void 0}}translateUnion(e){if(!e.patterns||e.patterns.length<2)throw new de("UNION pattern must have at least 2 patterns");let t=o(i=>i.type==="graph"?this.translateGraph(i):i.type==="service"?this.translateService(i):i.patterns&&Array.isArray(i.patterns)?this.translateWhere(i.patterns):this.translateWhere([i]),"translateBranch"),r={type:"union",left:t(e.patterns[0]),right:t(e.patterns[1])};for(let i=2;i<e.patterns.length;i++)r={type:"union",left:r,right:t(e.patterns[i])};return r}translateMinus(e){if(!e.patterns||e.patterns.length===0)throw new de("MINUS pattern must have patterns");return{type:"minus",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns)}}translateValues(e){if(!e.values||!Array.isArray(e.values))throw new de("VALUES pattern must have values array");let t=new Set;for(let i of e.values)for(let s of Object.keys(i)){let a=s.startsWith("?")?s.slice(1):s;t.add(a)}let r=e.values.map(i=>this.translateValuesBinding(i));return{type:"values",variables:Array.from(t),bindings:r}}translateValuesBinding(e){let t={};for(let[r,i]of Object.entries(e)){let s=r.startsWith("?")?r.slice(1):r,a=i;if(a)if(a.termType==="NamedNode")t[s]={type:"iri",value:a.value};else if(a.termType==="Literal"){let c={type:"literal",value:a.value,datatype:a.datatype?.value,language:a.language||void 0};if(a.language){let u=this.directionMappings.get(a.language.toLowerCase());u&&(c.direction=u)}t[s]=c}else throw new de(`Unsupported VALUES term type: ${a.termType}`)}return t}translateBind(e,t){if(!e.variable||!e.expression)throw new de("BIND pattern must have variable and expression");return{type:"extend",variable:e.variable.value,expression:this.translateExpression(e.expression),input:t}}translateOrderComparator(e){return{expression:this.translateExpression(e.expression),descending:e.descending||!1}}isLateralSubquery(e){return e.queryType!=="SELECT"||!e.variables?!1:e.variables.some(t=>t.termType==="Variable"&&t.value===D_.LateralTransformer.LATERAL_MARKER)}removeLateralMarker(e){return e.variables?{...e,variables:e.variables.filter(t=>!(t.termType==="Variable"&&t.value===D_.LateralTransformer.LATERAL_MARKER))}:e}translateSubquery(e){if(e.queryType!=="SELECT")throw new de(`Only SELECT subqueries are supported, got: ${e.queryType}`);let t=this.removeLateralMarker(e);return{type:"subquery",query:this.translateSelect(t)}}translateService(e){if(!e.name||e.name.termType!=="NamedNode")throw new de("SERVICE pattern must have a NamedNode endpoint");if(!e.patterns||!Array.isArray(e.patterns))throw new de("SERVICE pattern must have patterns array");let t=this.translateWhere(e.patterns);return{type:"service",endpoint:e.name.value,pattern:t,silent:e.silent||!1}}translateGraph(e){if(!e.name)throw new de("GRAPH pattern must have a name (IRI or variable)");if(!e.patterns||!Array.isArray(e.patterns))throw new de("GRAPH pattern must have patterns array");let t;if(e.name.termType==="NamedNode")t={type:"iri",value:e.name.value};else if(e.name.termType==="Variable")t={type:"variable",value:e.name.value};else throw new de(`GRAPH pattern name must be NamedNode or Variable, got: ${e.name.termType}`);let r=this.translateWhere(e.patterns);return{type:"graph",name:t,pattern:r}}translateDescribe(e){let t=[];if(e.variables&&Array.isArray(e.variables))for(let s of e.variables){let a=s;a.termType==="Wildcard"||a.value==="*"||(a.termType==="Variable"?t.push({type:"variable",value:a.value}):a.termType==="NamedNode"&&t.push({type:"iri",value:a.value}))}let r;e.where&&e.where.length>0&&(r=this.translateWhere(e.where));let i=e.describeOptions;return{type:"describe",resources:t,where:r,depth:i?.depth,symmetric:i?.symmetric}}};Ka.AlgebraTranslator=wy});var Ty=v(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0});Of.FilterContainsOptimizer=void 0;var ZF=Qe(),e4=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,Ey=class{static{o(this,"FilterContainsOptimizer")}constructor(){this.tripleStore=null,this.lastOptimizationHints=[]}setTripleStore(e){this.tripleStore=e}getLastOptimizationHints(){return this.lastOptimizationHints}clearHints(){this.lastOptimizationHints=[]}async optimize(e){return this.clearHints(),this.optimizeRecursive(e)}optimizeSync(e,t){return this.clearHints(),this.optimizeSyncRecursive(e,t)}async optimizeRecursive(e){return e.type==="filter"?this.optimizeFilter(e):e.type==="join"?{type:"join",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="leftjoin"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="union"?{type:"union",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="minus"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="project"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="orderby"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="slice"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="distinct"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="reduced"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="group"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="extend"?{...e,input:await this.optimizeRecursive(e.input)}:e}optimizeSyncRecursive(e,t){return e.type==="filter"?this.optimizeFilterSync(e,t):e.type==="join"?{type:"join",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="leftjoin"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="union"?{type:"union",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="minus"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="project"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="orderby"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="slice"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="distinct"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="reduced"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="group"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="extend"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e}async optimizeFilter(e){let t=this.detectContainsUUIDPattern(e.expression);if(!t)return{type:"filter",expression:e.expression,input:await this.optimizeRecursive(e.input)};let r=[];return this.tripleStore&&(r=await this.findSubjectsContainingUUID(t.uuid)),this.rewriteFilter(e,t,r)}optimizeFilterSync(e,t){let r=this.detectContainsUUIDPattern(e.expression);if(!r)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input,t)};let i=t?t.filter(s=>s.includes(r.uuid)):[];return this.rewriteFilter(e,r,i)}rewriteFilter(e,t,r){if(this.lastOptimizationHints.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${t.variable}), "${t.uuid}"))`,suggestedRewrite:r.length===1?`VALUES ?${t.variable} { <${r[0]}> }`:r.length>1?`VALUES ?${t.variable} { ${r.map(i=>`<${i}>`).join(" ")} }`:"No matching URIs found for UUID",estimatedSpeedup:r.length>0?"O(n) \u2192 O(1)":"N/A",matchedUri:r.length===1?r[0]:void 0}),r.length===0)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input)};if(r.length===1){let i=this.injectSubjectConstraint(e.input,t.variable,r[0]);if(i!==e.input)return i}return this.createValuesJoin(e,t,r)}detectContainsUUIDPattern(e){if(e.type==="function"||e.type==="functionCall"){let t=e;if((typeof t.function=="string"?t.function.toLowerCase():t.function?.value?.toLowerCase()??"")==="contains"&&t.args.length===2)return this.analyzeContainsArgs(t.args[0],t.args[1],e)}if(e.type==="logical"&&e.operator==="&&")for(let t of e.operands){let r=this.detectContainsUUIDPattern(t);if(r)return r}return null}analyzeContainsArgs(e,t,r){let i=null;if(e.type==="function"||e.type==="functionCall"){let s=e;if((typeof s.function=="string"?s.function.toLowerCase():s.function?.value?.toLowerCase()??"")==="str"&&s.args.length===1){let c=s.args[0];c.type==="variable"&&(i=c.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let c=String(t.value).match(e4);if(c)return{variable:i,uuid:c[0].toLowerCase(),originalExpression:r}}return null}async findSubjectsContainingUUID(e){if(!this.tripleStore)return[];if(this.tripleStore.findSubjectsByUUID)return(await this.tripleStore.findSubjectsByUUID(e)).map(s=>s.value);let t=await this.tripleStore.subjects(),r=[];for(let i of t)i instanceof ZF.IRI&&i.value.toLowerCase().includes(e.toLowerCase())&&r.push(i.value);return r}injectSubjectConstraint(e,t,r){if(e.type==="bgp"){let i=e.triples.map(a=>a.subject.type==="variable"&&a.subject.value===t?{...a,subject:{type:"iri",value:r}}:a);if(i.some((a,c)=>a.subject!==e.triples[c].subject))return{type:"bgp",triples:i}}if(e.type==="join"){let i=this.injectSubjectConstraint(e.left,t,r),s=this.injectSubjectConstraint(e.right,t,r);if(i!==e.left||s!==e.right)return{type:"join",left:i,right:s}}if(e.type==="filter"){let i=this.injectSubjectConstraint(e.input,t,r);if(i!==e.input)return{...e,input:i}}return e}createValuesJoin(e,t,r){return{type:"join",left:{type:"values",variables:[t.variable],bindings:r.map(a=>({[t.variable]:{type:"iri",value:a}}))},right:this.optimizeSyncRecursive(e.input)}}analyzeQuery(e){let t=[];return this.analyzeRecursive(e,t),t}analyzeRecursive(e,t){if(e.type==="filter"){let r=this.detectContainsUUIDPattern(e.expression);r&&t.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${r.variable}), "${r.uuid}"))`,suggestedRewrite:`Use --optimize flag or rewrite as VALUES ?${r.variable} { <uri-containing-uuid> }`,estimatedSpeedup:"O(n) \u2192 O(1) with UUID index lookup"}),this.analyzeRecursive(e.input,t);return}e.type==="join"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="leftjoin"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="union"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="minus"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="project"?this.analyzeRecursive(e.input,t):e.type==="orderby"?this.analyzeRecursive(e.input,t):e.type==="slice"?this.analyzeRecursive(e.input,t):e.type==="distinct"?this.analyzeRecursive(e.input,t):e.type==="reduced"?this.analyzeRecursive(e.input,t):e.type==="group"?this.analyzeRecursive(e.input,t):e.type==="extend"&&this.analyzeRecursive(e.input,t)}};Of.FilterContainsOptimizer=Ey});var F_=v(Pf=>{"use strict";Object.defineProperty(Pf,"__esModule",{value:!0});Pf.AlgebraOptimizer=void 0;var t4=Ty(),Ay=class{static{o(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new t4.FilterContainsOptimizer}setTripleStore(e){this.tripleStore=e,this.filterContainsOptimizer.setTripleStore(e)}getOptimizationHints(){return this.filterContainsOptimizer.getLastOptimizationHints()}analyzeQuery(e){return this.filterContainsOptimizer.analyzeQuery(e)}optimize(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),t=this.filterPushDown(t),t=this.joinReordering(t),t}async optimizeAsync(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),this.tripleStore&&(t=await this.filterContainsOptimizer.optimize(t)),t=this.filterPushDown(t),t=this.joinReordering(t),t}optimizeWithSubjects(e,t){let r=e;return r=this.eliminateEmptyBGPInFilterJoin(r),r=this.filterContainsOptimizer.optimizeSync(r,t),r=this.filterPushDown(r),r=this.joinReordering(r),r}eliminateEmptyBGPInFilterJoin(e){if(e.type==="join"){if(e.left.type==="filter"){let t=e.left;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.right)}}if(e.right.type==="filter"){let t=e.right;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.left)}}return{type:"join",left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}}return e.type==="filter"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="leftjoin"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="union"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="minus"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="project"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="orderby"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="slice"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="distinct"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e}filterPushDown(e){return e.type==="filter"?this.pushDownFilter(e):e.type==="join"?{type:"join",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="leftjoin"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="union"?{type:"union",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="minus"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="project"?{...e,input:this.filterPushDown(e.input)}:e.type==="orderby"?{...e,input:this.filterPushDown(e.input)}:e.type==="slice"?{...e,input:this.filterPushDown(e.input)}:e.type==="distinct"?{...e,input:this.filterPushDown(e.input)}:e}pushDownFilter(e){let t=e.input;if(t.type==="join"){let r=this.getFilterVariables(e.expression),i=this.getOperationVariables(t.left),s=this.getOperationVariables(t.right),a=r.every(u=>i.has(u)),c=r.every(u=>s.has(u));return a&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!a?{type:"join",left:this.filterPushDown(t.left),right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:{type:"join",left:this.filterPushDown(t.left),right:this.filterPushDown(t.right)}}}return t.type==="union"?{type:"union",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:this.filterPushDown(t)}}getFilterVariables(e){let t=[];if(e.type==="variable")t.push(e.name);else if(e.type==="comparison")t.push(...this.getFilterVariables(e.left)),t.push(...this.getFilterVariables(e.right));else if(e.type==="logical")for(let r of e.operands)t.push(...this.getFilterVariables(r));else if(e.type==="function")for(let r of e.args)t.push(...this.getFilterVariables(r));return Array.from(new Set(t))}getOperationVariables(e){let t=new Set;if(e.type==="bgp")for(let r of e.triples)r.subject.type==="variable"&&t.add(r.subject.value),r.predicate.type==="variable"&&t.add(r.predicate.value),r.object.type==="variable"&&t.add(r.object.value);else if(e.type==="join"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="filter")return this.getOperationVariables(e.input);if(e.type==="leftjoin"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else if(e.type==="union"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="minus")return this.getOperationVariables(e.left);if(e.type==="project")return new Set(e.variables)}}return t}joinReordering(e){return e.type==="join"?this.reorderJoin(e):e.type==="filter"?{...e,input:this.joinReordering(e.input)}:e.type==="leftjoin"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="union"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="minus"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="project"?{...e,input:this.joinReordering(e.input)}:e.type==="orderby"?{...e,input:this.joinReordering(e.input)}:e.type==="slice"?{...e,input:this.joinReordering(e.input)}:e.type==="distinct"?{...e,input:this.joinReordering(e.input)}:e}reorderJoin(e){let t=this.estimateCost(e.left);return this.estimateCost(e.right)<t?{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)}:{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)}}estimateCost(e){if(e.type==="bgp"){let t=e.triples.length*100;for(let r of e.triples)r.subject.type==="variable"&&(t+=10),r.predicate.type==="variable"&&(t+=20),r.object.type==="variable"&&(t+=10);return t}return e.type==="filter"?this.estimateCost(e.input)*.3:e.type==="join"?this.estimateCost(e.left)*this.estimateCost(e.right):e.type==="leftjoin"?this.estimateCost(e.left)+this.estimateCost(e.right)*.5:e.type==="union"?this.estimateCost(e.left)+this.estimateCost(e.right):e.type==="minus"?this.estimateCost(e.left)+this.estimateCost(e.right)*.3:100}setStatistics(e,t){this.stats.set(e,t)}getStatistics(e){return this.stats.get(e)}};Pf.AlgebraOptimizer=Ay});var N_=v(Df=>{"use strict";Object.defineProperty(Df,"__esModule",{value:!0});Df.AlgebraSerializer=void 0;var xy=class{static{o(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
|
|
256
|
+
`)return r+1;let s=e.substring(r).toUpperCase();if(s.startsWith("PREFIX")||s.startsWith("BASE")||s.startsWith("SELECT")||s.startsWith("CONSTRUCT")||s.startsWith("DESCRIBE")||s.startsWith("ASK"))return r;if(/\s/.test(i)){r++;continue}break}return r}extractPrefixFromUri(e){let t=e.replace(/^https?:\/\//,"");t=t.replace(/\/$/,"").replace(/#$/,"");let r=t.split(/[/.#]+/).filter(Boolean);if(r.length===0)return null;let i=r[r.length-1];return/^(ontology|vocab|schema|ns|core)$/i.test(i)&&r.length>1?r[r.length-2].toLowerCase():i.toLowerCase().replace(/[^a-z0-9]/g,"")}};is.PrefixStarTransformer=py;var Ga=class extends Error{static{o(this,"PrefixStarTransformerError")}constructor(e){super(`PREFIX* transformation error: ${e}`),this.name="PrefixStarTransformerError"}};is.PrefixStarTransformerError=Ga});var my=v(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.DescribeOptionsTransformer=Ha.DescribeOptionsTransformerError=void 0;var Cf=class extends Error{static{o(this,"DescribeOptionsTransformerError")}constructor(e){super(e),this.name="DescribeOptionsTransformerError"}};Ha.DescribeOptionsTransformerError=Cf;var Wa=class n{static{o(this,"DescribeOptionsTransformer")}transform(e){if(!n.DESCRIBE_QUERY_PATTERN.test(e))return{query:e};let t=e,r={},i=!1,s=n.DEPTH_PATTERN.exec(e);if(s){let a=parseInt(s[1],10);if(a<0)throw new Cf(`DESCRIBE DEPTH must be a non-negative integer, got: ${a}`);r.depth=a,i=!0,n.DEPTH_PATTERN.lastIndex=0,t=t.replace(n.DEPTH_PATTERN,"")}return n.DEPTH_PATTERN.lastIndex=0,n.SYMMETRIC_PATTERN.test(e)&&(r.symmetric=!0,i=!0,n.SYMMETRIC_PATTERN.lastIndex=0,t=t.replace(n.SYMMETRIC_PATTERN,"")),n.SYMMETRIC_PATTERN.lastIndex=0,t=t.replace(/\s{2,}/g," ").trim(),{query:t,options:i?r:void 0}}hasDescribeOptions(e){let t=n.DEPTH_PATTERN.test(e);n.DEPTH_PATTERN.lastIndex=0;let r=n.SYMMETRIC_PATTERN.test(e);return n.SYMMETRIC_PATTERN.lastIndex=0,t||r}};Ha.DescribeOptionsTransformer=Wa;Wa.DEPTH_PATTERN=/\bDEPTH\s+(\d+)/gi;Wa.SYMMETRIC_PATTERN=/\bSYMMETRIC\b/gi;Wa.DESCRIBE_QUERY_PATTERN=/\bDESCRIBE\b/i});var I_=v(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.DirectionalLangTagTransformerError=za.DirectionalLangTagTransformer=void 0;var If=class n{static{o(this,"DirectionalLangTagTransformer")}constructor(){this.directionMappings=new Map}transform(e){return this.directionMappings.clear(),e.replace(n.DIRECTIONAL_TAG_REGEX,(t,r,i,s,a)=>{let c=s.toLowerCase();return this.directionMappings.set(c,a),`${r}${i}${r}@${s}`})}getDirection(e){return this.directionMappings.get(e.toLowerCase())}getAllMappings(){return new Map(this.directionMappings)}hasDirectionalTags(e){return n.DIRECTIONAL_TAG_REGEX.lastIndex=0,n.DIRECTIONAL_TAG_REGEX.test(e)}clearMappings(){this.directionMappings.clear()}};za.DirectionalLangTagTransformer=If;If.DIRECTIONAL_TAG_REGEX=/(["'])((?:[^\\]|\\.)*?)\1@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)--(ltr|rtl)/g;var gy=class extends Error{static{o(this,"DirectionalLangTagTransformerError")}constructor(e){super(`Directional language tag transformation error: ${e}`),this.name="DirectionalLangTagTransformerError"}};za.DirectionalLangTagTransformerError=gy});var O_=v(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.TripleTermTransformerError=Ya.TripleTermTransformer=void 0;var yy=class{static{o(this,"TripleTermTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new Qa("Too many nested triple terms (max 100 iterations)");while(t!==r);return t}hasTripleTermSyntax(e){return this.findTripleTermPositions(e).length>0}transformSinglePass(e){let t=this.findTripleTermPositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],a=this.extractTripleTerm(r,s);if(a){let c=this.convertToStandardSyntax(a.content);r=r.substring(0,s)+c+r.substring(s+a.length)}}return r}findTripleTermPositions(e){let t=[],r=0;for(;r<e.length;){if(e[r]==="'"){r=this.skipStringLiteral(e,r,"'");continue}if(e[r]==='"'){r=this.skipStringLiteral(e,r,'"');continue}if(e.substring(r,r+2)==="<<"&&this.isParenthesizedTripleTerm(e,r)){t.push(r),r+=2;continue}r++}return t}skipStringLiteral(e,t,r){let i=r.repeat(3);if(e.substring(t,t+3)===i){for(t+=3;t<e.length;){if(e.substring(t,t+3)===i)return t+3;e[t]==="\\"&&t++,t++}return t}for(t++;t<e.length&&e[t]!==r;)e[t]==="\\"&&t++,t++;return t+1}isParenthesizedTripleTerm(e,t){let r=t+2;for(;r<e.length&&/\s/.test(e[r]);)r++;return e[r]==="("}extractTripleTerm(e,t){let r=t+2;for(;r<e.length&&/\s/.test(e[r]);)r++;if(e[r]!=="(")return null;r++;let i=1;for(;r<e.length&&i>0;){if(e[r]==="'"||e[r]==='"'){r=this.skipStringLiteral(e,r,e[r]);continue}if(e.substring(r,r+2)==="<<"&&this.isParenthesizedTripleTerm(e,r)){for(r+=2;r<e.length&&/\s/.test(e[r]);)r++;e[r]==="("&&(i++,r++);continue}if(e.substring(r,r+2)==="<<"){r+=2;let s=1;for(;r<e.length&&s>0;){if(e[r]==="'"||e[r]==='"'){r=this.skipStringLiteral(e,r,e[r]);continue}if(e.substring(r,r+2)==="<<"){s++,r+=2;continue}if(e.substring(r,r+2)===">>"){s--,r+=2;continue}r++}continue}if(e[r]==="("){i++,r++;continue}if(e[r]===")"){let s=r+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(e.substring(s,s+2)===">>"){if(i--,i===0){let a=e.substring(t,s+2);return{content:a,length:a.length}}r=s+2;continue}r++;continue}r++}if(i>0)throw new Qa(`Unclosed triple term at position ${t}: missing )>>`);return null}convertToStandardSyntax(e){let t=e.match(/^<<\s*\(\s*([\s\S]*?)\s*\)\s*>>$/);if(!t)throw new Qa(`Invalid triple term syntax: ${e.substring(0,50)}...`);return`<< ${t[1]} >>`}};Ya.TripleTermTransformer=yy;var Qa=class extends Error{static{o(this,"TripleTermTransformerError")}constructor(e){super(`Triple term transformation error: ${e}`),this.name="TripleTermTransformerError"}};Ya.TripleTermTransformerError=Qa});var R_=v(on=>{"use strict";var JF=on&&on.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),ZF=on&&on.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),e4=on&&on.__importStar||(function(){var n=o(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&JF(t,e,r[i]);return ZF(t,e),t}})();Object.defineProperty(on,"__esModule",{value:!0});on.SPARQLParser=on.SPARQLParseError=void 0;var P_=e4(x_()),vy=hy(),Sy=dy(),D_=C_(),_y=my(),t4=I_(),by=O_(),Pt=class extends Error{static{o(this,"SPARQLParseError")}constructor(e,t,r,i){super(e,i?{cause:i}:void 0),this.name="SPARQLParseError",this.line=t,this.column=r}};on.SPARQLParseError=Pt;var wy=class{static{o(this,"SPARQLParser")}constructor(e){this.lastDirectionMappings=new Map,this.parser=new P_.Parser({sparqlStar:!0}),this.generator=new P_.Generator({sparqlStar:!0}),this.caseWhenTransformer=new vy.CaseWhenTransformer,this.lateralTransformer=new Sy.LateralTransformer,this.prefixStarTransformer=new D_.PrefixStarTransformer(e?.vocabularyResolver),this.describeOptionsTransformer=new _y.DescribeOptionsTransformer,this.directionalLangTagTransformer=new t4.DirectionalLangTagTransformer,this.tripleTermTransformer=new by.TripleTermTransformer}parse(e){try{let t=this.describeOptionsTransformer.transform(e);this.lastDescribeOptions=t.options;let r=t.query;r=this.directionalLangTagTransformer.transform(r),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),r=this.lateralTransformer.transform(r),r=this.caseWhenTransformer.transform(r),r=this.tripleTermTransformer.transform(r);let i=this.parser.parse(r);return this.validateQuery(i),this.lastDescribeOptions&&this.isDescribeQuery(i)&&(i.describeOptions=this.lastDescribeOptions),i}catch(t){if(t instanceof _y.DescribeOptionsTransformerError)throw new Pt(t.message);if(t instanceof Sy.LateralTransformerError)throw new Pt(t.message);if(t instanceof vy.CaseWhenTransformerError)throw new Pt(t.message);if(t instanceof by.TripleTermTransformerError)throw new Pt(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new Pt(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}parseWithOptions(e){return{query:this.parse(e),describeOptions:this.lastDescribeOptions}}getLastDescribeOptions(){return this.lastDescribeOptions}async parseAsync(e){try{let t=this.describeOptionsTransformer.transform(e);this.lastDescribeOptions=t.options;let r=t.query;r=this.directionalLangTagTransformer.transform(r),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),r=await this.prefixStarTransformer.transform(r),r=this.lateralTransformer.transform(r),r=this.caseWhenTransformer.transform(r),r=this.tripleTermTransformer.transform(r);let i=this.parser.parse(r);return this.validateQuery(i),this.lastDescribeOptions&&this.isDescribeQuery(i)&&(i.describeOptions=this.lastDescribeOptions),i}catch(t){if(t instanceof _y.DescribeOptionsTransformerError)throw new Pt(t.message);if(t instanceof D_.PrefixStarTransformerError)throw new Pt(t.message);if(t instanceof Sy.LateralTransformerError)throw new Pt(t.message);if(t instanceof vy.CaseWhenTransformerError)throw new Pt(t.message);if(t instanceof by.TripleTermTransformerError)throw new Pt(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new Pt(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}async parseAsyncWithOptions(e){return{query:await this.parseAsync(e),describeOptions:this.lastDescribeOptions}}hasPrefixStar(e){return/PREFIX\s*\*/i.test(e)}hasLateral(e){return this.lateralTransformer.hasLateral(e)}hasDescribeOptions(e){return this.describeOptionsTransformer.hasDescribeOptions(e)}hasDirectionalLangTags(e){return this.directionalLangTagTransformer.hasDirectionalTags(e)}hasTripleTermSyntax(e){return this.tripleTermTransformer.hasTripleTermSyntax(e)}getLastDirectionMappings(){return new Map(this.lastDirectionMappings)}getDirectionForLanguage(e){return this.lastDirectionMappings.get(e.toLowerCase())}toString(e){try{return this.generator.stringify(e)}catch(t){throw t instanceof Error?new Pt(`Failed to serialize SPARQL query: ${t.message}`,void 0,void 0,t):t}}getQueryType(e){if("queryType"in e&&e.type==="query")return e.queryType;throw new Pt("Query does not have a valid queryType property")}isSelectQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="SELECT"}isConstructQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="CONSTRUCT"}isAskQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="ASK"}isDescribeQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="DESCRIBE"}isUpdateQuery(e){return e.type==="update"}isInsertDataOperation(e){return"updateType"in e&&e.updateType==="insert"}isDeleteDataOperation(e){return"updateType"in e&&e.updateType==="delete"}validateQuery(e){if(!e||typeof e!="object")throw new Pt("Invalid query: not an object");if(e.type!=="query"&&e.type!=="update")throw new Pt(`Invalid type: expected "query" or "update", got "${e.type}"`);if(e.type==="query"){let t=["SELECT","CONSTRUCT","ASK","DESCRIBE"];if(!t.includes(e.queryType))throw new Pt(`Invalid query type: expected one of ${t.join(", ")}, got "${e.queryType}"`)}}};on.SPARQLParser=wy});var N_=v(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.AlgebraTranslator=Ka.AlgebraTranslatorError=void 0;var F_=dy(),de=class extends Error{static{o(this,"AlgebraTranslatorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AlgebraTranslatorError"}};Ka.AlgebraTranslatorError=de;var Ey=class{static{o(this,"AlgebraTranslator")}constructor(){this.directionMappings=new Map,this.aggregateCounter=0}setDirectionMappings(e){this.directionMappings=e}translate(e){if(e.type!=="query")throw new de("Only query operations are supported (not updates)");if(e.queryType==="SELECT")return this.translateSelect(e);if(e.queryType==="CONSTRUCT")return this.translateConstruct(e);if(e.queryType==="ASK")return this.translateAsk(e);if(e.queryType==="DESCRIBE")return this.translateDescribe(e);throw new de(`Query type ${e.queryType} not yet supported`)}translateSelect(e){let t;if(!e.where||e.where.length===0)throw new de("SELECT query must have WHERE clause");t=this.translateWhere(e.where),this.aggregateCounter=0;let r=new Map,i=this.extractAggregatesWithMapping(e.variables,r),s=this.extractGroupVariables(e.group);if((i.length>0||s.length>0)&&(t={type:"group",variables:s,aggregates:i,input:t}),e.variables&&e.variables.length>0){for(let c of e.variables){let u=c;if(u.expression&&u.variable){if(u.expression.type==="aggregate")continue;let l=this.transformExpressionWithAggregateVars(u.expression,r);t={type:"extend",variable:u.variable.value,expression:l,input:t}}}let a=e.variables.filter(c=>c.termType==="Variable"||c.variable).map(c=>c.termType==="Variable"?c.value:c.variable.value);a.length>0&&(t={type:"project",variables:a,input:t})}return e.distinct&&(t={type:"distinct",input:t}),e.reduced&&(t={type:"reduced",input:t}),e.order&&e.order.length>0&&(t={type:"orderby",comparators:e.order.map(a=>this.translateOrderComparator(a)),input:t}),(e.limit!==void 0||e.offset!==void 0)&&(t={type:"slice",limit:e.limit,offset:e.offset,input:t}),t}translateConstruct(e){let t=this.translateConstructTemplate(e.template??[]);if(!e.where||e.where.length===0)throw new de("CONSTRUCT query must have WHERE clause");let r=this.translateWhere(e.where);return{type:"construct",template:t,where:r}}translateConstructTemplate(e){return!e||!Array.isArray(e)?[]:e.map(t=>this.translateTriple(t))}translateAsk(e){return{type:"ask",where:e.where&&e.where.length>0?this.translateWhere(e.where):{type:"bgp",triples:[]}}}extractAggregatesWithMapping(e,t){if(!e)return[];let r=[];for(let i of e)!i.expression||!i.variable||(i.expression.type==="aggregate"?(r.push({variable:i.variable.value,expression:this.translateAggregateExpression(i.expression)}),t.set(i.expression,i.variable.value)):this.collectNestedAggregates(i.expression,r,t));return r}collectNestedAggregates(e,t,r){if(e){if(e.type==="aggregate"){let i=`__agg${this.aggregateCounter++}`;t.push({variable:i,expression:this.translateAggregateExpression(e)}),r.set(e,i)}else if(e.type==="operation"&&e.args)for(let i of e.args)this.collectNestedAggregates(i,t,r)}}transformExpressionWithAggregateVars(e,t){if(t.has(e))return{type:"variable",name:t.get(e)};if(e.type==="operation"&&e.args){let r=e.args.map(c=>this.transformExpressionWithAggregateVars(c,t)),i=["=","!=","<",">","<=",">="],s=["&&","||","!"],a=["+","-","*","/"];return i.includes(e.operator)?{type:"comparison",operator:e.operator,left:r[0],right:r[1]}:s.includes(e.operator)?{type:"logical",operator:e.operator,operands:r}:a.includes(e.operator)?{type:"arithmetic",operator:e.operator,left:r[0],right:r[1]}:{type:"function",function:e.operator,args:r}}return this.translateExpression(e)}extractGroupVariables(e){return e?e.filter(t=>t.expression&&t.expression.termType==="Variable").map(t=>t.expression.value):[]}translateAggregateExpression(e){let t=e.aggregation;if(typeof t=="string"){let r=t.toLowerCase();return["count","sum","avg","min","max","group_concat","sample"].includes(r)?{type:"aggregate",aggregation:r,expression:e.expression?this.translateExpression(e.expression):void 0,distinct:e.distinct||!1,separator:e.separator}:{type:"aggregate",aggregation:{type:"custom",iri:t},expression:e.expression?this.translateExpression(e.expression):void 0,distinct:e.distinct||!1,separator:e.separator}}if(t&&typeof t=="object"){let r;if(t.termType==="NamedNode"&&t.value)r=t.value;else if("value"in t)r=String(t.value);else throw new de(`Invalid custom aggregate: expected IRI but got ${JSON.stringify(t)}`);return{type:"aggregate",aggregation:{type:"custom",iri:r},expression:e.expression?this.translateExpression(e.expression):void 0,distinct:e.distinct||!1,separator:e.separator}}throw new de(`Unknown aggregate format: ${JSON.stringify(t)}`)}isLateralPattern(e){if(e.type==="query"&&this.isLateralSubquery(e))return!0;if(e.type==="group"&&e.patterns?.length===1){let t=e.patterns[0];if(t.type==="query"&&this.isLateralSubquery(t))return!0}return!1}extractLateralSubquery(e){if(e.type==="query")return e;if(e.type==="group"&&e.patterns?.length===1)return e.patterns[0];throw new de("Invalid lateral pattern structure")}translateWhere(e){if(e.length===0)throw new de("Empty WHERE clause");let t=e.filter(a=>a.type==="filter"),r=e.filter(a=>a.type==="bind"),i=e.filter(a=>a.type!=="filter"&&a.type!=="bind"),s;if(i.length===0)s={type:"bgp",triples:[]};else if(i.length===1)s=this.translatePattern(i[0]);else{s=this.translatePattern(i[0]);for(let a=1;a<i.length;a++){let c=i[a];if(this.isLateralPattern(c)){let u=this.extractLateralSubquery(c),l=this.removeLateralMarker(u),f=this.translateSelect(l);s={type:"lateraljoin",left:s,right:f}}else{let u=this.translatePattern(c);s={type:"join",left:s,right:u}}}}for(let a of r)s=this.translateBind(a,s);for(let a of t)s={type:"filter",expression:this.translateExpression(a.expression),input:s};return s}translatePattern(e){if(!e||!e.type)throw new de("Invalid pattern: missing type");switch(e.type){case"bgp":return this.translateBGP(e);case"filter":return this.translateFilter(e);case"optional":return this.translateOptional(e);case"union":return this.translateUnion(e);case"minus":return this.translateMinus(e);case"values":return this.translateValues(e);case"group":return this.translateWhere(e.patterns);case"query":return this.translateSubquery(e);case"service":return this.translateService(e);case"graph":return this.translateGraph(e);default:throw new de(`Unsupported pattern type: ${e.type}`)}}translateBGP(e){if(!e.triples||!Array.isArray(e.triples))throw new de("BGP pattern must have triples array");return{type:"bgp",triples:e.triples.map(t=>this.translateTriple(t))}}translateTriple(e){if(!e.subject||!e.predicate||!e.object)throw new de("Triple must have subject, predicate, and object");return{subject:this.translateTripleElement(e.subject),predicate:this.translatePredicate(e.predicate),object:this.translateTripleElement(e.object)}}translatePredicate(e){return e.type==="path"?this.translatePropertyPath(e):this.translateTripleElement(e)}translatePropertyPath(e){if(!e.pathType)throw new de("Property path must have pathType");if(!e.items||!Array.isArray(e.items))throw new de("Property path must have items array");let t=e.items.map(r=>this.translatePathItem(r));switch(e.pathType){case"/":return{type:"path",pathType:"/",items:t};case"|":return{type:"path",pathType:"|",items:t};case"^":if(t.length!==1)throw new de("Inverse path must have exactly one item");return{type:"path",pathType:"^",items:[t[0]]};case"+":if(t.length!==1)throw new de("OneOrMore path must have exactly one item");return{type:"path",pathType:"+",items:[t[0]]};case"*":if(t.length!==1)throw new de("ZeroOrMore path must have exactly one item");return{type:"path",pathType:"*",items:[t[0]]};case"?":if(t.length!==1)throw new de("ZeroOrOne path must have exactly one item");return{type:"path",pathType:"?",items:[t[0]]};default:throw new de(`Unsupported property path type: ${e.pathType}`)}}translatePathItem(e){if(e.type==="path")return this.translatePropertyPath(e);if(e.termType==="NamedNode")return{type:"iri",value:e.value};throw new de(`Unsupported path item type: ${e.type||e.termType}`)}translateTripleElement(e){if(!e||!e.termType)throw new de("Triple element must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};case"Literal":{let t={type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language};if(e.language){let r=this.directionMappings.get(e.language.toLowerCase());r&&(t.direction=r)}return t}case"BlankNode":return{type:"blank",value:e.value};case"Quad":return this.translateQuotedTriple(e);default:throw new de(`Unsupported term type: ${e.termType}`)}}translateQuotedTriple(e){if(!e.subject||!e.predicate||!e.object)throw new de("Quoted triple must have subject, predicate, and object");let t=this.translateTripleElement(e.subject),r=this.translateQuotedTriplePredicate(e.predicate),i=this.translateTripleElement(e.object);return{type:"quoted",subject:t,predicate:r,object:i}}translateQuotedTriplePredicate(e){if(!e||!e.termType)throw new de("Quoted triple predicate must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};default:throw new de(`Quoted triple predicate must be IRI or Variable, got: ${e.termType}`)}}translateFilter(e){if(!e.expression)throw new de("Filter pattern must have expression");let t=e.patterns?this.translateWhere(e.patterns):{type:"bgp",triples:[]};return{type:"filter",expression:this.translateExpression(e.expression),input:t}}translateExpression(e){if(!e)throw new de("Expression cannot be null or undefined");if(e.type==="operation")return this.translateOperationExpression(e);if(e.type==="functioncall"||e.type==="functionCall")return{type:"functionCall",function:e.function,args:e.args.map(t=>this.translateExpression(t))};if(e.termType)return this.translateTermExpression(e);throw new de(`Unsupported expression structure: ${JSON.stringify(e)}`)}translateOperationExpression(e){let t=["=","!=","<",">","<=",">="],r=["&&","||","!"],i=["+","-","*","/"];return t.includes(e.operator)?{type:"comparison",operator:e.operator,left:this.translateExpression(e.args[0]),right:this.translateExpression(e.args[1])}:r.includes(e.operator)?{type:"logical",operator:e.operator,operands:e.args.map(s=>this.translateExpression(s))}:i.includes(e.operator)?{type:"arithmetic",operator:e.operator,left:this.translateExpression(e.args[0]),right:this.translateExpression(e.args[1])}:e.operator==="exists"||e.operator==="notexists"?this.translateExistsExpression(e):e.operator==="in"||e.operator==="notin"?this.translateInExpression(e):{type:"function",function:e.operator,args:e.args.map(s=>this.translateExpression(s))}}translateExistsExpression(e){if(!e.args||e.args.length!==1)throw new de("EXISTS/NOT EXISTS must have exactly one pattern argument");let t=e.args[0],r;return t.type==="group"&&t.patterns?r=this.translateWhere(t.patterns):t.type==="bgp"?r=this.translateBGP(t):r=this.translatePattern(t),{type:"exists",negated:e.operator==="notexists",pattern:r}}translateInExpression(e){if(!e.args||e.args.length!==2)throw new de("IN/NOT IN must have exactly 2 arguments (expression and list)");let t=e.args[0],r=e.args[1];if(!Array.isArray(r))throw new de("IN/NOT IN second argument must be an array of values");return{type:"in",expression:this.translateExpression(t),list:r.map(i=>this.translateExpression(i)),negated:e.operator==="notin"}}translateTermExpression(e){if(e.termType==="Variable")return{type:"variable",name:e.value};if(e.termType==="Literal"){let t=e.value;return e.datatype&&(e.datatype.value.includes("#integer")||e.datatype.value.includes("#decimal")?t=parseFloat(e.value):e.datatype.value.includes("#boolean")&&(t=e.value==="true")),{type:"literal",value:t,datatype:e.datatype?.value}}return{type:"literal",value:String(e.value||e)}}translateOptional(e){if(!e.patterns||e.patterns.length===0)throw new de("OPTIONAL pattern must have patterns");return{type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns),expression:e.expression?this.translateExpression(e.expression):void 0}}translateUnion(e){if(!e.patterns||e.patterns.length<2)throw new de("UNION pattern must have at least 2 patterns");let t=o(i=>i.type==="graph"?this.translateGraph(i):i.type==="service"?this.translateService(i):i.patterns&&Array.isArray(i.patterns)?this.translateWhere(i.patterns):this.translateWhere([i]),"translateBranch"),r={type:"union",left:t(e.patterns[0]),right:t(e.patterns[1])};for(let i=2;i<e.patterns.length;i++)r={type:"union",left:r,right:t(e.patterns[i])};return r}translateMinus(e){if(!e.patterns||e.patterns.length===0)throw new de("MINUS pattern must have patterns");return{type:"minus",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns)}}translateValues(e){if(!e.values||!Array.isArray(e.values))throw new de("VALUES pattern must have values array");let t=new Set;for(let i of e.values)for(let s of Object.keys(i)){let a=s.startsWith("?")?s.slice(1):s;t.add(a)}let r=e.values.map(i=>this.translateValuesBinding(i));return{type:"values",variables:Array.from(t),bindings:r}}translateValuesBinding(e){let t={};for(let[r,i]of Object.entries(e)){let s=r.startsWith("?")?r.slice(1):r,a=i;if(a)if(a.termType==="NamedNode")t[s]={type:"iri",value:a.value};else if(a.termType==="Literal"){let c={type:"literal",value:a.value,datatype:a.datatype?.value,language:a.language||void 0};if(a.language){let u=this.directionMappings.get(a.language.toLowerCase());u&&(c.direction=u)}t[s]=c}else throw new de(`Unsupported VALUES term type: ${a.termType}`)}return t}translateBind(e,t){if(!e.variable||!e.expression)throw new de("BIND pattern must have variable and expression");return{type:"extend",variable:e.variable.value,expression:this.translateExpression(e.expression),input:t}}translateOrderComparator(e){return{expression:this.translateExpression(e.expression),descending:e.descending||!1}}isLateralSubquery(e){return e.queryType!=="SELECT"||!e.variables?!1:e.variables.some(t=>t.termType==="Variable"&&t.value===F_.LateralTransformer.LATERAL_MARKER)}removeLateralMarker(e){return e.variables?{...e,variables:e.variables.filter(t=>!(t.termType==="Variable"&&t.value===F_.LateralTransformer.LATERAL_MARKER))}:e}translateSubquery(e){if(e.queryType!=="SELECT")throw new de(`Only SELECT subqueries are supported, got: ${e.queryType}`);let t=this.removeLateralMarker(e);return{type:"subquery",query:this.translateSelect(t)}}translateService(e){if(!e.name||e.name.termType!=="NamedNode")throw new de("SERVICE pattern must have a NamedNode endpoint");if(!e.patterns||!Array.isArray(e.patterns))throw new de("SERVICE pattern must have patterns array");let t=this.translateWhere(e.patterns);return{type:"service",endpoint:e.name.value,pattern:t,silent:e.silent||!1}}translateGraph(e){if(!e.name)throw new de("GRAPH pattern must have a name (IRI or variable)");if(!e.patterns||!Array.isArray(e.patterns))throw new de("GRAPH pattern must have patterns array");let t;if(e.name.termType==="NamedNode")t={type:"iri",value:e.name.value};else if(e.name.termType==="Variable")t={type:"variable",value:e.name.value};else throw new de(`GRAPH pattern name must be NamedNode or Variable, got: ${e.name.termType}`);let r=this.translateWhere(e.patterns);return{type:"graph",name:t,pattern:r}}translateDescribe(e){let t=[];if(e.variables&&Array.isArray(e.variables))for(let s of e.variables){let a=s;a.termType==="Wildcard"||a.value==="*"||(a.termType==="Variable"?t.push({type:"variable",value:a.value}):a.termType==="NamedNode"&&t.push({type:"iri",value:a.value}))}let r;e.where&&e.where.length>0&&(r=this.translateWhere(e.where));let i=e.describeOptions;return{type:"describe",resources:t,where:r,depth:i?.depth,symmetric:i?.symmetric}}};Ka.AlgebraTranslator=Ey});var Ay=v(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0});Of.FilterContainsOptimizer=void 0;var r4=Qe(),n4=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,Ty=class{static{o(this,"FilterContainsOptimizer")}constructor(){this.tripleStore=null,this.lastOptimizationHints=[]}setTripleStore(e){this.tripleStore=e}getLastOptimizationHints(){return this.lastOptimizationHints}clearHints(){this.lastOptimizationHints=[]}async optimize(e){return this.clearHints(),this.optimizeRecursive(e)}optimizeSync(e,t){return this.clearHints(),this.optimizeSyncRecursive(e,t)}async optimizeRecursive(e){return e.type==="filter"?this.optimizeFilter(e):e.type==="join"?{type:"join",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="leftjoin"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="union"?{type:"union",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="minus"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="project"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="orderby"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="slice"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="distinct"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="reduced"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="group"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="extend"?{...e,input:await this.optimizeRecursive(e.input)}:e}optimizeSyncRecursive(e,t){return e.type==="filter"?this.optimizeFilterSync(e,t):e.type==="join"?{type:"join",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="leftjoin"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="union"?{type:"union",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="minus"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="project"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="orderby"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="slice"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="distinct"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="reduced"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="group"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="extend"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e}async optimizeFilter(e){let t=this.detectContainsUUIDPattern(e.expression);if(!t)return{type:"filter",expression:e.expression,input:await this.optimizeRecursive(e.input)};let r=[];return this.tripleStore&&(r=await this.findSubjectsContainingUUID(t.uuid)),this.rewriteFilter(e,t,r)}optimizeFilterSync(e,t){let r=this.detectContainsUUIDPattern(e.expression);if(!r)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input,t)};let i=t?t.filter(s=>s.includes(r.uuid)):[];return this.rewriteFilter(e,r,i)}rewriteFilter(e,t,r){if(this.lastOptimizationHints.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${t.variable}), "${t.uuid}"))`,suggestedRewrite:r.length===1?`VALUES ?${t.variable} { <${r[0]}> }`:r.length>1?`VALUES ?${t.variable} { ${r.map(i=>`<${i}>`).join(" ")} }`:"No matching URIs found for UUID",estimatedSpeedup:r.length>0?"O(n) \u2192 O(1)":"N/A",matchedUri:r.length===1?r[0]:void 0}),r.length===0)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input)};if(r.length===1){let i=this.injectSubjectConstraint(e.input,t.variable,r[0]);if(i!==e.input)return i}return this.createValuesJoin(e,t,r)}detectContainsUUIDPattern(e){if(e.type==="function"||e.type==="functionCall"){let t=e;if((typeof t.function=="string"?t.function.toLowerCase():t.function?.value?.toLowerCase()??"")==="contains"&&t.args.length===2)return this.analyzeContainsArgs(t.args[0],t.args[1],e)}if(e.type==="logical"&&e.operator==="&&")for(let t of e.operands){let r=this.detectContainsUUIDPattern(t);if(r)return r}return null}analyzeContainsArgs(e,t,r){let i=null;if(e.type==="function"||e.type==="functionCall"){let s=e;if((typeof s.function=="string"?s.function.toLowerCase():s.function?.value?.toLowerCase()??"")==="str"&&s.args.length===1){let c=s.args[0];c.type==="variable"&&(i=c.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let c=String(t.value).match(n4);if(c)return{variable:i,uuid:c[0].toLowerCase(),originalExpression:r}}return null}async findSubjectsContainingUUID(e){if(!this.tripleStore)return[];if(this.tripleStore.findSubjectsByUUID)return(await this.tripleStore.findSubjectsByUUID(e)).map(s=>s.value);let t=await this.tripleStore.subjects(),r=[];for(let i of t)i instanceof r4.IRI&&i.value.toLowerCase().includes(e.toLowerCase())&&r.push(i.value);return r}injectSubjectConstraint(e,t,r){if(e.type==="bgp"){let i=e.triples.map(a=>a.subject.type==="variable"&&a.subject.value===t?{...a,subject:{type:"iri",value:r}}:a);if(i.some((a,c)=>a.subject!==e.triples[c].subject))return{type:"bgp",triples:i}}if(e.type==="join"){let i=this.injectSubjectConstraint(e.left,t,r),s=this.injectSubjectConstraint(e.right,t,r);if(i!==e.left||s!==e.right)return{type:"join",left:i,right:s}}if(e.type==="filter"){let i=this.injectSubjectConstraint(e.input,t,r);if(i!==e.input)return{...e,input:i}}return e}createValuesJoin(e,t,r){return{type:"join",left:{type:"values",variables:[t.variable],bindings:r.map(a=>({[t.variable]:{type:"iri",value:a}}))},right:this.optimizeSyncRecursive(e.input)}}analyzeQuery(e){let t=[];return this.analyzeRecursive(e,t),t}analyzeRecursive(e,t){if(e.type==="filter"){let r=this.detectContainsUUIDPattern(e.expression);r&&t.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${r.variable}), "${r.uuid}"))`,suggestedRewrite:`Use --optimize flag or rewrite as VALUES ?${r.variable} { <uri-containing-uuid> }`,estimatedSpeedup:"O(n) \u2192 O(1) with UUID index lookup"}),this.analyzeRecursive(e.input,t);return}e.type==="join"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="leftjoin"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="union"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="minus"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="project"?this.analyzeRecursive(e.input,t):e.type==="orderby"?this.analyzeRecursive(e.input,t):e.type==="slice"?this.analyzeRecursive(e.input,t):e.type==="distinct"?this.analyzeRecursive(e.input,t):e.type==="reduced"?this.analyzeRecursive(e.input,t):e.type==="group"?this.analyzeRecursive(e.input,t):e.type==="extend"&&this.analyzeRecursive(e.input,t)}};Of.FilterContainsOptimizer=Ty});var L_=v(Pf=>{"use strict";Object.defineProperty(Pf,"__esModule",{value:!0});Pf.AlgebraOptimizer=void 0;var i4=Ay(),xy=class{static{o(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new i4.FilterContainsOptimizer}setTripleStore(e){this.tripleStore=e,this.filterContainsOptimizer.setTripleStore(e)}getOptimizationHints(){return this.filterContainsOptimizer.getLastOptimizationHints()}analyzeQuery(e){return this.filterContainsOptimizer.analyzeQuery(e)}optimize(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),t=this.filterPushDown(t),t=this.joinReordering(t),t}async optimizeAsync(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),this.tripleStore&&(t=await this.filterContainsOptimizer.optimize(t)),t=this.filterPushDown(t),t=this.joinReordering(t),t}optimizeWithSubjects(e,t){let r=e;return r=this.eliminateEmptyBGPInFilterJoin(r),r=this.filterContainsOptimizer.optimizeSync(r,t),r=this.filterPushDown(r),r=this.joinReordering(r),r}eliminateEmptyBGPInFilterJoin(e){if(e.type==="join"){if(e.left.type==="filter"){let t=e.left;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.right)}}if(e.right.type==="filter"){let t=e.right;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.left)}}return{type:"join",left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}}return e.type==="filter"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="leftjoin"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="union"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="minus"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="project"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="orderby"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="slice"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="distinct"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e}filterPushDown(e){return e.type==="filter"?this.pushDownFilter(e):e.type==="join"?{type:"join",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="leftjoin"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="union"?{type:"union",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="minus"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="project"?{...e,input:this.filterPushDown(e.input)}:e.type==="orderby"?{...e,input:this.filterPushDown(e.input)}:e.type==="slice"?{...e,input:this.filterPushDown(e.input)}:e.type==="distinct"?{...e,input:this.filterPushDown(e.input)}:e}pushDownFilter(e){let t=e.input;if(t.type==="join"){let r=this.getFilterVariables(e.expression),i=this.getOperationVariables(t.left),s=this.getOperationVariables(t.right),a=r.every(u=>i.has(u)),c=r.every(u=>s.has(u));return a&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!a?{type:"join",left:this.filterPushDown(t.left),right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:{type:"join",left:this.filterPushDown(t.left),right:this.filterPushDown(t.right)}}}return t.type==="union"?{type:"union",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:this.filterPushDown(t)}}getFilterVariables(e){let t=[];if(e.type==="variable")t.push(e.name);else if(e.type==="comparison")t.push(...this.getFilterVariables(e.left)),t.push(...this.getFilterVariables(e.right));else if(e.type==="logical")for(let r of e.operands)t.push(...this.getFilterVariables(r));else if(e.type==="function")for(let r of e.args)t.push(...this.getFilterVariables(r));return Array.from(new Set(t))}getOperationVariables(e){let t=new Set;if(e.type==="bgp")for(let r of e.triples)r.subject.type==="variable"&&t.add(r.subject.value),r.predicate.type==="variable"&&t.add(r.predicate.value),r.object.type==="variable"&&t.add(r.object.value);else if(e.type==="join"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="filter")return this.getOperationVariables(e.input);if(e.type==="leftjoin"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else if(e.type==="union"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="minus")return this.getOperationVariables(e.left);if(e.type==="project")return new Set(e.variables)}}return t}joinReordering(e){return e.type==="join"?this.reorderJoin(e):e.type==="filter"?{...e,input:this.joinReordering(e.input)}:e.type==="leftjoin"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="union"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="minus"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="project"?{...e,input:this.joinReordering(e.input)}:e.type==="orderby"?{...e,input:this.joinReordering(e.input)}:e.type==="slice"?{...e,input:this.joinReordering(e.input)}:e.type==="distinct"?{...e,input:this.joinReordering(e.input)}:e}reorderJoin(e){let t=this.estimateCost(e.left);return this.estimateCost(e.right)<t?{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)}:{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)}}estimateCost(e){if(e.type==="bgp"){let t=e.triples.length*100;for(let r of e.triples)r.subject.type==="variable"&&(t+=10),r.predicate.type==="variable"&&(t+=20),r.object.type==="variable"&&(t+=10);return t}return e.type==="filter"?this.estimateCost(e.input)*.3:e.type==="join"?this.estimateCost(e.left)*this.estimateCost(e.right):e.type==="leftjoin"?this.estimateCost(e.left)+this.estimateCost(e.right)*.5:e.type==="union"?this.estimateCost(e.left)+this.estimateCost(e.right):e.type==="minus"?this.estimateCost(e.left)+this.estimateCost(e.right)*.3:100}setStatistics(e,t){this.stats.set(e,t)}getStatistics(e){return this.stats.get(e)}};Pf.AlgebraOptimizer=xy});var k_=v(Df=>{"use strict";Object.defineProperty(Df,"__esModule",{value:!0});Df.AlgebraSerializer=void 0;var Cy=class{static{o(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
|
|
257
257
|
${e.triples.map(l=>`${r} ${this.tripleToString(l)}`).join(`
|
|
258
258
|
`)}
|
|
259
259
|
${r}]`;case"filter":return`${r}Filter(
|
|
@@ -285,7 +285,7 @@ ${r})`;case"extend":return`${r}Extend (?${e.variable} = ${this.expressionToStrin
|
|
|
285
285
|
${this.toString(e.input,t+1)}
|
|
286
286
|
${r})`;case"subquery":return`${r}Subquery(
|
|
287
287
|
${this.toString(e.query,t+1)}
|
|
288
|
-
${r})`;default:return`${r}Unknown(${e.type})`}}tripleToString(e){return`${this.elementToString(e.subject)} ${this.predicateToString(e.predicate)} ${this.elementToString(e.object)}`}predicateToString(e){return this.isPropertyPath(e)?this.propertyPathToString(e):this.elementToString(e)}isPropertyPath(e){return e.type==="path"}propertyPathToString(e){let t=e.items.map(r=>r.type==="path"?`(${this.propertyPathToString(r)})`:`<${r.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}elementToString(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":let t=`"${e.value}"`;return e.language&&(t+=`@${e.language}`),e.datatype&&(t+=`^^<${e.datatype}>`),t;case"blank":return`_:${e.value}`;default:return String(e)}}expressionToString(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value}"`:String(e.value);case"comparison":return`(${this.expressionToString(e.left)} ${e.operator} ${this.expressionToString(e.right)})`;case"logical":return e.operator==="!"?`!(${this.expressionToString(e.operands[0])})`:`(${e.operands.map(t=>this.expressionToString(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.expressionToString(e.left)} ${e.operator} ${this.expressionToString(e.right)})`;case"function":return`${e.function}(${e.args.map(t=>this.expressionToString(t)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.toString(e.pattern,0)} }`;default:return"unknown"}}toJSON(e){return JSON.stringify(e,null,2)}};Df.AlgebraSerializer=xy});var Ni=v(Rf=>{"use strict";Object.defineProperty(Rf,"__esModule",{value:!0});Rf.SolutionMapping=void 0;var L_=lt(),k_=Qe(),M_=Ot(),Cy=class n{static{o(this,"SolutionMapping")}constructor(e){this.bindings=e?new Map(e):new Map}get(e){return this.bindings.get(e)}set(e,t){this.bindings.set(e,t)}has(e){return this.bindings.has(e)}variables(){return Array.from(this.bindings.keys())}getBindings(){return new Map(this.bindings)}isCompatibleWith(e){for(let[t,r]of this.bindings.entries()){let i=e.get(t);if(i!==void 0&&!this.areEqual(r,i))return!1}return!0}merge(e){if(!this.isCompatibleWith(e))return null;let t=new n(this.bindings);for(let[r,i]of e.getBindings().entries())t.set(r,i);return t}clone(){return new n(this.bindings)}areEqual(e,t){return e instanceof L_.Literal&&t instanceof L_.Literal?e.equals(t):e instanceof k_.IRI&&t instanceof k_.IRI?e.value===t.value:e instanceof M_.BlankNode&&t instanceof M_.BlankNode?e.id===t.id:!1}toJSON(){let e={};for(let[t,r]of this.bindings.entries())e[t]=r.toString();return e}size(){return this.bindings.size}};Rf.SolutionMapping=Cy});var $_=v(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.PropertyPathExecutor=Xa.PropertyPathExecutorError=void 0;var r4=Ni(),Ff=Qe(),j_=Ot(),Fc=class extends Error{static{o(this,"PropertyPathExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="PropertyPathExecutorError"}};Xa.PropertyPathExecutorError=Fc;var Iy=class{static{o(this,"PropertyPathExecutor")}constructor(e){this.tripleStore=e,this.MAX_DEPTH=100}async*execute(e,t,r){let i=await this.resolveElement(e),s=this.isVariable(r)?null:await this.resolveElement(r);for(let a of i){let c=await this.evaluatePath(a,t,s);for(let u of c){let l=new r4.SolutionMapping;this.isVariable(e)&&l.set(e.value,a),this.isVariable(r)&&l.set(r.value,u),yield l}}}async*executeWithBindings(e,t){if(!this.isPropertyPath(e.predicate))throw new Fc("Predicate is not a property path");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.object,t);for await(let s of this.execute(r,e.predicate,i)){let a=t.merge(s);a!==null&&(yield a)}}async evaluatePath(e,t,r){switch(t.pathType){case"/":return this.evaluateSequencePath(e,t.items,r);case"|":return this.evaluateAlternativePath(e,t.items,r);case"^":return this.evaluateInversePath(e,t.items[0],r);case"+":return this.evaluateOneOrMorePath(e,t.items[0],r);case"*":return this.evaluateZeroOrMorePath(e,t.items[0],r);case"?":return this.evaluateZeroOrOnePath(e,t.items[0],r)}}async evaluateSequencePath(e,t,r){let i=new Set([e]);for(let s=0;s<t.length;s++){let a=t[s],c=s===t.length-1,u=new Set;for(let l of i){let f=await this.evaluatePathItem(l,a,c?r:null);for(let h of f)u.add(h)}if(i=u,i.size===0)break}return i}async evaluateAlternativePath(e,t,r){let i=new Set;for(let s of t){let a=await this.evaluatePathItem(e,s,r);for(let c of a)i.add(c)}return i}async evaluateInversePath(e,t,r){if(t.type==="iri"){let i=new Ff.IRI(t.value),s=await this.tripleStore.match(void 0,i,e),a=new Set;for(let c of s)(r===null||this.nodeInSet(c.subject,r))&&a.add(c.subject);return a}else return this.evaluatePath(e,this.invertPath(t),r)}async evaluateOneOrMorePath(e,t,r){let i=new Set,s=new Set,a=[{node:e,depth:0}];for(;a.length>0;){let{node:c,depth:u}=a.shift();if(u>=this.MAX_DEPTH)continue;let l=await this.evaluatePathItem(c,t,null);for(let f of l){let h=this.nodeToKey(f);(r===null||this.nodeInSet(f,r))&&s.add(f),i.has(h)||(i.add(h),a.push({node:f,depth:u+1}))}}return s}async evaluateZeroOrMorePath(e,t,r){let i=await this.evaluateOneOrMorePath(e,t,r);return(r===null||this.nodeInSet(e,r))&&i.add(e),i}async evaluateZeroOrOnePath(e,t,r){let i=new Set;(r===null||this.nodeInSet(e,r))&&i.add(e);let s=await this.evaluatePathItem(e,t,r);for(let a of s)i.add(a);return i}async evaluatePathItem(e,t,r){if(t.type==="iri"){let i=new Ff.IRI(t.value),s=await this.tripleStore.match(e,i,void 0),a=new Set;for(let c of s)(r===null||this.nodeInSet(c.object,r))&&a.add(c.object);return a}else return this.evaluatePath(e,t,r)}invertPath(e){switch(e.pathType){case"^":return e.items[0];case"/":return{type:"path",pathType:"/",items:[...e.items].reverse().map(r=>r.type==="iri"?{type:"path",pathType:"^",items:[r]}:this.invertPath(r))};case"|":return{type:"path",pathType:"|",items:e.items.map(r=>r.type==="iri"?{type:"path",pathType:"^",items:[r]}:this.invertPath(r))};case"+":case"*":case"?":let t=e.items[0].type==="iri"?{type:"path",pathType:"^",items:[e.items[0]]}:this.invertPath(e.items[0]);return{type:"path",pathType:e.pathType,items:[t]}}}async resolveElement(e){if(this.isVariable(e)){let r=new Set,i=await this.tripleStore.match(void 0,void 0,void 0);for(let s of i)r.add(s.subject),r.add(s.object);return r}let t=new Set;switch(e.type){case"iri":t.add(new Ff.IRI(e.value));break;case"blank":t.add(new j_.BlankNode(e.value));break;default:throw new Fc(`Unsupported element type in subject/object position: ${e.type}`)}return t}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r){if(r instanceof Ff.IRI)return{type:"iri",value:r.value};if(r instanceof j_.BlankNode)return{type:"blank",value:r.id}}}return e}isVariable(e){return e.type==="variable"}isPropertyPath(e){return e.type==="path"}nodeToKey(e){return e.toString()}nodeInSet(e,t){let r=this.nodeToKey(e);for(let i of t)if(this.nodeToKey(i)===r)return!0;return!1}};Xa.PropertyPathExecutor=Iy});var Dy=v(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.BGPExecutor=Ja.BGPExecutorError=void 0;var Nf=Ni(),ss=Qe(),Oy=lt(),Lf=Ot(),kf=ac(),n4=$_(),sr=class extends Error{static{o(this,"BGPExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="BGPExecutorError"}};Ja.BGPExecutorError=sr;var Py=class{static{o(this,"BGPExecutor")}constructor(e){this.tripleStore=e,this.propertyPathExecutor=new n4.PropertyPathExecutor(e)}async*execute(e){if(e.triples.length===0){yield new Nf.SolutionMapping;return}let t=this.matchTriplePattern(e.triples[0]);for(let r=1;r<e.triples.length;r++)t=this.joinWithPattern(t,e.triples[r]);for await(let r of t)yield r}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*executeInGraph(e,t){if(e.triples.length===0){yield new Nf.SolutionMapping;return}let r=this.matchTriplePatternInGraph(e.triples[0],t);for(let i=1;i<e.triples.length;i++)r=this.joinWithPatternInGraph(r,e.triples[i],t);for await(let i of r)yield i}async*matchTriplePatternInGraph(e,t){if(this.isPropertyPath(e.predicate))throw new sr("Property paths within named graphs are not yet supported");let r=e.predicate,i=this.isVariable(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),s=this.isVariable(r)?void 0:this.toRDFTermAsPredicate(r),a=this.isVariable(e.object)?void 0:this.toRDFTerm(e.object);if(!this.tripleStore.matchInGraph)throw new sr("Triple store does not support named graph operations");let c=await this.tripleStore.matchInGraph(i,s,a,t);for(let u of c){let l=new Nf.SolutionMapping;this.isVariable(e.subject)&&l.set(e.subject.value,u.subject),this.isVariable(r)&&l.set(r.value,u.predicate),this.isVariable(e.object)&&l.set(e.object.value,u.object),yield l}}async*joinWithPatternInGraph(e,t,r){let i=[];for await(let s of e)i.push(s);for(let s of i){let a=this.instantiatePattern(t,s);for await(let c of this.matchTriplePatternInGraph(a,r)){let u=s.merge(c);u!==null&&(yield u)}}}async*matchTriplePattern(e){if(this.isPropertyPath(e.predicate)){yield*this.propertyPathExecutor.execute(e.subject,e.predicate,e.object);return}let t=e.predicate,r=this.isVariable(e.subject)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),i=this.isVariable(t)?void 0:this.toRDFTermAsPredicate(t),s=this.isVariable(e.object)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object)?void 0:this.toRDFTerm(e.object),a=await this.tripleStore.match(r,i,s);for(let c of a){let u=new Nf.SolutionMapping;if(this.isVariable(e.subject))u.set(e.subject.value,c.subject);else if(this.isQuotedTriple(e.subject)){let l=this.matchQuotedTriplePattern(e.subject,c.subject);if(l===null)continue;for(let[f,h]of l.entries())u.set(f,h)}if(this.isVariable(t)&&u.set(t.value,c.predicate),this.isVariable(e.object))u.set(e.object.value,c.object);else if(this.isQuotedTriple(e.object)){let l=this.matchQuotedTriplePattern(e.object,c.object);if(l===null)continue;for(let[f,h]of l.entries())u.set(f,h)}yield u}}hasVariablesInQuotedTriple(e){return!!(this.isVariable(e.subject)||e.predicate.type==="variable"||this.isVariable(e.object)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object))}matchQuotedTriplePattern(e,t){if(!(t instanceof kf.QuotedTriple))return null;let r=new Map;if(this.isVariable(e.subject))r.set(e.subject.value,t.subject);else if(this.isQuotedTriple(e.subject)){let i=this.matchQuotedTriplePattern(e.subject,t.subject);if(i===null)return null;for(let[s,a]of i)r.set(s,a)}else if(!this.elementsMatch(e.subject,t.subject))return null;if(e.predicate.type==="variable")r.set(e.predicate.value,t.predicate);else if(e.predicate.value!==t.predicate.value)return null;if(this.isVariable(e.object))r.set(e.object.value,t.object);else if(this.isQuotedTriple(e.object)){let i=this.matchQuotedTriplePattern(e.object,t.object);if(i===null)return null;for(let[s,a]of i)r.set(s,a)}else if(!this.elementsMatch(e.object,t.object))return null;return r}elementsMatch(e,t){switch(e.type){case"iri":return t instanceof ss.IRI&&e.value===t.value;case"literal":return!(!(t instanceof Oy.Literal)||e.value!==t.value||e.datatype!==t.datatype?.value||e.language!==t.language||e.direction!==t.direction);case"blank":return t instanceof Lf.BlankNode&&e.value===t.id;case"quoted":return t instanceof kf.QuotedTriple?this.toRDFQuotedTriple(e).equals(t):!1;default:return!1}}isPropertyPath(e){return e.type==="path"}async*joinWithPattern(e,t){let r=[];for await(let i of e)r.push(i);for(let i of r){let s=this.instantiatePattern(t,i);for await(let a of this.matchTriplePattern(s)){let c=i.merge(a);c!==null&&(yield c)}}}instantiatePattern(e,t){let r=this.isPropertyPath(e.predicate)?e.predicate:this.instantiateElement(e.predicate,t);return{subject:this.instantiateElement(e.subject,t),predicate:r,object:this.instantiateElement(e.object,t)}}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r)return this.toAlgebraElement(r)}return this.isQuotedTriple(e)?this.instantiateQuotedTriple(e,t):e}instantiateQuotedTriple(e,t){let r=this.instantiateElement(e.subject,t),i=e.predicate.type==="variable"?this.instantiatePredicateVariable(e.predicate,t):e.predicate,s=this.instantiateElement(e.object,t);return{type:"quoted",subject:r,predicate:i,object:s}}instantiatePredicateVariable(e,t){let r=t.get(e.value);return r&&r instanceof ss.IRI?{type:"iri",value:r.value}:e}isVariable(e){return e.type==="variable"}isQuotedTriple(e){return e.type==="quoted"}toRDFTermAsSubject(e){switch(e.type){case"iri":return new ss.IRI(e.value);case"blank":return new Lf.BlankNode(e.value);case"literal":throw new sr("Literals cannot appear in subject position");case"variable":throw new sr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new sr(`Unknown element type: ${e.type}`)}}toRDFQuotedTriple(e){let t=this.toRDFTermAsSubject(e.subject),r=e.predicate.type==="iri"?new ss.IRI(e.predicate.value):(()=>{throw new sr("Quoted triple predicate must be IRI")})(),i=this.toRDFTerm(e.object);return new kf.QuotedTriple(t,r,i)}toRDFTermAsPredicate(e){switch(e.type){case"iri":return new ss.IRI(e.value);case"literal":throw new sr("Literals cannot appear in predicate position");case"blank":throw new sr("Blank nodes cannot appear in predicate position");case"variable":throw new sr(`Cannot convert variable to RDF term: ${e.value}`);default:throw new sr(`Unknown element type: ${e.type}`)}}toRDFTerm(e){switch(e.type){case"iri":return new ss.IRI(e.value);case"literal":return new Oy.Literal(e.value,e.datatype?new ss.IRI(e.datatype):void 0,e.language,e.direction);case"blank":return new Lf.BlankNode(e.value);case"variable":throw new sr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new sr(`Unknown element type: ${e.type}`)}}toAlgebraElement(e){if(e instanceof ss.IRI)return{type:"iri",value:e.value};if(e instanceof Oy.Literal)return{type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language,direction:e.direction};if(e instanceof Lf.BlankNode)return{type:"blank",value:e.id};if(e instanceof kf.QuotedTriple)return this.toAlgebraQuotedTriple(e);throw new sr(`Unknown RDF term type: ${e.constructor?.name||"unknown"}`)}toAlgebraQuotedTriple(e){return{type:"quoted",subject:this.toAlgebraElement(e.subject),predicate:{type:"iri",value:e.predicate.value},object:this.toAlgebraElement(e.object)}}};Ja.BGPExecutor=Py});var Fy=v(Mf=>{"use strict";Object.defineProperty(Mf,"__esModule",{value:!0});Mf.BuiltInFunctions=void 0;var pe=Qe(),D=lt(),_r=Ot(),Za=ac(),Ry=yr(),Nc=class{static{o(this,"BuiltInFunctions")}static str(e){if(e===void 0)throw new Error("STR: argument is undefined");return e instanceof pe.IRI||e instanceof D.Literal?e.value:e instanceof _r.BlankNode?e.id:String(e)}static lang(e){if(e===void 0)throw new Error("LANG: argument is undefined");return e instanceof D.Literal&&e.language?e.language:""}static langdir(e){if(e===void 0)throw new Error("LANGDIR: argument is undefined");return!(e instanceof D.Literal)||!e.language?"":e.direction?`${e.language}--${e.direction}`:e.language}static langMatches(e,t){let[r,i]=this.parseDirectionalLangTag(e),[s,a]=this.parseDirectionalLangTag(t),c=r.toLowerCase(),u=s.toLowerCase();return u==="*"?c!=="":c===""?u==="":a&&i!==a?!1:c===u?!0:c.startsWith(u+"-")}static parseDirectionalLangTag(e){let t=e.indexOf("--");if(t===-1)return[e,void 0];let r=e.substring(0,t),i=e.substring(t+2).toLowerCase();return[r,i]}static datatype(e){if(e===void 0)throw new Error("DATATYPE: argument is undefined");if(e instanceof D.Literal)return e.datatype?e.datatype:e.language?new pe.IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"):new pe.IRI("http://www.w3.org/2001/XMLSchema#string");throw new Error("DATATYPE: argument must be a literal")}static bound(e){return e!==void 0}static isIRI(e){return e===void 0?!1:e instanceof pe.IRI}static isBlank(e){return e===void 0?!1:e instanceof _r.BlankNode}static isLiteral(e){return e===void 0?!1:e instanceof D.Literal}static isTriple(e){return e===void 0?!1:e instanceof Za.QuotedTriple}static hasLangdir(e){return e===void 0||!(e instanceof D.Literal)?!1:!!e.language&&!!e.direction}static isNumeric(e){if(e===void 0||!(e instanceof D.Literal))return!1;let t=e.datatype?.value;return t?["http://www.w3.org/2001/XMLSchema#integer","http://www.w3.org/2001/XMLSchema#decimal","http://www.w3.org/2001/XMLSchema#float","http://www.w3.org/2001/XMLSchema#double","http://www.w3.org/2001/XMLSchema#nonPositiveInteger","http://www.w3.org/2001/XMLSchema#negativeInteger","http://www.w3.org/2001/XMLSchema#long","http://www.w3.org/2001/XMLSchema#int","http://www.w3.org/2001/XMLSchema#short","http://www.w3.org/2001/XMLSchema#byte","http://www.w3.org/2001/XMLSchema#nonNegativeInteger","http://www.w3.org/2001/XMLSchema#unsignedLong","http://www.w3.org/2001/XMLSchema#unsignedInt","http://www.w3.org/2001/XMLSchema#unsignedShort","http://www.w3.org/2001/XMLSchema#unsignedByte","http://www.w3.org/2001/XMLSchema#positiveInteger"].includes(t):!1}static regex(e,t,r){try{return new RegExp(t,r).test(e)}catch(i){throw new Error(`REGEX: invalid pattern '${t}': ${i.message}`)}}static compare(e,t,r){if(this.isDayTimeDurationValue(e)&&this.isDayTimeDurationValue(t))return this.compareDurations(e instanceof D.Literal?e:String(e),t instanceof D.Literal?t:String(t),r);let i=this.toComparableValue(e),s=this.toComparableValue(t);switch(r){case"=":return i===s;case"!=":return i!==s;case"<":return i<s;case">":return i>s;case"<=":return i<=s;case">=":return i>=s;default:throw new Error(`Unknown comparison operator: ${r}`)}}static isDayTimeDurationValue(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static toComparableValue(e){if(typeof e=="string"||typeof e=="number")return e;if(e instanceof D.Literal){let t=e.datatype?.value;if(t?.includes("#integer")||t?.includes("#decimal")||t?.includes("#double")){let r=parseFloat(e.value);if(!isNaN(r))return r}if(t==="http://www.w3.org/2001/XMLSchema#dayTimeDuration")try{return this.parseDayTimeDuration(e.value)}catch{return e.value}return e.value}return e instanceof pe.IRI?e.value:e instanceof _r.BlankNode?e.id:String(e)}static contains(e,t){return e.includes(t)}static strStarts(e,t){return e.startsWith(t)}static strEnds(e,t){return e.endsWith(t)}static strlen(e){return e.length}static ucase(e){return e.toUpperCase()}static lcase(e){return e.toLowerCase()}static substr(e,t,r){let i=t-1;if(i<0){if(r!==void 0){let s=r+i;return s<=0?"":e.substring(0,s)}return e}return r!==void 0?e.substring(i,i+r):e.substring(i)}static strBefore(e,t){if(t==="")return"";let r=e.indexOf(t);return r===-1?"":e.substring(0,r)}static strAfter(e,t){if(t==="")return e;let r=e.indexOf(t);return r===-1?"":e.substring(r+t.length)}static concat(...e){return e.join("")}static replace(e,t,r,i){try{let s=new RegExp(t,i||"g");return e.replace(s,r)}catch(s){throw new Error(`REPLACE: invalid pattern '${t}': ${s.message}`)}}static parseDate(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`PARSEDATE: invalid date string '${e}'`);return t.getTime()}static dateBefore(e,t){let r=this.parseDate(e),i=this.parseDate(t);return r<i}static dateAfter(e,t){let r=this.parseDate(e),i=this.parseDate(t);return r>i}static dateInRange(e,t,r){let i=this.parseDate(e),s=this.parseDate(t),a=this.parseDate(r);return i>=s&&i<=a}static dateDiffMinutes(e,t){let r=this.parseDate(e),i=this.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60))}static dateDiffHours(e,t){let r=this.parseDate(e),i=this.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60*60)*100)/100}static logicalAnd(e){return e.every(t=>t===!0)}static logicalOr(e){return e.some(t=>t===!0)}static logicalNot(e){return!e}static year(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`YEAR: invalid date string '${e}'`);return t.getFullYear()}static month(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MONTH: invalid date string '${e}'`);return t.getMonth()+1}static day(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`DAY: invalid date string '${e}'`);return t.getDate()}static hours(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`HOURS: invalid date string '${e}'`);return t.getHours()}static minutes(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MINUTES: invalid date string '${e}'`);return t.getMinutes()}static seconds(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`SECONDS: invalid date string '${e}'`);return t.getSeconds()+t.getMilliseconds()/1e3}static timezone(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TIMEZONE: invalid date string '${e}'`);let r;if(e.endsWith("Z"))r="PT0S";else{let i=e.match(/([+-]\d{2}):?(\d{2})$/);if(i){let s=parseInt(i[1],10),a=parseInt(i[2],10),c=s>=0?"":"-",u=Math.abs(s);a===0?r=`${c}PT${u}H`:r=`${c}PT${u}H${a}M`}else{let s=-t.getTimezoneOffset(),a=Math.floor(Math.abs(s)/60),c=Math.abs(s)%60,u=s>=0?"":"-";c===0?r=`${u}PT${a}H`:r=`${u}PT${a}H${c}M`}}return new D.Literal(r,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static tz(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TZ: invalid date string '${e}'`);if(e.endsWith("Z"))return"Z";let r=e.match(/([+-]\d{2}:\d{2})$/);if(r)return r[1];let i=e.match(/([+-])(\d{2})(\d{2})$/);return i?`${i[1]}${i[2]}:${i[3]}`:""}static now(){return new Date().toISOString()}static msToMinutes(e){return Math.round(e/(1e3*60))}static msToHours(e){return Math.round(e/(1e3*60*60)*100)/100}static msToSeconds(e){return Math.round(e/1e3)}static abs(e){return Math.abs(e)}static round(e){return Math.round(e)}static ceil(e){return Math.ceil(e)}static floor(e){return Math.floor(e)}static rand(){return Math.random()}static coalesce(e){for(let t of e)if(t!=null)return t}static if(e,t,r){return e?t:r}static xsdDateTime(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`xsd:dateTime: invalid date string '${e}'`);return new D.Literal(t.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static xsdInteger(e){let t=parseInt(e,10);if(isNaN(t))throw new Error(`xsd:integer: cannot convert '${e}' to integer`);return new D.Literal(String(t),new pe.IRI("http://www.w3.org/2001/XMLSchema#integer"))}static xsdDecimal(e){let t=parseFloat(e);if(isNaN(t))throw new Error(`xsd:decimal: cannot convert '${e}' to decimal`);return new D.Literal(String(t),new pe.IRI("http://www.w3.org/2001/XMLSchema#decimal"))}static encodeForUri(e){return encodeURIComponent(e)}static md5(e){return require("crypto").createHash("md5").update(e).digest("hex")}static sha1(e){return require("crypto").createHash("sha1").update(e).digest("hex")}static sha256(e){return require("crypto").createHash("sha256").update(e).digest("hex")}static sha384(e){return require("crypto").createHash("sha384").update(e).digest("hex")}static sha512(e){return require("crypto").createHash("sha512").update(e).digest("hex")}static sameTerm(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0||e.constructor!==t.constructor)return!1;if(e instanceof pe.IRI&&t instanceof pe.IRI)return e.value===t.value;if(e instanceof _r.BlankNode&&t instanceof _r.BlankNode)return e.id===t.id;if(e instanceof D.Literal&&t instanceof D.Literal){if(e.value!==t.value||e.language!==t.language)return!1;let r=e.datatype?.value,i=t.datatype?.value;return r===i}return!1}static iri(e){if(e===void 0)throw new Error("IRI: argument is undefined");if(e instanceof pe.IRI)return e;if(e instanceof D.Literal)return new pe.IRI(e.value);throw e instanceof _r.BlankNode?new Error("IRI: cannot convert blank node to IRI"):new Error("IRI: unsupported term type")}static uri(e){return this.iri(e)}static bnode(e){if(e===void 0){let t=`b${(0,Ry.v4)().replace(/-/g,"").substring(0,12)}`;return new _r.BlankNode(t)}if(e instanceof D.Literal)return new _r.BlankNode(e.value);if(e instanceof _r.BlankNode)return e;throw new Error("BNODE: argument must be a string literal or omitted")}static strdt(e,t){if(e===void 0)throw new Error("STRDT: lexical form is undefined");if(t===void 0)throw new Error("STRDT: datatype IRI is undefined");let r;if(e instanceof D.Literal){if(e.language)throw new Error("STRDT: lexical form must not have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRDT: lexical form must be a string literal");let i;if(t instanceof pe.IRI)i=t;else if(t instanceof D.Literal)i=new pe.IRI(t.value);else throw new Error("STRDT: datatype must be an IRI");return new D.Literal(r,i)}static strlang(e,t){if(e===void 0)throw new Error("STRLANG: lexical form is undefined");if(t===void 0)throw new Error("STRLANG: language tag is undefined");let r;if(e instanceof D.Literal){if(e.language)throw new Error("STRLANG: lexical form must not already have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRLANG: lexical form must be a string literal");let i;if(t instanceof D.Literal)i=t.value;else if(typeof t=="string")i=t;else throw new Error("STRLANG: language tag must be a string literal");if(i==="")throw new Error("STRLANG: language tag cannot be empty");return new D.Literal(r,void 0,i)}static strlangdir(e,t,r){if(e===void 0)throw new Error("STRLANGDIR: lexical form is undefined");if(t===void 0)throw new Error("STRLANGDIR: language tag is undefined");if(r===void 0)throw new Error("STRLANGDIR: direction is undefined");let i;if(e instanceof D.Literal){if(e.language)throw new Error("STRLANGDIR: lexical form must not already have a language tag");i=e.value}else if(typeof e=="string")i=e;else throw new Error("STRLANGDIR: lexical form must be a string literal");let s;if(t instanceof D.Literal)s=t.value;else if(typeof t=="string")s=t;else throw new Error("STRLANGDIR: language tag must be a string literal");if(s==="")throw new Error("STRLANGDIR: language tag cannot be empty");let a;if(r instanceof D.Literal)a=r.value.toLowerCase();else throw new Error("STRLANGDIR: direction must be a string literal");if(a!=="ltr"&&a!=="rtl")throw new Error(`STRLANGDIR: invalid direction '${a}'. Must be 'ltr' or 'rtl'`);return new D.Literal(i,void 0,s,a)}static uuid(){let e=(0,Ry.v4)();return new pe.IRI(`urn:uuid:${e}`)}static struuid(){let e=(0,Ry.v4)();return new D.Literal(e)}static parseDayTimeDuration(e){if(!e)throw new Error("parseDayTimeDuration: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDayTimeDuration: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=r.indexOf("T"),a="",c="";if(s===-1?a=r:(a=r.substring(0,s),c=r.substring(s+1)),a){let u=a.match(/^(\d+(?:\.\d+)?)D$/);if(u){let l=parseFloat(u[1]);i+=l*24*60*60*1e3}else if(a!=="")throw new Error(`parseDayTimeDuration: invalid day component: '${a}' in '${e}'`)}if(c){let u=c,l=u.match(/^(\d+(?:\.\d+)?)H/);if(l){let d=parseFloat(l[1]);i+=d*60*60*1e3,u=u.substring(l[0].length)}let f=u.match(/^(\d+(?:\.\d+)?)M/);if(f){let d=parseFloat(f[1]);i+=d*60*1e3,u=u.substring(f[0].length)}let h=u.match(/^(\d+(?:\.\d+)?)S$/);if(h){let d=parseFloat(h[1]);i+=d*1e3,u=u.substring(h[0].length)}if(u!=="")throw new Error(`parseDayTimeDuration: invalid time component: '${u}' in '${e}'`)}return t?-i:i}static formatDayTimeDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/(1440*60*1e3));r=r%(1440*60*1e3);let s=Math.floor(r/(3600*1e3));r=r%(3600*1e3);let a=Math.floor(r/(60*1e3));r=r%(60*1e3);let c=r/1e3,u=t?"-P":"P";return i>0&&(u+=`${i}D`),(s>0||a>0||c>0||i===0)&&(u+="T",s>0&&(u+=`${s}H`),a>0&&(u+=`${a}M`),(c>0||s===0&&a===0)&&(Number.isInteger(c)?u+=`${c}S`:u+=`${parseFloat(c.toFixed(3))}S`)),u}static xsdDayTimeDuration(e){return this.parseDayTimeDuration(e),new D.Literal(e,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static compareDurations(e,t,r){let i=e instanceof D.Literal?e.value:e,s=t instanceof D.Literal?t.value:t,a=this.parseDayTimeDuration(i),c=this.parseDayTimeDuration(s);switch(r){case"=":return a===c;case"!=":return a!==c;case"<":return a<c;case">":return a>c;case"<=":return a<=c;case">=":return a>=c;default:throw new Error(`compareDurations: unknown operator: ${r}`)}}static isDayTimeDuration(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static isDate(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}static dateDiff(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r),a=this.parseXSDDate(i);if(s===null)throw new Error(`dateDiff: invalid first date: '${r}'`);if(a===null)throw new Error(`dateDiff: invalid second date: '${i}'`);let c=s.getTime()-a.getTime(),u=Math.round(c/(1440*60*1e3)),l=this.formatDateDuration(u);return new D.Literal(l,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static parseXSDDate(e){let t=/^(-?\d{4})-(\d{2})-(\d{2})(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r){let l=new Date(e);return isNaN(l.getTime())?null:new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()))}let i=parseInt(r[1],10),s=parseInt(r[2],10)-1,a=parseInt(r[3],10),c=r[4],u=new Date(Date.UTC(i,s,a));if(c&&c!=="Z"){let l=c.match(/([+-])(\d{2}):(\d{2})/);if(l){let f=l[1]==="+"?1:-1,h=parseInt(l[2],10),d=parseInt(l[3],10),p=f*(h*60+d)*60*1e3;u=new Date(u.getTime()-p)}}return u}static formatDateDuration(e){if(e===0)return"P0D";let t=e<0,r=Math.abs(e);return t?`-P${r}D`:`P${r}D`}static dateTimeDiff(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r),a=new Date(i);if(isNaN(s.getTime()))throw new Error(`dateTimeDiff: invalid first dateTime: '${r}'`);if(isNaN(a.getTime()))throw new Error(`dateTimeDiff: invalid second dateTime: '${i}'`);let c=s.getTime()-a.getTime(),u=this.formatDayTimeDuration(c);return new D.Literal(u,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static dateTimeAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAdd: invalid dateTime: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()+a,u=new Date(c);return new D.Literal(u.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtract: invalid dateTime: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()-a,u=new Date(c);return new D.Literal(u.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateAdd: invalid date: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()+a,u=new Date(c),l=u.getUTCFullYear(),f=String(u.getUTCMonth()+1).padStart(2,"0"),h=String(u.getUTCDate()).padStart(2,"0"),d=`${l}-${f}-${h}`;return new D.Literal(d,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateSubtract: invalid date: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()-a,u=new Date(c),l=u.getUTCFullYear(),f=String(u.getUTCMonth()+1).padStart(2,"0"),h=String(u.getUTCDate()).padStart(2,"0"),d=`${l}-${f}-${h}`;return new D.Literal(d,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static parseYearMonthDuration(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDuration: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),a=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDuration: invalid format (no duration components): '${e}'`);let c=s*12+a;return i?-c:c}static isYearMonthDuration(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}static dateTimeAddYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAddYearMonth: invalid dateTime: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()+a),s.getUTCDate()!==c&&s.setUTCDate(0),new D.Literal(s.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtractYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtractYearMonth: invalid dateTime: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()-a),s.getUTCDate()!==c&&s.setUTCDate(0),new D.Literal(s.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAddYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateAddYearMonth: invalid date: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()+a),s.getUTCDate()!==c&&s.setUTCDate(0);let u=s.getUTCFullYear(),l=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),h=`${u}-${l}-${f}`;return new D.Literal(h,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtractYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateSubtractYearMonth: invalid date: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()-a),s.getUTCDate()!==c&&s.setUTCDate(0);let u=s.getUTCFullYear(),l=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),h=`${u}-${l}-${f}`;return new D.Literal(h,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static durationAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseDayTimeDuration(r),a=this.parseDayTimeDuration(i),c=this.formatDayTimeDuration(s+a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseDayTimeDuration(r),a=this.parseDayTimeDuration(i),c=this.formatDayTimeDuration(s-a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationMultiply(e,t){let r=e instanceof D.Literal?e.value:e,i=this.parseDayTimeDuration(r),s=this.formatDayTimeDuration(i*t);return new D.Literal(s,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationDivide(e,t){if(t===0)throw new Error("durationDivide: division by zero");let r=e instanceof D.Literal?e.value:e,i=this.parseDayTimeDuration(r),s=this.formatDayTimeDuration(i/t);return new D.Literal(s,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static formatYearMonthDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/12),s=r%12,a=t?"-P":"P";return i>0&&(a+=`${i}Y`),(s>0||i===0)&&(a+=`${s}M`),a}static yearMonthDurationAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseYearMonthDuration(r),a=this.parseYearMonthDuration(i),c=this.formatYearMonthDuration(s+a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static yearMonthDurationSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseYearMonthDuration(r),a=this.parseYearMonthDuration(i),c=this.formatYearMonthDuration(s-a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static parseYearMonthDurationComponents(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDurationComponents: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),a=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDurationComponents: invalid format (no duration components): '${e}'`);return{years:s,months:a,negative:i}}static durationYears(e){let t=e instanceof D.Literal?e.value:e,r=this.parseYearMonthDurationComponents(t);return r.negative?-r.years:r.years}static durationMonths(e){let t=e instanceof D.Literal?e.value:e,r=this.parseYearMonthDurationComponents(t);return r.negative?-r.months:r.months}static durationToDays(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/(1440*60*1e3)}static durationToHours(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/(3600*1e3)}static durationToMinutes(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/(60*1e3)}static durationToSeconds(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/1e3}static parseDurationComponents(e){if(!e)throw new Error("parseDurationComponents: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDurationComponents: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=0,a=0,c=0,u=r.indexOf("T"),l="",f="";if(u===-1?l=r:(l=r.substring(0,u),f=r.substring(u+1)),l){let h=l.match(/^(\d+(?:\.\d+)?)D$/);if(h)i=parseFloat(h[1]);else if(l!=="")throw new Error(`parseDurationComponents: invalid day component: '${l}' in '${e}'`)}if(f){let h=f,d=h.match(/^(\d+(?:\.\d+)?)H/);d&&(s=parseFloat(d[1]),h=h.substring(d[0].length));let p=h.match(/^(\d+(?:\.\d+)?)M/);p&&(a=parseFloat(p[1]),h=h.substring(p[0].length));let S=h.match(/^(\d+(?:\.\d+)?)S$/);if(S&&(c=parseFloat(S[1]),h=h.substring(S[0].length)),h!=="")throw new Error(`parseDurationComponents: invalid time component: '${h}' in '${e}'`)}return{negative:t,days:i,hours:s,minutes:a,seconds:c}}static durationDays(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t),i=Math.floor(r.days);return r.negative?-i:i}static durationHours(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t),i=Math.floor(r.hours);return r.negative?-i:i}static durationMinutes(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t),i=Math.floor(r.minutes);return r.negative?-i:i}static durationSeconds(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t);return r.negative?-r.seconds:r.seconds}static adjust(e,t){let r=e instanceof D.Literal?e.value:e,i=new Date(r);if(isNaN(i.getTime()))throw new Error(`ADJUST: invalid dateTime: '${r}'`);if(t==null){let Ee=i.getUTCFullYear(),je=String(i.getUTCMonth()+1).padStart(2,"0"),Me=String(i.getUTCDate()).padStart(2,"0"),q=String(i.getUTCHours()).padStart(2,"0"),ie=String(i.getUTCMinutes()).padStart(2,"0"),Se=String(i.getUTCSeconds()).padStart(2,"0"),nt=i.getUTCMilliseconds(),Ke=`${Ee}-${je}-${Me}T${q}:${ie}:${Se}`;return nt>0&&(Ke+=`.${String(nt).padStart(3,"0")}`),new D.Literal(Ke,new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}let s=t instanceof D.Literal?t.value:t,a=this.parseDayTimeDuration(s),c=840*60*1e3;if(Math.abs(a)>c)throw new Error(`ADJUST: timezone offset out of range: '${s}'`);let u=i.getTime(),l=new Date(u+a),f=l.getUTCFullYear(),h=String(l.getUTCMonth()+1).padStart(2,"0"),d=String(l.getUTCDate()).padStart(2,"0"),p=String(l.getUTCHours()).padStart(2,"0"),S=String(l.getUTCMinutes()).padStart(2,"0"),b=String(l.getUTCSeconds()).padStart(2,"0"),T=l.getUTCMilliseconds(),I=a>=0?"+":"-",O=Math.floor(Math.abs(a)/(3600*1e3)),L=Math.floor(Math.abs(a)%(3600*1e3)/(60*1e3)),M=`${I}${String(O).padStart(2,"0")}:${String(L).padStart(2,"0")}`,G=`${f}-${h}-${d}T${p}:${S}:${b}`;return T>0&&(G+=`.${String(T).padStart(3,"0")}`),G+=M,new D.Literal(G,new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static normalize(e,t){if(e===void 0)throw new Error("NORMALIZE: string argument is undefined");let r;if(e instanceof D.Literal)r=e.value;else if(e instanceof pe.IRI)r=e.value;else if(e instanceof _r.BlankNode)r=e.id;else if(typeof e=="string")r=e;else throw new Error("NORMALIZE: first argument must be a string or literal");let i="NFC";if(t!==void 0)if(t instanceof D.Literal)i=t.value.toUpperCase();else if(typeof t=="string")i=t.toUpperCase();else if(t instanceof pe.IRI)i=t.value.toUpperCase();else throw new Error("NORMALIZE: second argument must be a string literal");if(!this.VALID_NORMALIZATION_FORMS.includes(i))throw new Error(`NORMALIZE: invalid normalization form '${i}'. Valid forms are: NFC, NFD, NFKC, NFKD`);let s=r.normalize(i);return new D.Literal(s,new pe.IRI("http://www.w3.org/2001/XMLSchema#string"))}static fold(e){if(e===void 0)throw new Error("FOLD: string argument is undefined");let t;if(e instanceof D.Literal)t=e.value;else if(e instanceof pe.IRI)t=e.value;else if(e instanceof _r.BlankNode)t=e.id;else if(typeof e=="string")t=e;else throw new Error("FOLD: argument must be a string or literal");let r=this.unicodeCaseFold(t);return new D.Literal(r,new pe.IRI("http://www.w3.org/2001/XMLSchema#string"))}static unicodeCaseFold(e){let t="";for(let r of e){let i=this.CASE_FOLDING_MAP.get(r);i!==void 0?t+=i:t+=r.toLowerCase()}return t}static isTime(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}static timeDiff(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDTime(r),a=this.parseXSDTime(i);if(s===null)throw new Error(`timeDiff: invalid first time: '${r}'`);if(a===null)throw new Error(`timeDiff: invalid second time: '${i}'`);let c=s-a,u=this.formatDayTimeDuration(c);return new D.Literal(u,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static parseXSDTime(e){let t=/^(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r)return null;let i=parseInt(r[1],10),s=parseInt(r[2],10),a=parseInt(r[3],10),c=r[4],u=r[5];if(i<0||i>24||s<0||s>59||a<0||a>59||i===24&&(s!==0||a!==0))return null;let l=0;if(c){let h=c.padEnd(3,"0").slice(0,3);l=parseInt(h,10)}let f=i*60*60*1e3+s*60*1e3+a*1e3+l;if(i===24&&(f=1440*60*1e3),u&&u!=="Z"){let h=u.match(/([+-])(\d{2}):(\d{2})/);if(h){let d=h[1]==="+"?1:-1,p=parseInt(h[2],10),S=parseInt(h[3],10),b=d*(p*60+S)*60*1e3;f-=b}}return f}static triple(e,t,r){if(e===void 0)throw new Error("TRIPLE: subject is undefined");if(t===void 0)throw new Error("TRIPLE: predicate is undefined");if(r===void 0)throw new Error("TRIPLE: object is undefined");if(e instanceof D.Literal)throw new Error("TRIPLE: subject must be IRI, BlankNode, or QuotedTriple, got Literal");if(!(t instanceof pe.IRI)){let c=t instanceof D.Literal?"Literal":t instanceof _r.BlankNode?"BlankNode":t instanceof Za.QuotedTriple?"QuotedTriple":typeof t;throw new Error(`TRIPLE: predicate must be IRI, got ${c}`)}let i=e,s=t,a=r;return new Za.QuotedTriple(i,s,a)}static subject(e){if(e===void 0)throw new Error("SUBJECT: argument is undefined");if(!(e instanceof Za.QuotedTriple)){let t=e instanceof pe.IRI?"IRI":e instanceof D.Literal?"Literal":e instanceof _r.BlankNode?"BlankNode":typeof e;throw new Error(`SUBJECT: argument must be QuotedTriple, got ${t}`)}return e.subject}static predicate(e){if(e===void 0)throw new Error("PREDICATE: argument is undefined");if(!(e instanceof Za.QuotedTriple)){let t=e instanceof pe.IRI?"IRI":e instanceof D.Literal?"Literal":e instanceof _r.BlankNode?"BlankNode":typeof e;throw new Error(`PREDICATE: argument must be QuotedTriple, got ${t}`)}return e.predicate}static object(e){if(e===void 0)throw new Error("OBJECT: argument is undefined");if(!(e instanceof Za.QuotedTriple)){let t=e instanceof pe.IRI?"IRI":e instanceof D.Literal?"Literal":e instanceof _r.BlankNode?"BlankNode":typeof e;throw new Error(`OBJECT: argument must be QuotedTriple, got ${t}`)}return e.object}};Mf.BuiltInFunctions=Nc;Nc.VALID_NORMALIZATION_FORMS=["NFC","NFD","NFKC","NFKD"];Nc.CASE_FOLDING_MAP=new Map([["\xDF","ss"],["\u1E9E","ss"],["\u03A3","\u03C3"],["\u03C2","\u03C3"],["\u0130","i\u0307"],["I","i"],["\u0587","\u0565\u0582"],["\uFB00","ff"],["\uFB01","fi"],["\uFB02","fl"],["\uFB03","ffi"],["\uFB04","ffl"],["\uFB05","st"],["\uFB06","st"],["\u0390","\u03B9\u0308\u0301"],["\u03B0","\u03C5\u0308\u0301"],["\u017F","s"],["\u1E9B","\u1E61"],["\u212A","k"],["\u212B","\xE5"]])});var jf=v(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.FilterExecutor=eo.FilterExecutorError=void 0;var R=Fy(),ra=lt(),Qt=class extends Error{static{o(this,"FilterExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="FilterExecutorError"}};eo.FilterExecutorError=Qt;var Ny=class{static{o(this,"FilterExecutor")}constructor(){this.existsEvaluator=null,this.tripleStore=null,this.uuidCache=new Map}setExistsEvaluator(e){this.existsEvaluator=e}setTripleStore(e){this.tripleStore=e,this.uuidCache.clear()}async*execute(e,t){let r=this.expressionContainsExists(e.expression);for await(let i of t)try{let s;r?s=await this.evaluateExpressionAsync(e.expression,i):s=this.evaluateExpression(e.expression,i),s===!0&&(yield i)}catch{continue}}expressionContainsExists(e){if(e.type==="exists")return!0;if(e.type==="logical")return e.operands.some(t=>this.expressionContainsExists(t));if(e.type==="comparison")return this.expressionContainsExists(e.left)||this.expressionContainsExists(e.right);if(e.type==="in"){let t=e;return this.expressionContainsExists(t.expression)||t.list.some(r=>this.expressionContainsExists(r))}return!1}async executeAll(e,t){let r=[];async function*i(){for(let s of t)yield s}o(i,"generator");for await(let s of this.execute(e,i()))r.push(s);return r}evaluateExpression(e,t){let r=e;if(r.termType)switch(r.termType){case"Variable":return t.get(r.value);case"Literal":return r.value;case"NamedNode":return r.value;default:throw new Qt(`Unsupported termType: ${r.termType}`)}switch(e.type){case"comparison":return this.evaluateComparison(e,t);case"logical":return this.evaluateLogical(e,t);case"arithmetic":return this.evaluateArithmetic(e,t);case"function":case"functionCall":return this.evaluateFunction(e,t);case"variable":return t.get(e.name);case"literal":return e.value;case"in":return this.evaluateIn(e,t);case"exists":throw new Qt("EXISTS expressions require async evaluation. Use evaluateExpressionAsync instead.");default:throw new Qt(`Unsupported expression type: ${e.type}, expr.termType=${r.termType}`)}}async evaluateExpressionAsync(e,t){return e.type==="exists"?this.evaluateExists(e,t):e.type==="logical"?this.evaluateLogicalAsync(e,t):this.evaluateExpression(e,t)}async evaluateExists(e,t){if(!this.existsEvaluator)throw new Qt("EXISTS evaluator not set. Call setExistsEvaluator before evaluating EXISTS expressions.");let r=await this.existsEvaluator(e.pattern,t);return e.negated?!r:r}async evaluateLogicalAsync(e,t){if(e.operator==="!"){let i=await this.evaluateExpressionAsync(e.operands[0],t);return R.BuiltInFunctions.logicalNot(i)}let r=[];for(let i of e.operands){let s=await this.evaluateExpressionAsync(i,t);r.push(s)}if(e.operator==="&&")return R.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return R.BuiltInFunctions.logicalOr(r);throw new Qt(`Unknown logical operator: ${e.operator}`)}evaluateComparison(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);return R.BuiltInFunctions.compare(r,i,e.operator)}evaluateLogical(e,t){if(e.operator==="!"){let i=this.evaluateExpression(e.operands[0],t);return R.BuiltInFunctions.logicalNot(i)}let r=e.operands.map(i=>this.evaluateExpression(i,t));if(e.operator==="&&")return R.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return R.BuiltInFunctions.logicalOr(r);throw new Qt(`Unknown logical operator: ${e.operator}`)}evaluateIn(e,t){let r=this.evaluateExpression(e.expression,t),i=e.list.some(s=>{let a=this.evaluateExpression(s,t);return R.BuiltInFunctions.compare(r,a,"=")});return e.negated?!i:i}evaluateArithmetic(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);if(e.operator==="-"&&this.isDateValue(r)&&this.isDateValue(i))return R.BuiltInFunctions.dateDiff(r,i);if(e.operator==="-"&&this.isTimeValue(r)&&this.isTimeValue(i))return R.BuiltInFunctions.timeDiff(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDateTimeValue(i))return R.BuiltInFunctions.dateTimeDiff(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateAdd(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateSubtract(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateAddYearMonth(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateTimeAdd(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateTimeSubtract(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateTimeAddYearMonth(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateTimeSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.durationAdd(r,i);if(e.operator==="-"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.durationSubtract(r,i);if(e.operator==="*"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let c=this.toNumericValue(i);return R.BuiltInFunctions.durationMultiply(r,c)}if(e.operator==="*"&&!this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i)){let c=this.toNumericValue(r);return R.BuiltInFunctions.durationMultiply(i,c)}if(e.operator==="/"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let c=this.toNumericValue(i);if(c===0)throw new Qt("Division by zero");return R.BuiltInFunctions.durationDivide(r,c)}if(e.operator==="+"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.yearMonthDurationAdd(r,i);if(e.operator==="-"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.yearMonthDurationSubtract(r,i);let s=this.toNumericValue(r),a=this.toNumericValue(i);switch(e.operator){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":if(a===0)throw new Qt("Division by zero");return s/a;default:throw new Qt(`Unknown arithmetic operator: ${e.operator}`)}}isDayTimeDurationValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}isYearMonthDurationValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}toNumericValue(e){if(typeof e=="number")return e;if(e instanceof ra.Literal){let t=e.datatype?.value||"";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let i=parseFloat(e.value);if(!isNaN(i))return i}let r=parseFloat(e.value);if(!isNaN(r))return r}if(typeof e=="string"){let t=parseFloat(e);if(!isNaN(t))return t}if(e&&typeof e=="object"&&"value"in e){let t=parseFloat(String(e.value));if(!isNaN(t))return t}throw new Qt(`Cannot convert to number: ${e}`)}isDateTimeValue(e){if(e instanceof ra.Literal){let t=e.datatype?.value||"";return t.includes("#dateTime")||t.includes("#date")?!0:/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e.value)}return typeof e=="string"?/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e):!1}isDateValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}isTimeValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}evaluateFunction(e,t){let r;if(typeof e.function=="string")r=e.function.toLowerCase();else if(e.function&&typeof e.function=="object"&&"value"in e.function){let i=e.function.value;r=((i.includes("#")?i.split("#").pop():i.split("/").pop())||i).toLowerCase()}else throw new Qt(`Unknown function format: ${e.function}`);switch(r){case"str":let i=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.str(i);case"lang":let s=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.lang(s);case"datatype":let a=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.datatype(a).value;case"bound":if(e.args[0].type==="variable"){let _=t.get(e.args[0].name);return R.BuiltInFunctions.bound(_)}return!0;case"isiri":case"isuri":let c=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isIRI(c);case"isblank":let u=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isBlank(u);case"isliteral":let l=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isLiteral(l);case"regex":let f=this.getStringValue(this.evaluateExpression(e.args[0],t)),h=this.getStringValue(this.evaluateExpression(e.args[1],t)),d=e.args[2]?this.getStringValue(this.evaluateExpression(e.args[2],t)):void 0;return R.BuiltInFunctions.regex(f,h,d);case"langmatches":let p=this.getStringValue(this.evaluateExpression(e.args[0],t)),S=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.langMatches(p,S);case"contains":let b=this.getStringValue(this.evaluateExpression(e.args[0],t)),T=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.contains(b,T);case"strstarts":let I=this.getStringValue(this.evaluateExpression(e.args[0],t)),O=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strStarts(I,O);case"strends":let L=this.getStringValue(this.evaluateExpression(e.args[0],t)),M=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strEnds(L,M);case"strlen":let G=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.strlen(G);case"ucase":let Ee=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.ucase(Ee);case"lcase":let je=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.lcase(je);case"substr":let Me=this.getStringValue(this.evaluateExpression(e.args[0],t)),q=Number(this.evaluateExpression(e.args[1],t));if(e.args[2]){let _=Number(this.evaluateExpression(e.args[2],t));return R.BuiltInFunctions.substr(Me,q,_)}return R.BuiltInFunctions.substr(Me,q);case"strbefore":let ie=this.getStringValue(this.evaluateExpression(e.args[0],t)),Se=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strBefore(ie,Se);case"strafter":let nt=this.getStringValue(this.evaluateExpression(e.args[0],t)),Ke=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strAfter(nt,Ke);case"concat":let at=e.args.map(_=>this.getStringValue(this.evaluateExpression(_,t)));return R.BuiltInFunctions.concat(...at);case"replace":let Ue=this.getStringValue(this.evaluateExpression(e.args[0],t)),Be=this.getStringValue(this.evaluateExpression(e.args[1],t)),ke=this.getStringValue(this.evaluateExpression(e.args[2],t)),Q=e.args[3]?this.getStringValue(this.evaluateExpression(e.args[3],t)):void 0;return R.BuiltInFunctions.replace(Ue,Be,ke,Q);case"parsedate":let k=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.parseDate(k);case"datebefore":let qe=this.getStringValue(this.evaluateExpression(e.args[0],t)),Xe=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateBefore(qe,Xe);case"dateafter":let V=this.getStringValue(this.evaluateExpression(e.args[0],t)),me=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateAfter(V,me);case"dateinrange":let Ie=this.getStringValue(this.evaluateExpression(e.args[0],t)),z=this.getStringValue(this.evaluateExpression(e.args[1],t)),Oe=this.getStringValue(this.evaluateExpression(e.args[2],t));return R.BuiltInFunctions.dateInRange(Ie,z,Oe);case"datediffminutes":let Pe=this.getStringValue(this.evaluateExpression(e.args[0],t)),Te=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateDiffMinutes(Pe,Te);case"datediffhours":let De=this.getStringValue(this.evaluateExpression(e.args[0],t)),he=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateDiffHours(De,he);case"year":case"years":{let _=this.evaluateExpression(e.args[0],t);return this.isYearMonthDurationValue(_)?R.BuiltInFunctions.durationYears(_):R.BuiltInFunctions.year(this.getStringValue(_))}case"month":case"months":{let _=this.evaluateExpression(e.args[0],t);return this.isYearMonthDurationValue(_)?R.BuiltInFunctions.durationMonths(_):R.BuiltInFunctions.month(this.getStringValue(_))}case"day":case"days":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationDays(_):R.BuiltInFunctions.day(this.getStringValue(_))}case"hours":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationHours(_):R.BuiltInFunctions.hours(this.getStringValue(_))}case"minutes":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationMinutes(_):R.BuiltInFunctions.minutes(this.getStringValue(_))}case"seconds":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationSeconds(_):R.BuiltInFunctions.seconds(this.getStringValue(_))}case"timezone":let Ae=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.timezone(Ae);case"tz":let ge=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.tz(ge);case"adjust":{let _=this.evaluateExpression(e.args[0],t),C=e.args.length>1?this.evaluateExpression(e.args[1],t):void 0;return R.BuiltInFunctions.adjust(_,C)}case"now":return R.BuiltInFunctions.now();case"datetime":case"xsd:datetime":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdDateTime(this.getStringValue(_))}case"integer":case"xsd:integer":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdInteger(this.getStringValue(_))}case"decimal":case"xsd:decimal":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdDecimal(this.getStringValue(_))}case"daytimeduration":case"xsd:daytimeduration":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdDayTimeDuration(this.getStringValue(_))}case"durationtodays":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToDays(_)}case"durationtohours":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToHours(_)}case"durationtominutes":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToMinutes(_)}case"durationtoseconds":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToSeconds(_)}case"durationdays":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationDays(_)}case"durationhours":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationHours(_)}case"durationminutes":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationMinutes(_)}case"durationseconds":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationSeconds(_)}case"durationyears":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationYears(_)}case"durationmonths":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationMonths(_)}case"datetimediff":{let _=this.evaluateExpression(e.args[0],t),C=this.evaluateExpression(e.args[1],t);return R.BuiltInFunctions.dateTimeDiff(_,C)}case"datetimeadd":{let _=this.evaluateExpression(e.args[0],t),C=this.evaluateExpression(e.args[1],t);return R.BuiltInFunctions.dateTimeAdd(_,C)}case"datetimesubtract":{let _=this.evaluateExpression(e.args[0],t),C=this.evaluateExpression(e.args[1],t);return R.BuiltInFunctions.dateTimeSubtract(_,C)}case"mstominutes":let xe=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.msToMinutes(xe);case"mstohours":let Re=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.msToHours(Re);case"mstoseconds":let Z=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.msToSeconds(Z);case"abs":let se=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.abs(se);case"round":let ae=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.round(ae);case"ceil":let ee=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.ceil(ee);case"floor":let te=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.floor(te);case"rand":return R.BuiltInFunctions.rand();case"coalesce":for(let _ of e.args)try{let C=this.evaluateExpression(_,t);if(C!=null)return C}catch{continue}return;case"if":if(!e.args||e.args.length!==3)throw new Qt("IF requires exactly 3 arguments");let re=this.evaluateExpression(e.args[0],t);return this.toBoolean(re)?this.evaluateExpression(e.args[1],t):this.evaluateExpression(e.args[2],t);case"encode_for_uri":let oe=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.encodeForUri(oe);case"isnumeric":let ce=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isNumeric(ce);case"haslangdir":let ue=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.hasLangdir(ue);case"istriple":let le=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isTriple(le);case"sameterm":let X=this.getTermFromExpression(e.args[0],t),fe=this.getTermFromExpression(e.args[1],t);return R.BuiltInFunctions.sameTerm(X,fe);case"md5":let $e=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.md5($e);case"sha1":let Fe=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha1(Fe);case"sha256":let be=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha256(be);case"sha384":let w=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha384(w);case"sha512":let E=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha512(E);case"byuuid":return this.evaluateByUUID(e,t);case"subject":{let _=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.subject(_)}case"predicate":{let _=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.predicate(_)}case"object":{let _=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.object(_)}case"triple":{let _=this.getTermFromExpression(e.args[0],t),C=this.getTermFromExpression(e.args[1],t),W=this.getTermFromExpression(e.args[2],t);return R.BuiltInFunctions.triple(_,C,W)}default:throw new Qt(`Unknown function: ${r}`)}}getTermFromExpression(e,t){if(e.type==="variable")return t.get(e.name)}getStringValue(e){return e==null?"":typeof e=="object"&&"value"in e?String(e.value):String(e)}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number")return!isNaN(e)&&e!==0;if(typeof e=="string")return e.length>0;if(e instanceof ra.Literal){let t=e.datatype?.value||"";if(t.includes("#boolean"))return e.value==="true"||e.value==="1";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let r=parseFloat(e.value);return!isNaN(r)&&r!==0}return e.value.length>0}return!!e}evaluateByUUID(e,t){if(!e.args||e.args.length!==1)throw new Qt("exo:byUUID requires exactly 1 argument (UUID string)");let r=this.evaluateExpression(e.args[0],t),i=this.getStringValue(r);if(!i)return;let s=i.toLowerCase();if(this.uuidCache.has(s))return this.uuidCache.get(s)??void 0;if(!this.tripleStore){this.uuidCache.set(s,null);return}if(this.tripleStore.findSubjectsByUUIDSync){let a=this.tripleStore.findSubjectsByUUIDSync(s);if(a.length===0){this.uuidCache.set(s,null);return}let c=a[0];return this.uuidCache.set(s,c),c}this.uuidCache.set(s,null)}cacheUUIDResult(e,t){let r=e.toLowerCase();this.uuidCache.set(r,t)}getCachedUUID(e){let t=e.toLowerCase();if(this.uuidCache.has(t))return this.uuidCache.get(t)}};eo.FilterExecutor=Ny});var ky=v($f=>{"use strict";Object.defineProperty($f,"__esModule",{value:!0});$f.OptionalExecutor=void 0;var Ly=class{static{o(this,"OptionalExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);for(let s of r){let a=!1;for(let c of i){let u=s.merge(c);u!==null&&(yield u,a=!0)}a||(yield s)}}async executeAll(e,t){let r=[];async function*i(){for(let a of e)yield a}o(i,"generateLeft");async function*s(){for(let a of t)yield a}o(s,"generateRight");for await(let a of this.execute(i(),s()))r.push(a);return r}};$f.OptionalExecutor=Ly});var jy=v(Vf=>{"use strict";Object.defineProperty(Vf,"__esModule",{value:!0});Vf.UnionExecutor=void 0;var My=class{static{o(this,"UnionExecutor")}async*execute(e,t){let r=new Set;for await(let i of e){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}for await(let i of t){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}}async executeAll(e,t){let r=[];async function*i(){for(let a of e)yield a}o(i,"generateLeft");async function*s(){for(let a of t)yield a}o(s,"generateRight");for await(let a of this.execute(i(),s()))r.push(a);return r}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}};Vf.UnionExecutor=My});var By=v(Uf=>{"use strict";Object.defineProperty(Uf,"__esModule",{value:!0});Uf.ConstructExecutor=void 0;var i4=xi(),na=Qe(),$y=lt(),Vy=Ot(),s4=ac(),Uy=class{static{o(this,"ConstructExecutor")}async execute(e,t){let r=[],i=new Set;for(let s of t)for(let a of e)try{let c=this.instantiateTriple(a,s),u=`${c.subject.toString()}|${c.predicate.toString()}|${c.object.toString()}`;i.has(u)||(i.add(u),r.push(c))}catch{continue}return r}instantiateTriple(e,t){if(this.isPropertyPath(e.predicate))throw new Error("Property paths are not supported in CONSTRUCT templates");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.predicate,t),s=this.instantiateElement(e.object,t);return new i4.Triple(r,i,s)}isPropertyPath(e){return e.type==="path"}instantiateElement(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable: ${e.value}`);return r}if(e.type==="iri")return new na.IRI(e.value);if(e.type==="literal")return new $y.Literal(e.value,e.datatype?new na.IRI(e.datatype):void 0,e.language);if(e.type==="blank")return new Vy.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Unknown element type: ${e.type}`)}instantiateQuotedTriple(e,t){let r=this.instantiateQuotedSubject(e.subject,t),i=this.instantiateQuotedPredicate(e.predicate,t),s=this.instantiateQuotedObject(e.object,t);return new s4.QuotedTriple(r,i,s)}instantiateQuotedSubject(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple subject: ${e.value}`);if(r instanceof $y.Literal)throw new Error("Literals cannot appear in quoted triple subject position");return r}if(e.type==="iri")return new na.IRI(e.value);if(e.type==="blank")return new Vy.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Invalid element type for quoted triple subject: ${e.type}`)}instantiateQuotedPredicate(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple predicate: ${e.value}`);if(!(r instanceof na.IRI))throw new Error("Quoted triple predicate must be an IRI");return r}return new na.IRI(e.value)}instantiateQuotedObject(e,t){if(e.type==="variable"){let i=t.get(e.value);if(!i)throw new Error(`Unbound variable in quoted triple object: ${e.value}`);return i}if(e.type==="iri")return new na.IRI(e.value);if(e.type==="blank")return new Vy.BlankNode(e.value);if(e.type==="literal")return new $y.Literal(e.value,e.datatype?new na.IRI(e.datatype):void 0,e.language);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);let r=e;throw new Error(`Invalid element type for quoted triple object: ${r.type}`)}};Uf.ConstructExecutor=Uy});var U_=v(Bf=>{"use strict";Object.defineProperty(Bf,"__esModule",{value:!0});Bf.DescribeExecutor=void 0;var V_=Qe(),qy=class{static{o(this,"DescribeExecutor")}constructor(e){this.tripleStore=e}async execute(e,t){let r=[],i=new Set,s=new Set,a=t?.depth;for(let c of e)await this.describeResourceWithDepth(c,a,1,t?.symmetric??!0,r,i,s);return r}async describeResourceWithDepth(e,t,r,i,s,a,c){let u=e.toString();if(c.has(u)||(c.add(u),t!==void 0&&r>t))return;let l=[],f=await this.tripleStore.match(e,void 0,void 0);if(l.push(...f),i){let d=await this.tripleStore.match(void 0,void 0,e);l.push(...d)}let h=[];for(let d of l){let p=`${d.subject.toString()}|${d.predicate.toString()}|${d.object.toString()}`;a.has(p)||(a.add(p),s.push(d),(t===void 0||r<t)&&(this.isIRI(d.subject)&&d.subject.toString()!==u&&h.push(d.subject),this.isIRI(d.object)&&d.object.toString()!==u&&h.push(d.object)))}for(let d of h)await this.describeResourceWithDepth(d,t,r+1,i,s,a,c)}isIRI(e){return e?e instanceof V_.IRI||e.termType==="NamedNode"||typeof e.value=="string"&&e.value.startsWith("http"):!1}async describeByIRI(e,t){let r=new V_.IRI(e);return this.execute([r],t)}};Bf.DescribeExecutor=qy});var B_=v(qf=>{"use strict";Object.defineProperty(qf,"__esModule",{value:!0});qf.MinusExecutor=void 0;var Gy=class{static{o(this,"MinusExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);for(let s of r){let a=!1;for(let c of i)if(this.areCompatible(s,c)){a=!0;break}a||(yield s)}}async executeAll(e,t){let r=[];async function*i(){for(let a of e)yield a}o(i,"generateLeft");async function*s(){for(let a of t)yield a}o(s,"generateRight");for await(let a of this.execute(i(),s()))r.push(a);return r}areCompatible(e,t){let r=e.variables(),i=new Set(t.variables()),s=r.filter(a=>i.has(a));if(s.length===0)return!1;for(let a of s){let c=e.get(a),u=t.get(a);if(c===void 0||u===void 0||c.toString()!==u.toString())return!1}return!0}};qf.MinusExecutor=Gy});var G_=v(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.ValuesExecutor=to.ValuesExecutorError=void 0;var a4=Ni(),q_=Qe(),o4=lt(),Gf=class extends Error{static{o(this,"ValuesExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ValuesExecutorError"}};to.ValuesExecutorError=Gf;var Wy=class{static{o(this,"ValuesExecutor")}async*execute(e){if(e.bindings.length!==0)for(let t of e.bindings)yield this.createSolutionMapping(t)}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}createSolutionMapping(e){let t=new a4.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.toRDFTerm(i);t.set(r,s)}return t}toRDFTerm(e){if(e.type==="iri")return new q_.IRI(e.value);if(e.type==="literal")return new o4.Literal(e.value,e.datatype?new q_.IRI(e.datatype):void 0,e.language,e.direction);throw new Gf(`Unknown term type: ${e.type}`)}};to.ValuesExecutor=Wy});var Hy=v(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.CustomAggregateRegistry=no.CustomAggregateError=void 0;var ro=class extends Error{static{o(this,"CustomAggregateError")}constructor(e,t){super(e),this.iri=t,this.name="CustomAggregateError"}};no.CustomAggregateError=ro;var Wf=class n{static{o(this,"CustomAggregateRegistry")}constructor(){this.aggregates=new Map}static getInstance(){return n.instance||(n.instance=new n),n.instance}static resetInstance(){n.instance&&n.instance.clear(),n.instance=null}register(e,t){if(!e||typeof e!="string")throw new ro("Aggregate IRI must be a non-empty string");if(!t||typeof t.init!="function"||typeof t.step!="function"||typeof t.finalize!="function")throw new ro("Aggregate must implement init(), step(), and finalize() methods",e);if(this.aggregates.has(e))throw new ro(`Aggregate with IRI "${e}" is already registered`,e);this.aggregates.set(e,t)}unregister(e){return this.aggregates.delete(e)}get(e){return this.aggregates.get(e)}has(e){return this.aggregates.has(e)}getRegisteredIris(){return Array.from(this.aggregates.keys())}clear(){this.aggregates.clear()}get size(){return this.aggregates.size}};no.CustomAggregateRegistry=Wf;Wf.instance=null});var zy=v(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.BUILT_IN_AGGREGATES=Ve.modeAggregate=Ve.stddevAggregate=Ve.varianceAggregate=Ve.medianAggregate=Ve.EXO_AGGREGATE_NS=void 0;Ve.getNumericValue=Hf;Ve.createDecimalLiteral=jn;Ve.createDoubleLiteral=l4;Ve.createPercentileAggregate=ia;var sa=lt(),io=Qe(),c4=new io.IRI("http://www.w3.org/2001/XMLSchema#decimal"),u4=new io.IRI("http://www.w3.org/2001/XMLSchema#double");Ve.EXO_AGGREGATE_NS="https://exocortex.my/ontology/agg#";function Hf(n){return n==null?NaN:typeof n=="number"?n:typeof n=="string"?parseFloat(n):n instanceof sa.Literal?parseFloat(n.value):n instanceof io.IRI?NaN:typeof n=="boolean"?n?1:0:NaN}o(Hf,"getNumericValue");function jn(n){return new sa.Literal(String(n),c4)}o(jn,"createDecimalLiteral");function l4(n){return new sa.Literal(String(n),u4)}o(l4,"createDoubleLiteral");Ve.medianAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Hf(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return jn(0);let r=[...t].sort((a,c)=>a-c),i=Math.floor(r.length/2),s=r.length%2!==0?r[i]:(r[i-1]+r[i])/2;return jn(s)}};Ve.varianceAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Hf(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return jn(0);let r=t.reduce((s,a)=>s+a,0)/t.length,i=t.reduce((s,a)=>s+Math.pow(a-r,2),0)/t.length;return jn(i)}};Ve.stddevAggregate={init(){return{values:[]}},step(n,e){Ve.varianceAggregate.step(n,e)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return jn(0);let r=t.reduce((s,a)=>s+a,0)/t.length,i=t.reduce((s,a)=>s+Math.pow(a-r,2),0)/t.length;return jn(Math.sqrt(i))}};Ve.modeAggregate={init(){return{counts:new Map,values:new Map}},step(n,e){if(e==null)return;let t=n,r=String(e instanceof sa.Literal||e instanceof io.IRI?e.value:e),i=t.counts.get(r)||0;t.counts.set(r,i+1),t.values.set(r,e)},finalize(n){let e=n;if(e.counts.size===0)return new sa.Literal(" ",new io.IRI("http://www.w3.org/2001/XMLSchema#string"));let t="",r=0;for(let[a,c]of e.counts)c>r&&(r=c,t=a);let i=e.values.get(t);if(i instanceof sa.Literal)return i;let s=parseFloat(t);return isNaN(s)?new sa.Literal(t,new io.IRI("http://www.w3.org/2001/XMLSchema#string")):jn(s)}};function ia(n){let e=Math.max(0,Math.min(100,n))/100;return{init(){return{values:[],percentile:e}},step(t,r){let i=t,s=Hf(r);isNaN(s)||i.values.push(s)},finalize(t){let r=t,{values:i}=r;if(i.length===0)return jn(0);let s=[...i].sort((h,d)=>h-d),a=r.percentile*(s.length-1),c=Math.floor(a),u=Math.ceil(a);if(c===u)return jn(s[c]);let l=a-c,f=s[c]*(1-l)+s[u]*l;return jn(f)}}}o(ia,"createPercentileAggregate");Ve.BUILT_IN_AGGREGATES={[`${Ve.EXO_AGGREGATE_NS}median`]:Ve.medianAggregate,[`${Ve.EXO_AGGREGATE_NS}variance`]:Ve.varianceAggregate,[`${Ve.EXO_AGGREGATE_NS}stddev`]:Ve.stddevAggregate,[`${Ve.EXO_AGGREGATE_NS}mode`]:Ve.modeAggregate,[`${Ve.EXO_AGGREGATE_NS}percentile25`]:ia(25),[`${Ve.EXO_AGGREGATE_NS}percentile50`]:ia(50),[`${Ve.EXO_AGGREGATE_NS}percentile75`]:ia(75),[`${Ve.EXO_AGGREGATE_NS}percentile90`]:ia(90),[`${Ve.EXO_AGGREGATE_NS}percentile95`]:ia(95),[`${Ve.EXO_AGGREGATE_NS}percentile99`]:ia(99)}});var z_=v(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.AggregateExecutor=so.AggregateExecutorError=void 0;var Dt=lt(),Yy=Qe(),f4=jf(),h4=Hy(),d4=zy(),W_=new Yy.IRI("http://www.w3.org/2001/XMLSchema#integer"),aa=new Yy.IRI("http://www.w3.org/2001/XMLSchema#decimal"),si=new Yy.IRI("http://www.w3.org/2001/XMLSchema#string");function H_(n){return typeof n=="object"&&n.type==="custom"}o(H_,"isCustomAggregation");var Lc=class extends Error{static{o(this,"AggregateExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AggregateExecutorError"}};so.AggregateExecutorError=Lc;var Qy=class{static{o(this,"AggregateExecutor")}constructor(){this.filterExecutor=new f4.FilterExecutor}execute(e,t){let r=this.groupSolutions(t,e.variables),i=[];for(let[s,a]of r.entries()){let c=new Map;for(let f of e.variables)if(a.length>0){let h=a[0].get(f);h&&c.set(f,h)}for(let f of e.aggregates){let h=this.computeAggregate(f.expression,a);c.set(f.variable,h)}let{SolutionMapping:u}=Ni(),l=new u;for(let[f,h]of c.entries())l.set(f,h);i.push(l)}if(i.length===0&&e.aggregates.length>0){let s=this.createEmptyAggregateResult(e);s&&i.push(s)}return i}groupSolutions(e,t){let r=new Map;if(t.length===0)return r.set("",e),r;for(let i of e){let s=this.computeGroupKey(i,t),a=r.get(s);a?a.push(i):r.set(s,[i])}return r}computeGroupKey(e,t){return t.map(r=>{let i=e.get(r);return i?this.termToString(i):""}).join("|")}termToString(e){if(e&&typeof e=="object"){if("value"in e)return String(e.value);if("id"in e)return String(e.id)}return String(e)}computeAggregate(e,t){if(H_(e.aggregation))return this.computeCustomAggregate(e,t);let r=this.extractValues(e,t),i=e.aggregation;switch(i){case"count":{let s=this.computeCount(r,e.distinct);return new Dt.Literal(String(s),W_)}case"sum":{let s=this.computeSum(r);return new Dt.Literal(String(s),aa)}case"avg":{let s=this.computeAvg(r);return new Dt.Literal(String(s),aa)}case"min":{let s=this.computeMin(r);return s===void 0?new Dt.Literal("",si):typeof s=="number"?new Dt.Literal(String(s),aa):new Dt.Literal(String(s),si)}case"max":{let s=this.computeMax(r);return s===void 0?new Dt.Literal("",si):typeof s=="number"?new Dt.Literal(String(s),aa):new Dt.Literal(String(s),si)}case"group_concat":{let s=this.computeGroupConcat(r,e.separator||" ",e.distinct);return new Dt.Literal(s||" ",si)}case"sample":{let s=this.computeSample(r,e.distinct);return s===void 0?new Dt.Literal(" ",si):typeof s=="number"?new Dt.Literal(String(s),aa):new Dt.Literal(String(s),si)}default:{let s=i;throw new Lc(`Unknown aggregation function: ${s}`)}}}computeCustomAggregate(e,t){let i=e.aggregation.iri,a=h4.CustomAggregateRegistry.getInstance().get(i);if(a||(a=d4.BUILT_IN_AGGREGATES[i]),!a)throw new Lc(`Unknown custom aggregate function: ${i}. Register it with CustomAggregateRegistry.getInstance().register() or use a built-in aggregate.`);let c=a.init();for(let u of t){let l=null;if(e.expression){let f=this.evaluateExpression(e.expression,u);f!==void 0&&(l=f)}else l=1;a.step(c,l)}return a.finalize(c)}extractValues(e,t){if(!e.expression)return t.map(()=>1);let r=[];for(let i of t){let s=this.evaluateExpression(e.expression,i);s!=null&&r.push(s)}return r}evaluateExpression(e,t){if(e.type==="variable"){let r=t.get(e.name);return r==null?void 0:typeof r=="number"||typeof r=="string"||typeof r=="boolean"?r:typeof r=="object"&&"value"in r?r.value:r}if(e.type==="literal")return e.value;try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}computeCount(e,t){return t?new Set(e.map(r=>String(r))).size:e.length}computeSum(e){return e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r)).reduce((r,i)=>r+i,0)}computeAvg(e){let t=e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r));return t.length===0?0:t.reduce((r,i)=>r+i,0)/t.length}computeMin(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.min(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s<i?s:i,r[0])}computeMax(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.max(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s>i?s:i,r[0])}computeGroupConcat(e,t,r){let i=e.map(s=>String(s));return r&&(i=[...new Set(i)]),i.join(t)}computeSample(e,t){if(e.length===0)return;if(t){let s=[...new Set(e.map(u=>String(u)))];if(s.length===0)return;let a=s[0],c=parseFloat(a);return isNaN(c)?a:c}let r=e[0];if(typeof r=="number")return r;let i=parseFloat(String(r));return isNaN(i)?String(r):i}createEmptyAggregateResult(e){let{SolutionMapping:t}=Ni(),r=new t;for(let i of e.aggregates){let s=i.expression.aggregation;if(H_(s)){r.set(i.variable,new Dt.Literal("0",aa));continue}switch(s){case"count":r.set(i.variable,new Dt.Literal("0",W_));break;case"sum":case"avg":r.set(i.variable,new Dt.Literal("0",aa));break;case"group_concat":r.set(i.variable,new Dt.Literal(" ",si));break;case"min":case"max":case"sample":r.set(i.variable,new Dt.Literal("",si));break;default:r.set(i.variable,new Dt.Literal("",si))}}return r}};so.AggregateExecutor=Qy});var Y_=v(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.ServiceExecutor=ao.ServiceExecutorError=void 0;var p4=Ni(),Q_=Qe(),m4=lt(),g4=Ot(),oa=class extends Error{static{o(this,"ServiceExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ServiceExecutorError"}};ao.ServiceExecutorError=oa;var Ky=class{static{o(this,"ServiceExecutor")}constructor(e={}){this.timeout=e.timeout??3e4,this.httpClient=e.httpClient??((t,r)=>fetch(t,r)),this.maxRetries=e.maxRetries??2,this.retryDelay=e.retryDelay??1e3}async*execute(e,t){try{let r=t(e.pattern),i=await this.executeRemoteQuery(e.endpoint,r);for(let s of i)yield s}catch(r){if(e.silent)return;throw r}}async executeRemoteQuery(e,t){let r;for(let i=0;i<=this.maxRetries;i++)try{let s=new AbortController,a=setTimeout(()=>s.abort(),this.timeout);try{let c=await this.httpClient(e,{method:"POST",headers:{"Content-Type":"application/sparql-query",Accept:"application/sparql-results+json"},body:t,signal:s.signal});if(!c.ok)throw new oa(`Remote SPARQL endpoint returned ${c.status}: ${c.statusText}`);let u=await c.json();return this.parseJsonResults(u)}finally{clearTimeout(a)}}catch(s){if(r=s instanceof Error?s:new Error(String(s)),this.isRetryableError(r)&&i<this.maxRetries){await this.delay(this.retryDelay);continue}throw new oa(`Failed to query remote SPARQL endpoint ${e}: ${r.message}`,r)}throw new oa(`Failed to query remote SPARQL endpoint ${e} after ${this.maxRetries+1} attempts`,r)}parseJsonResults(e){return!e.results||!Array.isArray(e.results.bindings)?[]:e.results.bindings.map(t=>this.parseBinding(t))}parseBinding(e){let t=new p4.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.parseRDFTerm(i);t.set(r,s)}return t}parseRDFTerm(e){switch(e.type){case"uri":return new Q_.IRI(e.value);case"literal":{let t=e.datatype?new Q_.IRI(e.datatype):void 0;return new m4.Literal(e.value,t,e["xml:lang"])}case"bnode":return new g4.BlankNode(e.value);default:throw new oa(`Unknown RDF term type: ${e.type}`)}}isRetryableError(e){let t=e.message.toLowerCase();return!!(e.name==="AbortError"||t.includes("network")||t.includes("econnreset")||t.includes("econnrefused")||t.includes("etimedout")||t.includes("returned 5"))}delay(e){return new Promise(t=>setTimeout(t,e))}};ao.ServiceExecutor=Ky});var X_=v(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.GraphExecutor=oo.GraphExecutorError=void 0;var K_=Qe(),zf=class extends Error{static{o(this,"GraphExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="GraphExecutorError"}};oo.GraphExecutorError=zf;var Xy=class{static{o(this,"GraphExecutor")}constructor(e){this.tripleStore=e}async*execute(e,t,r){let i=e.name;if(i.type==="iri")yield*this.executeWithGraph(e.pattern,i,t);else if(i.type==="variable")yield*this.executeWithGraphVariable(e,i,t,r);else throw new zf(`Invalid graph name type: ${i.type}`)}async*executeWithGraph(e,t,r){let i=new K_.IRI(t.value);this.tripleStore.hasGraph&&!await this.tripleStore.hasGraph(i)||(yield*r(e,i))}async*executeWithGraphVariable(e,t,r,i){if(i){let a=i.get(t.value);if(a&&a instanceof K_.IRI){yield*this.executeWithGraph(e.pattern,{type:"iri",value:a.value},r);return}}if(!this.tripleStore.getNamedGraphs)return;let s=await this.tripleStore.getNamedGraphs();for(let a of s)for await(let c of r(e.pattern,a)){let u=c.clone();u.set(t.value,a),yield u}}};oo.GraphExecutor=Xy});var J_=v(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.SPARQLGenerator=uo.SPARQLGeneratorError=void 0;var co=class extends Error{static{o(this,"SPARQLGeneratorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="SPARQLGeneratorError"}};uo.SPARQLGeneratorError=co;var Jy=class{static{o(this,"SPARQLGenerator")}collectVariables(e){let t=new Set;return this.collectVariablesFromOperation(e,t),t}generateSelect(e){let t=this.collectVariables(e),r=t.size>0?Array.from(t).map(s=>`?${s}`).join(" "):"*",i=this.generateWhereClause(e);return`SELECT ${r} WHERE {
|
|
288
|
+
${r})`;default:return`${r}Unknown(${e.type})`}}tripleToString(e){return`${this.elementToString(e.subject)} ${this.predicateToString(e.predicate)} ${this.elementToString(e.object)}`}predicateToString(e){return this.isPropertyPath(e)?this.propertyPathToString(e):this.elementToString(e)}isPropertyPath(e){return e.type==="path"}propertyPathToString(e){let t=e.items.map(r=>r.type==="path"?`(${this.propertyPathToString(r)})`:`<${r.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}elementToString(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":let t=`"${e.value}"`;return e.language&&(t+=`@${e.language}`),e.datatype&&(t+=`^^<${e.datatype}>`),t;case"blank":return`_:${e.value}`;default:return String(e)}}expressionToString(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value}"`:String(e.value);case"comparison":return`(${this.expressionToString(e.left)} ${e.operator} ${this.expressionToString(e.right)})`;case"logical":return e.operator==="!"?`!(${this.expressionToString(e.operands[0])})`:`(${e.operands.map(t=>this.expressionToString(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.expressionToString(e.left)} ${e.operator} ${this.expressionToString(e.right)})`;case"function":return`${e.function}(${e.args.map(t=>this.expressionToString(t)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.toString(e.pattern,0)} }`;default:return"unknown"}}toJSON(e){return JSON.stringify(e,null,2)}};Df.AlgebraSerializer=Cy});var Ni=v(Rf=>{"use strict";Object.defineProperty(Rf,"__esModule",{value:!0});Rf.SolutionMapping=void 0;var M_=lt(),j_=Qe(),$_=Ot(),Iy=class n{static{o(this,"SolutionMapping")}constructor(e){this.bindings=e?new Map(e):new Map}get(e){return this.bindings.get(e)}set(e,t){this.bindings.set(e,t)}has(e){return this.bindings.has(e)}variables(){return Array.from(this.bindings.keys())}getBindings(){return new Map(this.bindings)}isCompatibleWith(e){for(let[t,r]of this.bindings.entries()){let i=e.get(t);if(i!==void 0&&!this.areEqual(r,i))return!1}return!0}merge(e){if(!this.isCompatibleWith(e))return null;let t=new n(this.bindings);for(let[r,i]of e.getBindings().entries())t.set(r,i);return t}clone(){return new n(this.bindings)}areEqual(e,t){return e instanceof M_.Literal&&t instanceof M_.Literal?e.equals(t):e instanceof j_.IRI&&t instanceof j_.IRI?e.value===t.value:e instanceof $_.BlankNode&&t instanceof $_.BlankNode?e.id===t.id:!1}toJSON(){let e={};for(let[t,r]of this.bindings.entries())e[t]=r.toString();return e}size(){return this.bindings.size}};Rf.SolutionMapping=Iy});var U_=v(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.PropertyPathExecutor=Xa.PropertyPathExecutorError=void 0;var s4=Ni(),Ff=Qe(),V_=Ot(),Fc=class extends Error{static{o(this,"PropertyPathExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="PropertyPathExecutorError"}};Xa.PropertyPathExecutorError=Fc;var Oy=class{static{o(this,"PropertyPathExecutor")}constructor(e){this.tripleStore=e,this.MAX_DEPTH=100}async*execute(e,t,r){let i=await this.resolveElement(e),s=this.isVariable(r)?null:await this.resolveElement(r);for(let a of i){let c=await this.evaluatePath(a,t,s);for(let u of c){let l=new s4.SolutionMapping;this.isVariable(e)&&l.set(e.value,a),this.isVariable(r)&&l.set(r.value,u),yield l}}}async*executeWithBindings(e,t){if(!this.isPropertyPath(e.predicate))throw new Fc("Predicate is not a property path");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.object,t);for await(let s of this.execute(r,e.predicate,i)){let a=t.merge(s);a!==null&&(yield a)}}async evaluatePath(e,t,r){switch(t.pathType){case"/":return this.evaluateSequencePath(e,t.items,r);case"|":return this.evaluateAlternativePath(e,t.items,r);case"^":return this.evaluateInversePath(e,t.items[0],r);case"+":return this.evaluateOneOrMorePath(e,t.items[0],r);case"*":return this.evaluateZeroOrMorePath(e,t.items[0],r);case"?":return this.evaluateZeroOrOnePath(e,t.items[0],r)}}async evaluateSequencePath(e,t,r){let i=new Set([e]);for(let s=0;s<t.length;s++){let a=t[s],c=s===t.length-1,u=new Set;for(let l of i){let f=await this.evaluatePathItem(l,a,c?r:null);for(let h of f)u.add(h)}if(i=u,i.size===0)break}return i}async evaluateAlternativePath(e,t,r){let i=new Set;for(let s of t){let a=await this.evaluatePathItem(e,s,r);for(let c of a)i.add(c)}return i}async evaluateInversePath(e,t,r){if(t.type==="iri"){let i=new Ff.IRI(t.value),s=await this.tripleStore.match(void 0,i,e),a=new Set;for(let c of s)(r===null||this.nodeInSet(c.subject,r))&&a.add(c.subject);return a}else return this.evaluatePath(e,this.invertPath(t),r)}async evaluateOneOrMorePath(e,t,r){let i=new Set,s=new Set,a=[{node:e,depth:0}];for(;a.length>0;){let{node:c,depth:u}=a.shift();if(u>=this.MAX_DEPTH)continue;let l=await this.evaluatePathItem(c,t,null);for(let f of l){let h=this.nodeToKey(f);(r===null||this.nodeInSet(f,r))&&s.add(f),i.has(h)||(i.add(h),a.push({node:f,depth:u+1}))}}return s}async evaluateZeroOrMorePath(e,t,r){let i=await this.evaluateOneOrMorePath(e,t,r);return(r===null||this.nodeInSet(e,r))&&i.add(e),i}async evaluateZeroOrOnePath(e,t,r){let i=new Set;(r===null||this.nodeInSet(e,r))&&i.add(e);let s=await this.evaluatePathItem(e,t,r);for(let a of s)i.add(a);return i}async evaluatePathItem(e,t,r){if(t.type==="iri"){let i=new Ff.IRI(t.value),s=await this.tripleStore.match(e,i,void 0),a=new Set;for(let c of s)(r===null||this.nodeInSet(c.object,r))&&a.add(c.object);return a}else return this.evaluatePath(e,t,r)}invertPath(e){switch(e.pathType){case"^":return e.items[0];case"/":return{type:"path",pathType:"/",items:[...e.items].reverse().map(r=>r.type==="iri"?{type:"path",pathType:"^",items:[r]}:this.invertPath(r))};case"|":return{type:"path",pathType:"|",items:e.items.map(r=>r.type==="iri"?{type:"path",pathType:"^",items:[r]}:this.invertPath(r))};case"+":case"*":case"?":let t=e.items[0].type==="iri"?{type:"path",pathType:"^",items:[e.items[0]]}:this.invertPath(e.items[0]);return{type:"path",pathType:e.pathType,items:[t]}}}async resolveElement(e){if(this.isVariable(e)){let r=new Set,i=await this.tripleStore.match(void 0,void 0,void 0);for(let s of i)r.add(s.subject),r.add(s.object);return r}let t=new Set;switch(e.type){case"iri":t.add(new Ff.IRI(e.value));break;case"blank":t.add(new V_.BlankNode(e.value));break;default:throw new Fc(`Unsupported element type in subject/object position: ${e.type}`)}return t}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r){if(r instanceof Ff.IRI)return{type:"iri",value:r.value};if(r instanceof V_.BlankNode)return{type:"blank",value:r.id}}}return e}isVariable(e){return e.type==="variable"}isPropertyPath(e){return e.type==="path"}nodeToKey(e){return e.toString()}nodeInSet(e,t){let r=this.nodeToKey(e);for(let i of t)if(this.nodeToKey(i)===r)return!0;return!1}};Xa.PropertyPathExecutor=Oy});var Ry=v(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.BGPExecutor=Ja.BGPExecutorError=void 0;var Nf=Ni(),ss=Qe(),Py=lt(),Lf=Ot(),kf=ac(),a4=U_(),sr=class extends Error{static{o(this,"BGPExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="BGPExecutorError"}};Ja.BGPExecutorError=sr;var Dy=class{static{o(this,"BGPExecutor")}constructor(e){this.tripleStore=e,this.propertyPathExecutor=new a4.PropertyPathExecutor(e)}async*execute(e){if(e.triples.length===0){yield new Nf.SolutionMapping;return}let t=this.matchTriplePattern(e.triples[0]);for(let r=1;r<e.triples.length;r++)t=this.joinWithPattern(t,e.triples[r]);for await(let r of t)yield r}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*executeInGraph(e,t){if(e.triples.length===0){yield new Nf.SolutionMapping;return}let r=this.matchTriplePatternInGraph(e.triples[0],t);for(let i=1;i<e.triples.length;i++)r=this.joinWithPatternInGraph(r,e.triples[i],t);for await(let i of r)yield i}async*matchTriplePatternInGraph(e,t){if(this.isPropertyPath(e.predicate))throw new sr("Property paths within named graphs are not yet supported");let r=e.predicate,i=this.isVariable(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),s=this.isVariable(r)?void 0:this.toRDFTermAsPredicate(r),a=this.isVariable(e.object)?void 0:this.toRDFTerm(e.object);if(!this.tripleStore.matchInGraph)throw new sr("Triple store does not support named graph operations");let c=await this.tripleStore.matchInGraph(i,s,a,t);for(let u of c){let l=new Nf.SolutionMapping;this.isVariable(e.subject)&&l.set(e.subject.value,u.subject),this.isVariable(r)&&l.set(r.value,u.predicate),this.isVariable(e.object)&&l.set(e.object.value,u.object),yield l}}async*joinWithPatternInGraph(e,t,r){let i=[];for await(let s of e)i.push(s);for(let s of i){let a=this.instantiatePattern(t,s);for await(let c of this.matchTriplePatternInGraph(a,r)){let u=s.merge(c);u!==null&&(yield u)}}}async*matchTriplePattern(e){if(this.isPropertyPath(e.predicate)){yield*this.propertyPathExecutor.execute(e.subject,e.predicate,e.object);return}let t=e.predicate,r=this.isVariable(e.subject)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),i=this.isVariable(t)?void 0:this.toRDFTermAsPredicate(t),s=this.isVariable(e.object)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object)?void 0:this.toRDFTerm(e.object),a=await this.tripleStore.match(r,i,s);for(let c of a){let u=new Nf.SolutionMapping;if(this.isVariable(e.subject))u.set(e.subject.value,c.subject);else if(this.isQuotedTriple(e.subject)){let l=this.matchQuotedTriplePattern(e.subject,c.subject);if(l===null)continue;for(let[f,h]of l.entries())u.set(f,h)}if(this.isVariable(t)&&u.set(t.value,c.predicate),this.isVariable(e.object))u.set(e.object.value,c.object);else if(this.isQuotedTriple(e.object)){let l=this.matchQuotedTriplePattern(e.object,c.object);if(l===null)continue;for(let[f,h]of l.entries())u.set(f,h)}yield u}}hasVariablesInQuotedTriple(e){return!!(this.isVariable(e.subject)||e.predicate.type==="variable"||this.isVariable(e.object)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object))}matchQuotedTriplePattern(e,t){if(!(t instanceof kf.QuotedTriple))return null;let r=new Map;if(this.isVariable(e.subject))r.set(e.subject.value,t.subject);else if(this.isQuotedTriple(e.subject)){let i=this.matchQuotedTriplePattern(e.subject,t.subject);if(i===null)return null;for(let[s,a]of i)r.set(s,a)}else if(!this.elementsMatch(e.subject,t.subject))return null;if(e.predicate.type==="variable")r.set(e.predicate.value,t.predicate);else if(e.predicate.value!==t.predicate.value)return null;if(this.isVariable(e.object))r.set(e.object.value,t.object);else if(this.isQuotedTriple(e.object)){let i=this.matchQuotedTriplePattern(e.object,t.object);if(i===null)return null;for(let[s,a]of i)r.set(s,a)}else if(!this.elementsMatch(e.object,t.object))return null;return r}elementsMatch(e,t){switch(e.type){case"iri":return t instanceof ss.IRI&&e.value===t.value;case"literal":return!(!(t instanceof Py.Literal)||e.value!==t.value||e.datatype!==t.datatype?.value||e.language!==t.language||e.direction!==t.direction);case"blank":return t instanceof Lf.BlankNode&&e.value===t.id;case"quoted":return t instanceof kf.QuotedTriple?this.toRDFQuotedTriple(e).equals(t):!1;default:return!1}}isPropertyPath(e){return e.type==="path"}async*joinWithPattern(e,t){let r=[];for await(let i of e)r.push(i);for(let i of r){let s=this.instantiatePattern(t,i);for await(let a of this.matchTriplePattern(s)){let c=i.merge(a);c!==null&&(yield c)}}}instantiatePattern(e,t){let r=this.isPropertyPath(e.predicate)?e.predicate:this.instantiateElement(e.predicate,t);return{subject:this.instantiateElement(e.subject,t),predicate:r,object:this.instantiateElement(e.object,t)}}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r)return this.toAlgebraElement(r)}return this.isQuotedTriple(e)?this.instantiateQuotedTriple(e,t):e}instantiateQuotedTriple(e,t){let r=this.instantiateElement(e.subject,t),i=e.predicate.type==="variable"?this.instantiatePredicateVariable(e.predicate,t):e.predicate,s=this.instantiateElement(e.object,t);return{type:"quoted",subject:r,predicate:i,object:s}}instantiatePredicateVariable(e,t){let r=t.get(e.value);return r&&r instanceof ss.IRI?{type:"iri",value:r.value}:e}isVariable(e){return e.type==="variable"}isQuotedTriple(e){return e.type==="quoted"}toRDFTermAsSubject(e){switch(e.type){case"iri":return new ss.IRI(e.value);case"blank":return new Lf.BlankNode(e.value);case"literal":throw new sr("Literals cannot appear in subject position");case"variable":throw new sr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new sr(`Unknown element type: ${e.type}`)}}toRDFQuotedTriple(e){let t=this.toRDFTermAsSubject(e.subject),r=e.predicate.type==="iri"?new ss.IRI(e.predicate.value):(()=>{throw new sr("Quoted triple predicate must be IRI")})(),i=this.toRDFTerm(e.object);return new kf.QuotedTriple(t,r,i)}toRDFTermAsPredicate(e){switch(e.type){case"iri":return new ss.IRI(e.value);case"literal":throw new sr("Literals cannot appear in predicate position");case"blank":throw new sr("Blank nodes cannot appear in predicate position");case"variable":throw new sr(`Cannot convert variable to RDF term: ${e.value}`);default:throw new sr(`Unknown element type: ${e.type}`)}}toRDFTerm(e){switch(e.type){case"iri":return new ss.IRI(e.value);case"literal":return new Py.Literal(e.value,e.datatype?new ss.IRI(e.datatype):void 0,e.language,e.direction);case"blank":return new Lf.BlankNode(e.value);case"variable":throw new sr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new sr(`Unknown element type: ${e.type}`)}}toAlgebraElement(e){if(e instanceof ss.IRI)return{type:"iri",value:e.value};if(e instanceof Py.Literal)return{type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language,direction:e.direction};if(e instanceof Lf.BlankNode)return{type:"blank",value:e.id};if(e instanceof kf.QuotedTriple)return this.toAlgebraQuotedTriple(e);throw new sr(`Unknown RDF term type: ${e.constructor?.name||"unknown"}`)}toAlgebraQuotedTriple(e){return{type:"quoted",subject:this.toAlgebraElement(e.subject),predicate:{type:"iri",value:e.predicate.value},object:this.toAlgebraElement(e.object)}}};Ja.BGPExecutor=Dy});var Ny=v(Mf=>{"use strict";Object.defineProperty(Mf,"__esModule",{value:!0});Mf.BuiltInFunctions=void 0;var pe=Qe(),D=lt(),_r=Ot(),Za=ac(),Fy=yr(),Nc=class{static{o(this,"BuiltInFunctions")}static str(e){if(e===void 0)throw new Error("STR: argument is undefined");return e instanceof pe.IRI||e instanceof D.Literal?e.value:e instanceof _r.BlankNode?e.id:String(e)}static lang(e){if(e===void 0)throw new Error("LANG: argument is undefined");return e instanceof D.Literal&&e.language?e.language:""}static langdir(e){if(e===void 0)throw new Error("LANGDIR: argument is undefined");return!(e instanceof D.Literal)||!e.language?"":e.direction?`${e.language}--${e.direction}`:e.language}static langMatches(e,t){let[r,i]=this.parseDirectionalLangTag(e),[s,a]=this.parseDirectionalLangTag(t),c=r.toLowerCase(),u=s.toLowerCase();return u==="*"?c!=="":c===""?u==="":a&&i!==a?!1:c===u?!0:c.startsWith(u+"-")}static parseDirectionalLangTag(e){let t=e.indexOf("--");if(t===-1)return[e,void 0];let r=e.substring(0,t),i=e.substring(t+2).toLowerCase();return[r,i]}static datatype(e){if(e===void 0)throw new Error("DATATYPE: argument is undefined");if(e instanceof D.Literal)return e.datatype?e.datatype:e.language?new pe.IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"):new pe.IRI("http://www.w3.org/2001/XMLSchema#string");throw new Error("DATATYPE: argument must be a literal")}static bound(e){return e!==void 0}static isIRI(e){return e===void 0?!1:e instanceof pe.IRI}static isBlank(e){return e===void 0?!1:e instanceof _r.BlankNode}static isLiteral(e){return e===void 0?!1:e instanceof D.Literal}static isTriple(e){return e===void 0?!1:e instanceof Za.QuotedTriple}static hasLangdir(e){return e===void 0||!(e instanceof D.Literal)?!1:!!e.language&&!!e.direction}static isNumeric(e){if(e===void 0||!(e instanceof D.Literal))return!1;let t=e.datatype?.value;return t?["http://www.w3.org/2001/XMLSchema#integer","http://www.w3.org/2001/XMLSchema#decimal","http://www.w3.org/2001/XMLSchema#float","http://www.w3.org/2001/XMLSchema#double","http://www.w3.org/2001/XMLSchema#nonPositiveInteger","http://www.w3.org/2001/XMLSchema#negativeInteger","http://www.w3.org/2001/XMLSchema#long","http://www.w3.org/2001/XMLSchema#int","http://www.w3.org/2001/XMLSchema#short","http://www.w3.org/2001/XMLSchema#byte","http://www.w3.org/2001/XMLSchema#nonNegativeInteger","http://www.w3.org/2001/XMLSchema#unsignedLong","http://www.w3.org/2001/XMLSchema#unsignedInt","http://www.w3.org/2001/XMLSchema#unsignedShort","http://www.w3.org/2001/XMLSchema#unsignedByte","http://www.w3.org/2001/XMLSchema#positiveInteger"].includes(t):!1}static regex(e,t,r){try{return new RegExp(t,r).test(e)}catch(i){throw new Error(`REGEX: invalid pattern '${t}': ${i.message}`)}}static compare(e,t,r){if(this.isDayTimeDurationValue(e)&&this.isDayTimeDurationValue(t))return this.compareDurations(e instanceof D.Literal?e:String(e),t instanceof D.Literal?t:String(t),r);let i=this.toComparableValue(e),s=this.toComparableValue(t);switch(r){case"=":return i===s;case"!=":return i!==s;case"<":return i<s;case">":return i>s;case"<=":return i<=s;case">=":return i>=s;default:throw new Error(`Unknown comparison operator: ${r}`)}}static isDayTimeDurationValue(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static toComparableValue(e){if(typeof e=="string"||typeof e=="number")return e;if(e instanceof D.Literal){let t=e.datatype?.value;if(t?.includes("#integer")||t?.includes("#decimal")||t?.includes("#double")){let r=parseFloat(e.value);if(!isNaN(r))return r}if(t==="http://www.w3.org/2001/XMLSchema#dayTimeDuration")try{return this.parseDayTimeDuration(e.value)}catch{return e.value}return e.value}return e instanceof pe.IRI?e.value:e instanceof _r.BlankNode?e.id:String(e)}static contains(e,t){return e.includes(t)}static strStarts(e,t){return e.startsWith(t)}static strEnds(e,t){return e.endsWith(t)}static strlen(e){return e.length}static ucase(e){return e.toUpperCase()}static lcase(e){return e.toLowerCase()}static substr(e,t,r){let i=t-1;if(i<0){if(r!==void 0){let s=r+i;return s<=0?"":e.substring(0,s)}return e}return r!==void 0?e.substring(i,i+r):e.substring(i)}static strBefore(e,t){if(t==="")return"";let r=e.indexOf(t);return r===-1?"":e.substring(0,r)}static strAfter(e,t){if(t==="")return e;let r=e.indexOf(t);return r===-1?"":e.substring(r+t.length)}static concat(...e){return e.join("")}static replace(e,t,r,i){try{let s=new RegExp(t,i||"g");return e.replace(s,r)}catch(s){throw new Error(`REPLACE: invalid pattern '${t}': ${s.message}`)}}static parseDate(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`PARSEDATE: invalid date string '${e}'`);return t.getTime()}static dateBefore(e,t){let r=this.parseDate(e),i=this.parseDate(t);return r<i}static dateAfter(e,t){let r=this.parseDate(e),i=this.parseDate(t);return r>i}static dateInRange(e,t,r){let i=this.parseDate(e),s=this.parseDate(t),a=this.parseDate(r);return i>=s&&i<=a}static dateDiffMinutes(e,t){let r=this.parseDate(e),i=this.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60))}static dateDiffHours(e,t){let r=this.parseDate(e),i=this.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60*60)*100)/100}static logicalAnd(e){return e.every(t=>t===!0)}static logicalOr(e){return e.some(t=>t===!0)}static logicalNot(e){return!e}static year(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`YEAR: invalid date string '${e}'`);return t.getFullYear()}static month(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MONTH: invalid date string '${e}'`);return t.getMonth()+1}static day(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`DAY: invalid date string '${e}'`);return t.getDate()}static hours(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`HOURS: invalid date string '${e}'`);return t.getHours()}static minutes(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MINUTES: invalid date string '${e}'`);return t.getMinutes()}static seconds(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`SECONDS: invalid date string '${e}'`);return t.getSeconds()+t.getMilliseconds()/1e3}static timezone(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TIMEZONE: invalid date string '${e}'`);let r;if(e.endsWith("Z"))r="PT0S";else{let i=e.match(/([+-]\d{2}):?(\d{2})$/);if(i){let s=parseInt(i[1],10),a=parseInt(i[2],10),c=s>=0?"":"-",u=Math.abs(s);a===0?r=`${c}PT${u}H`:r=`${c}PT${u}H${a}M`}else{let s=-t.getTimezoneOffset(),a=Math.floor(Math.abs(s)/60),c=Math.abs(s)%60,u=s>=0?"":"-";c===0?r=`${u}PT${a}H`:r=`${u}PT${a}H${c}M`}}return new D.Literal(r,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static tz(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TZ: invalid date string '${e}'`);if(e.endsWith("Z"))return"Z";let r=e.match(/([+-]\d{2}:\d{2})$/);if(r)return r[1];let i=e.match(/([+-])(\d{2})(\d{2})$/);return i?`${i[1]}${i[2]}:${i[3]}`:""}static now(){return new Date().toISOString()}static msToMinutes(e){return Math.round(e/(1e3*60))}static msToHours(e){return Math.round(e/(1e3*60*60)*100)/100}static msToSeconds(e){return Math.round(e/1e3)}static abs(e){return Math.abs(e)}static round(e){return Math.round(e)}static ceil(e){return Math.ceil(e)}static floor(e){return Math.floor(e)}static rand(){return Math.random()}static coalesce(e){for(let t of e)if(t!=null)return t}static if(e,t,r){return e?t:r}static xsdDateTime(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`xsd:dateTime: invalid date string '${e}'`);return new D.Literal(t.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static xsdInteger(e){let t=parseInt(e,10);if(isNaN(t))throw new Error(`xsd:integer: cannot convert '${e}' to integer`);return new D.Literal(String(t),new pe.IRI("http://www.w3.org/2001/XMLSchema#integer"))}static xsdDecimal(e){let t=parseFloat(e);if(isNaN(t))throw new Error(`xsd:decimal: cannot convert '${e}' to decimal`);return new D.Literal(String(t),new pe.IRI("http://www.w3.org/2001/XMLSchema#decimal"))}static encodeForUri(e){return encodeURIComponent(e)}static md5(e){return require("crypto").createHash("md5").update(e).digest("hex")}static sha1(e){return require("crypto").createHash("sha1").update(e).digest("hex")}static sha256(e){return require("crypto").createHash("sha256").update(e).digest("hex")}static sha384(e){return require("crypto").createHash("sha384").update(e).digest("hex")}static sha512(e){return require("crypto").createHash("sha512").update(e).digest("hex")}static sameTerm(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0||e.constructor!==t.constructor)return!1;if(e instanceof pe.IRI&&t instanceof pe.IRI)return e.value===t.value;if(e instanceof _r.BlankNode&&t instanceof _r.BlankNode)return e.id===t.id;if(e instanceof D.Literal&&t instanceof D.Literal){if(e.value!==t.value||e.language!==t.language)return!1;let r=e.datatype?.value,i=t.datatype?.value;return r===i}return!1}static iri(e){if(e===void 0)throw new Error("IRI: argument is undefined");if(e instanceof pe.IRI)return e;if(e instanceof D.Literal)return new pe.IRI(e.value);throw e instanceof _r.BlankNode?new Error("IRI: cannot convert blank node to IRI"):new Error("IRI: unsupported term type")}static uri(e){return this.iri(e)}static bnode(e){if(e===void 0){let t=`b${(0,Fy.v4)().replace(/-/g,"").substring(0,12)}`;return new _r.BlankNode(t)}if(e instanceof D.Literal)return new _r.BlankNode(e.value);if(e instanceof _r.BlankNode)return e;throw new Error("BNODE: argument must be a string literal or omitted")}static strdt(e,t){if(e===void 0)throw new Error("STRDT: lexical form is undefined");if(t===void 0)throw new Error("STRDT: datatype IRI is undefined");let r;if(e instanceof D.Literal){if(e.language)throw new Error("STRDT: lexical form must not have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRDT: lexical form must be a string literal");let i;if(t instanceof pe.IRI)i=t;else if(t instanceof D.Literal)i=new pe.IRI(t.value);else throw new Error("STRDT: datatype must be an IRI");return new D.Literal(r,i)}static strlang(e,t){if(e===void 0)throw new Error("STRLANG: lexical form is undefined");if(t===void 0)throw new Error("STRLANG: language tag is undefined");let r;if(e instanceof D.Literal){if(e.language)throw new Error("STRLANG: lexical form must not already have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRLANG: lexical form must be a string literal");let i;if(t instanceof D.Literal)i=t.value;else if(typeof t=="string")i=t;else throw new Error("STRLANG: language tag must be a string literal");if(i==="")throw new Error("STRLANG: language tag cannot be empty");return new D.Literal(r,void 0,i)}static strlangdir(e,t,r){if(e===void 0)throw new Error("STRLANGDIR: lexical form is undefined");if(t===void 0)throw new Error("STRLANGDIR: language tag is undefined");if(r===void 0)throw new Error("STRLANGDIR: direction is undefined");let i;if(e instanceof D.Literal){if(e.language)throw new Error("STRLANGDIR: lexical form must not already have a language tag");i=e.value}else if(typeof e=="string")i=e;else throw new Error("STRLANGDIR: lexical form must be a string literal");let s;if(t instanceof D.Literal)s=t.value;else if(typeof t=="string")s=t;else throw new Error("STRLANGDIR: language tag must be a string literal");if(s==="")throw new Error("STRLANGDIR: language tag cannot be empty");let a;if(r instanceof D.Literal)a=r.value.toLowerCase();else throw new Error("STRLANGDIR: direction must be a string literal");if(a!=="ltr"&&a!=="rtl")throw new Error(`STRLANGDIR: invalid direction '${a}'. Must be 'ltr' or 'rtl'`);return new D.Literal(i,void 0,s,a)}static uuid(){let e=(0,Fy.v4)();return new pe.IRI(`urn:uuid:${e}`)}static struuid(){let e=(0,Fy.v4)();return new D.Literal(e)}static parseDayTimeDuration(e){if(!e)throw new Error("parseDayTimeDuration: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDayTimeDuration: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=r.indexOf("T"),a="",c="";if(s===-1?a=r:(a=r.substring(0,s),c=r.substring(s+1)),a){let u=a.match(/^(\d+(?:\.\d+)?)D$/);if(u){let l=parseFloat(u[1]);i+=l*24*60*60*1e3}else if(a!=="")throw new Error(`parseDayTimeDuration: invalid day component: '${a}' in '${e}'`)}if(c){let u=c,l=u.match(/^(\d+(?:\.\d+)?)H/);if(l){let d=parseFloat(l[1]);i+=d*60*60*1e3,u=u.substring(l[0].length)}let f=u.match(/^(\d+(?:\.\d+)?)M/);if(f){let d=parseFloat(f[1]);i+=d*60*1e3,u=u.substring(f[0].length)}let h=u.match(/^(\d+(?:\.\d+)?)S$/);if(h){let d=parseFloat(h[1]);i+=d*1e3,u=u.substring(h[0].length)}if(u!=="")throw new Error(`parseDayTimeDuration: invalid time component: '${u}' in '${e}'`)}return t?-i:i}static formatDayTimeDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/(1440*60*1e3));r=r%(1440*60*1e3);let s=Math.floor(r/(3600*1e3));r=r%(3600*1e3);let a=Math.floor(r/(60*1e3));r=r%(60*1e3);let c=r/1e3,u=t?"-P":"P";return i>0&&(u+=`${i}D`),(s>0||a>0||c>0||i===0)&&(u+="T",s>0&&(u+=`${s}H`),a>0&&(u+=`${a}M`),(c>0||s===0&&a===0)&&(Number.isInteger(c)?u+=`${c}S`:u+=`${parseFloat(c.toFixed(3))}S`)),u}static xsdDayTimeDuration(e){return this.parseDayTimeDuration(e),new D.Literal(e,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static compareDurations(e,t,r){let i=e instanceof D.Literal?e.value:e,s=t instanceof D.Literal?t.value:t,a=this.parseDayTimeDuration(i),c=this.parseDayTimeDuration(s);switch(r){case"=":return a===c;case"!=":return a!==c;case"<":return a<c;case">":return a>c;case"<=":return a<=c;case">=":return a>=c;default:throw new Error(`compareDurations: unknown operator: ${r}`)}}static isDayTimeDuration(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static isDate(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}static dateDiff(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r),a=this.parseXSDDate(i);if(s===null)throw new Error(`dateDiff: invalid first date: '${r}'`);if(a===null)throw new Error(`dateDiff: invalid second date: '${i}'`);let c=s.getTime()-a.getTime(),u=Math.round(c/(1440*60*1e3)),l=this.formatDateDuration(u);return new D.Literal(l,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static parseXSDDate(e){let t=/^(-?\d{4})-(\d{2})-(\d{2})(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r){let l=new Date(e);return isNaN(l.getTime())?null:new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()))}let i=parseInt(r[1],10),s=parseInt(r[2],10)-1,a=parseInt(r[3],10),c=r[4],u=new Date(Date.UTC(i,s,a));if(c&&c!=="Z"){let l=c.match(/([+-])(\d{2}):(\d{2})/);if(l){let f=l[1]==="+"?1:-1,h=parseInt(l[2],10),d=parseInt(l[3],10),p=f*(h*60+d)*60*1e3;u=new Date(u.getTime()-p)}}return u}static formatDateDuration(e){if(e===0)return"P0D";let t=e<0,r=Math.abs(e);return t?`-P${r}D`:`P${r}D`}static dateTimeDiff(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r),a=new Date(i);if(isNaN(s.getTime()))throw new Error(`dateTimeDiff: invalid first dateTime: '${r}'`);if(isNaN(a.getTime()))throw new Error(`dateTimeDiff: invalid second dateTime: '${i}'`);let c=s.getTime()-a.getTime(),u=this.formatDayTimeDuration(c);return new D.Literal(u,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static dateTimeAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAdd: invalid dateTime: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()+a,u=new Date(c);return new D.Literal(u.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtract: invalid dateTime: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()-a,u=new Date(c);return new D.Literal(u.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateAdd: invalid date: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()+a,u=new Date(c),l=u.getUTCFullYear(),f=String(u.getUTCMonth()+1).padStart(2,"0"),h=String(u.getUTCDate()).padStart(2,"0"),d=`${l}-${f}-${h}`;return new D.Literal(d,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateSubtract: invalid date: '${r}'`);let a=this.parseDayTimeDuration(i),c=s.getTime()-a,u=new Date(c),l=u.getUTCFullYear(),f=String(u.getUTCMonth()+1).padStart(2,"0"),h=String(u.getUTCDate()).padStart(2,"0"),d=`${l}-${f}-${h}`;return new D.Literal(d,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static parseYearMonthDuration(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDuration: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),a=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDuration: invalid format (no duration components): '${e}'`);let c=s*12+a;return i?-c:c}static isYearMonthDuration(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}static dateTimeAddYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAddYearMonth: invalid dateTime: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()+a),s.getUTCDate()!==c&&s.setUTCDate(0),new D.Literal(s.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtractYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtractYearMonth: invalid dateTime: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()-a),s.getUTCDate()!==c&&s.setUTCDate(0),new D.Literal(s.toISOString(),new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAddYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateAddYearMonth: invalid date: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()+a),s.getUTCDate()!==c&&s.setUTCDate(0);let u=s.getUTCFullYear(),l=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),h=`${u}-${l}-${f}`;return new D.Literal(h,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtractYearMonth(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDDate(r);if(s===null)throw new Error(`dateSubtractYearMonth: invalid date: '${r}'`);let a=this.parseYearMonthDuration(i),c=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()-a),s.getUTCDate()!==c&&s.setUTCDate(0);let u=s.getUTCFullYear(),l=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),h=`${u}-${l}-${f}`;return new D.Literal(h,new pe.IRI("http://www.w3.org/2001/XMLSchema#date"))}static durationAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseDayTimeDuration(r),a=this.parseDayTimeDuration(i),c=this.formatDayTimeDuration(s+a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseDayTimeDuration(r),a=this.parseDayTimeDuration(i),c=this.formatDayTimeDuration(s-a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationMultiply(e,t){let r=e instanceof D.Literal?e.value:e,i=this.parseDayTimeDuration(r),s=this.formatDayTimeDuration(i*t);return new D.Literal(s,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationDivide(e,t){if(t===0)throw new Error("durationDivide: division by zero");let r=e instanceof D.Literal?e.value:e,i=this.parseDayTimeDuration(r),s=this.formatDayTimeDuration(i/t);return new D.Literal(s,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static formatYearMonthDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/12),s=r%12,a=t?"-P":"P";return i>0&&(a+=`${i}Y`),(s>0||i===0)&&(a+=`${s}M`),a}static yearMonthDurationAdd(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseYearMonthDuration(r),a=this.parseYearMonthDuration(i),c=this.formatYearMonthDuration(s+a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static yearMonthDurationSubtract(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseYearMonthDuration(r),a=this.parseYearMonthDuration(i),c=this.formatYearMonthDuration(s-a);return new D.Literal(c,new pe.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static parseYearMonthDurationComponents(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDurationComponents: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),a=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDurationComponents: invalid format (no duration components): '${e}'`);return{years:s,months:a,negative:i}}static durationYears(e){let t=e instanceof D.Literal?e.value:e,r=this.parseYearMonthDurationComponents(t);return r.negative?-r.years:r.years}static durationMonths(e){let t=e instanceof D.Literal?e.value:e,r=this.parseYearMonthDurationComponents(t);return r.negative?-r.months:r.months}static durationToDays(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/(1440*60*1e3)}static durationToHours(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/(3600*1e3)}static durationToMinutes(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/(60*1e3)}static durationToSeconds(e){let t=e instanceof D.Literal?e.value:e;return this.parseDayTimeDuration(t)/1e3}static parseDurationComponents(e){if(!e)throw new Error("parseDurationComponents: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDurationComponents: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=0,a=0,c=0,u=r.indexOf("T"),l="",f="";if(u===-1?l=r:(l=r.substring(0,u),f=r.substring(u+1)),l){let h=l.match(/^(\d+(?:\.\d+)?)D$/);if(h)i=parseFloat(h[1]);else if(l!=="")throw new Error(`parseDurationComponents: invalid day component: '${l}' in '${e}'`)}if(f){let h=f,d=h.match(/^(\d+(?:\.\d+)?)H/);d&&(s=parseFloat(d[1]),h=h.substring(d[0].length));let p=h.match(/^(\d+(?:\.\d+)?)M/);p&&(a=parseFloat(p[1]),h=h.substring(p[0].length));let S=h.match(/^(\d+(?:\.\d+)?)S$/);if(S&&(c=parseFloat(S[1]),h=h.substring(S[0].length)),h!=="")throw new Error(`parseDurationComponents: invalid time component: '${h}' in '${e}'`)}return{negative:t,days:i,hours:s,minutes:a,seconds:c}}static durationDays(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t),i=Math.floor(r.days);return r.negative?-i:i}static durationHours(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t),i=Math.floor(r.hours);return r.negative?-i:i}static durationMinutes(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t),i=Math.floor(r.minutes);return r.negative?-i:i}static durationSeconds(e){let t=e instanceof D.Literal?e.value:e,r=this.parseDurationComponents(t);return r.negative?-r.seconds:r.seconds}static adjust(e,t){let r=e instanceof D.Literal?e.value:e,i=new Date(r);if(isNaN(i.getTime()))throw new Error(`ADJUST: invalid dateTime: '${r}'`);if(t==null){let Ee=i.getUTCFullYear(),je=String(i.getUTCMonth()+1).padStart(2,"0"),Me=String(i.getUTCDate()).padStart(2,"0"),q=String(i.getUTCHours()).padStart(2,"0"),ie=String(i.getUTCMinutes()).padStart(2,"0"),Se=String(i.getUTCSeconds()).padStart(2,"0"),nt=i.getUTCMilliseconds(),Ke=`${Ee}-${je}-${Me}T${q}:${ie}:${Se}`;return nt>0&&(Ke+=`.${String(nt).padStart(3,"0")}`),new D.Literal(Ke,new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}let s=t instanceof D.Literal?t.value:t,a=this.parseDayTimeDuration(s),c=840*60*1e3;if(Math.abs(a)>c)throw new Error(`ADJUST: timezone offset out of range: '${s}'`);let u=i.getTime(),l=new Date(u+a),f=l.getUTCFullYear(),h=String(l.getUTCMonth()+1).padStart(2,"0"),d=String(l.getUTCDate()).padStart(2,"0"),p=String(l.getUTCHours()).padStart(2,"0"),S=String(l.getUTCMinutes()).padStart(2,"0"),b=String(l.getUTCSeconds()).padStart(2,"0"),T=l.getUTCMilliseconds(),I=a>=0?"+":"-",O=Math.floor(Math.abs(a)/(3600*1e3)),L=Math.floor(Math.abs(a)%(3600*1e3)/(60*1e3)),M=`${I}${String(O).padStart(2,"0")}:${String(L).padStart(2,"0")}`,G=`${f}-${h}-${d}T${p}:${S}:${b}`;return T>0&&(G+=`.${String(T).padStart(3,"0")}`),G+=M,new D.Literal(G,new pe.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static normalize(e,t){if(e===void 0)throw new Error("NORMALIZE: string argument is undefined");let r;if(e instanceof D.Literal)r=e.value;else if(e instanceof pe.IRI)r=e.value;else if(e instanceof _r.BlankNode)r=e.id;else if(typeof e=="string")r=e;else throw new Error("NORMALIZE: first argument must be a string or literal");let i="NFC";if(t!==void 0)if(t instanceof D.Literal)i=t.value.toUpperCase();else if(typeof t=="string")i=t.toUpperCase();else if(t instanceof pe.IRI)i=t.value.toUpperCase();else throw new Error("NORMALIZE: second argument must be a string literal");if(!this.VALID_NORMALIZATION_FORMS.includes(i))throw new Error(`NORMALIZE: invalid normalization form '${i}'. Valid forms are: NFC, NFD, NFKC, NFKD`);let s=r.normalize(i);return new D.Literal(s,new pe.IRI("http://www.w3.org/2001/XMLSchema#string"))}static fold(e){if(e===void 0)throw new Error("FOLD: string argument is undefined");let t;if(e instanceof D.Literal)t=e.value;else if(e instanceof pe.IRI)t=e.value;else if(e instanceof _r.BlankNode)t=e.id;else if(typeof e=="string")t=e;else throw new Error("FOLD: argument must be a string or literal");let r=this.unicodeCaseFold(t);return new D.Literal(r,new pe.IRI("http://www.w3.org/2001/XMLSchema#string"))}static unicodeCaseFold(e){let t="";for(let r of e){let i=this.CASE_FOLDING_MAP.get(r);i!==void 0?t+=i:t+=r.toLowerCase()}return t}static isTime(e){return e instanceof D.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}static timeDiff(e,t){let r=e instanceof D.Literal?e.value:e,i=t instanceof D.Literal?t.value:t,s=this.parseXSDTime(r),a=this.parseXSDTime(i);if(s===null)throw new Error(`timeDiff: invalid first time: '${r}'`);if(a===null)throw new Error(`timeDiff: invalid second time: '${i}'`);let c=s-a,u=this.formatDayTimeDuration(c);return new D.Literal(u,new pe.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static parseXSDTime(e){let t=/^(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r)return null;let i=parseInt(r[1],10),s=parseInt(r[2],10),a=parseInt(r[3],10),c=r[4],u=r[5];if(i<0||i>24||s<0||s>59||a<0||a>59||i===24&&(s!==0||a!==0))return null;let l=0;if(c){let h=c.padEnd(3,"0").slice(0,3);l=parseInt(h,10)}let f=i*60*60*1e3+s*60*1e3+a*1e3+l;if(i===24&&(f=1440*60*1e3),u&&u!=="Z"){let h=u.match(/([+-])(\d{2}):(\d{2})/);if(h){let d=h[1]==="+"?1:-1,p=parseInt(h[2],10),S=parseInt(h[3],10),b=d*(p*60+S)*60*1e3;f-=b}}return f}static triple(e,t,r){if(e===void 0)throw new Error("TRIPLE: subject is undefined");if(t===void 0)throw new Error("TRIPLE: predicate is undefined");if(r===void 0)throw new Error("TRIPLE: object is undefined");if(e instanceof D.Literal)throw new Error("TRIPLE: subject must be IRI, BlankNode, or QuotedTriple, got Literal");if(!(t instanceof pe.IRI)){let c=t instanceof D.Literal?"Literal":t instanceof _r.BlankNode?"BlankNode":t instanceof Za.QuotedTriple?"QuotedTriple":typeof t;throw new Error(`TRIPLE: predicate must be IRI, got ${c}`)}let i=e,s=t,a=r;return new Za.QuotedTriple(i,s,a)}static subject(e){if(e===void 0)throw new Error("SUBJECT: argument is undefined");if(!(e instanceof Za.QuotedTriple)){let t=e instanceof pe.IRI?"IRI":e instanceof D.Literal?"Literal":e instanceof _r.BlankNode?"BlankNode":typeof e;throw new Error(`SUBJECT: argument must be QuotedTriple, got ${t}`)}return e.subject}static predicate(e){if(e===void 0)throw new Error("PREDICATE: argument is undefined");if(!(e instanceof Za.QuotedTriple)){let t=e instanceof pe.IRI?"IRI":e instanceof D.Literal?"Literal":e instanceof _r.BlankNode?"BlankNode":typeof e;throw new Error(`PREDICATE: argument must be QuotedTriple, got ${t}`)}return e.predicate}static object(e){if(e===void 0)throw new Error("OBJECT: argument is undefined");if(!(e instanceof Za.QuotedTriple)){let t=e instanceof pe.IRI?"IRI":e instanceof D.Literal?"Literal":e instanceof _r.BlankNode?"BlankNode":typeof e;throw new Error(`OBJECT: argument must be QuotedTriple, got ${t}`)}return e.object}};Mf.BuiltInFunctions=Nc;Nc.VALID_NORMALIZATION_FORMS=["NFC","NFD","NFKC","NFKD"];Nc.CASE_FOLDING_MAP=new Map([["\xDF","ss"],["\u1E9E","ss"],["\u03A3","\u03C3"],["\u03C2","\u03C3"],["\u0130","i\u0307"],["I","i"],["\u0587","\u0565\u0582"],["\uFB00","ff"],["\uFB01","fi"],["\uFB02","fl"],["\uFB03","ffi"],["\uFB04","ffl"],["\uFB05","st"],["\uFB06","st"],["\u0390","\u03B9\u0308\u0301"],["\u03B0","\u03C5\u0308\u0301"],["\u017F","s"],["\u1E9B","\u1E61"],["\u212A","k"],["\u212B","\xE5"]])});var jf=v(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.FilterExecutor=eo.FilterExecutorError=void 0;var R=Ny(),ra=lt(),Qt=class extends Error{static{o(this,"FilterExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="FilterExecutorError"}};eo.FilterExecutorError=Qt;var Ly=class{static{o(this,"FilterExecutor")}constructor(){this.existsEvaluator=null,this.tripleStore=null,this.uuidCache=new Map}setExistsEvaluator(e){this.existsEvaluator=e}setTripleStore(e){this.tripleStore=e,this.uuidCache.clear()}async*execute(e,t){let r=this.expressionContainsExists(e.expression);for await(let i of t)try{let s;r?s=await this.evaluateExpressionAsync(e.expression,i):s=this.evaluateExpression(e.expression,i),s===!0&&(yield i)}catch{continue}}expressionContainsExists(e){if(e.type==="exists")return!0;if(e.type==="logical")return e.operands.some(t=>this.expressionContainsExists(t));if(e.type==="comparison")return this.expressionContainsExists(e.left)||this.expressionContainsExists(e.right);if(e.type==="in"){let t=e;return this.expressionContainsExists(t.expression)||t.list.some(r=>this.expressionContainsExists(r))}return!1}async executeAll(e,t){let r=[];async function*i(){for(let s of t)yield s}o(i,"generator");for await(let s of this.execute(e,i()))r.push(s);return r}evaluateExpression(e,t){let r=e;if(r.termType)switch(r.termType){case"Variable":return t.get(r.value);case"Literal":return r.value;case"NamedNode":return r.value;default:throw new Qt(`Unsupported termType: ${r.termType}`)}switch(e.type){case"comparison":return this.evaluateComparison(e,t);case"logical":return this.evaluateLogical(e,t);case"arithmetic":return this.evaluateArithmetic(e,t);case"function":case"functionCall":return this.evaluateFunction(e,t);case"variable":return t.get(e.name);case"literal":return e.value;case"in":return this.evaluateIn(e,t);case"exists":throw new Qt("EXISTS expressions require async evaluation. Use evaluateExpressionAsync instead.");default:throw new Qt(`Unsupported expression type: ${e.type}, expr.termType=${r.termType}`)}}async evaluateExpressionAsync(e,t){return e.type==="exists"?this.evaluateExists(e,t):e.type==="logical"?this.evaluateLogicalAsync(e,t):this.evaluateExpression(e,t)}async evaluateExists(e,t){if(!this.existsEvaluator)throw new Qt("EXISTS evaluator not set. Call setExistsEvaluator before evaluating EXISTS expressions.");let r=await this.existsEvaluator(e.pattern,t);return e.negated?!r:r}async evaluateLogicalAsync(e,t){if(e.operator==="!"){let i=await this.evaluateExpressionAsync(e.operands[0],t);return R.BuiltInFunctions.logicalNot(i)}let r=[];for(let i of e.operands){let s=await this.evaluateExpressionAsync(i,t);r.push(s)}if(e.operator==="&&")return R.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return R.BuiltInFunctions.logicalOr(r);throw new Qt(`Unknown logical operator: ${e.operator}`)}evaluateComparison(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);return R.BuiltInFunctions.compare(r,i,e.operator)}evaluateLogical(e,t){if(e.operator==="!"){let i=this.evaluateExpression(e.operands[0],t);return R.BuiltInFunctions.logicalNot(i)}let r=e.operands.map(i=>this.evaluateExpression(i,t));if(e.operator==="&&")return R.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return R.BuiltInFunctions.logicalOr(r);throw new Qt(`Unknown logical operator: ${e.operator}`)}evaluateIn(e,t){let r=this.evaluateExpression(e.expression,t),i=e.list.some(s=>{let a=this.evaluateExpression(s,t);return R.BuiltInFunctions.compare(r,a,"=")});return e.negated?!i:i}evaluateArithmetic(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);if(e.operator==="-"&&this.isDateValue(r)&&this.isDateValue(i))return R.BuiltInFunctions.dateDiff(r,i);if(e.operator==="-"&&this.isTimeValue(r)&&this.isTimeValue(i))return R.BuiltInFunctions.timeDiff(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDateTimeValue(i))return R.BuiltInFunctions.dateTimeDiff(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateAdd(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateSubtract(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateAddYearMonth(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateTimeAdd(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.dateTimeSubtract(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateTimeAddYearMonth(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.dateTimeSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.durationAdd(r,i);if(e.operator==="-"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return R.BuiltInFunctions.durationSubtract(r,i);if(e.operator==="*"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let c=this.toNumericValue(i);return R.BuiltInFunctions.durationMultiply(r,c)}if(e.operator==="*"&&!this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i)){let c=this.toNumericValue(r);return R.BuiltInFunctions.durationMultiply(i,c)}if(e.operator==="/"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let c=this.toNumericValue(i);if(c===0)throw new Qt("Division by zero");return R.BuiltInFunctions.durationDivide(r,c)}if(e.operator==="+"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.yearMonthDurationAdd(r,i);if(e.operator==="-"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return R.BuiltInFunctions.yearMonthDurationSubtract(r,i);let s=this.toNumericValue(r),a=this.toNumericValue(i);switch(e.operator){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":if(a===0)throw new Qt("Division by zero");return s/a;default:throw new Qt(`Unknown arithmetic operator: ${e.operator}`)}}isDayTimeDurationValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}isYearMonthDurationValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}toNumericValue(e){if(typeof e=="number")return e;if(e instanceof ra.Literal){let t=e.datatype?.value||"";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let i=parseFloat(e.value);if(!isNaN(i))return i}let r=parseFloat(e.value);if(!isNaN(r))return r}if(typeof e=="string"){let t=parseFloat(e);if(!isNaN(t))return t}if(e&&typeof e=="object"&&"value"in e){let t=parseFloat(String(e.value));if(!isNaN(t))return t}throw new Qt(`Cannot convert to number: ${e}`)}isDateTimeValue(e){if(e instanceof ra.Literal){let t=e.datatype?.value||"";return t.includes("#dateTime")||t.includes("#date")?!0:/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e.value)}return typeof e=="string"?/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e):!1}isDateValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}isTimeValue(e){return e instanceof ra.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}evaluateFunction(e,t){let r;if(typeof e.function=="string")r=e.function.toLowerCase();else if(e.function&&typeof e.function=="object"&&"value"in e.function){let i=e.function.value;r=((i.includes("#")?i.split("#").pop():i.split("/").pop())||i).toLowerCase()}else throw new Qt(`Unknown function format: ${e.function}`);switch(r){case"str":let i=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.str(i);case"lang":let s=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.lang(s);case"datatype":let a=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.datatype(a).value;case"bound":if(e.args[0].type==="variable"){let _=t.get(e.args[0].name);return R.BuiltInFunctions.bound(_)}return!0;case"isiri":case"isuri":let c=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isIRI(c);case"isblank":let u=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isBlank(u);case"isliteral":let l=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isLiteral(l);case"regex":let f=this.getStringValue(this.evaluateExpression(e.args[0],t)),h=this.getStringValue(this.evaluateExpression(e.args[1],t)),d=e.args[2]?this.getStringValue(this.evaluateExpression(e.args[2],t)):void 0;return R.BuiltInFunctions.regex(f,h,d);case"langmatches":let p=this.getStringValue(this.evaluateExpression(e.args[0],t)),S=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.langMatches(p,S);case"contains":let b=this.getStringValue(this.evaluateExpression(e.args[0],t)),T=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.contains(b,T);case"strstarts":let I=this.getStringValue(this.evaluateExpression(e.args[0],t)),O=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strStarts(I,O);case"strends":let L=this.getStringValue(this.evaluateExpression(e.args[0],t)),M=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strEnds(L,M);case"strlen":let G=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.strlen(G);case"ucase":let Ee=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.ucase(Ee);case"lcase":let je=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.lcase(je);case"substr":let Me=this.getStringValue(this.evaluateExpression(e.args[0],t)),q=Number(this.evaluateExpression(e.args[1],t));if(e.args[2]){let _=Number(this.evaluateExpression(e.args[2],t));return R.BuiltInFunctions.substr(Me,q,_)}return R.BuiltInFunctions.substr(Me,q);case"strbefore":let ie=this.getStringValue(this.evaluateExpression(e.args[0],t)),Se=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strBefore(ie,Se);case"strafter":let nt=this.getStringValue(this.evaluateExpression(e.args[0],t)),Ke=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.strAfter(nt,Ke);case"concat":let at=e.args.map(_=>this.getStringValue(this.evaluateExpression(_,t)));return R.BuiltInFunctions.concat(...at);case"replace":let Ue=this.getStringValue(this.evaluateExpression(e.args[0],t)),Be=this.getStringValue(this.evaluateExpression(e.args[1],t)),ke=this.getStringValue(this.evaluateExpression(e.args[2],t)),Q=e.args[3]?this.getStringValue(this.evaluateExpression(e.args[3],t)):void 0;return R.BuiltInFunctions.replace(Ue,Be,ke,Q);case"parsedate":let k=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.parseDate(k);case"datebefore":let qe=this.getStringValue(this.evaluateExpression(e.args[0],t)),Xe=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateBefore(qe,Xe);case"dateafter":let V=this.getStringValue(this.evaluateExpression(e.args[0],t)),me=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateAfter(V,me);case"dateinrange":let Ie=this.getStringValue(this.evaluateExpression(e.args[0],t)),z=this.getStringValue(this.evaluateExpression(e.args[1],t)),Oe=this.getStringValue(this.evaluateExpression(e.args[2],t));return R.BuiltInFunctions.dateInRange(Ie,z,Oe);case"datediffminutes":let Pe=this.getStringValue(this.evaluateExpression(e.args[0],t)),Te=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateDiffMinutes(Pe,Te);case"datediffhours":let De=this.getStringValue(this.evaluateExpression(e.args[0],t)),he=this.getStringValue(this.evaluateExpression(e.args[1],t));return R.BuiltInFunctions.dateDiffHours(De,he);case"year":case"years":{let _=this.evaluateExpression(e.args[0],t);return this.isYearMonthDurationValue(_)?R.BuiltInFunctions.durationYears(_):R.BuiltInFunctions.year(this.getStringValue(_))}case"month":case"months":{let _=this.evaluateExpression(e.args[0],t);return this.isYearMonthDurationValue(_)?R.BuiltInFunctions.durationMonths(_):R.BuiltInFunctions.month(this.getStringValue(_))}case"day":case"days":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationDays(_):R.BuiltInFunctions.day(this.getStringValue(_))}case"hours":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationHours(_):R.BuiltInFunctions.hours(this.getStringValue(_))}case"minutes":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationMinutes(_):R.BuiltInFunctions.minutes(this.getStringValue(_))}case"seconds":{let _=this.evaluateExpression(e.args[0],t);return this.isDayTimeDurationValue(_)?R.BuiltInFunctions.durationSeconds(_):R.BuiltInFunctions.seconds(this.getStringValue(_))}case"timezone":let Ae=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.timezone(Ae);case"tz":let ge=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.tz(ge);case"adjust":{let _=this.evaluateExpression(e.args[0],t),C=e.args.length>1?this.evaluateExpression(e.args[1],t):void 0;return R.BuiltInFunctions.adjust(_,C)}case"now":return R.BuiltInFunctions.now();case"datetime":case"xsd:datetime":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdDateTime(this.getStringValue(_))}case"integer":case"xsd:integer":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdInteger(this.getStringValue(_))}case"decimal":case"xsd:decimal":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdDecimal(this.getStringValue(_))}case"daytimeduration":case"xsd:daytimeduration":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.xsdDayTimeDuration(this.getStringValue(_))}case"durationtodays":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToDays(_)}case"durationtohours":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToHours(_)}case"durationtominutes":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToMinutes(_)}case"durationtoseconds":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationToSeconds(_)}case"durationdays":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationDays(_)}case"durationhours":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationHours(_)}case"durationminutes":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationMinutes(_)}case"durationseconds":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationSeconds(_)}case"durationyears":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationYears(_)}case"durationmonths":{let _=this.evaluateExpression(e.args[0],t);return R.BuiltInFunctions.durationMonths(_)}case"datetimediff":{let _=this.evaluateExpression(e.args[0],t),C=this.evaluateExpression(e.args[1],t);return R.BuiltInFunctions.dateTimeDiff(_,C)}case"datetimeadd":{let _=this.evaluateExpression(e.args[0],t),C=this.evaluateExpression(e.args[1],t);return R.BuiltInFunctions.dateTimeAdd(_,C)}case"datetimesubtract":{let _=this.evaluateExpression(e.args[0],t),C=this.evaluateExpression(e.args[1],t);return R.BuiltInFunctions.dateTimeSubtract(_,C)}case"mstominutes":let xe=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.msToMinutes(xe);case"mstohours":let Re=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.msToHours(Re);case"mstoseconds":let Z=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.msToSeconds(Z);case"abs":let se=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.abs(se);case"round":let ae=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.round(ae);case"ceil":let ee=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.ceil(ee);case"floor":let te=Number(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.floor(te);case"rand":return R.BuiltInFunctions.rand();case"coalesce":for(let _ of e.args)try{let C=this.evaluateExpression(_,t);if(C!=null)return C}catch{continue}return;case"if":if(!e.args||e.args.length!==3)throw new Qt("IF requires exactly 3 arguments");let re=this.evaluateExpression(e.args[0],t);return this.toBoolean(re)?this.evaluateExpression(e.args[1],t):this.evaluateExpression(e.args[2],t);case"encode_for_uri":let oe=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.encodeForUri(oe);case"isnumeric":let ce=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isNumeric(ce);case"haslangdir":let ue=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.hasLangdir(ue);case"istriple":let le=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.isTriple(le);case"sameterm":let X=this.getTermFromExpression(e.args[0],t),fe=this.getTermFromExpression(e.args[1],t);return R.BuiltInFunctions.sameTerm(X,fe);case"md5":let $e=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.md5($e);case"sha1":let Fe=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha1(Fe);case"sha256":let be=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha256(be);case"sha384":let w=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha384(w);case"sha512":let E=this.getStringValue(this.evaluateExpression(e.args[0],t));return R.BuiltInFunctions.sha512(E);case"byuuid":return this.evaluateByUUID(e,t);case"subject":{let _=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.subject(_)}case"predicate":{let _=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.predicate(_)}case"object":{let _=this.getTermFromExpression(e.args[0],t);return R.BuiltInFunctions.object(_)}case"triple":{let _=this.getTermFromExpression(e.args[0],t),C=this.getTermFromExpression(e.args[1],t),W=this.getTermFromExpression(e.args[2],t);return R.BuiltInFunctions.triple(_,C,W)}default:throw new Qt(`Unknown function: ${r}`)}}getTermFromExpression(e,t){if(e.type==="variable")return t.get(e.name)}getStringValue(e){return e==null?"":typeof e=="object"&&"value"in e?String(e.value):String(e)}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number")return!isNaN(e)&&e!==0;if(typeof e=="string")return e.length>0;if(e instanceof ra.Literal){let t=e.datatype?.value||"";if(t.includes("#boolean"))return e.value==="true"||e.value==="1";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let r=parseFloat(e.value);return!isNaN(r)&&r!==0}return e.value.length>0}return!!e}evaluateByUUID(e,t){if(!e.args||e.args.length!==1)throw new Qt("exo:byUUID requires exactly 1 argument (UUID string)");let r=this.evaluateExpression(e.args[0],t),i=this.getStringValue(r);if(!i)return;let s=i.toLowerCase();if(this.uuidCache.has(s))return this.uuidCache.get(s)??void 0;if(!this.tripleStore){this.uuidCache.set(s,null);return}if(this.tripleStore.findSubjectsByUUIDSync){let a=this.tripleStore.findSubjectsByUUIDSync(s);if(a.length===0){this.uuidCache.set(s,null);return}let c=a[0];return this.uuidCache.set(s,c),c}this.uuidCache.set(s,null)}cacheUUIDResult(e,t){let r=e.toLowerCase();this.uuidCache.set(r,t)}getCachedUUID(e){let t=e.toLowerCase();if(this.uuidCache.has(t))return this.uuidCache.get(t)}};eo.FilterExecutor=Ly});var My=v($f=>{"use strict";Object.defineProperty($f,"__esModule",{value:!0});$f.OptionalExecutor=void 0;var ky=class{static{o(this,"OptionalExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);for(let s of r){let a=!1;for(let c of i){let u=s.merge(c);u!==null&&(yield u,a=!0)}a||(yield s)}}async executeAll(e,t){let r=[];async function*i(){for(let a of e)yield a}o(i,"generateLeft");async function*s(){for(let a of t)yield a}o(s,"generateRight");for await(let a of this.execute(i(),s()))r.push(a);return r}};$f.OptionalExecutor=ky});var $y=v(Vf=>{"use strict";Object.defineProperty(Vf,"__esModule",{value:!0});Vf.UnionExecutor=void 0;var jy=class{static{o(this,"UnionExecutor")}async*execute(e,t){let r=new Set;for await(let i of e){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}for await(let i of t){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}}async executeAll(e,t){let r=[];async function*i(){for(let a of e)yield a}o(i,"generateLeft");async function*s(){for(let a of t)yield a}o(s,"generateRight");for await(let a of this.execute(i(),s()))r.push(a);return r}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}};Vf.UnionExecutor=jy});var qy=v(Uf=>{"use strict";Object.defineProperty(Uf,"__esModule",{value:!0});Uf.ConstructExecutor=void 0;var o4=xi(),na=Qe(),Vy=lt(),Uy=Ot(),c4=ac(),By=class{static{o(this,"ConstructExecutor")}async execute(e,t){let r=[],i=new Set;for(let s of t)for(let a of e)try{let c=this.instantiateTriple(a,s),u=`${c.subject.toString()}|${c.predicate.toString()}|${c.object.toString()}`;i.has(u)||(i.add(u),r.push(c))}catch{continue}return r}instantiateTriple(e,t){if(this.isPropertyPath(e.predicate))throw new Error("Property paths are not supported in CONSTRUCT templates");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.predicate,t),s=this.instantiateElement(e.object,t);return new o4.Triple(r,i,s)}isPropertyPath(e){return e.type==="path"}instantiateElement(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable: ${e.value}`);return r}if(e.type==="iri")return new na.IRI(e.value);if(e.type==="literal")return new Vy.Literal(e.value,e.datatype?new na.IRI(e.datatype):void 0,e.language);if(e.type==="blank")return new Uy.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Unknown element type: ${e.type}`)}instantiateQuotedTriple(e,t){let r=this.instantiateQuotedSubject(e.subject,t),i=this.instantiateQuotedPredicate(e.predicate,t),s=this.instantiateQuotedObject(e.object,t);return new c4.QuotedTriple(r,i,s)}instantiateQuotedSubject(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple subject: ${e.value}`);if(r instanceof Vy.Literal)throw new Error("Literals cannot appear in quoted triple subject position");return r}if(e.type==="iri")return new na.IRI(e.value);if(e.type==="blank")return new Uy.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Invalid element type for quoted triple subject: ${e.type}`)}instantiateQuotedPredicate(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple predicate: ${e.value}`);if(!(r instanceof na.IRI))throw new Error("Quoted triple predicate must be an IRI");return r}return new na.IRI(e.value)}instantiateQuotedObject(e,t){if(e.type==="variable"){let i=t.get(e.value);if(!i)throw new Error(`Unbound variable in quoted triple object: ${e.value}`);return i}if(e.type==="iri")return new na.IRI(e.value);if(e.type==="blank")return new Uy.BlankNode(e.value);if(e.type==="literal")return new Vy.Literal(e.value,e.datatype?new na.IRI(e.datatype):void 0,e.language);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);let r=e;throw new Error(`Invalid element type for quoted triple object: ${r.type}`)}};Uf.ConstructExecutor=By});var q_=v(Bf=>{"use strict";Object.defineProperty(Bf,"__esModule",{value:!0});Bf.DescribeExecutor=void 0;var B_=Qe(),Gy=class{static{o(this,"DescribeExecutor")}constructor(e){this.tripleStore=e}async execute(e,t){let r=[],i=new Set,s=new Set,a=t?.depth;for(let c of e)await this.describeResourceWithDepth(c,a,1,t?.symmetric??!0,r,i,s);return r}async describeResourceWithDepth(e,t,r,i,s,a,c){let u=e.toString();if(c.has(u)||(c.add(u),t!==void 0&&r>t))return;let l=[],f=await this.tripleStore.match(e,void 0,void 0);if(l.push(...f),i){let d=await this.tripleStore.match(void 0,void 0,e);l.push(...d)}let h=[];for(let d of l){let p=`${d.subject.toString()}|${d.predicate.toString()}|${d.object.toString()}`;a.has(p)||(a.add(p),s.push(d),(t===void 0||r<t)&&(this.isIRI(d.subject)&&d.subject.toString()!==u&&h.push(d.subject),this.isIRI(d.object)&&d.object.toString()!==u&&h.push(d.object)))}for(let d of h)await this.describeResourceWithDepth(d,t,r+1,i,s,a,c)}isIRI(e){return e?e instanceof B_.IRI||e.termType==="NamedNode"||typeof e.value=="string"&&e.value.startsWith("http"):!1}async describeByIRI(e,t){let r=new B_.IRI(e);return this.execute([r],t)}};Bf.DescribeExecutor=Gy});var G_=v(qf=>{"use strict";Object.defineProperty(qf,"__esModule",{value:!0});qf.MinusExecutor=void 0;var Wy=class{static{o(this,"MinusExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);for(let s of r){let a=!1;for(let c of i)if(this.areCompatible(s,c)){a=!0;break}a||(yield s)}}async executeAll(e,t){let r=[];async function*i(){for(let a of e)yield a}o(i,"generateLeft");async function*s(){for(let a of t)yield a}o(s,"generateRight");for await(let a of this.execute(i(),s()))r.push(a);return r}areCompatible(e,t){let r=e.variables(),i=new Set(t.variables()),s=r.filter(a=>i.has(a));if(s.length===0)return!1;for(let a of s){let c=e.get(a),u=t.get(a);if(c===void 0||u===void 0||c.toString()!==u.toString())return!1}return!0}};qf.MinusExecutor=Wy});var H_=v(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.ValuesExecutor=to.ValuesExecutorError=void 0;var u4=Ni(),W_=Qe(),l4=lt(),Gf=class extends Error{static{o(this,"ValuesExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ValuesExecutorError"}};to.ValuesExecutorError=Gf;var Hy=class{static{o(this,"ValuesExecutor")}async*execute(e){if(e.bindings.length!==0)for(let t of e.bindings)yield this.createSolutionMapping(t)}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}createSolutionMapping(e){let t=new u4.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.toRDFTerm(i);t.set(r,s)}return t}toRDFTerm(e){if(e.type==="iri")return new W_.IRI(e.value);if(e.type==="literal")return new l4.Literal(e.value,e.datatype?new W_.IRI(e.datatype):void 0,e.language,e.direction);throw new Gf(`Unknown term type: ${e.type}`)}};to.ValuesExecutor=Hy});var zy=v(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.CustomAggregateRegistry=no.CustomAggregateError=void 0;var ro=class extends Error{static{o(this,"CustomAggregateError")}constructor(e,t){super(e),this.iri=t,this.name="CustomAggregateError"}};no.CustomAggregateError=ro;var Wf=class n{static{o(this,"CustomAggregateRegistry")}constructor(){this.aggregates=new Map}static getInstance(){return n.instance||(n.instance=new n),n.instance}static resetInstance(){n.instance&&n.instance.clear(),n.instance=null}register(e,t){if(!e||typeof e!="string")throw new ro("Aggregate IRI must be a non-empty string");if(!t||typeof t.init!="function"||typeof t.step!="function"||typeof t.finalize!="function")throw new ro("Aggregate must implement init(), step(), and finalize() methods",e);if(this.aggregates.has(e))throw new ro(`Aggregate with IRI "${e}" is already registered`,e);this.aggregates.set(e,t)}unregister(e){return this.aggregates.delete(e)}get(e){return this.aggregates.get(e)}has(e){return this.aggregates.has(e)}getRegisteredIris(){return Array.from(this.aggregates.keys())}clear(){this.aggregates.clear()}get size(){return this.aggregates.size}};no.CustomAggregateRegistry=Wf;Wf.instance=null});var Qy=v(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.BUILT_IN_AGGREGATES=Ve.modeAggregate=Ve.stddevAggregate=Ve.varianceAggregate=Ve.medianAggregate=Ve.EXO_AGGREGATE_NS=void 0;Ve.getNumericValue=Hf;Ve.createDecimalLiteral=jn;Ve.createDoubleLiteral=d4;Ve.createPercentileAggregate=ia;var sa=lt(),io=Qe(),f4=new io.IRI("http://www.w3.org/2001/XMLSchema#decimal"),h4=new io.IRI("http://www.w3.org/2001/XMLSchema#double");Ve.EXO_AGGREGATE_NS="https://exocortex.my/ontology/agg#";function Hf(n){return n==null?NaN:typeof n=="number"?n:typeof n=="string"?parseFloat(n):n instanceof sa.Literal?parseFloat(n.value):n instanceof io.IRI?NaN:typeof n=="boolean"?n?1:0:NaN}o(Hf,"getNumericValue");function jn(n){return new sa.Literal(String(n),f4)}o(jn,"createDecimalLiteral");function d4(n){return new sa.Literal(String(n),h4)}o(d4,"createDoubleLiteral");Ve.medianAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Hf(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return jn(0);let r=[...t].sort((a,c)=>a-c),i=Math.floor(r.length/2),s=r.length%2!==0?r[i]:(r[i-1]+r[i])/2;return jn(s)}};Ve.varianceAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Hf(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return jn(0);let r=t.reduce((s,a)=>s+a,0)/t.length,i=t.reduce((s,a)=>s+Math.pow(a-r,2),0)/t.length;return jn(i)}};Ve.stddevAggregate={init(){return{values:[]}},step(n,e){Ve.varianceAggregate.step(n,e)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return jn(0);let r=t.reduce((s,a)=>s+a,0)/t.length,i=t.reduce((s,a)=>s+Math.pow(a-r,2),0)/t.length;return jn(Math.sqrt(i))}};Ve.modeAggregate={init(){return{counts:new Map,values:new Map}},step(n,e){if(e==null)return;let t=n,r=String(e instanceof sa.Literal||e instanceof io.IRI?e.value:e),i=t.counts.get(r)||0;t.counts.set(r,i+1),t.values.set(r,e)},finalize(n){let e=n;if(e.counts.size===0)return new sa.Literal(" ",new io.IRI("http://www.w3.org/2001/XMLSchema#string"));let t="",r=0;for(let[a,c]of e.counts)c>r&&(r=c,t=a);let i=e.values.get(t);if(i instanceof sa.Literal)return i;let s=parseFloat(t);return isNaN(s)?new sa.Literal(t,new io.IRI("http://www.w3.org/2001/XMLSchema#string")):jn(s)}};function ia(n){let e=Math.max(0,Math.min(100,n))/100;return{init(){return{values:[],percentile:e}},step(t,r){let i=t,s=Hf(r);isNaN(s)||i.values.push(s)},finalize(t){let r=t,{values:i}=r;if(i.length===0)return jn(0);let s=[...i].sort((h,d)=>h-d),a=r.percentile*(s.length-1),c=Math.floor(a),u=Math.ceil(a);if(c===u)return jn(s[c]);let l=a-c,f=s[c]*(1-l)+s[u]*l;return jn(f)}}}o(ia,"createPercentileAggregate");Ve.BUILT_IN_AGGREGATES={[`${Ve.EXO_AGGREGATE_NS}median`]:Ve.medianAggregate,[`${Ve.EXO_AGGREGATE_NS}variance`]:Ve.varianceAggregate,[`${Ve.EXO_AGGREGATE_NS}stddev`]:Ve.stddevAggregate,[`${Ve.EXO_AGGREGATE_NS}mode`]:Ve.modeAggregate,[`${Ve.EXO_AGGREGATE_NS}percentile25`]:ia(25),[`${Ve.EXO_AGGREGATE_NS}percentile50`]:ia(50),[`${Ve.EXO_AGGREGATE_NS}percentile75`]:ia(75),[`${Ve.EXO_AGGREGATE_NS}percentile90`]:ia(90),[`${Ve.EXO_AGGREGATE_NS}percentile95`]:ia(95),[`${Ve.EXO_AGGREGATE_NS}percentile99`]:ia(99)}});var Y_=v(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.AggregateExecutor=so.AggregateExecutorError=void 0;var Dt=lt(),Ky=Qe(),p4=jf(),m4=zy(),g4=Qy(),z_=new Ky.IRI("http://www.w3.org/2001/XMLSchema#integer"),aa=new Ky.IRI("http://www.w3.org/2001/XMLSchema#decimal"),si=new Ky.IRI("http://www.w3.org/2001/XMLSchema#string");function Q_(n){return typeof n=="object"&&n.type==="custom"}o(Q_,"isCustomAggregation");var Lc=class extends Error{static{o(this,"AggregateExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AggregateExecutorError"}};so.AggregateExecutorError=Lc;var Yy=class{static{o(this,"AggregateExecutor")}constructor(){this.filterExecutor=new p4.FilterExecutor}execute(e,t){let r=this.groupSolutions(t,e.variables),i=[];for(let[s,a]of r.entries()){let c=new Map;for(let f of e.variables)if(a.length>0){let h=a[0].get(f);h&&c.set(f,h)}for(let f of e.aggregates){let h=this.computeAggregate(f.expression,a);c.set(f.variable,h)}let{SolutionMapping:u}=Ni(),l=new u;for(let[f,h]of c.entries())l.set(f,h);i.push(l)}if(i.length===0&&e.aggregates.length>0){let s=this.createEmptyAggregateResult(e);s&&i.push(s)}return i}groupSolutions(e,t){let r=new Map;if(t.length===0)return r.set("",e),r;for(let i of e){let s=this.computeGroupKey(i,t),a=r.get(s);a?a.push(i):r.set(s,[i])}return r}computeGroupKey(e,t){return t.map(r=>{let i=e.get(r);return i?this.termToString(i):""}).join("|")}termToString(e){if(e&&typeof e=="object"){if("value"in e)return String(e.value);if("id"in e)return String(e.id)}return String(e)}computeAggregate(e,t){if(Q_(e.aggregation))return this.computeCustomAggregate(e,t);let r=this.extractValues(e,t),i=e.aggregation;switch(i){case"count":{let s=this.computeCount(r,e.distinct);return new Dt.Literal(String(s),z_)}case"sum":{let s=this.computeSum(r);return new Dt.Literal(String(s),aa)}case"avg":{let s=this.computeAvg(r);return new Dt.Literal(String(s),aa)}case"min":{let s=this.computeMin(r);return s===void 0?new Dt.Literal("",si):typeof s=="number"?new Dt.Literal(String(s),aa):new Dt.Literal(String(s),si)}case"max":{let s=this.computeMax(r);return s===void 0?new Dt.Literal("",si):typeof s=="number"?new Dt.Literal(String(s),aa):new Dt.Literal(String(s),si)}case"group_concat":{let s=this.computeGroupConcat(r,e.separator||" ",e.distinct);return new Dt.Literal(s||" ",si)}case"sample":{let s=this.computeSample(r,e.distinct);return s===void 0?new Dt.Literal(" ",si):typeof s=="number"?new Dt.Literal(String(s),aa):new Dt.Literal(String(s),si)}default:{let s=i;throw new Lc(`Unknown aggregation function: ${s}`)}}}computeCustomAggregate(e,t){let i=e.aggregation.iri,a=m4.CustomAggregateRegistry.getInstance().get(i);if(a||(a=g4.BUILT_IN_AGGREGATES[i]),!a)throw new Lc(`Unknown custom aggregate function: ${i}. Register it with CustomAggregateRegistry.getInstance().register() or use a built-in aggregate.`);let c=a.init();for(let u of t){let l=null;if(e.expression){let f=this.evaluateExpression(e.expression,u);f!==void 0&&(l=f)}else l=1;a.step(c,l)}return a.finalize(c)}extractValues(e,t){if(!e.expression)return t.map(()=>1);let r=[];for(let i of t){let s=this.evaluateExpression(e.expression,i);s!=null&&r.push(s)}return r}evaluateExpression(e,t){if(e.type==="variable"){let r=t.get(e.name);return r==null?void 0:typeof r=="number"||typeof r=="string"||typeof r=="boolean"?r:typeof r=="object"&&"value"in r?r.value:r}if(e.type==="literal")return e.value;try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}computeCount(e,t){return t?new Set(e.map(r=>String(r))).size:e.length}computeSum(e){return e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r)).reduce((r,i)=>r+i,0)}computeAvg(e){let t=e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r));return t.length===0?0:t.reduce((r,i)=>r+i,0)/t.length}computeMin(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.min(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s<i?s:i,r[0])}computeMax(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.max(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s>i?s:i,r[0])}computeGroupConcat(e,t,r){let i=e.map(s=>String(s));return r&&(i=[...new Set(i)]),i.join(t)}computeSample(e,t){if(e.length===0)return;if(t){let s=[...new Set(e.map(u=>String(u)))];if(s.length===0)return;let a=s[0],c=parseFloat(a);return isNaN(c)?a:c}let r=e[0];if(typeof r=="number")return r;let i=parseFloat(String(r));return isNaN(i)?String(r):i}createEmptyAggregateResult(e){let{SolutionMapping:t}=Ni(),r=new t;for(let i of e.aggregates){let s=i.expression.aggregation;if(Q_(s)){r.set(i.variable,new Dt.Literal("0",aa));continue}switch(s){case"count":r.set(i.variable,new Dt.Literal("0",z_));break;case"sum":case"avg":r.set(i.variable,new Dt.Literal("0",aa));break;case"group_concat":r.set(i.variable,new Dt.Literal(" ",si));break;case"min":case"max":case"sample":r.set(i.variable,new Dt.Literal("",si));break;default:r.set(i.variable,new Dt.Literal("",si))}}return r}};so.AggregateExecutor=Yy});var X_=v(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.ServiceExecutor=ao.ServiceExecutorError=void 0;var y4=Ni(),K_=Qe(),v4=lt(),S4=Ot(),oa=class extends Error{static{o(this,"ServiceExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ServiceExecutorError"}};ao.ServiceExecutorError=oa;var Xy=class{static{o(this,"ServiceExecutor")}constructor(e={}){this.timeout=e.timeout??3e4,this.httpClient=e.httpClient??((t,r)=>fetch(t,r)),this.maxRetries=e.maxRetries??2,this.retryDelay=e.retryDelay??1e3}async*execute(e,t){try{let r=t(e.pattern),i=await this.executeRemoteQuery(e.endpoint,r);for(let s of i)yield s}catch(r){if(e.silent)return;throw r}}async executeRemoteQuery(e,t){let r;for(let i=0;i<=this.maxRetries;i++)try{let s=new AbortController,a=setTimeout(()=>s.abort(),this.timeout);try{let c=await this.httpClient(e,{method:"POST",headers:{"Content-Type":"application/sparql-query",Accept:"application/sparql-results+json"},body:t,signal:s.signal});if(!c.ok)throw new oa(`Remote SPARQL endpoint returned ${c.status}: ${c.statusText}`);let u=await c.json();return this.parseJsonResults(u)}finally{clearTimeout(a)}}catch(s){if(r=s instanceof Error?s:new Error(String(s)),this.isRetryableError(r)&&i<this.maxRetries){await this.delay(this.retryDelay);continue}throw new oa(`Failed to query remote SPARQL endpoint ${e}: ${r.message}`,r)}throw new oa(`Failed to query remote SPARQL endpoint ${e} after ${this.maxRetries+1} attempts`,r)}parseJsonResults(e){return!e.results||!Array.isArray(e.results.bindings)?[]:e.results.bindings.map(t=>this.parseBinding(t))}parseBinding(e){let t=new y4.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.parseRDFTerm(i);t.set(r,s)}return t}parseRDFTerm(e){switch(e.type){case"uri":return new K_.IRI(e.value);case"literal":{let t=e.datatype?new K_.IRI(e.datatype):void 0;return new v4.Literal(e.value,t,e["xml:lang"])}case"bnode":return new S4.BlankNode(e.value);default:throw new oa(`Unknown RDF term type: ${e.type}`)}}isRetryableError(e){let t=e.message.toLowerCase();return!!(e.name==="AbortError"||t.includes("network")||t.includes("econnreset")||t.includes("econnrefused")||t.includes("etimedout")||t.includes("returned 5"))}delay(e){return new Promise(t=>setTimeout(t,e))}};ao.ServiceExecutor=Xy});var Z_=v(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.GraphExecutor=oo.GraphExecutorError=void 0;var J_=Qe(),zf=class extends Error{static{o(this,"GraphExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="GraphExecutorError"}};oo.GraphExecutorError=zf;var Jy=class{static{o(this,"GraphExecutor")}constructor(e){this.tripleStore=e}async*execute(e,t,r){let i=e.name;if(i.type==="iri")yield*this.executeWithGraph(e.pattern,i,t);else if(i.type==="variable")yield*this.executeWithGraphVariable(e,i,t,r);else throw new zf(`Invalid graph name type: ${i.type}`)}async*executeWithGraph(e,t,r){let i=new J_.IRI(t.value);this.tripleStore.hasGraph&&!await this.tripleStore.hasGraph(i)||(yield*r(e,i))}async*executeWithGraphVariable(e,t,r,i){if(i){let a=i.get(t.value);if(a&&a instanceof J_.IRI){yield*this.executeWithGraph(e.pattern,{type:"iri",value:a.value},r);return}}if(!this.tripleStore.getNamedGraphs)return;let s=await this.tripleStore.getNamedGraphs();for(let a of s)for await(let c of r(e.pattern,a)){let u=c.clone();u.set(t.value,a),yield u}}};oo.GraphExecutor=Jy});var eb=v(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.SPARQLGenerator=uo.SPARQLGeneratorError=void 0;var co=class extends Error{static{o(this,"SPARQLGeneratorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="SPARQLGeneratorError"}};uo.SPARQLGeneratorError=co;var Zy=class{static{o(this,"SPARQLGenerator")}collectVariables(e){let t=new Set;return this.collectVariablesFromOperation(e,t),t}generateSelect(e){let t=this.collectVariables(e),r=t.size>0?Array.from(t).map(s=>`?${s}`).join(" "):"*",i=this.generateWhereClause(e);return`SELECT ${r} WHERE {
|
|
289
289
|
${i}
|
|
290
290
|
}`}generateWhereClause(e,t=2){let r=" ".repeat(t);switch(e.type){case"bgp":return this.generateBGP(e,t);case"filter":return`${this.generateWhereClause(e.input,t)}
|
|
291
291
|
${r}FILTER(${this.generateExpression(e.expression)})`;case"join":return`${this.generateWhereClause(e.left,t)}
|
|
@@ -307,90 +307,90 @@ ${r}}`}default:throw new co(`Unsupported operation type for SPARQL generation: $
|
|
|
307
307
|
`)}generateTriple(e){let t=this.generateElement(e.subject),r=this.generatePredicate(e.predicate),i=this.generateElement(e.object);return`${t} ${r} ${i}`}generatePredicate(e){return"pathType"in e?this.generatePropertyPath(e):this.generateElement(e)}generatePropertyPath(e){let t=e.items.map(r=>"pathType"in r?`(${this.generatePropertyPath(r)})`:`<${r.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}generateElement(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":{let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}case"blank":return`_:${e.value}`;default:throw new co(`Unknown element type: ${e.type}`)}}generateValues(e,t){let r=" ".repeat(t);if(e.variables.length===0||e.bindings.length===0)return"";if(e.variables.length===1){let a=e.variables[0],c=e.bindings.map(u=>{let l=u[a];return l?this.generateValuesTerm(l):"UNDEF"}).join(" ");return`${r}VALUES ?${a} { ${c} }`}let i=e.variables.map(a=>`?${a}`).join(" "),s=e.bindings.map(a=>`(${e.variables.map(u=>{let l=a[u];return l?this.generateValuesTerm(l):"UNDEF"}).join(" ")})`);return`${r}VALUES (${i}) {
|
|
308
308
|
${s.map(a=>`${r} ${a}`).join(`
|
|
309
309
|
`)}
|
|
310
|
-
${r}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(r=>this.generateExpression(r)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),r=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${r})`:`${t} IN (${r})`}default:throw new co(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let r of e.triples)this.collectVariablesFromTriple(r,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let r of e.variables)t.add(r);break;case"project":for(let r of e.variables)t.add(r);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let r of e.variables)t.add(r);for(let r of e.aggregates)t.add(r.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let r of e.operands)this.collectVariablesFromExpression(r,t);break;case"function":case"functionCall":for(let r of e.args)this.collectVariablesFromExpression(r,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let r of e.list)this.collectVariablesFromExpression(r,t);break}}};uo.SPARQLGenerator=Jy});var Z_=v(cn=>{"use strict";var y4=cn&&cn.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),v4=cn&&cn.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),S4=cn&&cn.__importStar||(function(){var n=o(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&y4(t,e,r[i]);return v4(t,e),t}})();Object.defineProperty(cn,"__esModule",{value:!0});cn.QueryExecutor=cn.QueryExecutorError=void 0;var _4=Dy(),b4=jf(),w4=ky(),E4=jy(),T4=B_(),A4=G_(),x4=z_(),C4=By(),I4=Y_(),O4=X_(),P4=J_(),D4=Qe(),lo=class extends Error{static{o(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};cn.QueryExecutorError=lo;var Zy=class{static{o(this,"QueryExecutor")}constructor(e,t={}){this.tripleStore=e,this.bgpExecutor=new _4.BGPExecutor(e),this.filterExecutor=new b4.FilterExecutor,this.optionalExecutor=new w4.OptionalExecutor,this.unionExecutor=new E4.UnionExecutor,this.minusExecutor=new T4.MinusExecutor,this.valuesExecutor=new A4.ValuesExecutor,this.aggregateExecutor=new x4.AggregateExecutor,this.constructExecutor=new C4.ConstructExecutor,this.serviceExecutor=new I4.ServiceExecutor(t.serviceConfig),this.graphExecutor=new O4.GraphExecutor(e),this.sparqlGenerator=new P4.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(r,i)=>this.evaluateExistsPattern(r,i)),this.filterExecutor.setTripleStore(e)}async evaluateExistsPattern(e,t){for await(let r of this.execute(e))if(t.merge(r)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new lo(`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 r of this.execute(e.left))t.push(r);for(let r of t)for await(let i of this.execute(e.right)){let s=r.merge(i);s!==null&&(yield s)}}async*executeLeftJoin(e){let t=[];for await(let a of this.execute(e.left))t.push(a);let r=[];for await(let a of this.execute(e.right))r.push(a);async function*i(){for(let a of t)yield a}o(i,"leftGen");async function*s(){for(let a of r)yield a}o(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let a of this.execute(e.left))t.push(a);let r=[];for await(let a of this.execute(e.right))r.push(a);async function*i(){for(let a of t)yield a}o(i,"leftGen");async function*s(){for(let a of r)yield a}o(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let a of this.execute(e.left))t.push(a);let r=[];for await(let a of this.execute(e.right))r.push(a);async function*i(){for(let a of t)yield a}o(i,"leftGen");async function*s(){for(let a of r)yield a}o(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){for await(let t of this.execute(e.input))yield t}async*executeOrderBy(e){let t=[];for await(let r of this.execute(e.input))t.push(r);t.sort((r,i)=>{for(let s of e.comparators){let a=this.getExpressionValue(s.expression,r),c=this.getExpressionValue(s.expression,i),u=0;if(a===void 0&&c===void 0?u=0:a===void 0?u=1:c===void 0?u=-1:typeof a=="number"&&typeof c=="number"?u=a-c:u=String(a).localeCompare(String(c)),s.descending&&(u=-u),u!==0)return u}return 0});for(let r of t)yield r}async*executeSlice(e){let t=0,r=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=r){if(i!==void 0&&t-r>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeReduced(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let r=this.aggregateExecutor.execute(e,t);for(let i of r)yield i}async*executeExtend(e){for await(let t of this.execute(e.input)){let r=t.clone(),i=this.evaluateExtendExpression(e.expression,t);i!==void 0&&r.set(e.variable,i),yield r}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let r of this.execute(e.left))t.push(r);for(let r of t){let i=this.substituteVariables(e.right,r);for await(let s of this.execute(i)){let a=r.merge(s);a!==null&&(yield a)}}}substituteVariables(e,t){let r=JSON.parse(JSON.stringify(e));return this.substituteInOperation(r,t)}substituteInOperation(e,t){return!e||typeof e!="object"?e:e.type==="bgp"&&e.triples?(e.triples=e.triples.map(r=>this.substituteInTriple(r,t)),e):(e.input&&(e.input=this.substituteInOperation(e.input,t)),e.left&&(e.left=this.substituteInOperation(e.left,t)),e.right&&(e.right=this.substituteInOperation(e.right,t)),e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.query&&(e.query=this.substituteInOperation(e.query,t)),e.where&&(e.where=this.substituteInOperation(e.where,t)),e)}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let r=t.get(e.value);if(r){if(r instanceof D4.IRI||r.termType==="NamedNode")return{type:"iri",value:r.value};if(r.termType==="Literal"||typeof r.value=="string"){let i=r;return{type:"literal",value:i.value,datatype:i.datatype?.value||i._datatype?.value,language:i.language||i._language}}}}return e}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(r,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{r.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(r,i):yield*this.execute(r)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:r}=await Promise.resolve().then(()=>S4(Ni()));yield new r;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let r=t.get(e.name);return r?r.value??r.id??String(r):void 0}return e.value}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 lo("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 lo("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};cn.QueryExecutor=Zy});var tb=v(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.UpdateExecutor=ho.UpdateExecutorError=void 0;var R4=xi(),fo=Qe(),e0=lt(),eb=Ot(),ar=class extends Error{static{o(this,"UpdateExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="UpdateExecutorError"}};ho.UpdateExecutorError=ar;var t0=class{static{o(this,"UpdateExecutor")}constructor(e){this.tripleStore=e}async execute(e){if(e.type!=="update")throw new ar("Expected UPDATE request");let t=[];for(let r of e.updates){let i=await this.executeOperation(r);t.push(i)}return t}async executeOperation(e){if("updateType"in e)switch(e.updateType){case"insert":return this.executeInsertData(e);case"delete":return this.executeDeleteData(e);case"insertdelete":throw new ar("INSERT/DELETE with WHERE clause not yet implemented");case"deletewhere":throw new ar("DELETE WHERE not yet implemented");default:throw new ar(`Unknown update type: ${e.updateType}`)}if("type"in e)switch(e.type){case"clear":case"drop":case"load":case"create":case"copy":case"move":case"add":throw new ar(`${e.type.toUpperCase()} operation not yet implemented`);default:throw new ar(`Unknown operation type: ${e.type}`)}throw new ar("Unknown update operation structure")}async executeInsertData(e){if(e.updateType!=="insert")throw new ar("Expected INSERT DATA operation");let t=e,r=0;for(let i of t.insert)if(i.type==="bgp"){let s=this.resolveGraphName(t.graph);r+=await this.insertTriples(i.triples,s)}else if(i.type==="graph"){let s=i,a=this.parseGraphName(s.name);r+=await this.insertTriples(s.triples,a)}return{type:"insert",inserted:r,success:!0}}async executeDeleteData(e){if(e.updateType!=="delete")throw new ar("Expected DELETE DATA operation");let t=e,r=0;for(let i of t.delete)if(i.type==="bgp"){let s=this.resolveGraphName(t.graph);r+=await this.deleteTriples(i.triples,s)}else if(i.type==="graph"){let s=i,a=this.parseGraphName(s.name);r+=await this.deleteTriples(s.triples,a)}return{type:"delete",deleted:r,success:!0}}async insertTriples(e,t){let r=0;for(let i of e){let s=this.convertTriple(i);t&&this.tripleStore.addToGraph?await this.tripleStore.addToGraph(s,t):await this.tripleStore.add(s),r++}return r}async deleteTriples(e,t){let r=0;for(let i of e){let s=this.convertTriple(i),a;t&&this.tripleStore.removeFromGraph?a=await this.tripleStore.removeFromGraph(s,t):a=await this.tripleStore.remove(s),a&&r++}return r}convertTriple(e){return new R4.Triple(this.convertSubject(e.subject),this.convertPredicate(e.predicate),this.convertObject(e.object))}convertSubject(e){if(e.termType==="NamedNode")return new fo.IRI(e.value);if(e.termType==="BlankNode")return new eb.BlankNode(e.value);throw new ar(`Invalid subject term type: ${e.termType}. Variables are not allowed in INSERT DATA.`)}convertPredicate(e){if("termType"in e&&e.termType==="NamedNode")return new fo.IRI(e.value);throw new ar("Invalid predicate term type. Only IRIs are allowed in INSERT DATA.")}convertObject(e){if(e.termType==="NamedNode")return new fo.IRI(e.value);if(e.termType==="BlankNode")return new eb.BlankNode(e.value);if(e.termType==="Literal"){let t=e;return t.language?new e0.Literal(t.value,void 0,t.language):t.datatype?new e0.Literal(t.value,new fo.IRI(t.datatype.value)):new e0.Literal(t.value)}throw new ar(`Invalid object term type: ${e.termType}. Variables are not allowed in INSERT DATA.`)}resolveGraphName(e){if(e&&!e.default&&e.name)return new fo.IRI(e.name.value)}parseGraphName(e){if(e.termType==="Variable")throw new ar("Variables are not allowed as graph names in INSERT DATA / DELETE DATA.");return new fo.IRI(e.value)}};ho.UpdateExecutor=t0});var nb=v(Qf=>{"use strict";Object.defineProperty(Qf,"__esModule",{value:!0});Qf.AggregateFunctions=void 0;var r0=lt(),rb=Qe(),n0=class{static{o(this,"AggregateFunctions")}static count(e,t){if(!t)return e.length;let r=0;for(let i of e)i.has(t)&&r++;return r}static countDistinct(e,t){let r=new Set;for(let i of e){let s=i.get(t);s&&r.add(s.toString())}return r.size}static sum(e,t){let r=0;for(let i of e){let s=i.get(t);if(s instanceof r0.Literal){let a=this.toNumber(s);isNaN(a)||(r+=a)}}return r}static avg(e,t){let r=this.sum(e,t),i=this.count(e,t);return i>0?r/i:0}static min(e,t){let r=null;for(let i of e){let s=i.get(t);if(!s)continue;let a=this.toComparable(s);(r===null||a<r)&&(r=a)}return r}static max(e,t){let r=null;for(let i of e){let s=i.get(t);if(!s)continue;let a=this.toComparable(s);(r===null||a>r)&&(r=a)}return r}static groupConcat(e,t,r=" "){let i=[];for(let s of e){let a=s.get(t);a&&(a instanceof r0.Literal||a instanceof rb.IRI?i.push(a.value):i.push(a.toString()))}return i.join(r)}static sample(e,t){for(let r of e){let i=r.get(t);if(i)return this.toComparable(i)}return null}static sampleDistinct(e,t){return this.sample(e,t)}static toNumber(e){let t=e.datatype?.value;return t?.includes("#integer")||t?.includes("#decimal")||t?.includes("#double"),parseFloat(e.value)}static toComparable(e){if(e instanceof r0.Literal){let t=this.toNumber(e);return isNaN(t)?e.value:t}return e instanceof rb.IRI?e.value:String(e)}};Qf.AggregateFunctions=n0});var ib=v(Yf=>{"use strict";Object.defineProperty(Yf,"__esModule",{value:!0});Yf.QueryPlanCache=void 0;var F4=hf(),i0=class{static{o(this,"QueryPlanCache")}constructor(e=100){this.hits=0,this.misses=0,this.cache=new F4.LRUCache(e)}get(e){let t=this.normalizeQuery(e),r=this.cache.get(t);return r!==void 0?this.hits++:this.misses++,r}set(e,t){let r=this.normalizeQuery(e);this.cache.set(r,t)}has(e){let t=this.normalizeQuery(e);return this.cache.get(t)!==void 0}clear(){this.cache.clear()}getStats(){let e=this.hits+this.misses;return{hits:this.hits,misses:this.misses,hitRate:e>0?this.hits/e:0,size:this.cache.size()}}resetStats(){this.hits=0,this.misses=0}normalizeQuery(e){return e.replace(/\s+/g," ").trim()}};Yf.QueryPlanCache=i0});var sb=v(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.SPARQLResultCache=void 0;kc.createSPARQLResultCache=k4;var N4=hf(),L4={maxSize:500,ttlMs:300*1e3,enableFileInvalidation:!0,maxResultSizeBytes:10*1024*1024},Kf=class{static{o(this,"SPARQLResultCache")}constructor(e={}){this.fileToQueries=new Map,this.stats={hits:0,misses:0,evictions:0,ttlInvalidations:0,fileInvalidations:0,totalTimeSavedMs:0},this.avgQueryTimeMs=100,this.options={...L4,...e},this.cache=new N4.LRUCache(this.options.maxSize)}normalizeQuery(e){return e.replace(/\s+/g," ").trim()}hashResult(e){return this.isTripleArray(e)?`T:${e.length}`:`S:${e.length}`}isTripleArray(e){return e.length>0&&"subject"in e[0]}estimateResultSize(e){return this.isTripleArray(e)?e.length*300:e.length*200}get(e){let t=this.normalizeQuery(e),r=this.cache.get(t);if(r===void 0){this.stats.misses++;return}if(Date.now()-r.timestamp>this.options.ttlMs){this.cache.set(t,void 0),this.stats.ttlInvalidations++,this.stats.misses++;return}return this.stats.hits++,this.stats.totalTimeSavedMs+=this.avgQueryTimeMs,r.result}set(e,t,r,i){if(this.estimateResultSize(t)>this.options.maxResultSizeBytes)return;i!==void 0&&(this.avgQueryTimeMs=(this.avgQueryTimeMs+i)/2);let a=this.normalizeQuery(e),c=r??new Set,u={result:t,timestamp:Date.now(),affectedFiles:c,resultHash:this.hashResult(t)};if(this.cache.size()>=this.options.maxSize&&this.stats.evictions++,this.cache.set(a,u),this.options.enableFileInvalidation)for(let f of c){let h=this.fileToQueries.get(f);h||(h=new Set,this.fileToQueries.set(f,h)),h.add(a)}}has(e){let t=this.normalizeQuery(e),r=this.cache.get(t);return r===void 0?!1:Date.now()-r.timestamp<=this.options.ttlMs}invalidateByFile(e){if(!this.options.enableFileInvalidation)return 0;let t=this.fileToQueries.get(e);if(!t)return 0;let r=0;for(let i of t)this.cache.set(i,void 0),r++,this.stats.fileInvalidations++;return this.fileToQueries.delete(e),r}clear(){this.cache.clear(),this.fileToQueries.clear()}getStats(){let e=this.stats.hits+this.stats.misses,t=e>0?this.stats.hits/e:0;return{hits:this.stats.hits,misses:this.stats.misses,hitRate:t,size:this.cache.size(),maxSize:this.options.maxSize,evictions:this.stats.evictions,ttlInvalidations:this.stats.ttlInvalidations,fileInvalidations:this.stats.fileInvalidations,avgTimeSavedMs:this.stats.hits>0?this.stats.totalTimeSavedMs/this.stats.hits:0}}resetStats(){this.stats={hits:0,misses:0,evictions:0,ttlInvalidations:0,fileInvalidations:0,totalTimeSavedMs:0}}size(){return this.cache.size()}pruneExpired(){return 0}};kc.SPARQLResultCache=Kf;function k4(n){return new Kf(n)}o(k4,"createSPARQLResultCache")});var ab=v(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.IncrementalIndexer=void 0;Mc.createIncrementalIndexer=j4;var M4={throttleMs:500,maxBatchSize:100,useContentHashing:!1},Xf=class{static{o(this,"IncrementalIndexer")}constructor(e={}){this.fileMetadata=new Map,this.pendingChanges=[],this.throttleTimer=null,this.invalidateCallbacks=[],this.lastIndexTime=0,this.stats={totalChanges:0,invalidations:0,noOpChanges:0,indexDurations:[]},this.options={...M4,...e}}recordChange(e){this.pendingChanges.push(e),this.stats.totalChanges++,this.throttleTimer===null&&(this.throttleTimer=setTimeout(()=>{this.processPendingChanges(),this.throttleTimer=null},this.options.throttleMs))}processPendingChanges(){if(this.pendingChanges.length===0)return;let e=performance.now(),t=new Map;for(let a of this.pendingChanges)t.set(a.path,a);let r=Array.from(t.values()),i=[];for(let a of r)switch(a.type){case"deleted":this.fileMetadata.delete(a.path),i.push(a);break;case"renamed":a.oldPath&&this.fileMetadata.delete(a.oldPath),i.push(a);break;case"created":case"modified":i.push(a);break}if(i.length>0){this.stats.invalidations+=i.length;for(let a of this.invalidateCallbacks)try{a(i)}catch(c){console.error("IncrementalIndexer: Error in invalidation callback:",c)}}let s=performance.now()-e;this.stats.indexDurations.push(s),this.stats.indexDurations.length>100&&this.stats.indexDurations.shift(),this.lastIndexTime=Date.now(),this.pendingChanges=[]}flush(){this.throttleTimer!==null&&(clearTimeout(this.throttleTimer),this.throttleTimer=null),this.processPendingChanges()}updateMetadata(e,t,r,i){this.fileMetadata.set(e,{mtime:t,size:r,contentHash:i})}hasChanged(e,t,r){let i=this.fileMetadata.get(e);return i===void 0||i.mtime!==t||r!==void 0&&i.size!==r}getChangedFiles(e){let t=[];for(let[r,i]of this.fileMetadata.entries())i.mtime>e&&t.push(r);return t}onInvalidate(e){return this.invalidateCallbacks.push(e),()=>{let t=this.invalidateCallbacks.indexOf(e);t!==-1&&this.invalidateCallbacks.splice(t,1)}}getStats(){let e=this.stats.indexDurations,t=e.length>0?e.reduce((i,s)=>i+s,0)/e.length:0,r=e.length>0?e[e.length-1]:0;return{trackedFiles:this.fileMetadata.size,totalChanges:this.stats.totalChanges,invalidations:this.stats.invalidations,noOpChanges:this.stats.noOpChanges,lastIndexDurationMs:r,avgIndexDurationMs:t,lastIndexTime:this.lastIndexTime}}resetStats(){this.stats={totalChanges:0,invalidations:0,noOpChanges:0,indexDurations:[]}}clear(){this.fileMetadata.clear(),this.pendingChanges=[],this.throttleTimer!==null&&(clearTimeout(this.throttleTimer),this.throttleTimer=null)}size(){return this.fileMetadata.size}isTracked(e){return this.fileMetadata.has(e)}getMetadata(e){return this.fileMetadata.get(e)}dispose(){this.throttleTimer!==null&&(clearTimeout(this.throttleTimer),this.throttleTimer=null),this.invalidateCallbacks=[],this.pendingChanges=[],this.fileMetadata.clear()}};Mc.IncrementalIndexer=Xf;function j4(n){return new Xf(n)}o(j4,"createIncrementalIndexer")});var ob=v(th=>{"use strict";Object.defineProperty(th,"__esModule",{value:!0});th.ResultSerializer=void 0;var Jf=lt(),Zf=Qe(),eh=Ot(),s0=class{static{o(this,"ResultSerializer")}serialize(e,t,r={}){switch(t){case"json":return this.serializeJSON(e,r);case"xml":return this.serializeXML(e,r);case"csv":return this.serializeCSV(e,r);case"turtle":return this.serializeTurtle(e,r);default:throw new Error(`Unsupported result format: ${t}`)}}serializeJSON(e,t={}){let r=this.toJSONResultSet(e,t),i=t.pretty?t.indent??2:void 0;return JSON.stringify(r,null,i)}toJSONResultSet(e,t={}){let r=new Set;for(let a of e)for(let c of a.variables())r.add(c);let i=t.variables??Array.from(r).sort(),s=e.map(a=>{let c={};for(let u of i){let l=a.get(u);l!==void 0&&(c[u]=this.termToJSONBinding(l))}return c});return{head:{vars:i},results:{bindings:s}}}termToJSONBinding(e){return e instanceof Zf.IRI?{type:"uri",value:e.value}:e instanceof eh.BlankNode?{type:"bnode",value:e.id}:e instanceof Jf.Literal?this.literalToJSONBinding(e):{type:"literal",value:String(e)}}literalToJSONBinding(e){let t={type:"literal",value:e.value};return e.datatype?t.datatype=e.datatype.value:e.language&&(t["xml:lang"]=e.language,e.hasDirection()&&e.direction&&(t.direction=e.direction)),t}serializeXML(e,t={}){let r=new Set;for(let a of e)for(let c of a.variables())r.add(c);let i=t.variables??Array.from(r).sort(),s=['<?xml version="1.0"?>','<sparql xmlns="http://www.w3.org/2005/sparql-results#">'," <head>"];for(let a of i)s.push(` <variable name="${this.escapeXML(a)}"/>`);s.push(" </head>"),s.push(" <results>");for(let a of e){s.push(" <result>");for(let c of i){let u=a.get(c);u!==void 0&&(s.push(` <binding name="${this.escapeXML(c)}">`),s.push(" "+this.termToXML(u)),s.push(" </binding>"))}s.push(" </result>")}return s.push(" </results>"),s.push("</sparql>"),s.join(`
|
|
310
|
+
${r}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(r=>this.generateExpression(r)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),r=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${r})`:`${t} IN (${r})`}default:throw new co(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let r of e.triples)this.collectVariablesFromTriple(r,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let r of e.variables)t.add(r);break;case"project":for(let r of e.variables)t.add(r);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let r of e.variables)t.add(r);for(let r of e.aggregates)t.add(r.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let r of e.operands)this.collectVariablesFromExpression(r,t);break;case"function":case"functionCall":for(let r of e.args)this.collectVariablesFromExpression(r,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let r of e.list)this.collectVariablesFromExpression(r,t);break}}};uo.SPARQLGenerator=Zy});var tb=v(cn=>{"use strict";var _4=cn&&cn.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),b4=cn&&cn.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),w4=cn&&cn.__importStar||(function(){var n=o(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&_4(t,e,r[i]);return b4(t,e),t}})();Object.defineProperty(cn,"__esModule",{value:!0});cn.QueryExecutor=cn.QueryExecutorError=void 0;var E4=Ry(),T4=jf(),A4=My(),x4=$y(),C4=G_(),I4=H_(),O4=Y_(),P4=qy(),D4=X_(),R4=Z_(),F4=eb(),N4=Qe(),lo=class extends Error{static{o(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};cn.QueryExecutorError=lo;var e0=class{static{o(this,"QueryExecutor")}constructor(e,t={}){this.tripleStore=e,this.bgpExecutor=new E4.BGPExecutor(e),this.filterExecutor=new T4.FilterExecutor,this.optionalExecutor=new A4.OptionalExecutor,this.unionExecutor=new x4.UnionExecutor,this.minusExecutor=new C4.MinusExecutor,this.valuesExecutor=new I4.ValuesExecutor,this.aggregateExecutor=new O4.AggregateExecutor,this.constructExecutor=new P4.ConstructExecutor,this.serviceExecutor=new D4.ServiceExecutor(t.serviceConfig),this.graphExecutor=new R4.GraphExecutor(e),this.sparqlGenerator=new F4.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(r,i)=>this.evaluateExistsPattern(r,i)),this.filterExecutor.setTripleStore(e)}async evaluateExistsPattern(e,t){for await(let r of this.execute(e))if(t.merge(r)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new lo(`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 r of this.execute(e.left))t.push(r);for(let r of t)for await(let i of this.execute(e.right)){let s=r.merge(i);s!==null&&(yield s)}}async*executeLeftJoin(e){let t=[];for await(let a of this.execute(e.left))t.push(a);let r=[];for await(let a of this.execute(e.right))r.push(a);async function*i(){for(let a of t)yield a}o(i,"leftGen");async function*s(){for(let a of r)yield a}o(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let a of this.execute(e.left))t.push(a);let r=[];for await(let a of this.execute(e.right))r.push(a);async function*i(){for(let a of t)yield a}o(i,"leftGen");async function*s(){for(let a of r)yield a}o(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let a of this.execute(e.left))t.push(a);let r=[];for await(let a of this.execute(e.right))r.push(a);async function*i(){for(let a of t)yield a}o(i,"leftGen");async function*s(){for(let a of r)yield a}o(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){for await(let t of this.execute(e.input))yield t}async*executeOrderBy(e){let t=[];for await(let r of this.execute(e.input))t.push(r);t.sort((r,i)=>{for(let s of e.comparators){let a=this.getExpressionValue(s.expression,r),c=this.getExpressionValue(s.expression,i),u=0;if(a===void 0&&c===void 0?u=0:a===void 0?u=1:c===void 0?u=-1:typeof a=="number"&&typeof c=="number"?u=a-c:u=String(a).localeCompare(String(c)),s.descending&&(u=-u),u!==0)return u}return 0});for(let r of t)yield r}async*executeSlice(e){let t=0,r=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=r){if(i!==void 0&&t-r>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeReduced(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let r=this.aggregateExecutor.execute(e,t);for(let i of r)yield i}async*executeExtend(e){for await(let t of this.execute(e.input)){let r=t.clone(),i=this.evaluateExtendExpression(e.expression,t);i!==void 0&&r.set(e.variable,i),yield r}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let r of this.execute(e.left))t.push(r);for(let r of t){let i=this.substituteVariables(e.right,r);for await(let s of this.execute(i)){let a=r.merge(s);a!==null&&(yield a)}}}substituteVariables(e,t){let r=JSON.parse(JSON.stringify(e));return this.substituteInOperation(r,t)}substituteInOperation(e,t){return!e||typeof e!="object"?e:e.type==="bgp"&&e.triples?(e.triples=e.triples.map(r=>this.substituteInTriple(r,t)),e):(e.input&&(e.input=this.substituteInOperation(e.input,t)),e.left&&(e.left=this.substituteInOperation(e.left,t)),e.right&&(e.right=this.substituteInOperation(e.right,t)),e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.query&&(e.query=this.substituteInOperation(e.query,t)),e.where&&(e.where=this.substituteInOperation(e.where,t)),e)}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let r=t.get(e.value);if(r){if(r instanceof N4.IRI||r.termType==="NamedNode")return{type:"iri",value:r.value};if(r.termType==="Literal"||typeof r.value=="string"){let i=r;return{type:"literal",value:i.value,datatype:i.datatype?.value||i._datatype?.value,language:i.language||i._language}}}}return e}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(r,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{r.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(r,i):yield*this.execute(r)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:r}=await Promise.resolve().then(()=>w4(Ni()));yield new r;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let r=t.get(e.name);return r?r.value??r.id??String(r):void 0}return e.value}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 lo("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 lo("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};cn.QueryExecutor=e0});var nb=v(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.UpdateExecutor=ho.UpdateExecutorError=void 0;var L4=xi(),fo=Qe(),t0=lt(),rb=Ot(),ar=class extends Error{static{o(this,"UpdateExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="UpdateExecutorError"}};ho.UpdateExecutorError=ar;var r0=class{static{o(this,"UpdateExecutor")}constructor(e){this.tripleStore=e}async execute(e){if(e.type!=="update")throw new ar("Expected UPDATE request");let t=[];for(let r of e.updates){let i=await this.executeOperation(r);t.push(i)}return t}async executeOperation(e){if("updateType"in e)switch(e.updateType){case"insert":return this.executeInsertData(e);case"delete":return this.executeDeleteData(e);case"insertdelete":throw new ar("INSERT/DELETE with WHERE clause not yet implemented");case"deletewhere":throw new ar("DELETE WHERE not yet implemented");default:throw new ar(`Unknown update type: ${e.updateType}`)}if("type"in e)switch(e.type){case"clear":case"drop":case"load":case"create":case"copy":case"move":case"add":throw new ar(`${e.type.toUpperCase()} operation not yet implemented`);default:throw new ar(`Unknown operation type: ${e.type}`)}throw new ar("Unknown update operation structure")}async executeInsertData(e){if(e.updateType!=="insert")throw new ar("Expected INSERT DATA operation");let t=e,r=0;for(let i of t.insert)if(i.type==="bgp"){let s=this.resolveGraphName(t.graph);r+=await this.insertTriples(i.triples,s)}else if(i.type==="graph"){let s=i,a=this.parseGraphName(s.name);r+=await this.insertTriples(s.triples,a)}return{type:"insert",inserted:r,success:!0}}async executeDeleteData(e){if(e.updateType!=="delete")throw new ar("Expected DELETE DATA operation");let t=e,r=0;for(let i of t.delete)if(i.type==="bgp"){let s=this.resolveGraphName(t.graph);r+=await this.deleteTriples(i.triples,s)}else if(i.type==="graph"){let s=i,a=this.parseGraphName(s.name);r+=await this.deleteTriples(s.triples,a)}return{type:"delete",deleted:r,success:!0}}async insertTriples(e,t){let r=0;for(let i of e){let s=this.convertTriple(i);t&&this.tripleStore.addToGraph?await this.tripleStore.addToGraph(s,t):await this.tripleStore.add(s),r++}return r}async deleteTriples(e,t){let r=0;for(let i of e){let s=this.convertTriple(i),a;t&&this.tripleStore.removeFromGraph?a=await this.tripleStore.removeFromGraph(s,t):a=await this.tripleStore.remove(s),a&&r++}return r}convertTriple(e){return new L4.Triple(this.convertSubject(e.subject),this.convertPredicate(e.predicate),this.convertObject(e.object))}convertSubject(e){if(e.termType==="NamedNode")return new fo.IRI(e.value);if(e.termType==="BlankNode")return new rb.BlankNode(e.value);throw new ar(`Invalid subject term type: ${e.termType}. Variables are not allowed in INSERT DATA.`)}convertPredicate(e){if("termType"in e&&e.termType==="NamedNode")return new fo.IRI(e.value);throw new ar("Invalid predicate term type. Only IRIs are allowed in INSERT DATA.")}convertObject(e){if(e.termType==="NamedNode")return new fo.IRI(e.value);if(e.termType==="BlankNode")return new rb.BlankNode(e.value);if(e.termType==="Literal"){let t=e;return t.language?new t0.Literal(t.value,void 0,t.language):t.datatype?new t0.Literal(t.value,new fo.IRI(t.datatype.value)):new t0.Literal(t.value)}throw new ar(`Invalid object term type: ${e.termType}. Variables are not allowed in INSERT DATA.`)}resolveGraphName(e){if(e&&!e.default&&e.name)return new fo.IRI(e.name.value)}parseGraphName(e){if(e.termType==="Variable")throw new ar("Variables are not allowed as graph names in INSERT DATA / DELETE DATA.");return new fo.IRI(e.value)}};ho.UpdateExecutor=r0});var sb=v(Qf=>{"use strict";Object.defineProperty(Qf,"__esModule",{value:!0});Qf.AggregateFunctions=void 0;var n0=lt(),ib=Qe(),i0=class{static{o(this,"AggregateFunctions")}static count(e,t){if(!t)return e.length;let r=0;for(let i of e)i.has(t)&&r++;return r}static countDistinct(e,t){let r=new Set;for(let i of e){let s=i.get(t);s&&r.add(s.toString())}return r.size}static sum(e,t){let r=0;for(let i of e){let s=i.get(t);if(s instanceof n0.Literal){let a=this.toNumber(s);isNaN(a)||(r+=a)}}return r}static avg(e,t){let r=this.sum(e,t),i=this.count(e,t);return i>0?r/i:0}static min(e,t){let r=null;for(let i of e){let s=i.get(t);if(!s)continue;let a=this.toComparable(s);(r===null||a<r)&&(r=a)}return r}static max(e,t){let r=null;for(let i of e){let s=i.get(t);if(!s)continue;let a=this.toComparable(s);(r===null||a>r)&&(r=a)}return r}static groupConcat(e,t,r=" "){let i=[];for(let s of e){let a=s.get(t);a&&(a instanceof n0.Literal||a instanceof ib.IRI?i.push(a.value):i.push(a.toString()))}return i.join(r)}static sample(e,t){for(let r of e){let i=r.get(t);if(i)return this.toComparable(i)}return null}static sampleDistinct(e,t){return this.sample(e,t)}static toNumber(e){let t=e.datatype?.value;return t?.includes("#integer")||t?.includes("#decimal")||t?.includes("#double"),parseFloat(e.value)}static toComparable(e){if(e instanceof n0.Literal){let t=this.toNumber(e);return isNaN(t)?e.value:t}return e instanceof ib.IRI?e.value:String(e)}};Qf.AggregateFunctions=i0});var ab=v(Yf=>{"use strict";Object.defineProperty(Yf,"__esModule",{value:!0});Yf.QueryPlanCache=void 0;var k4=hf(),s0=class{static{o(this,"QueryPlanCache")}constructor(e=100){this.hits=0,this.misses=0,this.cache=new k4.LRUCache(e)}get(e){let t=this.normalizeQuery(e),r=this.cache.get(t);return r!==void 0?this.hits++:this.misses++,r}set(e,t){let r=this.normalizeQuery(e);this.cache.set(r,t)}has(e){let t=this.normalizeQuery(e);return this.cache.get(t)!==void 0}clear(){this.cache.clear()}getStats(){let e=this.hits+this.misses;return{hits:this.hits,misses:this.misses,hitRate:e>0?this.hits/e:0,size:this.cache.size()}}resetStats(){this.hits=0,this.misses=0}normalizeQuery(e){return e.replace(/\s+/g," ").trim()}};Yf.QueryPlanCache=s0});var ob=v(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.SPARQLResultCache=void 0;kc.createSPARQLResultCache=$4;var M4=hf(),j4={maxSize:500,ttlMs:300*1e3,enableFileInvalidation:!0,maxResultSizeBytes:10*1024*1024},Kf=class{static{o(this,"SPARQLResultCache")}constructor(e={}){this.fileToQueries=new Map,this.stats={hits:0,misses:0,evictions:0,ttlInvalidations:0,fileInvalidations:0,totalTimeSavedMs:0},this.avgQueryTimeMs=100,this.options={...j4,...e},this.cache=new M4.LRUCache(this.options.maxSize)}normalizeQuery(e){return e.replace(/\s+/g," ").trim()}hashResult(e){return this.isTripleArray(e)?`T:${e.length}`:`S:${e.length}`}isTripleArray(e){return e.length>0&&"subject"in e[0]}estimateResultSize(e){return this.isTripleArray(e)?e.length*300:e.length*200}get(e){let t=this.normalizeQuery(e),r=this.cache.get(t);if(r===void 0){this.stats.misses++;return}if(Date.now()-r.timestamp>this.options.ttlMs){this.cache.set(t,void 0),this.stats.ttlInvalidations++,this.stats.misses++;return}return this.stats.hits++,this.stats.totalTimeSavedMs+=this.avgQueryTimeMs,r.result}set(e,t,r,i){if(this.estimateResultSize(t)>this.options.maxResultSizeBytes)return;i!==void 0&&(this.avgQueryTimeMs=(this.avgQueryTimeMs+i)/2);let a=this.normalizeQuery(e),c=r??new Set,u={result:t,timestamp:Date.now(),affectedFiles:c,resultHash:this.hashResult(t)};if(this.cache.size()>=this.options.maxSize&&this.stats.evictions++,this.cache.set(a,u),this.options.enableFileInvalidation)for(let f of c){let h=this.fileToQueries.get(f);h||(h=new Set,this.fileToQueries.set(f,h)),h.add(a)}}has(e){let t=this.normalizeQuery(e),r=this.cache.get(t);return r===void 0?!1:Date.now()-r.timestamp<=this.options.ttlMs}invalidateByFile(e){if(!this.options.enableFileInvalidation)return 0;let t=this.fileToQueries.get(e);if(!t)return 0;let r=0;for(let i of t)this.cache.set(i,void 0),r++,this.stats.fileInvalidations++;return this.fileToQueries.delete(e),r}clear(){this.cache.clear(),this.fileToQueries.clear()}getStats(){let e=this.stats.hits+this.stats.misses,t=e>0?this.stats.hits/e:0;return{hits:this.stats.hits,misses:this.stats.misses,hitRate:t,size:this.cache.size(),maxSize:this.options.maxSize,evictions:this.stats.evictions,ttlInvalidations:this.stats.ttlInvalidations,fileInvalidations:this.stats.fileInvalidations,avgTimeSavedMs:this.stats.hits>0?this.stats.totalTimeSavedMs/this.stats.hits:0}}resetStats(){this.stats={hits:0,misses:0,evictions:0,ttlInvalidations:0,fileInvalidations:0,totalTimeSavedMs:0}}size(){return this.cache.size()}pruneExpired(){return 0}};kc.SPARQLResultCache=Kf;function $4(n){return new Kf(n)}o($4,"createSPARQLResultCache")});var cb=v(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.IncrementalIndexer=void 0;Mc.createIncrementalIndexer=U4;var V4={throttleMs:500,maxBatchSize:100,useContentHashing:!1},Xf=class{static{o(this,"IncrementalIndexer")}constructor(e={}){this.fileMetadata=new Map,this.pendingChanges=[],this.throttleTimer=null,this.invalidateCallbacks=[],this.lastIndexTime=0,this.stats={totalChanges:0,invalidations:0,noOpChanges:0,indexDurations:[]},this.options={...V4,...e}}recordChange(e){this.pendingChanges.push(e),this.stats.totalChanges++,this.throttleTimer===null&&(this.throttleTimer=setTimeout(()=>{this.processPendingChanges(),this.throttleTimer=null},this.options.throttleMs))}processPendingChanges(){if(this.pendingChanges.length===0)return;let e=performance.now(),t=new Map;for(let a of this.pendingChanges)t.set(a.path,a);let r=Array.from(t.values()),i=[];for(let a of r)switch(a.type){case"deleted":this.fileMetadata.delete(a.path),i.push(a);break;case"renamed":a.oldPath&&this.fileMetadata.delete(a.oldPath),i.push(a);break;case"created":case"modified":i.push(a);break}if(i.length>0){this.stats.invalidations+=i.length;for(let a of this.invalidateCallbacks)try{a(i)}catch(c){console.error("IncrementalIndexer: Error in invalidation callback:",c)}}let s=performance.now()-e;this.stats.indexDurations.push(s),this.stats.indexDurations.length>100&&this.stats.indexDurations.shift(),this.lastIndexTime=Date.now(),this.pendingChanges=[]}flush(){this.throttleTimer!==null&&(clearTimeout(this.throttleTimer),this.throttleTimer=null),this.processPendingChanges()}updateMetadata(e,t,r,i){this.fileMetadata.set(e,{mtime:t,size:r,contentHash:i})}hasChanged(e,t,r){let i=this.fileMetadata.get(e);return i===void 0||i.mtime!==t||r!==void 0&&i.size!==r}getChangedFiles(e){let t=[];for(let[r,i]of this.fileMetadata.entries())i.mtime>e&&t.push(r);return t}onInvalidate(e){return this.invalidateCallbacks.push(e),()=>{let t=this.invalidateCallbacks.indexOf(e);t!==-1&&this.invalidateCallbacks.splice(t,1)}}getStats(){let e=this.stats.indexDurations,t=e.length>0?e.reduce((i,s)=>i+s,0)/e.length:0,r=e.length>0?e[e.length-1]:0;return{trackedFiles:this.fileMetadata.size,totalChanges:this.stats.totalChanges,invalidations:this.stats.invalidations,noOpChanges:this.stats.noOpChanges,lastIndexDurationMs:r,avgIndexDurationMs:t,lastIndexTime:this.lastIndexTime}}resetStats(){this.stats={totalChanges:0,invalidations:0,noOpChanges:0,indexDurations:[]}}clear(){this.fileMetadata.clear(),this.pendingChanges=[],this.throttleTimer!==null&&(clearTimeout(this.throttleTimer),this.throttleTimer=null)}size(){return this.fileMetadata.size}isTracked(e){return this.fileMetadata.has(e)}getMetadata(e){return this.fileMetadata.get(e)}dispose(){this.throttleTimer!==null&&(clearTimeout(this.throttleTimer),this.throttleTimer=null),this.invalidateCallbacks=[],this.pendingChanges=[],this.fileMetadata.clear()}};Mc.IncrementalIndexer=Xf;function U4(n){return new Xf(n)}o(U4,"createIncrementalIndexer")});var ub=v(th=>{"use strict";Object.defineProperty(th,"__esModule",{value:!0});th.ResultSerializer=void 0;var Jf=lt(),Zf=Qe(),eh=Ot(),a0=class{static{o(this,"ResultSerializer")}serialize(e,t,r={}){switch(t){case"json":return this.serializeJSON(e,r);case"xml":return this.serializeXML(e,r);case"csv":return this.serializeCSV(e,r);case"turtle":return this.serializeTurtle(e,r);default:throw new Error(`Unsupported result format: ${t}`)}}serializeJSON(e,t={}){let r=this.toJSONResultSet(e,t),i=t.pretty?t.indent??2:void 0;return JSON.stringify(r,null,i)}toJSONResultSet(e,t={}){let r=new Set;for(let a of e)for(let c of a.variables())r.add(c);let i=t.variables??Array.from(r).sort(),s=e.map(a=>{let c={};for(let u of i){let l=a.get(u);l!==void 0&&(c[u]=this.termToJSONBinding(l))}return c});return{head:{vars:i},results:{bindings:s}}}termToJSONBinding(e){return e instanceof Zf.IRI?{type:"uri",value:e.value}:e instanceof eh.BlankNode?{type:"bnode",value:e.id}:e instanceof Jf.Literal?this.literalToJSONBinding(e):{type:"literal",value:String(e)}}literalToJSONBinding(e){let t={type:"literal",value:e.value};return e.datatype?t.datatype=e.datatype.value:e.language&&(t["xml:lang"]=e.language,e.hasDirection()&&e.direction&&(t.direction=e.direction)),t}serializeXML(e,t={}){let r=new Set;for(let a of e)for(let c of a.variables())r.add(c);let i=t.variables??Array.from(r).sort(),s=['<?xml version="1.0"?>','<sparql xmlns="http://www.w3.org/2005/sparql-results#">'," <head>"];for(let a of i)s.push(` <variable name="${this.escapeXML(a)}"/>`);s.push(" </head>"),s.push(" <results>");for(let a of e){s.push(" <result>");for(let c of i){let u=a.get(c);u!==void 0&&(s.push(` <binding name="${this.escapeXML(c)}">`),s.push(" "+this.termToXML(u)),s.push(" </binding>"))}s.push(" </result>")}return s.push(" </results>"),s.push("</sparql>"),s.join(`
|
|
311
311
|
`)}termToXML(e){return e instanceof Zf.IRI?`<uri>${this.escapeXML(e.value)}</uri>`:e instanceof eh.BlankNode?`<bnode>${this.escapeXML(e.id)}</bnode>`:e instanceof Jf.Literal?this.literalToXML(e):`<literal>${this.escapeXML(String(e))}</literal>`}literalToXML(e){let t=this.escapeXML(e.value);if(e.datatype)return`<literal datatype="${this.escapeXML(e.datatype.value)}">${t}</literal>`;if(e.language){let r=`xml:lang="${this.escapeXML(e.language)}"`;return e.hasDirection()&&e.direction&&(r+=` direction="${e.direction}"`),`<literal ${r}>${t}</literal>`}return`<literal>${t}</literal>`}serializeCSV(e,t={}){let r=new Set;for(let a of e)for(let c of a.variables())r.add(c);let i=t.variables??Array.from(r).sort(),s=[];s.push(i.map(a=>this.escapeCSV(a)).join(","));for(let a of e){let c=i.map(u=>{let l=a.get(u);return l===void 0?"":this.escapeCSV(this.termToCSV(l))});s.push(c.join(","))}return s.join(`
|
|
312
312
|
`)}termToCSV(e){return e instanceof Zf.IRI?e.value:e instanceof eh.BlankNode?`_:${e.id}`:e instanceof Jf.Literal?this.literalToCSV(e):String(e)}literalToCSV(e){if(e.datatype)return`${e.value}^^<${e.datatype.value}>`;if(e.language){let t=e.language;return e.hasDirection()&&e.direction&&(t+=`--${e.direction}`),`${e.value}@${t}`}return e.value}serializeTurtle(e,t={}){let r=new Set;for(let a of e)for(let c of a.variables())r.add(c);let i=t.variables??Array.from(r).sort(),s=[];s.push(`# SPARQL Results - ${e.length} solution(s)`),s.push(`# Variables: ${i.join(", ")}`),s.push("");for(let a=0;a<e.length;a++){let c=e[a];s.push(`# Solution ${a+1}`);for(let u of i){let l=c.get(u);l!==void 0&&s.push(`?${u} = ${this.termToTurtle(l)}`)}s.push("")}return s.join(`
|
|
313
313
|
`).trimEnd()}termToTurtle(e){return e instanceof Zf.IRI?`<${e.value}>`:e instanceof eh.BlankNode?`_:${e.id}`:e instanceof Jf.Literal?e.toString():`"${String(e)}"`}escapeXML(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}escapeCSV(e){return e.includes(",")||e.includes('"')||e.includes(`
|
|
314
|
-
`)?`"${e.replace(/"/g,'""')}"`:e}};th.ResultSerializer=s0});var cb=v(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.FileAlreadyExistsError=po.FileNotFoundError=void 0;var a0=class extends Error{static{o(this,"FileNotFoundError")}constructor(e){super(`File not found: ${e}`),this.name="FileNotFoundError"}};po.FileNotFoundError=a0;var o0=class extends Error{static{o(this,"FileAlreadyExistsError")}constructor(e){super(`File already exists: ${e}`),this.name="FileAlreadyExistsError"}};po.FileAlreadyExistsError=o0});var ub=v(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.container=void 0;as.registerCoreServices=lN;as.createChildContainer=fN;as.getContainer=hN;as.resetContainer=dN;Qu();var jc=Le();Object.defineProperty(as,"container",{enumerable:!0,get:o(function(){return jc.container},"get")});var ht=ct(),$4=Im(),V4=Bl(),U4=sg(),B4=ql(),q4=Xm(),G4=Pm(),W4=km(),H4=Nm(),z4=Ql(),Q4=Yl(),Y4=Hm(),K4=Qm(),X4=Zm(),J4=Gm(),Z4=og(),eN=fg(),tN=ug(),rN=Vm(),nN=Bm(),iN=ng(),sN=tg(),aN=Jg(),oN=jm(),cN=dg(),uN=gg();function lN(n){let e=n||jc.container;e.registerSingleton(ht.DI_TOKENS.TaskFrontmatterGenerator,V4.TaskFrontmatterGenerator),e.registerSingleton(ht.DI_TOKENS.DynamicFrontmatterGenerator,U4.DynamicFrontmatterGenerator),e.registerSingleton(ht.DI_TOKENS.AlgorithmExtractor,B4.AlgorithmExtractor),e.registerSingleton(ht.DI_TOKENS.EffortStatusWorkflow,z4.EffortStatusWorkflow),e.registerSingleton(ht.DI_TOKENS.StatusTimestampService,Q4.StatusTimestampService),e.registerSingleton(ht.DI_TOKENS.TaskStatusService,H4.TaskStatusService),e.registerSingleton(ht.DI_TOKENS.TaskCreationService,$4.TaskCreationService),e.registerSingleton(ht.DI_TOKENS.ProjectCreationService,G4.ProjectCreationService),e.registerSingleton(ht.DI_TOKENS.AreaCreationService,W4.AreaCreationService),e.registerSingleton(ht.DI_TOKENS.ClassCreationService,rN.ClassCreationService),e.registerSingleton(ht.DI_TOKENS.ConceptCreationService,nN.ConceptCreationService),e.registerSingleton(ht.DI_TOKENS.FleetingNoteCreationService,iN.FleetingNoteCreationService),e.registerSingleton(ht.DI_TOKENS.SupervisionCreationService,sN.SupervisionCreationService),e.registerSingleton(ht.DI_TOKENS.GenericAssetCreationService,uN.GenericAssetCreationService),e.registerSingleton(ht.DI_TOKENS.PropertyCleanupService,q4.PropertyCleanupService),e.registerSingleton(ht.DI_TOKENS.FolderRepairService,Y4.FolderRepairService),e.registerSingleton(ht.DI_TOKENS.LabelToAliasService,K4.LabelToAliasService),e.registerSingleton(ht.DI_TOKENS.RenameToUidService,X4.RenameToUidService),e.registerSingleton(ht.DI_TOKENS.PlanningService,Z4.PlanningService),e.registerSingleton(ht.DI_TOKENS.EffortVotingService,J4.EffortVotingService),e.registerSingleton(ht.DI_TOKENS.SessionEventService,eN.SessionEventService),e.registerSingleton(ht.DI_TOKENS.AssetConversionService,tN.AssetConversionService),e.registerSingleton(ht.DI_TOKENS.NoteToRDFConverter,aN.NoteToRDFConverter),e.registerSingleton(ht.DI_TOKENS.AreaHierarchyBuilder,oN.AreaHierarchyBuilder),e.registerSingleton(ht.DI_TOKENS.URIConstructionService,cN.URIConstructionService)}o(lN,"registerCoreServices");function fN(){return jc.container.createChildContainer()}o(fN,"createChildContainer");function hN(){return jc.container}o(hN,"getContainer");function dN(){jc.container.reset()}o(dN,"resetContainer")});var c0=v(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.DEFAULT_COLORS=mo.NODE_FLAGS=void 0;mo.NODE_FLAGS={PINNED:1,VISIBLE:2,SELECTED:4,HOVERED:8,ARCHIVED:16,SEARCH_MATCH:32,HIGHLIGHTED:64};mo.DEFAULT_COLORS={NODE:1251006975,NODE_SELECTED:4290840575,NODE_HOVERED:1723558655,EDGE:2576980479,EDGE_SELECTED:4288151807,EDGE_HIERARCHY:2619846911}});var l0=v(rh=>{"use strict";Object.defineProperty(rh,"__esModule",{value:!0});rh.StringTable=void 0;var u0=class n{static{o(this,"StringTable")}constructor(e){if(this.stringToIndex=new Map,this.strings=[],this.memoryBytes=0,e)for(let t of e)this.intern(t)}intern(e){let t=this.stringToIndex.get(e);if(t!==void 0)return t;let r=this.strings.length;return this.strings.push(e),this.stringToIndex.set(e,r),this.memoryBytes+=e.length*2+50,r}getIndex(e){return this.stringToIndex.get(e)??-1}getString(e){if(e<0||e>=this.strings.length)throw new RangeError(`StringTable index out of bounds: ${e}`);return this.strings[e]}has(e){return this.stringToIndex.has(e)}hasIndex(e){return e>=0&&e<this.strings.length}get size(){return this.strings.length}getMemoryBytes(){return this.memoryBytes}*entries(){for(let e=0;e<this.strings.length;e++)yield[e,this.strings[e]]}*values(){for(let e of this.strings)yield e}toArray(){return[...this.strings]}clear(){this.stringToIndex.clear(),this.strings=[],this.memoryBytes=0}static fromJSON(e){return new n(e)}toJSON(){return this.strings}internAll(e){return e.map(t=>this.intern(t))}getStrings(e){return e.map(t=>this.getString(t))}search(e){let t=typeof e=="string"?new RegExp(e):e,r=[];for(let i=0;i<this.strings.length;i++)t.test(this.strings[i])&&r.push([i,this.strings[i]]);return r}getStats(){let e=this.strings.reduce((t,r)=>t+r.length,0);return{count:this.strings.length,memoryBytes:this.memoryBytes,avgStringLength:this.strings.length>0?e/this.strings.length:0}}};rh.StringTable=u0});var lb=v(ih=>{"use strict";Object.defineProperty(ih,"__esModule",{value:!0});ih.CompactGraphStore=void 0;var nh=l0(),kr=c0(),pN={initialNodeCapacity:1e4,initialEdgeCapacity:5e4,growthFactor:2,maxCapacity:1e6};function f0(n,e){if(n===void 0)return e;if(typeof n=="number")return n;if(n.startsWith("#")){let t=n.slice(1);if(t.length===6)return parseInt(t,16)<<8|255;if(t.length===8)return parseInt(t,16)}return e}o(f0,"parseColor");var h0=class{static{o(this,"CompactGraphStore")}constructor(e){this.nodeCount=0,this.edgeCount=0,this.nodeIdToIndex=new Map,this.indexToNodeId=[],this.edgeIdToIndex=new Map,this.config={...pN,...e},this.nodeCapacity=this.config.initialNodeCapacity,this.edgeCapacity=this.config.initialEdgeCapacity,this.nodes=this.allocateNodeArrays(this.nodeCapacity),this.edges=this.allocateEdgeArrays(this.edgeCapacity),this.uriTable=new nh.StringTable,this.labelTable=new nh.StringTable,this.typeTable=new nh.StringTable,this.predicateTable=new nh.StringTable}allocateNodeArrays(e){return{positions:new Float32Array(e*2),radii:new Float32Array(e),colors:new Uint32Array(e),types:new Uint16Array(e),flags:new Uint8Array(e)}}allocateEdgeArrays(e){return{sourceIndices:new Uint32Array(e),targetIndices:new Uint32Array(e),predicateIndices:new Uint16Array(e),widths:new Float32Array(e),colors:new Uint32Array(e)}}resizeNodeArrays(e){if(e<=this.nodeCapacity)return;if(e>this.config.maxCapacity)throw new Error(`Cannot resize beyond max capacity (${this.config.maxCapacity})`);let t=this.allocateNodeArrays(e);t.positions.set(this.nodes.positions.subarray(0,this.nodeCount*2)),t.radii.set(this.nodes.radii.subarray(0,this.nodeCount)),t.colors.set(this.nodes.colors.subarray(0,this.nodeCount)),t.types.set(this.nodes.types.subarray(0,this.nodeCount)),t.flags.set(this.nodes.flags.subarray(0,this.nodeCount)),this.nodes=t,this.nodeCapacity=e}resizeEdgeArrays(e){if(e<=this.edgeCapacity)return;if(e>this.config.maxCapacity)throw new Error(`Cannot resize beyond max capacity (${this.config.maxCapacity})`);let t=this.allocateEdgeArrays(e);t.sourceIndices.set(this.edges.sourceIndices.subarray(0,this.edgeCount)),t.targetIndices.set(this.edges.targetIndices.subarray(0,this.edgeCount)),t.predicateIndices.set(this.edges.predicateIndices.subarray(0,this.edgeCount)),t.widths.set(this.edges.widths.subarray(0,this.edgeCount)),t.colors.set(this.edges.colors.subarray(0,this.edgeCount)),this.edges=t,this.edgeCapacity=e}ensureNodeCapacity(e){let t=this.nodeCount+e;if(t>this.nodeCapacity){let r=Math.max(t,Math.floor(this.nodeCapacity*this.config.growthFactor));this.resizeNodeArrays(r)}}ensureEdgeCapacity(e){let t=this.edgeCount+e;if(t>this.edgeCapacity){let r=Math.max(t,Math.floor(this.edgeCapacity*this.config.growthFactor));this.resizeEdgeArrays(r)}}addNode(e){let t=this.nodeIdToIndex.get(e.id);if(t!==void 0)return this.updateNodeAt(t,e),t;this.ensureNodeCapacity(1);let r=this.nodeCount++,i=r*2;this.nodes.positions[i]=e.x??Math.random()*1e3-500,this.nodes.positions[i+1]=e.y??Math.random()*1e3-500,this.nodes.radii[r]=e.radius??8,this.nodes.colors[r]=f0(e.color,kr.DEFAULT_COLORS.NODE),e.assetClass?this.nodes.types[r]=this.typeTable.intern(e.assetClass):this.nodes.types[r]=0;let s=kr.NODE_FLAGS.VISIBLE;return e.isPinned&&(s|=kr.NODE_FLAGS.PINNED),e.isArchived&&(s|=kr.NODE_FLAGS.ARCHIVED),this.nodes.flags[r]=s,this.nodeIdToIndex.set(e.id,r),this.indexToNodeId[r]=e.id,this.uriTable.intern(e.id),e.label&&this.labelTable.intern(e.label),r}updateNodeAt(e,t){let r=e*2;t.x!==void 0&&(this.nodes.positions[r]=t.x),t.y!==void 0&&(this.nodes.positions[r+1]=t.y),t.radius!==void 0&&(this.nodes.radii[e]=t.radius),t.color!==void 0&&(this.nodes.colors[e]=f0(t.color,kr.DEFAULT_COLORS.NODE)),t.assetClass!==void 0&&(this.nodes.types[e]=this.typeTable.intern(t.assetClass));let i=this.nodes.flags[e];t.isPinned!==void 0&&(i=t.isPinned?i|kr.NODE_FLAGS.PINNED:i&~kr.NODE_FLAGS.PINNED),t.isArchived!==void 0&&(i=t.isArchived?i|kr.NODE_FLAGS.ARCHIVED:i&~kr.NODE_FLAGS.ARCHIVED),this.nodes.flags[e]=i}addEdge(e){let t=this.nodeIdToIndex.get(e.sourceId),r=this.nodeIdToIndex.get(e.targetId);if(t===void 0||r===void 0)return-1;let i=`${e.sourceId}->${e.targetId}:${e.predicate??"link"}`,s=this.edgeIdToIndex.get(i);if(s!==void 0)return s;this.ensureEdgeCapacity(1);let a=this.edgeCount++;return this.edges.sourceIndices[a]=t,this.edges.targetIndices[a]=r,this.edges.widths[a]=e.width??1,this.edges.colors[a]=f0(e.color,kr.DEFAULT_COLORS.EDGE),e.predicate?this.edges.predicateIndices[a]=this.predicateTable.intern(e.predicate):this.edges.predicateIndices[a]=0,this.edgeIdToIndex.set(i,a),a}addNodes(e){return this.ensureNodeCapacity(e.length),e.map(t=>this.addNode(t))}addEdges(e){return this.ensureEdgeCapacity(e.length),e.map(t=>this.addEdge(t))}loadChunk(e){let r=this.addNodes(e.nodes).filter(a=>a>=0).length,s=this.addEdges(e.edges).filter(a=>a>=0).length;return{nodesAdded:r,edgesAdded:s}}getNodePosition(e){let t=this.nodeIdToIndex.get(e);if(t===void 0)return null;let r=t*2;return{x:this.nodes.positions[r],y:this.nodes.positions[r+1]}}getNodePositionByIndex(e){let t=e*2;return{x:this.nodes.positions[t],y:this.nodes.positions[t+1]}}setNodePosition(e,t,r){let i=this.nodeIdToIndex.get(e);if(i===void 0)return!1;let s=i*2;return this.nodes.positions[s]=t,this.nodes.positions[s+1]=r,!0}setNodePositionByIndex(e,t,r){let i=e*2;this.nodes.positions[i]=t,this.nodes.positions[i+1]=r}updateNodePositions(e){let t=0;for(let[r,i]of e)this.setNodePosition(r,i.x,i.y)&&t++;return t}applyNodeUpdates(e){let t=performance.now(),r=0;for(let i of e){let s=i.index;if(!(s<0||s>=this.nodeCount)){if(i.x!==void 0||i.y!==void 0){let a=s*2;i.x!==void 0&&(this.nodes.positions[a]=i.x),i.y!==void 0&&(this.nodes.positions[a+1]=i.y)}i.radius!==void 0&&(this.nodes.radii[s]=i.radius),i.color!==void 0&&(this.nodes.colors[s]=i.color),i.setFlags!==void 0&&(this.nodes.flags[s]|=i.setFlags),i.clearFlags!==void 0&&(this.nodes.flags[s]&=~i.clearFlags),r++}}return{nodesUpdated:r,edgesUpdated:0,timeMs:performance.now()-t}}getNodeFlags(e){let t=this.nodeIdToIndex.get(e);return t===void 0?0:this.nodes.flags[t]}setNodeFlag(e,t){let r=this.nodeIdToIndex.get(e);return r===void 0?!1:(this.nodes.flags[r]|=t,!0)}clearNodeFlag(e,t){let r=this.nodeIdToIndex.get(e);return r===void 0?!1:(this.nodes.flags[r]&=~t,!0)}hasNodeFlag(e,t){return(this.getNodeFlags(e)&t)!==0}selectNode(e){return this.setNodeFlag(e,kr.NODE_FLAGS.SELECTED)}deselectNode(e){return this.clearNodeFlag(e,kr.NODE_FLAGS.SELECTED)}clearSelection(){for(let e=0;e<this.nodeCount;e++)this.nodes.flags[e]&=~kr.NODE_FLAGS.SELECTED}getSelectedNodeIds(){let e=[];for(let t=0;t<this.nodeCount;t++)this.nodes.flags[t]&kr.NODE_FLAGS.SELECTED&&e.push(this.indexToNodeId[t]);return e}getNodeId(e){return this.indexToNodeId[e]}getNodeIndex(e){return this.nodeIdToIndex.get(e)}hasNode(e){return this.nodeIdToIndex.has(e)}getNodeCount(){return this.nodeCount}getEdgeCount(){return this.edgeCount}getNodeEdges(e){let t=this.nodeIdToIndex.get(e);if(t===void 0)return[];let r=[];for(let i=0;i<this.edgeCount;i++)this.edges.sourceIndices[i]===t?r.push({edgeIndex:i,isSource:!0}):this.edges.targetIndices[i]===t&&r.push({edgeIndex:i,isSource:!1});return r}getNeighbors(e){let t=this.nodeIdToIndex.get(e);if(t===void 0)return[];let r=new Set;for(let i=0;i<this.edgeCount;i++)if(this.edges.sourceIndices[i]===t){let s=this.edges.targetIndices[i];r.add(this.indexToNodeId[s])}else if(this.edges.targetIndices[i]===t){let s=this.edges.sourceIndices[i];r.add(this.indexToNodeId[s])}return Array.from(r)}getRawArrays(){return{nodes:this.nodes,edges:this.edges,nodeCount:this.nodeCount,edgeCount:this.edgeCount}}getPositionsArray(){return this.nodes.positions.subarray(0,this.nodeCount*2)}getMemoryStats(){let e=this.nodeCapacity*2*4+this.nodeCapacity*4+this.nodeCapacity*4+this.nodeCapacity*2+this.nodeCapacity,t=this.edgeCapacity*4+this.edgeCapacity*4+this.edgeCapacity*2+this.edgeCapacity*4+this.edgeCapacity*4,r=this.uriTable.getMemoryBytes()+this.labelTable.getMemoryBytes()+this.typeTable.getMemoryBytes()+this.predicateTable.getMemoryBytes();return{nodeCount:this.nodeCount,edgeCount:this.edgeCount,nodeCapacity:this.nodeCapacity,edgeCapacity:this.edgeCapacity,nodeMemoryBytes:e,edgeMemoryBytes:t,stringTableBytes:r,totalBytes:e+t+r,internedStringCount:this.uriTable.size+this.labelTable.size+this.typeTable.size+this.predicateTable.size}}clear(){this.nodeCount=0,this.edgeCount=0,this.nodeIdToIndex.clear(),this.indexToNodeId=[],this.edgeIdToIndex.clear(),this.uriTable.clear(),this.labelTable.clear(),this.typeTable.clear(),this.predicateTable.clear(),this.nodeCapacity=this.config.initialNodeCapacity,this.edgeCapacity=this.config.initialEdgeCapacity,this.nodes=this.allocateNodeArrays(this.nodeCapacity),this.edges=this.allocateEdgeArrays(this.edgeCapacity)}getTypeTable(){return this.typeTable}getLabelTable(){return this.labelTable}getUriTable(){return this.uriTable}getPredicateTable(){return this.predicateTable}};ih.CompactGraphStore=h0});var fb=v(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.MemoryPool=void 0;yo.getGlobalPool=gN;yo.resetGlobalPool=yN;var mN={maxPooledArrays:16,sizeBuckets:[64,256,1024,4096,16384,65536,262144],autoCleanup:!0,maxPoolMemory:50*1024*1024},sh=class{static{o(this,"MemoryPool")}constructor(e){this.float32Pool=new Map,this.uint32Pool=new Map,this.uint16Pool=new Map,this.uint8Pool=new Map,this.stats={poolHits:0,poolMisses:0,pooledArrays:0,pooledMemory:0,returned:0,rejected:0},this.config={...mN,...e};for(let t of this.config.sizeBuckets)this.float32Pool.set(t,[]),this.uint32Pool.set(t,[]),this.uint16Pool.set(t,[]),this.uint8Pool.set(t,[])}getBucketSize(e){for(let t of this.config.sizeBuckets)if(t>=e)return t;return e}getFloat32(e){let t=this.getBucketSize(e),r=this.float32Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t*4;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Float32Array(t)}getUint32(e){let t=this.getBucketSize(e),r=this.uint32Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t*4;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Uint32Array(t)}getUint16(e){let t=this.getBucketSize(e),r=this.uint16Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t*2;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Uint16Array(t)}getUint8(e){let t=this.getBucketSize(e),r=this.uint8Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Uint8Array(t)}releaseFloat32(e){this.releaseToPool(this.float32Pool,e,4)}releaseUint32(e){this.releaseToPool(this.uint32Pool,e,4)}releaseUint16(e){this.releaseToPool(this.uint16Pool,e,2)}releaseUint8(e){this.releaseToPool(this.uint8Pool,e,1)}releaseToPool(e,t,r){let i=t.length,s=e.get(i);if(s&&s.length<this.config.maxPooledArrays){if(this.config.autoCleanup&&this.stats.pooledMemory+i*r>this.config.maxPoolMemory){this.stats.rejected++;return}s.push(t),this.stats.returned++,this.stats.pooledArrays++,this.stats.pooledMemory+=i*r}else this.stats.rejected++}getStats(){return{...this.stats}}getHitRatio(){let e=this.stats.poolHits+this.stats.poolMisses;return e>0?this.stats.poolHits/e:0}clear(){for(let e of this.float32Pool.values())e.length=0;for(let e of this.uint32Pool.values())e.length=0;for(let e of this.uint16Pool.values())e.length=0;for(let e of this.uint8Pool.values())e.length=0;this.stats.pooledArrays=0,this.stats.pooledMemory=0}cleanup(e){if(this.stats.pooledMemory<=e)return;let t=[...this.config.sizeBuckets].sort((r,i)=>i-r);for(let r of t){if(this.stats.pooledMemory<=e)break;for(let[i,s]of[[this.float32Pool,4],[this.uint32Pool,4],[this.uint16Pool,2],[this.uint8Pool,1]]){let a=i.get(r);if(a)for(;a.length>0&&this.stats.pooledMemory>e;)a.pop(),this.stats.pooledArrays--,this.stats.pooledMemory-=r*s}}}resetStats(){this.stats.poolHits=0,this.stats.poolMisses=0,this.stats.returned=0,this.stats.rejected=0}};yo.MemoryPool=sh;var go=null;function gN(){return go||(go=new sh),go}o(gN,"getGlobalPool");function yN(){go&&go.clear(),go=null}o(yN,"resetGlobalPool")});var hb=v($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.StreamingLoader=void 0;$c.createStreamingSource=SN;var vN={chunkSize:1e3,chunkDelay:0,autoResolveEdges:!0,maxConcurrency:1},d0=class{static{o(this,"StreamingLoader")}constructor(e,t){this.state="idle",this.pendingEdges=[],this.nodesLoaded=0,this.edgesLoaded=0,this.chunksProcessed=0,this.progressCallbacks=[],this.abortController=null,this.store=e,this.config={...vN,...t}}getState(){return this.state}getProgress(){let e=this.totalChunks!==void 0&&this.totalChunks>0?this.chunksProcessed/this.totalChunks:0;return{currentChunk:this.chunksProcessed,totalChunks:this.totalChunks,nodesLoaded:this.nodesLoaded,edgesLoaded:this.edgesLoaded,progress:e,isComplete:this.state==="completed"}}onProgress(e){return this.progressCallbacks.push(e),()=>{let t=this.progressCallbacks.indexOf(e);t>=0&&this.progressCallbacks.splice(t,1)}}notifyProgress(){let e=this.getProgress();for(let t of this.progressCallbacks)t(e)}loadChunk(e){if(this.state==="error")throw new Error("Loader is in error state");this.state="loading",e.totalChunks!==void 0&&(this.totalChunks=e.totalChunks);for(let t of e.nodes)this.store.addNode(t),this.nodesLoaded++;for(let t of e.edges)this.store.addEdge(t)>=0?this.edgesLoaded++:this.pendingEdges.push(t);this.chunksProcessed++,e.isLast&&this.finishLoading(),this.notifyProgress()}finishLoading(){if(this.config.autoResolveEdges&&this.pendingEdges.length>0){for(let e of this.pendingEdges)this.store.addEdge(e)>=0&&this.edgesLoaded++;this.pendingEdges=[]}this.state="completed",this.notifyProgress()}async loadFromIterator(e){this.reset(),this.state="loading",this.abortController=new AbortController;try{for await(let r of e){if(this.abortController.signal.aborted){this.state="paused";return}this.loadChunk(r),this.config.chunkDelay>0&&await this.delay(this.config.chunkDelay)}this.state!=="completed"&&this.finishLoading()}catch(t){throw this.state="error",t}finally{this.abortController=null}}async loadFromArrays(e,t){let r=this.createChunks(e,t);await this.loadFromIterator(this.arrayToAsyncIterator(r))}createChunks(e,t){let r=[],{chunkSize:i}=this.config,s=Math.ceil(e.length/i),a=Array(s).fill(null).map(()=>[]);for(let c of t){let u=e.findIndex(l=>l.id===c.sourceId);if(u>=0){let l=Math.floor(u/i);a[l].push(c)}}for(let c=0;c<s;c++){let u=c*i,l=Math.min(u+i,e.length);r.push({chunkIndex:c,totalChunks:s,nodes:e.slice(u,l),edges:a[c],isLast:c===s-1})}return r}async*arrayToAsyncIterator(e){for(let t of e)yield t}delay(e){return new Promise(t=>setTimeout(t,e))}cancel(){this.abortController&&this.abortController.abort(),this.state="paused"}reset(){this.state="idle",this.pendingEdges=[],this.nodesLoaded=0,this.edgesLoaded=0,this.chunksProcessed=0,this.totalChunks=void 0,this.abortController=null}getPendingEdgeCount(){return this.pendingEdges.length}getStats(){return{state:this.state,nodesLoaded:this.nodesLoaded,edgesLoaded:this.edgesLoaded,chunksProcessed:this.chunksProcessed,totalChunks:this.totalChunks,pendingEdges:this.pendingEdges.length,storeStats:this.store.getMemoryStats()}}};$c.StreamingLoader=d0;async function*SN(n,e,t=1e3){let r=0,i=0,s;for(;;){let a=await e(n,r,t);if(a.totalCount!==void 0&&s===void 0&&(s=Math.ceil(a.totalCount/t)),yield{chunkIndex:i,totalChunks:s,nodes:a.nodes,edges:a.edges,isLast:!a.hasMore},!a.hasMore)break;r+=t,i++}}o(SN,"createStreamingSource")});var mb=v(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.createStreamingSource=xt.StreamingLoader=xt.resetGlobalPool=xt.getGlobalPool=xt.MemoryPool=xt.CompactGraphStore=xt.StringTable=xt.DEFAULT_COLORS=xt.NODE_FLAGS=void 0;var db=c0();Object.defineProperty(xt,"NODE_FLAGS",{enumerable:!0,get:o(function(){return db.NODE_FLAGS},"get")});Object.defineProperty(xt,"DEFAULT_COLORS",{enumerable:!0,get:o(function(){return db.DEFAULT_COLORS},"get")});var _N=l0();Object.defineProperty(xt,"StringTable",{enumerable:!0,get:o(function(){return _N.StringTable},"get")});var bN=lb();Object.defineProperty(xt,"CompactGraphStore",{enumerable:!0,get:o(function(){return bN.CompactGraphStore},"get")});var p0=fb();Object.defineProperty(xt,"MemoryPool",{enumerable:!0,get:o(function(){return p0.MemoryPool},"get")});Object.defineProperty(xt,"getGlobalPool",{enumerable:!0,get:o(function(){return p0.getGlobalPool},"get")});Object.defineProperty(xt,"resetGlobalPool",{enumerable:!0,get:o(function(){return p0.resetGlobalPool},"get")});var pb=hb();Object.defineProperty(xt,"StreamingLoader",{enumerable:!0,get:o(function(){return pb.StreamingLoader},"get")});Object.defineProperty(xt,"createStreamingSource",{enumerable:!0,get:o(function(){return pb.createStreamingSource},"get")})});var ai=v(ah=>{"use strict";Object.defineProperty(ah,"__esModule",{value:!0});ah.ErrorCode=void 0;var gb;(function(n){n[n.INVALID_INPUT=1e3]="INVALID_INPUT",n[n.INVALID_FORMAT=1001]="INVALID_FORMAT",n[n.MISSING_REQUIRED_FIELD=1002]="MISSING_REQUIRED_FIELD",n[n.INVALID_SCHEMA=1003]="INVALID_SCHEMA",n[n.NETWORK_ERROR=2e3]="NETWORK_ERROR",n[n.REQUEST_TIMEOUT=2001]="REQUEST_TIMEOUT",n[n.CONNECTION_FAILED=2002]="CONNECTION_FAILED",n[n.FILE_READ_ERROR=2003]="FILE_READ_ERROR",n[n.FILE_WRITE_ERROR=2004]="FILE_WRITE_ERROR",n[n.INVALID_STATE=3e3]="INVALID_STATE",n[n.INVALID_TRANSITION=3001]="INVALID_TRANSITION",n[n.OPERATION_FAILED=3002]="OPERATION_FAILED",n[n.CONCURRENT_MODIFICATION=3003]="CONCURRENT_MODIFICATION",n[n.PERMISSION_DENIED=4e3]="PERMISSION_DENIED",n[n.UNAUTHORIZED=4001]="UNAUTHORIZED",n[n.FORBIDDEN=4003]="FORBIDDEN",n[n.NOT_FOUND=5e3]="NOT_FOUND",n[n.RESOURCE_EXHAUSTED=5001]="RESOURCE_EXHAUSTED",n[n.ALREADY_EXISTS=5002]="ALREADY_EXISTS",n[n.UNKNOWN_ERROR=9e3]="UNKNOWN_ERROR",n[n.INTERNAL_ERROR=9001]="INTERNAL_ERROR"})(gb||(ah.ErrorCode=gb={}))});var oi=v(oh=>{"use strict";Object.defineProperty(oh,"__esModule",{value:!0});oh.ApplicationError=void 0;var m0=class extends Error{static{o(this,"ApplicationError")}constructor(e,t){super(e),this.name=this.constructor.name,this.context=t,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}format(){let e=`\u274C ${this.name}: ${this.message}`;if(this.guidance&&(e+=`
|
|
314
|
+
`)?`"${e.replace(/"/g,'""')}"`:e}};th.ResultSerializer=a0});var lb=v(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.FileAlreadyExistsError=po.FileNotFoundError=void 0;var o0=class extends Error{static{o(this,"FileNotFoundError")}constructor(e){super(`File not found: ${e}`),this.name="FileNotFoundError"}};po.FileNotFoundError=o0;var c0=class extends Error{static{o(this,"FileAlreadyExistsError")}constructor(e){super(`File already exists: ${e}`),this.name="FileAlreadyExistsError"}};po.FileAlreadyExistsError=c0});var fb=v(rh=>{"use strict";Object.defineProperty(rh,"__esModule",{value:!0});rh.HeadlessError=void 0;var u0=class extends Error{static{o(this,"HeadlessError")}constructor(e,t){super(`"${e}" requires UI. CLI alternative: ${t}`),this.action=e,this.cliAlternative=t,this.name="HeadlessError"}};rh.HeadlessError=u0});var hb=v(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.container=void 0;as.registerCoreServices=dN;as.createChildContainer=pN;as.getContainer=mN;as.resetContainer=gN;Qu();var jc=Le();Object.defineProperty(as,"container",{enumerable:!0,get:o(function(){return jc.container},"get")});var ht=ct(),B4=Om(),q4=Bl(),G4=ag(),W4=ql(),H4=Jm(),z4=Dm(),Q4=Mm(),Y4=Lm(),K4=Ql(),X4=Yl(),J4=zm(),Z4=Ym(),eN=eg(),tN=Wm(),rN=cg(),nN=hg(),iN=lg(),sN=Um(),aN=qm(),oN=ig(),cN=rg(),uN=Zg(),lN=$m(),fN=pg(),hN=yg();function dN(n){let e=n||jc.container;e.registerSingleton(ht.DI_TOKENS.TaskFrontmatterGenerator,q4.TaskFrontmatterGenerator),e.registerSingleton(ht.DI_TOKENS.DynamicFrontmatterGenerator,G4.DynamicFrontmatterGenerator),e.registerSingleton(ht.DI_TOKENS.AlgorithmExtractor,W4.AlgorithmExtractor),e.registerSingleton(ht.DI_TOKENS.EffortStatusWorkflow,K4.EffortStatusWorkflow),e.registerSingleton(ht.DI_TOKENS.StatusTimestampService,X4.StatusTimestampService),e.registerSingleton(ht.DI_TOKENS.TaskStatusService,Y4.TaskStatusService),e.registerSingleton(ht.DI_TOKENS.TaskCreationService,B4.TaskCreationService),e.registerSingleton(ht.DI_TOKENS.ProjectCreationService,z4.ProjectCreationService),e.registerSingleton(ht.DI_TOKENS.AreaCreationService,Q4.AreaCreationService),e.registerSingleton(ht.DI_TOKENS.ClassCreationService,sN.ClassCreationService),e.registerSingleton(ht.DI_TOKENS.ConceptCreationService,aN.ConceptCreationService),e.registerSingleton(ht.DI_TOKENS.FleetingNoteCreationService,oN.FleetingNoteCreationService),e.registerSingleton(ht.DI_TOKENS.SupervisionCreationService,cN.SupervisionCreationService),e.registerSingleton(ht.DI_TOKENS.GenericAssetCreationService,hN.GenericAssetCreationService),e.registerSingleton(ht.DI_TOKENS.PropertyCleanupService,H4.PropertyCleanupService),e.registerSingleton(ht.DI_TOKENS.FolderRepairService,J4.FolderRepairService),e.registerSingleton(ht.DI_TOKENS.LabelToAliasService,Z4.LabelToAliasService),e.registerSingleton(ht.DI_TOKENS.RenameToUidService,eN.RenameToUidService),e.registerSingleton(ht.DI_TOKENS.PlanningService,rN.PlanningService),e.registerSingleton(ht.DI_TOKENS.EffortVotingService,tN.EffortVotingService),e.registerSingleton(ht.DI_TOKENS.SessionEventService,nN.SessionEventService),e.registerSingleton(ht.DI_TOKENS.AssetConversionService,iN.AssetConversionService),e.registerSingleton(ht.DI_TOKENS.NoteToRDFConverter,uN.NoteToRDFConverter),e.registerSingleton(ht.DI_TOKENS.AreaHierarchyBuilder,lN.AreaHierarchyBuilder),e.registerSingleton(ht.DI_TOKENS.URIConstructionService,fN.URIConstructionService)}o(dN,"registerCoreServices");function pN(){return jc.container.createChildContainer()}o(pN,"createChildContainer");function mN(){return jc.container}o(mN,"getContainer");function gN(){jc.container.reset()}o(gN,"resetContainer")});var l0=v(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.DEFAULT_COLORS=mo.NODE_FLAGS=void 0;mo.NODE_FLAGS={PINNED:1,VISIBLE:2,SELECTED:4,HOVERED:8,ARCHIVED:16,SEARCH_MATCH:32,HIGHLIGHTED:64};mo.DEFAULT_COLORS={NODE:1251006975,NODE_SELECTED:4290840575,NODE_HOVERED:1723558655,EDGE:2576980479,EDGE_SELECTED:4288151807,EDGE_HIERARCHY:2619846911}});var h0=v(nh=>{"use strict";Object.defineProperty(nh,"__esModule",{value:!0});nh.StringTable=void 0;var f0=class n{static{o(this,"StringTable")}constructor(e){if(this.stringToIndex=new Map,this.strings=[],this.memoryBytes=0,e)for(let t of e)this.intern(t)}intern(e){let t=this.stringToIndex.get(e);if(t!==void 0)return t;let r=this.strings.length;return this.strings.push(e),this.stringToIndex.set(e,r),this.memoryBytes+=e.length*2+50,r}getIndex(e){return this.stringToIndex.get(e)??-1}getString(e){if(e<0||e>=this.strings.length)throw new RangeError(`StringTable index out of bounds: ${e}`);return this.strings[e]}has(e){return this.stringToIndex.has(e)}hasIndex(e){return e>=0&&e<this.strings.length}get size(){return this.strings.length}getMemoryBytes(){return this.memoryBytes}*entries(){for(let e=0;e<this.strings.length;e++)yield[e,this.strings[e]]}*values(){for(let e of this.strings)yield e}toArray(){return[...this.strings]}clear(){this.stringToIndex.clear(),this.strings=[],this.memoryBytes=0}static fromJSON(e){return new n(e)}toJSON(){return this.strings}internAll(e){return e.map(t=>this.intern(t))}getStrings(e){return e.map(t=>this.getString(t))}search(e){let t=typeof e=="string"?new RegExp(e):e,r=[];for(let i=0;i<this.strings.length;i++)t.test(this.strings[i])&&r.push([i,this.strings[i]]);return r}getStats(){let e=this.strings.reduce((t,r)=>t+r.length,0);return{count:this.strings.length,memoryBytes:this.memoryBytes,avgStringLength:this.strings.length>0?e/this.strings.length:0}}};nh.StringTable=f0});var db=v(sh=>{"use strict";Object.defineProperty(sh,"__esModule",{value:!0});sh.CompactGraphStore=void 0;var ih=h0(),kr=l0(),yN={initialNodeCapacity:1e4,initialEdgeCapacity:5e4,growthFactor:2,maxCapacity:1e6};function d0(n,e){if(n===void 0)return e;if(typeof n=="number")return n;if(n.startsWith("#")){let t=n.slice(1);if(t.length===6)return parseInt(t,16)<<8|255;if(t.length===8)return parseInt(t,16)}return e}o(d0,"parseColor");var p0=class{static{o(this,"CompactGraphStore")}constructor(e){this.nodeCount=0,this.edgeCount=0,this.nodeIdToIndex=new Map,this.indexToNodeId=[],this.edgeIdToIndex=new Map,this.config={...yN,...e},this.nodeCapacity=this.config.initialNodeCapacity,this.edgeCapacity=this.config.initialEdgeCapacity,this.nodes=this.allocateNodeArrays(this.nodeCapacity),this.edges=this.allocateEdgeArrays(this.edgeCapacity),this.uriTable=new ih.StringTable,this.labelTable=new ih.StringTable,this.typeTable=new ih.StringTable,this.predicateTable=new ih.StringTable}allocateNodeArrays(e){return{positions:new Float32Array(e*2),radii:new Float32Array(e),colors:new Uint32Array(e),types:new Uint16Array(e),flags:new Uint8Array(e)}}allocateEdgeArrays(e){return{sourceIndices:new Uint32Array(e),targetIndices:new Uint32Array(e),predicateIndices:new Uint16Array(e),widths:new Float32Array(e),colors:new Uint32Array(e)}}resizeNodeArrays(e){if(e<=this.nodeCapacity)return;if(e>this.config.maxCapacity)throw new Error(`Cannot resize beyond max capacity (${this.config.maxCapacity})`);let t=this.allocateNodeArrays(e);t.positions.set(this.nodes.positions.subarray(0,this.nodeCount*2)),t.radii.set(this.nodes.radii.subarray(0,this.nodeCount)),t.colors.set(this.nodes.colors.subarray(0,this.nodeCount)),t.types.set(this.nodes.types.subarray(0,this.nodeCount)),t.flags.set(this.nodes.flags.subarray(0,this.nodeCount)),this.nodes=t,this.nodeCapacity=e}resizeEdgeArrays(e){if(e<=this.edgeCapacity)return;if(e>this.config.maxCapacity)throw new Error(`Cannot resize beyond max capacity (${this.config.maxCapacity})`);let t=this.allocateEdgeArrays(e);t.sourceIndices.set(this.edges.sourceIndices.subarray(0,this.edgeCount)),t.targetIndices.set(this.edges.targetIndices.subarray(0,this.edgeCount)),t.predicateIndices.set(this.edges.predicateIndices.subarray(0,this.edgeCount)),t.widths.set(this.edges.widths.subarray(0,this.edgeCount)),t.colors.set(this.edges.colors.subarray(0,this.edgeCount)),this.edges=t,this.edgeCapacity=e}ensureNodeCapacity(e){let t=this.nodeCount+e;if(t>this.nodeCapacity){let r=Math.max(t,Math.floor(this.nodeCapacity*this.config.growthFactor));this.resizeNodeArrays(r)}}ensureEdgeCapacity(e){let t=this.edgeCount+e;if(t>this.edgeCapacity){let r=Math.max(t,Math.floor(this.edgeCapacity*this.config.growthFactor));this.resizeEdgeArrays(r)}}addNode(e){let t=this.nodeIdToIndex.get(e.id);if(t!==void 0)return this.updateNodeAt(t,e),t;this.ensureNodeCapacity(1);let r=this.nodeCount++,i=r*2;this.nodes.positions[i]=e.x??Math.random()*1e3-500,this.nodes.positions[i+1]=e.y??Math.random()*1e3-500,this.nodes.radii[r]=e.radius??8,this.nodes.colors[r]=d0(e.color,kr.DEFAULT_COLORS.NODE),e.assetClass?this.nodes.types[r]=this.typeTable.intern(e.assetClass):this.nodes.types[r]=0;let s=kr.NODE_FLAGS.VISIBLE;return e.isPinned&&(s|=kr.NODE_FLAGS.PINNED),e.isArchived&&(s|=kr.NODE_FLAGS.ARCHIVED),this.nodes.flags[r]=s,this.nodeIdToIndex.set(e.id,r),this.indexToNodeId[r]=e.id,this.uriTable.intern(e.id),e.label&&this.labelTable.intern(e.label),r}updateNodeAt(e,t){let r=e*2;t.x!==void 0&&(this.nodes.positions[r]=t.x),t.y!==void 0&&(this.nodes.positions[r+1]=t.y),t.radius!==void 0&&(this.nodes.radii[e]=t.radius),t.color!==void 0&&(this.nodes.colors[e]=d0(t.color,kr.DEFAULT_COLORS.NODE)),t.assetClass!==void 0&&(this.nodes.types[e]=this.typeTable.intern(t.assetClass));let i=this.nodes.flags[e];t.isPinned!==void 0&&(i=t.isPinned?i|kr.NODE_FLAGS.PINNED:i&~kr.NODE_FLAGS.PINNED),t.isArchived!==void 0&&(i=t.isArchived?i|kr.NODE_FLAGS.ARCHIVED:i&~kr.NODE_FLAGS.ARCHIVED),this.nodes.flags[e]=i}addEdge(e){let t=this.nodeIdToIndex.get(e.sourceId),r=this.nodeIdToIndex.get(e.targetId);if(t===void 0||r===void 0)return-1;let i=`${e.sourceId}->${e.targetId}:${e.predicate??"link"}`,s=this.edgeIdToIndex.get(i);if(s!==void 0)return s;this.ensureEdgeCapacity(1);let a=this.edgeCount++;return this.edges.sourceIndices[a]=t,this.edges.targetIndices[a]=r,this.edges.widths[a]=e.width??1,this.edges.colors[a]=d0(e.color,kr.DEFAULT_COLORS.EDGE),e.predicate?this.edges.predicateIndices[a]=this.predicateTable.intern(e.predicate):this.edges.predicateIndices[a]=0,this.edgeIdToIndex.set(i,a),a}addNodes(e){return this.ensureNodeCapacity(e.length),e.map(t=>this.addNode(t))}addEdges(e){return this.ensureEdgeCapacity(e.length),e.map(t=>this.addEdge(t))}loadChunk(e){let r=this.addNodes(e.nodes).filter(a=>a>=0).length,s=this.addEdges(e.edges).filter(a=>a>=0).length;return{nodesAdded:r,edgesAdded:s}}getNodePosition(e){let t=this.nodeIdToIndex.get(e);if(t===void 0)return null;let r=t*2;return{x:this.nodes.positions[r],y:this.nodes.positions[r+1]}}getNodePositionByIndex(e){let t=e*2;return{x:this.nodes.positions[t],y:this.nodes.positions[t+1]}}setNodePosition(e,t,r){let i=this.nodeIdToIndex.get(e);if(i===void 0)return!1;let s=i*2;return this.nodes.positions[s]=t,this.nodes.positions[s+1]=r,!0}setNodePositionByIndex(e,t,r){let i=e*2;this.nodes.positions[i]=t,this.nodes.positions[i+1]=r}updateNodePositions(e){let t=0;for(let[r,i]of e)this.setNodePosition(r,i.x,i.y)&&t++;return t}applyNodeUpdates(e){let t=performance.now(),r=0;for(let i of e){let s=i.index;if(!(s<0||s>=this.nodeCount)){if(i.x!==void 0||i.y!==void 0){let a=s*2;i.x!==void 0&&(this.nodes.positions[a]=i.x),i.y!==void 0&&(this.nodes.positions[a+1]=i.y)}i.radius!==void 0&&(this.nodes.radii[s]=i.radius),i.color!==void 0&&(this.nodes.colors[s]=i.color),i.setFlags!==void 0&&(this.nodes.flags[s]|=i.setFlags),i.clearFlags!==void 0&&(this.nodes.flags[s]&=~i.clearFlags),r++}}return{nodesUpdated:r,edgesUpdated:0,timeMs:performance.now()-t}}getNodeFlags(e){let t=this.nodeIdToIndex.get(e);return t===void 0?0:this.nodes.flags[t]}setNodeFlag(e,t){let r=this.nodeIdToIndex.get(e);return r===void 0?!1:(this.nodes.flags[r]|=t,!0)}clearNodeFlag(e,t){let r=this.nodeIdToIndex.get(e);return r===void 0?!1:(this.nodes.flags[r]&=~t,!0)}hasNodeFlag(e,t){return(this.getNodeFlags(e)&t)!==0}selectNode(e){return this.setNodeFlag(e,kr.NODE_FLAGS.SELECTED)}deselectNode(e){return this.clearNodeFlag(e,kr.NODE_FLAGS.SELECTED)}clearSelection(){for(let e=0;e<this.nodeCount;e++)this.nodes.flags[e]&=~kr.NODE_FLAGS.SELECTED}getSelectedNodeIds(){let e=[];for(let t=0;t<this.nodeCount;t++)this.nodes.flags[t]&kr.NODE_FLAGS.SELECTED&&e.push(this.indexToNodeId[t]);return e}getNodeId(e){return this.indexToNodeId[e]}getNodeIndex(e){return this.nodeIdToIndex.get(e)}hasNode(e){return this.nodeIdToIndex.has(e)}getNodeCount(){return this.nodeCount}getEdgeCount(){return this.edgeCount}getNodeEdges(e){let t=this.nodeIdToIndex.get(e);if(t===void 0)return[];let r=[];for(let i=0;i<this.edgeCount;i++)this.edges.sourceIndices[i]===t?r.push({edgeIndex:i,isSource:!0}):this.edges.targetIndices[i]===t&&r.push({edgeIndex:i,isSource:!1});return r}getNeighbors(e){let t=this.nodeIdToIndex.get(e);if(t===void 0)return[];let r=new Set;for(let i=0;i<this.edgeCount;i++)if(this.edges.sourceIndices[i]===t){let s=this.edges.targetIndices[i];r.add(this.indexToNodeId[s])}else if(this.edges.targetIndices[i]===t){let s=this.edges.sourceIndices[i];r.add(this.indexToNodeId[s])}return Array.from(r)}getRawArrays(){return{nodes:this.nodes,edges:this.edges,nodeCount:this.nodeCount,edgeCount:this.edgeCount}}getPositionsArray(){return this.nodes.positions.subarray(0,this.nodeCount*2)}getMemoryStats(){let e=this.nodeCapacity*2*4+this.nodeCapacity*4+this.nodeCapacity*4+this.nodeCapacity*2+this.nodeCapacity,t=this.edgeCapacity*4+this.edgeCapacity*4+this.edgeCapacity*2+this.edgeCapacity*4+this.edgeCapacity*4,r=this.uriTable.getMemoryBytes()+this.labelTable.getMemoryBytes()+this.typeTable.getMemoryBytes()+this.predicateTable.getMemoryBytes();return{nodeCount:this.nodeCount,edgeCount:this.edgeCount,nodeCapacity:this.nodeCapacity,edgeCapacity:this.edgeCapacity,nodeMemoryBytes:e,edgeMemoryBytes:t,stringTableBytes:r,totalBytes:e+t+r,internedStringCount:this.uriTable.size+this.labelTable.size+this.typeTable.size+this.predicateTable.size}}clear(){this.nodeCount=0,this.edgeCount=0,this.nodeIdToIndex.clear(),this.indexToNodeId=[],this.edgeIdToIndex.clear(),this.uriTable.clear(),this.labelTable.clear(),this.typeTable.clear(),this.predicateTable.clear(),this.nodeCapacity=this.config.initialNodeCapacity,this.edgeCapacity=this.config.initialEdgeCapacity,this.nodes=this.allocateNodeArrays(this.nodeCapacity),this.edges=this.allocateEdgeArrays(this.edgeCapacity)}getTypeTable(){return this.typeTable}getLabelTable(){return this.labelTable}getUriTable(){return this.uriTable}getPredicateTable(){return this.predicateTable}};sh.CompactGraphStore=p0});var pb=v(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.MemoryPool=void 0;yo.getGlobalPool=SN;yo.resetGlobalPool=_N;var vN={maxPooledArrays:16,sizeBuckets:[64,256,1024,4096,16384,65536,262144],autoCleanup:!0,maxPoolMemory:50*1024*1024},ah=class{static{o(this,"MemoryPool")}constructor(e){this.float32Pool=new Map,this.uint32Pool=new Map,this.uint16Pool=new Map,this.uint8Pool=new Map,this.stats={poolHits:0,poolMisses:0,pooledArrays:0,pooledMemory:0,returned:0,rejected:0},this.config={...vN,...e};for(let t of this.config.sizeBuckets)this.float32Pool.set(t,[]),this.uint32Pool.set(t,[]),this.uint16Pool.set(t,[]),this.uint8Pool.set(t,[])}getBucketSize(e){for(let t of this.config.sizeBuckets)if(t>=e)return t;return e}getFloat32(e){let t=this.getBucketSize(e),r=this.float32Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t*4;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Float32Array(t)}getUint32(e){let t=this.getBucketSize(e),r=this.uint32Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t*4;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Uint32Array(t)}getUint16(e){let t=this.getBucketSize(e),r=this.uint16Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t*2;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Uint16Array(t)}getUint8(e){let t=this.getBucketSize(e),r=this.uint8Pool.get(t);if(r&&r.length>0){this.stats.poolHits++,this.stats.pooledArrays--,this.stats.pooledMemory-=t;let i=r.pop();return i.fill(0),i}return this.stats.poolMisses++,new Uint8Array(t)}releaseFloat32(e){this.releaseToPool(this.float32Pool,e,4)}releaseUint32(e){this.releaseToPool(this.uint32Pool,e,4)}releaseUint16(e){this.releaseToPool(this.uint16Pool,e,2)}releaseUint8(e){this.releaseToPool(this.uint8Pool,e,1)}releaseToPool(e,t,r){let i=t.length,s=e.get(i);if(s&&s.length<this.config.maxPooledArrays){if(this.config.autoCleanup&&this.stats.pooledMemory+i*r>this.config.maxPoolMemory){this.stats.rejected++;return}s.push(t),this.stats.returned++,this.stats.pooledArrays++,this.stats.pooledMemory+=i*r}else this.stats.rejected++}getStats(){return{...this.stats}}getHitRatio(){let e=this.stats.poolHits+this.stats.poolMisses;return e>0?this.stats.poolHits/e:0}clear(){for(let e of this.float32Pool.values())e.length=0;for(let e of this.uint32Pool.values())e.length=0;for(let e of this.uint16Pool.values())e.length=0;for(let e of this.uint8Pool.values())e.length=0;this.stats.pooledArrays=0,this.stats.pooledMemory=0}cleanup(e){if(this.stats.pooledMemory<=e)return;let t=[...this.config.sizeBuckets].sort((r,i)=>i-r);for(let r of t){if(this.stats.pooledMemory<=e)break;for(let[i,s]of[[this.float32Pool,4],[this.uint32Pool,4],[this.uint16Pool,2],[this.uint8Pool,1]]){let a=i.get(r);if(a)for(;a.length>0&&this.stats.pooledMemory>e;)a.pop(),this.stats.pooledArrays--,this.stats.pooledMemory-=r*s}}}resetStats(){this.stats.poolHits=0,this.stats.poolMisses=0,this.stats.returned=0,this.stats.rejected=0}};yo.MemoryPool=ah;var go=null;function SN(){return go||(go=new ah),go}o(SN,"getGlobalPool");function _N(){go&&go.clear(),go=null}o(_N,"resetGlobalPool")});var mb=v($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.StreamingLoader=void 0;$c.createStreamingSource=wN;var bN={chunkSize:1e3,chunkDelay:0,autoResolveEdges:!0,maxConcurrency:1},m0=class{static{o(this,"StreamingLoader")}constructor(e,t){this.state="idle",this.pendingEdges=[],this.nodesLoaded=0,this.edgesLoaded=0,this.chunksProcessed=0,this.progressCallbacks=[],this.abortController=null,this.store=e,this.config={...bN,...t}}getState(){return this.state}getProgress(){let e=this.totalChunks!==void 0&&this.totalChunks>0?this.chunksProcessed/this.totalChunks:0;return{currentChunk:this.chunksProcessed,totalChunks:this.totalChunks,nodesLoaded:this.nodesLoaded,edgesLoaded:this.edgesLoaded,progress:e,isComplete:this.state==="completed"}}onProgress(e){return this.progressCallbacks.push(e),()=>{let t=this.progressCallbacks.indexOf(e);t>=0&&this.progressCallbacks.splice(t,1)}}notifyProgress(){let e=this.getProgress();for(let t of this.progressCallbacks)t(e)}loadChunk(e){if(this.state==="error")throw new Error("Loader is in error state");this.state="loading",e.totalChunks!==void 0&&(this.totalChunks=e.totalChunks);for(let t of e.nodes)this.store.addNode(t),this.nodesLoaded++;for(let t of e.edges)this.store.addEdge(t)>=0?this.edgesLoaded++:this.pendingEdges.push(t);this.chunksProcessed++,e.isLast&&this.finishLoading(),this.notifyProgress()}finishLoading(){if(this.config.autoResolveEdges&&this.pendingEdges.length>0){for(let e of this.pendingEdges)this.store.addEdge(e)>=0&&this.edgesLoaded++;this.pendingEdges=[]}this.state="completed",this.notifyProgress()}async loadFromIterator(e){this.reset(),this.state="loading",this.abortController=new AbortController;try{for await(let r of e){if(this.abortController.signal.aborted){this.state="paused";return}this.loadChunk(r),this.config.chunkDelay>0&&await this.delay(this.config.chunkDelay)}this.state!=="completed"&&this.finishLoading()}catch(t){throw this.state="error",t}finally{this.abortController=null}}async loadFromArrays(e,t){let r=this.createChunks(e,t);await this.loadFromIterator(this.arrayToAsyncIterator(r))}createChunks(e,t){let r=[],{chunkSize:i}=this.config,s=Math.ceil(e.length/i),a=Array(s).fill(null).map(()=>[]);for(let c of t){let u=e.findIndex(l=>l.id===c.sourceId);if(u>=0){let l=Math.floor(u/i);a[l].push(c)}}for(let c=0;c<s;c++){let u=c*i,l=Math.min(u+i,e.length);r.push({chunkIndex:c,totalChunks:s,nodes:e.slice(u,l),edges:a[c],isLast:c===s-1})}return r}async*arrayToAsyncIterator(e){for(let t of e)yield t}delay(e){return new Promise(t=>setTimeout(t,e))}cancel(){this.abortController&&this.abortController.abort(),this.state="paused"}reset(){this.state="idle",this.pendingEdges=[],this.nodesLoaded=0,this.edgesLoaded=0,this.chunksProcessed=0,this.totalChunks=void 0,this.abortController=null}getPendingEdgeCount(){return this.pendingEdges.length}getStats(){return{state:this.state,nodesLoaded:this.nodesLoaded,edgesLoaded:this.edgesLoaded,chunksProcessed:this.chunksProcessed,totalChunks:this.totalChunks,pendingEdges:this.pendingEdges.length,storeStats:this.store.getMemoryStats()}}};$c.StreamingLoader=m0;async function*wN(n,e,t=1e3){let r=0,i=0,s;for(;;){let a=await e(n,r,t);if(a.totalCount!==void 0&&s===void 0&&(s=Math.ceil(a.totalCount/t)),yield{chunkIndex:i,totalChunks:s,nodes:a.nodes,edges:a.edges,isLast:!a.hasMore},!a.hasMore)break;r+=t,i++}}o(wN,"createStreamingSource")});var vb=v(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.createStreamingSource=xt.StreamingLoader=xt.resetGlobalPool=xt.getGlobalPool=xt.MemoryPool=xt.CompactGraphStore=xt.StringTable=xt.DEFAULT_COLORS=xt.NODE_FLAGS=void 0;var gb=l0();Object.defineProperty(xt,"NODE_FLAGS",{enumerable:!0,get:o(function(){return gb.NODE_FLAGS},"get")});Object.defineProperty(xt,"DEFAULT_COLORS",{enumerable:!0,get:o(function(){return gb.DEFAULT_COLORS},"get")});var EN=h0();Object.defineProperty(xt,"StringTable",{enumerable:!0,get:o(function(){return EN.StringTable},"get")});var TN=db();Object.defineProperty(xt,"CompactGraphStore",{enumerable:!0,get:o(function(){return TN.CompactGraphStore},"get")});var g0=pb();Object.defineProperty(xt,"MemoryPool",{enumerable:!0,get:o(function(){return g0.MemoryPool},"get")});Object.defineProperty(xt,"getGlobalPool",{enumerable:!0,get:o(function(){return g0.getGlobalPool},"get")});Object.defineProperty(xt,"resetGlobalPool",{enumerable:!0,get:o(function(){return g0.resetGlobalPool},"get")});var yb=mb();Object.defineProperty(xt,"StreamingLoader",{enumerable:!0,get:o(function(){return yb.StreamingLoader},"get")});Object.defineProperty(xt,"createStreamingSource",{enumerable:!0,get:o(function(){return yb.createStreamingSource},"get")})});var ai=v(oh=>{"use strict";Object.defineProperty(oh,"__esModule",{value:!0});oh.ErrorCode=void 0;var Sb;(function(n){n[n.INVALID_INPUT=1e3]="INVALID_INPUT",n[n.INVALID_FORMAT=1001]="INVALID_FORMAT",n[n.MISSING_REQUIRED_FIELD=1002]="MISSING_REQUIRED_FIELD",n[n.INVALID_SCHEMA=1003]="INVALID_SCHEMA",n[n.NETWORK_ERROR=2e3]="NETWORK_ERROR",n[n.REQUEST_TIMEOUT=2001]="REQUEST_TIMEOUT",n[n.CONNECTION_FAILED=2002]="CONNECTION_FAILED",n[n.FILE_READ_ERROR=2003]="FILE_READ_ERROR",n[n.FILE_WRITE_ERROR=2004]="FILE_WRITE_ERROR",n[n.INVALID_STATE=3e3]="INVALID_STATE",n[n.INVALID_TRANSITION=3001]="INVALID_TRANSITION",n[n.OPERATION_FAILED=3002]="OPERATION_FAILED",n[n.CONCURRENT_MODIFICATION=3003]="CONCURRENT_MODIFICATION",n[n.PERMISSION_DENIED=4e3]="PERMISSION_DENIED",n[n.UNAUTHORIZED=4001]="UNAUTHORIZED",n[n.FORBIDDEN=4003]="FORBIDDEN",n[n.NOT_FOUND=5e3]="NOT_FOUND",n[n.RESOURCE_EXHAUSTED=5001]="RESOURCE_EXHAUSTED",n[n.ALREADY_EXISTS=5002]="ALREADY_EXISTS",n[n.UNKNOWN_ERROR=9e3]="UNKNOWN_ERROR",n[n.INTERNAL_ERROR=9001]="INTERNAL_ERROR"})(Sb||(oh.ErrorCode=Sb={}))});var oi=v(ch=>{"use strict";Object.defineProperty(ch,"__esModule",{value:!0});ch.ApplicationError=void 0;var y0=class extends Error{static{o(this,"ApplicationError")}constructor(e,t){super(e),this.name=this.constructor.name,this.context=t,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}format(){let e=`\u274C ${this.name}: ${this.message}`;if(this.guidance&&(e+=`
|
|
315
315
|
|
|
316
316
|
\u{1F4A1} ${this.guidance}`),this.context&&Object.keys(this.context).length>0){e+=`
|
|
317
317
|
|
|
318
318
|
\u{1F4CB} Context:`;for(let[t,r]of Object.entries(this.context))e+=`
|
|
319
|
-
${t}: ${JSON.stringify(r)}`}return e}toJSON(){return{name:this.name,message:this.message,code:this.code,retriable:this.retriable,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}};
|
|
319
|
+
${t}: ${JSON.stringify(r)}`}return e}toJSON(){return{name:this.name,message:this.message,code:this.code,retriable:this.retriable,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}};ch.ApplicationError=y0});var _b=v(uh=>{"use strict";Object.defineProperty(uh,"__esModule",{value:!0});uh.ValidationError=void 0;var AN=oi(),xN=ai(),v0=class extends AN.ApplicationError{static{o(this,"ValidationError")}constructor(e,t){super(e,t),this.code=xN.ErrorCode.INVALID_INPUT,this.retriable=!1,this.guidance=`Check the input data for correctness.
|
|
320
320
|
Common issues:
|
|
321
321
|
\u2022 Missing required fields
|
|
322
322
|
\u2022 Invalid data format or type
|
|
323
323
|
\u2022 Values outside allowed range
|
|
324
|
-
\u2022 Schema validation failed`}};
|
|
324
|
+
\u2022 Schema validation failed`}};uh.ValidationError=v0});var bb=v(lh=>{"use strict";Object.defineProperty(lh,"__esModule",{value:!0});lh.NetworkError=void 0;var CN=oi(),IN=ai(),S0=class extends CN.ApplicationError{static{o(this,"NetworkError")}constructor(e,t){super(e,t),this.code=IN.ErrorCode.NETWORK_ERROR,this.retriable=!0,this.guidance=`This is typically a transient network issue.
|
|
325
325
|
To resolve:
|
|
326
326
|
\u2022 Check your internet connection
|
|
327
327
|
\u2022 Retry the operation
|
|
328
328
|
\u2022 Verify external services are available
|
|
329
|
-
\u2022 Check firewall/proxy settings`}};
|
|
329
|
+
\u2022 Check firewall/proxy settings`}};lh.NetworkError=S0});var wb=v(fh=>{"use strict";Object.defineProperty(fh,"__esModule",{value:!0});fh.StateTransitionError=void 0;var ON=oi(),PN=ai(),_0=class extends ON.ApplicationError{static{o(this,"StateTransitionError")}constructor(e,t){super(e,t),this.code=PN.ErrorCode.INVALID_TRANSITION,this.retriable=!1,this.guidance=`The requested state transition is not allowed.
|
|
330
330
|
To fix:
|
|
331
331
|
\u2022 Check the current state of the resource
|
|
332
332
|
\u2022 Verify the transition is valid for this workflow
|
|
333
333
|
\u2022 Review state machine documentation
|
|
334
|
-
\u2022 Ensure no concurrent modifications occurred`}};
|
|
334
|
+
\u2022 Ensure no concurrent modifications occurred`}};fh.StateTransitionError=_0});var Eb=v(hh=>{"use strict";Object.defineProperty(hh,"__esModule",{value:!0});hh.PermissionError=void 0;var DN=oi(),RN=ai(),b0=class extends DN.ApplicationError{static{o(this,"PermissionError")}constructor(e,t){super(e,t),this.code=RN.ErrorCode.PERMISSION_DENIED,this.retriable=!1,this.guidance=`You don't have permission to perform this operation.
|
|
335
335
|
To resolve:
|
|
336
336
|
\u2022 Check file/directory permissions
|
|
337
337
|
\u2022 Verify you're authenticated
|
|
338
338
|
\u2022 Ensure you have sufficient privileges
|
|
339
|
-
\u2022 Contact administrator if access is needed`}};
|
|
339
|
+
\u2022 Contact administrator if access is needed`}};hh.PermissionError=b0});var Tb=v(dh=>{"use strict";Object.defineProperty(dh,"__esModule",{value:!0});dh.NotFoundError=void 0;var FN=oi(),NN=ai(),w0=class extends FN.ApplicationError{static{o(this,"NotFoundError")}constructor(e,t){super(e,t),this.code=NN.ErrorCode.NOT_FOUND,this.retriable=!1,this.guidance=`The requested resource could not be found.
|
|
340
340
|
To resolve:
|
|
341
341
|
\u2022 Verify the resource path/ID is correct
|
|
342
342
|
\u2022 Check the resource exists
|
|
343
343
|
\u2022 Ensure proper file extension (.md for notes)
|
|
344
|
-
\u2022 Verify resource hasn't been deleted`}};
|
|
344
|
+
\u2022 Verify resource hasn't been deleted`}};dh.NotFoundError=w0});var Ab=v(ph=>{"use strict";Object.defineProperty(ph,"__esModule",{value:!0});ph.ResourceExhaustedError=void 0;var LN=oi(),kN=ai(),E0=class extends LN.ApplicationError{static{o(this,"ResourceExhaustedError")}constructor(e,t){super(e,t),this.code=kN.ErrorCode.RESOURCE_EXHAUSTED,this.retriable=!0,this.guidance=`A resource limit has been exceeded.
|
|
345
345
|
To resolve:
|
|
346
346
|
\u2022 Free up system resources (memory, disk space)
|
|
347
347
|
\u2022 Reduce the size of your request
|
|
348
348
|
\u2022 Wait and retry (for rate limits)
|
|
349
349
|
\u2022 Close unused files/connections
|
|
350
|
-
\u2022 Paginate large queries`}};
|
|
350
|
+
\u2022 Paginate large queries`}};ph.ResourceExhaustedError=E0});var xb=v(mh=>{"use strict";Object.defineProperty(mh,"__esModule",{value:!0});mh.ServiceError=void 0;var MN=oi(),jN=ai(),T0=class extends MN.ApplicationError{static{o(this,"ServiceError")}constructor(e,t){super(e,t),this.code=jN.ErrorCode.INTERNAL_ERROR,this.retriable=!1,this.guidance=`This is an internal service error.
|
|
351
351
|
To resolve:
|
|
352
352
|
\u2022 Check service initialization parameters
|
|
353
353
|
\u2022 Verify all required dependencies are available
|
|
354
354
|
\u2022 Review service logs for detailed error information
|
|
355
|
-
\u2022 Contact support if the issue persists`}};
|
|
356
|
-
`)}calculateDelay(e){let t=this.retryConfig.initialDelayMs*Math.pow(this.retryConfig.backoffMultiplier,e);return Math.min(t,this.retryConfig.maxDelayMs)}sleep(e){return new Promise(t=>setTimeout(t,e))}callTelemetryHooks(e,...t){for(let r of this.telemetryHooks)try{let i=r[e];i&&i.apply(r,t)}catch(i){console.error("Error in telemetry hook:",i)}}};mh.ApplicationErrorHandler=T0});var xb=v(gh=>{"use strict";Object.defineProperty(gh,"__esModule",{value:!0});gh.ApplicationErrorHandler=void 0;var HN=Ab();Object.defineProperty(gh,"ApplicationErrorHandler",{enumerable:!0,get:o(function(){return HN.ApplicationErrorHandler},"get")})});var $n=v(y=>{"use strict";var zN=y&&y.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),un=y&&y.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&zN(e,n,t)};Object.defineProperty(y,"__esModule",{value:!0});y.validateParameters=y.fillTemplate=y.findMatchingTemplates=y.KNOWN_PROTOTYPES=y.EFFORT_STATUSES=y.ASSET_CLASSES=y.PREDICATES=y.SPARQL_PREFIXES=y.SPARQL_TEMPLATES=y.DEFAULT_NL_TO_SPARQL_CONFIG=y.NLToSPARQLService=y.TypeRegistry=y.GraphQueryService=y.DEFAULT_SEMANTIC_SEARCH_CONFIG=y.SemanticSearchService=y.DEFAULT_VECTOR_STORE_CONFIG=y.VectorStore=y.DEFAULT_EMBEDDING_CONFIG=y.EmbeddingService=y.GenericAssetCreationService=y.WebhookService=y.URIConstructionService=y.SessionEventService=y.AssetConversionService=y.PlanningService=y.AlgorithmExtractor=y.DynamicFrontmatterGenerator=y.TaskFrontmatterGenerator=y.FleetingNoteCreationService=y.SupervisionCreationService=y.StatusTimestampService=y.RenameToUidService=y.PropertyCleanupService=y.LoggingService=y.LabelToAliasService=y.FolderRepairService=y.EffortVotingService=y.EffortStatusWorkflow=y.ConceptCreationService=y.ClassCreationService=y.AreaHierarchyBuilder=y.AreaCreationService=y.TaskStatusService=y.ProjectCreationService=y.TaskCreationService=y.extractPropertyLabel=y.uriToPropertyName=y.propertyNameToUri=y.rangeToFieldType=y.PropertyFieldType=void 0;y.SPARQLResultCache=y.QueryPlanCache=y.createDoubleLiteral=y.createDecimalLiteral=y.getNumericValue=y.createPercentileAggregate=y.modeAggregate=y.stddevAggregate=y.varianceAggregate=y.medianAggregate=y.EXO_AGGREGATE_NS=y.BUILT_IN_AGGREGATES=y.CustomAggregateError=y.CustomAggregateRegistry=y.AggregateFunctions=y.BuiltInFunctions=y.SolutionMapping=y.UpdateExecutorError=y.UpdateExecutor=y.QueryExecutor=y.DescribeExecutor=y.ConstructExecutor=y.UnionExecutor=y.OptionalExecutor=y.FilterExecutor=y.BGPExecutor=y.AlgebraSerializer=y.AlgebraOptimizer=y.AlgebraTranslator=y.DescribeOptionsTransformerError=y.DescribeOptionsTransformer=y.SPARQLParseError=y.SPARQLParser=y.NoteToRDFConverter=y.RDFVocabularyMapper=y.InMemoryTripleStore=y.RDFSerializer=y.FilenameValidator=y.EffortSortingHelpers=y.MetadataExtractor=y.MetadataHelpers=y.WikiLinkHelpers=y.DateFormatter=y.FrontmatterService=y.DailyReviewService=y.DEFAULT_AUTOCOMPLETE_CONFIG=y.AutocompleteService=y.TrendDetectionService=y.AnalyticsService=y.getTemplateByName=void 0;y.createStreamingSource=y.StreamingLoader=y.resetGlobalPool=y.getGlobalPool=y.MemoryPool=y.CompactGraphStore=y.StringTable=y.DEFAULT_COLORS=y.NODE_FLAGS=y.container=y.resetContainer=y.getContainer=y.createChildContainer=y.registerCoreServices=y.DI_TOKENS=y.TransactionError=y.TripleNotFoundError=y.TripleAlreadyExistsError=y.FileAlreadyExistsError=y.FileNotFoundError=y.FilterContainsOptimizer=y.CaseWhenTransformerError=y.CaseWhenTransformer=y.ResultSerializer=y.createIncrementalIndexer=y.IncrementalIndexer=y.createSPARQLResultCache=void 0;un(Kd(),y);un(Xd(),y);un(k2(),y);un(M2(),y);un(Jd(),y);un(Zd(),y);un($2(),y);un(B2(),y);un(Np(),y);un(Dv(),y);var Cb=jp();Object.defineProperty(y,"PropertyFieldType",{enumerable:!0,get:o(function(){return Cb.PropertyFieldType},"get")});Object.defineProperty(y,"rangeToFieldType",{enumerable:!0,get:o(function(){return Cb.rangeToFieldType},"get")});var A0=Nv();Object.defineProperty(y,"propertyNameToUri",{enumerable:!0,get:o(function(){return A0.propertyNameToUri},"get")});Object.defineProperty(y,"uriToPropertyName",{enumerable:!0,get:o(function(){return A0.uriToPropertyName},"get")});Object.defineProperty(y,"extractPropertyLabel",{enumerable:!0,get:o(function(){return A0.extractPropertyLabel},"get")});var QN=Im();Object.defineProperty(y,"TaskCreationService",{enumerable:!0,get:o(function(){return QN.TaskCreationService},"get")});var YN=Pm();Object.defineProperty(y,"ProjectCreationService",{enumerable:!0,get:o(function(){return YN.ProjectCreationService},"get")});var KN=Nm();Object.defineProperty(y,"TaskStatusService",{enumerable:!0,get:o(function(){return KN.TaskStatusService},"get")});var XN=km();Object.defineProperty(y,"AreaCreationService",{enumerable:!0,get:o(function(){return XN.AreaCreationService},"get")});var JN=jm();Object.defineProperty(y,"AreaHierarchyBuilder",{enumerable:!0,get:o(function(){return JN.AreaHierarchyBuilder},"get")});var ZN=Vm();Object.defineProperty(y,"ClassCreationService",{enumerable:!0,get:o(function(){return ZN.ClassCreationService},"get")});var e5=Bm();Object.defineProperty(y,"ConceptCreationService",{enumerable:!0,get:o(function(){return e5.ConceptCreationService},"get")});var t5=Ql();Object.defineProperty(y,"EffortStatusWorkflow",{enumerable:!0,get:o(function(){return t5.EffortStatusWorkflow},"get")});var r5=Gm();Object.defineProperty(y,"EffortVotingService",{enumerable:!0,get:o(function(){return r5.EffortVotingService},"get")});var n5=Hm();Object.defineProperty(y,"FolderRepairService",{enumerable:!0,get:o(function(){return n5.FolderRepairService},"get")});var i5=Qm();Object.defineProperty(y,"LabelToAliasService",{enumerable:!0,get:o(function(){return i5.LabelToAliasService},"get")});var s5=Ji();Object.defineProperty(y,"LoggingService",{enumerable:!0,get:o(function(){return s5.LoggingService},"get")});var a5=Xm();Object.defineProperty(y,"PropertyCleanupService",{enumerable:!0,get:o(function(){return a5.PropertyCleanupService},"get")});var o5=Zm();Object.defineProperty(y,"RenameToUidService",{enumerable:!0,get:o(function(){return o5.RenameToUidService},"get")});var c5=Yl();Object.defineProperty(y,"StatusTimestampService",{enumerable:!0,get:o(function(){return c5.StatusTimestampService},"get")});var u5=tg();Object.defineProperty(y,"SupervisionCreationService",{enumerable:!0,get:o(function(){return u5.SupervisionCreationService},"get")});var l5=ng();Object.defineProperty(y,"FleetingNoteCreationService",{enumerable:!0,get:o(function(){return l5.FleetingNoteCreationService},"get")});var f5=Bl();Object.defineProperty(y,"TaskFrontmatterGenerator",{enumerable:!0,get:o(function(){return f5.TaskFrontmatterGenerator},"get")});var h5=sg();Object.defineProperty(y,"DynamicFrontmatterGenerator",{enumerable:!0,get:o(function(){return h5.DynamicFrontmatterGenerator},"get")});var d5=ql();Object.defineProperty(y,"AlgorithmExtractor",{enumerable:!0,get:o(function(){return d5.AlgorithmExtractor},"get")});var p5=og();Object.defineProperty(y,"PlanningService",{enumerable:!0,get:o(function(){return p5.PlanningService},"get")});var m5=ug();Object.defineProperty(y,"AssetConversionService",{enumerable:!0,get:o(function(){return m5.AssetConversionService},"get")});var g5=fg();Object.defineProperty(y,"SessionEventService",{enumerable:!0,get:o(function(){return g5.SessionEventService},"get")});var y5=dg();Object.defineProperty(y,"URIConstructionService",{enumerable:!0,get:o(function(){return y5.URIConstructionService},"get")});var v5=MS();Object.defineProperty(y,"WebhookService",{enumerable:!0,get:o(function(){return v5.WebhookService},"get")});var S5=gg();Object.defineProperty(y,"GenericAssetCreationService",{enumerable:!0,get:o(function(){return S5.GenericAssetCreationService},"get")});var Ib=vg();Object.defineProperty(y,"EmbeddingService",{enumerable:!0,get:o(function(){return Ib.EmbeddingService},"get")});Object.defineProperty(y,"DEFAULT_EMBEDDING_CONFIG",{enumerable:!0,get:o(function(){return Ib.DEFAULT_EMBEDDING_CONFIG},"get")});var Ob=bg();Object.defineProperty(y,"VectorStore",{enumerable:!0,get:o(function(){return Ob.VectorStore},"get")});Object.defineProperty(y,"DEFAULT_VECTOR_STORE_CONFIG",{enumerable:!0,get:o(function(){return Ob.DEFAULT_VECTOR_STORE_CONFIG},"get")});var Pb=US();Object.defineProperty(y,"SemanticSearchService",{enumerable:!0,get:o(function(){return Pb.SemanticSearchService},"get")});Object.defineProperty(y,"DEFAULT_SEMANTIC_SEARCH_CONFIG",{enumerable:!0,get:o(function(){return Pb.DEFAULT_SEMANTIC_SEARCH_CONFIG},"get")});var _5=BS();Object.defineProperty(y,"GraphQueryService",{enumerable:!0,get:o(function(){return _5.GraphQueryService},"get")});var b5=GS();Object.defineProperty(y,"TypeRegistry",{enumerable:!0,get:o(function(){return b5.TypeRegistry},"get")});var Db=WS();Object.defineProperty(y,"NLToSPARQLService",{enumerable:!0,get:o(function(){return Db.NLToSPARQLService},"get")});Object.defineProperty(y,"DEFAULT_NL_TO_SPARQL_CONFIG",{enumerable:!0,get:o(function(){return Db.DEFAULT_NL_TO_SPARQL_CONFIG},"get")});var ci=Ag();Object.defineProperty(y,"SPARQL_TEMPLATES",{enumerable:!0,get:o(function(){return ci.SPARQL_TEMPLATES},"get")});Object.defineProperty(y,"SPARQL_PREFIXES",{enumerable:!0,get:o(function(){return ci.SPARQL_PREFIXES},"get")});Object.defineProperty(y,"PREDICATES",{enumerable:!0,get:o(function(){return ci.PREDICATES},"get")});Object.defineProperty(y,"ASSET_CLASSES",{enumerable:!0,get:o(function(){return ci.ASSET_CLASSES},"get")});Object.defineProperty(y,"EFFORT_STATUSES",{enumerable:!0,get:o(function(){return ci.EFFORT_STATUSES},"get")});Object.defineProperty(y,"KNOWN_PROTOTYPES",{enumerable:!0,get:o(function(){return ci.KNOWN_PROTOTYPES},"get")});Object.defineProperty(y,"findMatchingTemplates",{enumerable:!0,get:o(function(){return ci.findMatchingTemplates},"get")});Object.defineProperty(y,"fillTemplate",{enumerable:!0,get:o(function(){return ci.fillTemplate},"get")});Object.defineProperty(y,"validateParameters",{enumerable:!0,get:o(function(){return ci.validateParameters},"get")});Object.defineProperty(y,"getTemplateByName",{enumerable:!0,get:o(function(){return ci.getTemplateByName},"get")});var w5=zS();Object.defineProperty(y,"AnalyticsService",{enumerable:!0,get:o(function(){return w5.AnalyticsService},"get")});var E5=QS();Object.defineProperty(y,"TrendDetectionService",{enumerable:!0,get:o(function(){return E5.TrendDetectionService},"get")});var Rb=KS();Object.defineProperty(y,"AutocompleteService",{enumerable:!0,get:o(function(){return Rb.AutocompleteService},"get")});Object.defineProperty(y,"DEFAULT_AUTOCOMPLETE_CONFIG",{enumerable:!0,get:o(function(){return Rb.DEFAULT_AUTOCOMPLETE_CONFIG},"get")});var T5=JS();Object.defineProperty(y,"DailyReviewService",{enumerable:!0,get:o(function(){return T5.DailyReviewService},"get")});var A5=Xi();Object.defineProperty(y,"FrontmatterService",{enumerable:!0,get:o(function(){return A5.FrontmatterService},"get")});var x5=Ht();Object.defineProperty(y,"DateFormatter",{enumerable:!0,get:o(function(){return x5.DateFormatter},"get")});var C5=Ls();Object.defineProperty(y,"WikiLinkHelpers",{enumerable:!0,get:o(function(){return C5.WikiLinkHelpers},"get")});var I5=en();Object.defineProperty(y,"MetadataHelpers",{enumerable:!0,get:o(function(){return I5.MetadataHelpers},"get")});var O5=bc();Object.defineProperty(y,"MetadataExtractor",{enumerable:!0,get:o(function(){return O5.MetadataExtractor},"get")});var P5=ZS();Object.defineProperty(y,"EffortSortingHelpers",{enumerable:!0,get:o(function(){return P5.EffortSortingHelpers},"get")});var D5=e_();Object.defineProperty(y,"FilenameValidator",{enumerable:!0,get:o(function(){return D5.FilenameValidator},"get")});var R5=o_();Object.defineProperty(y,"RDFSerializer",{enumerable:!0,get:o(function(){return R5.RDFSerializer},"get")});var F5=c_();Object.defineProperty(y,"InMemoryTripleStore",{enumerable:!0,get:o(function(){return F5.InMemoryTripleStore},"get")});var N5=Kg();Object.defineProperty(y,"RDFVocabularyMapper",{enumerable:!0,get:o(function(){return N5.RDFVocabularyMapper},"get")});var L5=Jg();Object.defineProperty(y,"NoteToRDFConverter",{enumerable:!0,get:o(function(){return L5.NoteToRDFConverter},"get")});var Fb=P_();Object.defineProperty(y,"SPARQLParser",{enumerable:!0,get:o(function(){return Fb.SPARQLParser},"get")});Object.defineProperty(y,"SPARQLParseError",{enumerable:!0,get:o(function(){return Fb.SPARQLParseError},"get")});var Nb=py();Object.defineProperty(y,"DescribeOptionsTransformer",{enumerable:!0,get:o(function(){return Nb.DescribeOptionsTransformer},"get")});Object.defineProperty(y,"DescribeOptionsTransformerError",{enumerable:!0,get:o(function(){return Nb.DescribeOptionsTransformerError},"get")});var k5=R_();Object.defineProperty(y,"AlgebraTranslator",{enumerable:!0,get:o(function(){return k5.AlgebraTranslator},"get")});var M5=F_();Object.defineProperty(y,"AlgebraOptimizer",{enumerable:!0,get:o(function(){return M5.AlgebraOptimizer},"get")});var j5=N_();Object.defineProperty(y,"AlgebraSerializer",{enumerable:!0,get:o(function(){return j5.AlgebraSerializer},"get")});var $5=Dy();Object.defineProperty(y,"BGPExecutor",{enumerable:!0,get:o(function(){return $5.BGPExecutor},"get")});var V5=jf();Object.defineProperty(y,"FilterExecutor",{enumerable:!0,get:o(function(){return V5.FilterExecutor},"get")});var U5=ky();Object.defineProperty(y,"OptionalExecutor",{enumerable:!0,get:o(function(){return U5.OptionalExecutor},"get")});var B5=jy();Object.defineProperty(y,"UnionExecutor",{enumerable:!0,get:o(function(){return B5.UnionExecutor},"get")});var q5=By();Object.defineProperty(y,"ConstructExecutor",{enumerable:!0,get:o(function(){return q5.ConstructExecutor},"get")});var G5=U_();Object.defineProperty(y,"DescribeExecutor",{enumerable:!0,get:o(function(){return G5.DescribeExecutor},"get")});var W5=Z_();Object.defineProperty(y,"QueryExecutor",{enumerable:!0,get:o(function(){return W5.QueryExecutor},"get")});var Lb=tb();Object.defineProperty(y,"UpdateExecutor",{enumerable:!0,get:o(function(){return Lb.UpdateExecutor},"get")});Object.defineProperty(y,"UpdateExecutorError",{enumerable:!0,get:o(function(){return Lb.UpdateExecutorError},"get")});var H5=Ni();Object.defineProperty(y,"SolutionMapping",{enumerable:!0,get:o(function(){return H5.SolutionMapping},"get")});var z5=Fy();Object.defineProperty(y,"BuiltInFunctions",{enumerable:!0,get:o(function(){return z5.BuiltInFunctions},"get")});var Q5=nb();Object.defineProperty(y,"AggregateFunctions",{enumerable:!0,get:o(function(){return Q5.AggregateFunctions},"get")});var kb=Hy();Object.defineProperty(y,"CustomAggregateRegistry",{enumerable:!0,get:o(function(){return kb.CustomAggregateRegistry},"get")});Object.defineProperty(y,"CustomAggregateError",{enumerable:!0,get:o(function(){return kb.CustomAggregateError},"get")});var ui=zy();Object.defineProperty(y,"BUILT_IN_AGGREGATES",{enumerable:!0,get:o(function(){return ui.BUILT_IN_AGGREGATES},"get")});Object.defineProperty(y,"EXO_AGGREGATE_NS",{enumerable:!0,get:o(function(){return ui.EXO_AGGREGATE_NS},"get")});Object.defineProperty(y,"medianAggregate",{enumerable:!0,get:o(function(){return ui.medianAggregate},"get")});Object.defineProperty(y,"varianceAggregate",{enumerable:!0,get:o(function(){return ui.varianceAggregate},"get")});Object.defineProperty(y,"stddevAggregate",{enumerable:!0,get:o(function(){return ui.stddevAggregate},"get")});Object.defineProperty(y,"modeAggregate",{enumerable:!0,get:o(function(){return ui.modeAggregate},"get")});Object.defineProperty(y,"createPercentileAggregate",{enumerable:!0,get:o(function(){return ui.createPercentileAggregate},"get")});Object.defineProperty(y,"getNumericValue",{enumerable:!0,get:o(function(){return ui.getNumericValue},"get")});Object.defineProperty(y,"createDecimalLiteral",{enumerable:!0,get:o(function(){return ui.createDecimalLiteral},"get")});Object.defineProperty(y,"createDoubleLiteral",{enumerable:!0,get:o(function(){return ui.createDoubleLiteral},"get")});var Y5=ib();Object.defineProperty(y,"QueryPlanCache",{enumerable:!0,get:o(function(){return Y5.QueryPlanCache},"get")});var Mb=sb();Object.defineProperty(y,"SPARQLResultCache",{enumerable:!0,get:o(function(){return Mb.SPARQLResultCache},"get")});Object.defineProperty(y,"createSPARQLResultCache",{enumerable:!0,get:o(function(){return Mb.createSPARQLResultCache},"get")});var jb=ab();Object.defineProperty(y,"IncrementalIndexer",{enumerable:!0,get:o(function(){return jb.IncrementalIndexer},"get")});Object.defineProperty(y,"createIncrementalIndexer",{enumerable:!0,get:o(function(){return jb.createIncrementalIndexer},"get")});var K5=ob();Object.defineProperty(y,"ResultSerializer",{enumerable:!0,get:o(function(){return K5.ResultSerializer},"get")});var $b=fy();Object.defineProperty(y,"CaseWhenTransformer",{enumerable:!0,get:o(function(){return $b.CaseWhenTransformer},"get")});Object.defineProperty(y,"CaseWhenTransformerError",{enumerable:!0,get:o(function(){return $b.CaseWhenTransformerError},"get")});var X5=Ty();Object.defineProperty(y,"FilterContainsOptimizer",{enumerable:!0,get:o(function(){return X5.FilterContainsOptimizer},"get")});var Vb=cb();Object.defineProperty(y,"FileNotFoundError",{enumerable:!0,get:o(function(){return Vb.FileNotFoundError},"get")});Object.defineProperty(y,"FileAlreadyExistsError",{enumerable:!0,get:o(function(){return Vb.FileAlreadyExistsError},"get")});var x0=Wg();Object.defineProperty(y,"TripleAlreadyExistsError",{enumerable:!0,get:o(function(){return x0.TripleAlreadyExistsError},"get")});Object.defineProperty(y,"TripleNotFoundError",{enumerable:!0,get:o(function(){return x0.TripleNotFoundError},"get")});Object.defineProperty(y,"TransactionError",{enumerable:!0,get:o(function(){return x0.TransactionError},"get")});var J5=ct();Object.defineProperty(y,"DI_TOKENS",{enumerable:!0,get:o(function(){return J5.DI_TOKENS},"get")});var Vc=ub();Object.defineProperty(y,"registerCoreServices",{enumerable:!0,get:o(function(){return Vc.registerCoreServices},"get")});Object.defineProperty(y,"createChildContainer",{enumerable:!0,get:o(function(){return Vc.createChildContainer},"get")});Object.defineProperty(y,"getContainer",{enumerable:!0,get:o(function(){return Vc.getContainer},"get")});Object.defineProperty(y,"resetContainer",{enumerable:!0,get:o(function(){return Vc.resetContainer},"get")});Object.defineProperty(y,"container",{enumerable:!0,get:o(function(){return Vc.container},"get")});var Li=mb();Object.defineProperty(y,"NODE_FLAGS",{enumerable:!0,get:o(function(){return Li.NODE_FLAGS},"get")});Object.defineProperty(y,"DEFAULT_COLORS",{enumerable:!0,get:o(function(){return Li.DEFAULT_COLORS},"get")});Object.defineProperty(y,"StringTable",{enumerable:!0,get:o(function(){return Li.StringTable},"get")});Object.defineProperty(y,"CompactGraphStore",{enumerable:!0,get:o(function(){return Li.CompactGraphStore},"get")});Object.defineProperty(y,"MemoryPool",{enumerable:!0,get:o(function(){return Li.MemoryPool},"get")});Object.defineProperty(y,"getGlobalPool",{enumerable:!0,get:o(function(){return Li.getGlobalPool},"get")});Object.defineProperty(y,"resetGlobalPool",{enumerable:!0,get:o(function(){return Li.resetGlobalPool},"get")});Object.defineProperty(y,"StreamingLoader",{enumerable:!0,get:o(function(){return Li.StreamingLoader},"get")});Object.defineProperty(y,"createStreamingSource",{enumerable:!0,get:o(function(){return Li.createStreamingSource},"get")});un(Tb(),y);un(xb(),y)});var kt=v(C0=>{"use strict";C0.fromCallback=function(n){return Object.defineProperty(function(...e){if(typeof e[e.length-1]=="function")n.apply(this,e);else return new Promise((t,r)=>{e.push((i,s)=>i!=null?r(i):t(s)),n.apply(this,e)})},"name",{value:n.name})};C0.fromPromise=function(n){return Object.defineProperty(function(...e){let t=e[e.length-1];if(typeof t!="function")return n.apply(this,e);e.pop(),n.apply(this,e).then(r=>t(null,r),t)},"name",{value:n.name})}});var Bb=v((MW,Ub)=>{var os=require("constants"),Z5=process.cwd,yh=null,eL=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return yh||(yh=Z5.call(process)),yh};try{process.cwd()}catch{}typeof process.chdir=="function"&&(I0=process.chdir,process.chdir=function(n){yh=null,I0.call(process,n)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,I0));var I0;Ub.exports=tL;function tL(n){os.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(n),n.lutimes||t(n),n.chown=s(n.chown),n.fchown=s(n.fchown),n.lchown=s(n.lchown),n.chmod=r(n.chmod),n.fchmod=r(n.fchmod),n.lchmod=r(n.lchmod),n.chownSync=a(n.chownSync),n.fchownSync=a(n.fchownSync),n.lchownSync=a(n.lchownSync),n.chmodSync=i(n.chmodSync),n.fchmodSync=i(n.fchmodSync),n.lchmodSync=i(n.lchmodSync),n.stat=c(n.stat),n.fstat=c(n.fstat),n.lstat=c(n.lstat),n.statSync=u(n.statSync),n.fstatSync=u(n.fstatSync),n.lstatSync=u(n.lstatSync),n.chmod&&!n.lchmod&&(n.lchmod=function(f,h,d){d&&process.nextTick(d)},n.lchmodSync=function(){}),n.chown&&!n.lchown&&(n.lchown=function(f,h,d,p){p&&process.nextTick(p)},n.lchownSync=function(){}),eL==="win32"&&(n.rename=typeof n.rename!="function"?n.rename:(function(f){function h(d,p,S){var b=Date.now(),T=0;f(d,p,o(function I(O){if(O&&(O.code==="EACCES"||O.code==="EPERM"||O.code==="EBUSY")&&Date.now()-b<6e4){setTimeout(function(){n.stat(p,function(L,M){L&&L.code==="ENOENT"?f(d,p,I):S(O)})},T),T<100&&(T+=10);return}S&&S(O)},"CB"))}return o(h,"rename"),Object.setPrototypeOf&&Object.setPrototypeOf(h,f),h})(n.rename)),n.read=typeof n.read!="function"?n.read:(function(f){function h(d,p,S,b,T,I){var O;if(I&&typeof I=="function"){var L=0;O=o(function(M,G,Ee){if(M&&M.code==="EAGAIN"&&L<10)return L++,f.call(n,d,p,S,b,T,O);I.apply(this,arguments)},"callback")}return f.call(n,d,p,S,b,T,O)}return o(h,"read"),Object.setPrototypeOf&&Object.setPrototypeOf(h,f),h})(n.read),n.readSync=typeof n.readSync!="function"?n.readSync:(function(f){return function(h,d,p,S,b){for(var T=0;;)try{return f.call(n,h,d,p,S,b)}catch(I){if(I.code==="EAGAIN"&&T<10){T++;continue}throw I}}})(n.readSync);function e(f){f.lchmod=function(h,d,p){f.open(h,os.O_WRONLY|os.O_SYMLINK,d,function(S,b){if(S){p&&p(S);return}f.fchmod(b,d,function(T){f.close(b,function(I){p&&p(T||I)})})})},f.lchmodSync=function(h,d){var p=f.openSync(h,os.O_WRONLY|os.O_SYMLINK,d),S=!0,b;try{b=f.fchmodSync(p,d),S=!1}finally{if(S)try{f.closeSync(p)}catch{}else f.closeSync(p)}return b}}o(e,"patchLchmod");function t(f){os.hasOwnProperty("O_SYMLINK")&&f.futimes?(f.lutimes=function(h,d,p,S){f.open(h,os.O_SYMLINK,function(b,T){if(b){S&&S(b);return}f.futimes(T,d,p,function(I){f.close(T,function(O){S&&S(I||O)})})})},f.lutimesSync=function(h,d,p){var S=f.openSync(h,os.O_SYMLINK),b,T=!0;try{b=f.futimesSync(S,d,p),T=!1}finally{if(T)try{f.closeSync(S)}catch{}else f.closeSync(S)}return b}):f.futimes&&(f.lutimes=function(h,d,p,S){S&&process.nextTick(S)},f.lutimesSync=function(){})}o(t,"patchLutimes");function r(f){return f&&function(h,d,p){return f.call(n,h,d,function(S){l(S)&&(S=null),p&&p.apply(this,arguments)})}}o(r,"chmodFix");function i(f){return f&&function(h,d){try{return f.call(n,h,d)}catch(p){if(!l(p))throw p}}}o(i,"chmodFixSync");function s(f){return f&&function(h,d,p,S){return f.call(n,h,d,p,function(b){l(b)&&(b=null),S&&S.apply(this,arguments)})}}o(s,"chownFix");function a(f){return f&&function(h,d,p){try{return f.call(n,h,d,p)}catch(S){if(!l(S))throw S}}}o(a,"chownFixSync");function c(f){return f&&function(h,d,p){typeof d=="function"&&(p=d,d=null);function S(b,T){T&&(T.uid<0&&(T.uid+=4294967296),T.gid<0&&(T.gid+=4294967296)),p&&p.apply(this,arguments)}return o(S,"callback"),d?f.call(n,h,d,S):f.call(n,h,S)}}o(c,"statFix");function u(f){return f&&function(h,d){var p=d?f.call(n,h,d):f.call(n,h);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}o(u,"statFixSync");function l(f){if(!f||f.code==="ENOSYS")return!0;var h=!process.getuid||process.getuid()!==0;return!!(h&&(f.code==="EINVAL"||f.code==="EPERM"))}o(l,"chownErOk")}o(tL,"patch")});var Wb=v(($W,Gb)=>{var qb=require("stream").Stream;Gb.exports=rL;function rL(n){return{ReadStream:e,WriteStream:t};function e(r,i){if(!(this instanceof e))return new e(r,i);qb.call(this);var s=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var a=Object.keys(i),c=0,u=a.length;c<u;c++){var l=a[c];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){s._read()});return}n.open(this.path,this.flags,this.mode,function(f,h){if(f){s.emit("error",f),s.readable=!1;return}s.fd=h,s.emit("open",h),s._read()})}function t(r,i){if(!(this instanceof t))return new t(r,i);qb.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var s=Object.keys(i),a=0,c=s.length;a<c;a++){var u=s[a];this[u]=i[u]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=n.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}o(rL,"legacy")});var zb=v((UW,Hb)=>{"use strict";Hb.exports=iL;var nL=Object.getPrototypeOf||function(n){return n.__proto__};function iL(n){if(n===null||typeof n!="object")return n;if(n instanceof Object)var e={__proto__:nL(n)};else var e=Object.create(null);return Object.getOwnPropertyNames(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}o(iL,"clone")});var So=v((qW,D0)=>{var pt=require("fs"),sL=Bb(),aL=Wb(),oL=zb(),vh=require("util"),Yt,_h;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Yt=Symbol.for("graceful-fs.queue"),_h=Symbol.for("graceful-fs.previous")):(Yt="___graceful-fs.queue",_h="___graceful-fs.previous");function cL(){}o(cL,"noop");function Kb(n,e){Object.defineProperty(n,Yt,{get:o(function(){return e},"get")})}o(Kb,"publishQueue");var ca=cL;vh.debuglog?ca=vh.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ca=o(function(){var n=vh.format.apply(vh,arguments);n="GFS4: "+n.split(/\n/).join(`
|
|
357
|
-
GFS4: `),console.error(n)},"debug"));pt[Yt]||(Qb=global[Yt]||[],Kb(pt,Qb),pt.close=(function(n){function e(t,r){return n.call(pt,t,function(i){i||Yb(),typeof r=="function"&&r.apply(this,arguments)})}return o(e,"close"),Object.defineProperty(e,_h,{value:n}),e})(pt.close),pt.closeSync=(function(n){function e(t){n.apply(pt,arguments),Yb()}return o(e,"closeSync"),Object.defineProperty(e,_h,{value:n}),e})(pt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ca(pt[Yt]),require("assert").equal(pt[Yt].length,0)}));var Qb;global[Yt]||Kb(global,pt[Yt]);D0.exports=O0(oL(pt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!pt.__patched&&(D0.exports=O0(pt),pt.__patched=!0);function O0(n){sL(n),n.gracefulify=O0,n.createReadStream=G,n.createWriteStream=Ee;var e=n.readFile;n.readFile=t;function t(q,ie,Se){return typeof ie=="function"&&(Se=ie,ie=null),nt(q,ie,Se);function nt(Ke,at,Ue,Be){return e(Ke,at,function(ke){ke&&(ke.code==="EMFILE"||ke.code==="ENFILE")?vo([nt,[Ke,at,Ue],ke,Be||Date.now(),Date.now()]):typeof Ue=="function"&&Ue.apply(this,arguments)})}o(nt,"go$readFile")}o(t,"readFile");var r=n.writeFile;n.writeFile=i;function i(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=null),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return r(at,Ue,Be,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$writeFile")}o(i,"writeFile");var s=n.appendFile;s&&(n.appendFile=a);function a(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=null),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return s(at,Ue,Be,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$appendFile")}o(a,"appendFile");var c=n.copyFile;c&&(n.copyFile=u);function u(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=0),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return c(at,Ue,Be,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$copyFile")}o(u,"copyFile");var l=n.readdir;n.readdir=h;var f=/^v[0-5]\./;function h(q,ie,Se){typeof ie=="function"&&(Se=ie,ie=null);var nt=f.test(process.version)?o(function(Ue,Be,ke,Q){return l(Ue,Ke(Ue,Be,ke,Q))},"go$readdir"):o(function(Ue,Be,ke,Q){return l(Ue,Be,Ke(Ue,Be,ke,Q))},"go$readdir");return nt(q,ie,Se);function Ke(at,Ue,Be,ke){return function(Q,k){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?vo([nt,[at,Ue,Be],Q,ke||Date.now(),Date.now()]):(k&&k.sort&&k.sort(),typeof Be=="function"&&Be.call(this,Q,k))}}}if(o(h,"readdir"),process.version.substr(0,4)==="v0.8"){var d=aL(n);I=d.ReadStream,L=d.WriteStream}var p=n.ReadStream;p&&(I.prototype=Object.create(p.prototype),I.prototype.open=O);var S=n.WriteStream;S&&(L.prototype=Object.create(S.prototype),L.prototype.open=M),Object.defineProperty(n,"ReadStream",{get:o(function(){return I},"get"),set:o(function(q){I=q},"set"),enumerable:!0,configurable:!0}),Object.defineProperty(n,"WriteStream",{get:o(function(){return L},"get"),set:o(function(q){L=q},"set"),enumerable:!0,configurable:!0});var b=I;Object.defineProperty(n,"FileReadStream",{get:o(function(){return b},"get"),set:o(function(q){b=q},"set"),enumerable:!0,configurable:!0});var T=L;Object.defineProperty(n,"FileWriteStream",{get:o(function(){return T},"get"),set:o(function(q){T=q},"set"),enumerable:!0,configurable:!0});function I(q,ie){return this instanceof I?(p.apply(this,arguments),this):I.apply(Object.create(I.prototype),arguments)}o(I,"ReadStream");function O(){var q=this;Me(q.path,q.flags,q.mode,function(ie,Se){ie?(q.autoClose&&q.destroy(),q.emit("error",ie)):(q.fd=Se,q.emit("open",Se),q.read())})}o(O,"ReadStream$open");function L(q,ie){return this instanceof L?(S.apply(this,arguments),this):L.apply(Object.create(L.prototype),arguments)}o(L,"WriteStream");function M(){var q=this;Me(q.path,q.flags,q.mode,function(ie,Se){ie?(q.destroy(),q.emit("error",ie)):(q.fd=Se,q.emit("open",Se))})}o(M,"WriteStream$open");function G(q,ie){return new n.ReadStream(q,ie)}o(G,"createReadStream");function Ee(q,ie){return new n.WriteStream(q,ie)}o(Ee,"createWriteStream");var je=n.open;n.open=Me;function Me(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=null),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return je(at,Ue,Be,function(k,qe){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$open")}return o(Me,"open"),n}o(O0,"patch");function vo(n){ca("ENQUEUE",n[0].name,n[1]),pt[Yt].push(n),P0()}o(vo,"enqueue");var Sh;function Yb(){for(var n=Date.now(),e=0;e<pt[Yt].length;++e)pt[Yt][e].length>2&&(pt[Yt][e][3]=n,pt[Yt][e][4]=n);P0()}o(Yb,"resetQueue");function P0(){if(clearTimeout(Sh),Sh=void 0,pt[Yt].length!==0){var n=pt[Yt].shift(),e=n[0],t=n[1],r=n[2],i=n[3],s=n[4];if(i===void 0)ca("RETRY",e.name,t),e.apply(null,t);else if(Date.now()-i>=6e4){ca("TIMEOUT",e.name,t);var a=t.pop();typeof a=="function"&&a.call(null,r)}else{var c=Date.now()-s,u=Math.max(s-i,1),l=Math.min(u*1.2,100);c>=l?(ca("RETRY",e.name,t),e.apply(null,t.concat([i]))):pt[Yt].push(n)}Sh===void 0&&(Sh=setTimeout(P0,0))}}o(P0,"retry")});var wr=v(ki=>{"use strict";var Xb=kt().fromCallback,br=So(),uL=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(n=>typeof br[n]=="function");Object.assign(ki,br);uL.forEach(n=>{ki[n]=Xb(br[n])});ki.exists=function(n,e){return typeof e=="function"?br.exists(n,e):new Promise(t=>br.exists(n,t))};ki.read=function(n,e,t,r,i,s){return typeof s=="function"?br.read(n,e,t,r,i,s):new Promise((a,c)=>{br.read(n,e,t,r,i,(u,l,f)=>{if(u)return c(u);a({bytesRead:l,buffer:f})})})};ki.write=function(n,e,...t){return typeof t[t.length-1]=="function"?br.write(n,e,...t):new Promise((r,i)=>{br.write(n,e,...t,(s,a,c)=>{if(s)return i(s);r({bytesWritten:a,buffer:c})})})};ki.readv=function(n,e,...t){return typeof t[t.length-1]=="function"?br.readv(n,e,...t):new Promise((r,i)=>{br.readv(n,e,...t,(s,a,c)=>{if(s)return i(s);r({bytesRead:a,buffers:c})})})};ki.writev=function(n,e,...t){return typeof t[t.length-1]=="function"?br.writev(n,e,...t):new Promise((r,i)=>{br.writev(n,e,...t,(s,a,c)=>{if(s)return i(s);r({bytesWritten:a,buffers:c})})})};typeof br.realpath.native=="function"?ki.realpath.native=Xb(br.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var Zb=v((HW,Jb)=>{"use strict";var lL=require("path");Jb.exports.checkPath=o(function(e){if(process.platform==="win32"&&/[<>:"|?*]/.test(e.replace(lL.parse(e).root,""))){let r=new Error(`Path contains invalid characters: ${e}`);throw r.code="EINVAL",r}},"checkPath")});var nw=v((QW,R0)=>{"use strict";var ew=wr(),{checkPath:tw}=Zb(),rw=o(n=>{let e={mode:511};return typeof n=="number"?n:{...e,...n}.mode},"getMode");R0.exports.makeDir=async(n,e)=>(tw(n),ew.mkdir(n,{mode:rw(e),recursive:!0}));R0.exports.makeDirSync=(n,e)=>(tw(n),ew.mkdirSync(n,{mode:rw(e),recursive:!0}))});var Vn=v((KW,iw)=>{"use strict";var fL=kt().fromPromise,{makeDir:hL,makeDirSync:F0}=nw(),N0=fL(hL);iw.exports={mkdirs:N0,mkdirsSync:F0,mkdirp:N0,mkdirpSync:F0,ensureDir:N0,ensureDirSync:F0}});var cs=v((XW,aw)=>{"use strict";var dL=kt().fromPromise,sw=wr();function pL(n){return sw.access(n).then(()=>!0).catch(()=>!1)}o(pL,"pathExists");aw.exports={pathExists:dL(pL),pathExistsSync:sw.existsSync}});var L0=v((ZW,ow)=>{"use strict";var _o=wr(),mL=kt().fromPromise;async function gL(n,e,t){let r=await _o.open(n,"r+"),i=null;try{await _o.futimes(r,e,t)}finally{try{await _o.close(r)}catch(s){i=s}}if(i)throw i}o(gL,"utimesMillis");function yL(n,e,t){let r=_o.openSync(n,"r+");return _o.futimesSync(r,e,t),_o.closeSync(r)}o(yL,"utimesMillisSync");ow.exports={utimesMillis:mL(gL),utimesMillisSync:yL}});var ua=v((tH,fw)=>{"use strict";var bo=wr(),Mt=require("path"),cw=kt().fromPromise;function vL(n,e,t){let r=t.dereference?i=>bo.stat(i,{bigint:!0}):i=>bo.lstat(i,{bigint:!0});return Promise.all([r(n),r(e).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,s])=>({srcStat:i,destStat:s}))}o(vL,"getStats");function SL(n,e,t){let r,i=t.dereference?a=>bo.statSync(a,{bigint:!0}):a=>bo.lstatSync(a,{bigint:!0}),s=i(n);try{r=i(e)}catch(a){if(a.code==="ENOENT")return{srcStat:s,destStat:null};throw a}return{srcStat:s,destStat:r}}o(SL,"getStatsSync");async function _L(n,e,t,r){let{srcStat:i,destStat:s}=await vL(n,e,r);if(s){if(Uc(i,s)){let a=Mt.basename(n),c=Mt.basename(e);if(t==="move"&&a!==c&&a.toLowerCase()===c.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&k0(n,e))throw new Error(bh(n,e,t));return{srcStat:i,destStat:s}}o(_L,"checkPaths");function bL(n,e,t,r){let{srcStat:i,destStat:s}=SL(n,e,r);if(s){if(Uc(i,s)){let a=Mt.basename(n),c=Mt.basename(e);if(t==="move"&&a!==c&&a.toLowerCase()===c.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&k0(n,e))throw new Error(bh(n,e,t));return{srcStat:i,destStat:s}}o(bL,"checkPathsSync");async function uw(n,e,t,r){let i=Mt.resolve(Mt.dirname(n)),s=Mt.resolve(Mt.dirname(t));if(s===i||s===Mt.parse(s).root)return;let a;try{a=await bo.stat(s,{bigint:!0})}catch(c){if(c.code==="ENOENT")return;throw c}if(Uc(e,a))throw new Error(bh(n,t,r));return uw(n,e,s,r)}o(uw,"checkParentPaths");function lw(n,e,t,r){let i=Mt.resolve(Mt.dirname(n)),s=Mt.resolve(Mt.dirname(t));if(s===i||s===Mt.parse(s).root)return;let a;try{a=bo.statSync(s,{bigint:!0})}catch(c){if(c.code==="ENOENT")return;throw c}if(Uc(e,a))throw new Error(bh(n,t,r));return lw(n,e,s,r)}o(lw,"checkParentPathsSync");function Uc(n,e){return e.ino!==void 0&&e.dev!==void 0&&e.ino===n.ino&&e.dev===n.dev}o(Uc,"areIdentical");function k0(n,e){let t=Mt.resolve(n).split(Mt.sep).filter(i=>i),r=Mt.resolve(e).split(Mt.sep).filter(i=>i);return t.every((i,s)=>r[s]===i)}o(k0,"isSrcSubdir");function bh(n,e,t){return`Cannot ${t} '${n}' to a subdirectory of itself, '${e}'.`}o(bh,"errMsg");fw.exports={checkPaths:cw(_L),checkPathsSync:bL,checkParentPaths:cw(uw),checkParentPathsSync:lw,isSrcSubdir:k0,areIdentical:Uc}});var dw=v((nH,hw)=>{"use strict";async function wL(n,e){let t=[];for await(let r of n)t.push(e(r).then(()=>null,i=>i??new Error("unknown error")));await Promise.all(t.map(r=>r.then(i=>{if(i!==null)throw i})))}o(wL,"asyncIteratorConcurrentProcess");hw.exports={asyncIteratorConcurrentProcess:wL}});var vw=v((sH,yw)=>{"use strict";var or=wr(),Bc=require("path"),{mkdirs:EL}=Vn(),{pathExists:TL}=cs(),{utimesMillis:AL}=L0(),qc=ua(),{asyncIteratorConcurrentProcess:xL}=dw();async function CL(n,e,t={}){typeof t=="function"&&(t={filter:t}),t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
355
|
+
\u2022 Contact support if the issue persists`}};mh.ServiceError=T0});var Cb=v(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.ServiceError=Ct.ResourceExhaustedError=Ct.NotFoundError=Ct.PermissionError=Ct.StateTransitionError=Ct.NetworkError=Ct.ValidationError=Ct.ApplicationError=Ct.ErrorCode=void 0;var $N=ai();Object.defineProperty(Ct,"ErrorCode",{enumerable:!0,get:o(function(){return $N.ErrorCode},"get")});var VN=oi();Object.defineProperty(Ct,"ApplicationError",{enumerable:!0,get:o(function(){return VN.ApplicationError},"get")});var UN=_b();Object.defineProperty(Ct,"ValidationError",{enumerable:!0,get:o(function(){return UN.ValidationError},"get")});var BN=bb();Object.defineProperty(Ct,"NetworkError",{enumerable:!0,get:o(function(){return BN.NetworkError},"get")});var qN=wb();Object.defineProperty(Ct,"StateTransitionError",{enumerable:!0,get:o(function(){return qN.StateTransitionError},"get")});var GN=Eb();Object.defineProperty(Ct,"PermissionError",{enumerable:!0,get:o(function(){return GN.PermissionError},"get")});var WN=Tb();Object.defineProperty(Ct,"NotFoundError",{enumerable:!0,get:o(function(){return WN.NotFoundError},"get")});var HN=Ab();Object.defineProperty(Ct,"ResourceExhaustedError",{enumerable:!0,get:o(function(){return HN.ResourceExhaustedError},"get")});var zN=xb();Object.defineProperty(Ct,"ServiceError",{enumerable:!0,get:o(function(){return zN.ServiceError},"get")})});var Ib=v(gh=>{"use strict";Object.defineProperty(gh,"__esModule",{value:!0});gh.ApplicationErrorHandler=void 0;var A0=oi(),QN=ai(),x0=class{static{o(this,"ApplicationErrorHandler")}constructor(e={},t,r){this.logger=t,this.notifier=r,this.telemetryHooks=new Set,this.retryConfig={maxRetries:e.maxRetries??3,initialDelayMs:e.initialDelayMs??1e3,backoffMultiplier:e.backoffMultiplier??2,maxDelayMs:e.maxDelayMs??1e4}}handle(e,t){let r=this.ensureApplicationError(e,t);return this.notifier&&this.notifier.error(r.message),this.callTelemetryHooks("onError",r,t),this.formatError(r)}async executeWithRetry(e,t){let r,i=0;for(;i<=this.retryConfig.maxRetries;)try{return await e()}catch(s){if(r=this.ensureApplicationError(s,t),!r.retriable||i>=this.retryConfig.maxRetries)throw this.callTelemetryHooks("onError",r,t),i>=this.retryConfig.maxRetries&&r.retriable&&this.callTelemetryHooks("onRetryExhausted",r,i+1),r;let a=this.calculateDelay(i);this.callTelemetryHooks("onRetry",r,i+1,a),this.logger?.debug(`Retrying after ${a}ms (attempt ${i+1}/${this.retryConfig.maxRetries})`),await this.sleep(a),i++}throw r}registerTelemetryHook(e){this.telemetryHooks.add(e)}unregisterTelemetryHook(e){this.telemetryHooks.delete(e)}ensureApplicationError(e,t){if(e instanceof A0.ApplicationError){if(t){let i=e,s={...e.context,...t};return new class extends A0.ApplicationError{constructor(){super(...arguments),this.code=i.code,this.retriable=i.retriable,this.guidance=i.guidance}}(e.message,s)}return e}return new class extends A0.ApplicationError{static{o(this,"UnknownError")}constructor(s,a){super(s,{originalError:a.name,...t}),this.code=QN.ErrorCode.UNKNOWN_ERROR,this.retriable=!1,this.guidance="An unexpected error occurred"}}(e.message,e)}formatError(e){let t=[];return t.push(`\u274C ${e.name}: ${e.message}`),e.guidance&&t.push(`\u{1F4A1} ${e.guidance}`),e.context&&Object.keys(e.context).length>0&&t.push(`Context: ${JSON.stringify(e.context,null,2)}`),t.join(`
|
|
356
|
+
`)}calculateDelay(e){let t=this.retryConfig.initialDelayMs*Math.pow(this.retryConfig.backoffMultiplier,e);return Math.min(t,this.retryConfig.maxDelayMs)}sleep(e){return new Promise(t=>setTimeout(t,e))}callTelemetryHooks(e,...t){for(let r of this.telemetryHooks)try{let i=r[e];i&&i.apply(r,t)}catch(i){console.error("Error in telemetry hook:",i)}}};gh.ApplicationErrorHandler=x0});var Ob=v(yh=>{"use strict";Object.defineProperty(yh,"__esModule",{value:!0});yh.ApplicationErrorHandler=void 0;var YN=Ib();Object.defineProperty(yh,"ApplicationErrorHandler",{enumerable:!0,get:o(function(){return YN.ApplicationErrorHandler},"get")})});var $n=v(y=>{"use strict";var KN=y&&y.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:o(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),un=y&&y.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&KN(e,n,t)};Object.defineProperty(y,"__esModule",{value:!0});y.validateParameters=y.fillTemplate=y.findMatchingTemplates=y.KNOWN_PROTOTYPES=y.EFFORT_STATUSES=y.ASSET_CLASSES=y.PREDICATES=y.SPARQL_PREFIXES=y.SPARQL_TEMPLATES=y.DEFAULT_NL_TO_SPARQL_CONFIG=y.NLToSPARQLService=y.TypeRegistry=y.GraphQueryService=y.DEFAULT_SEMANTIC_SEARCH_CONFIG=y.SemanticSearchService=y.DEFAULT_VECTOR_STORE_CONFIG=y.VectorStore=y.DEFAULT_EMBEDDING_CONFIG=y.EmbeddingService=y.GenericAssetCreationService=y.WebhookService=y.URIConstructionService=y.SessionEventService=y.AssetConversionService=y.PlanningService=y.AlgorithmExtractor=y.DynamicFrontmatterGenerator=y.TaskFrontmatterGenerator=y.FleetingNoteCreationService=y.SupervisionCreationService=y.StatusTimestampService=y.RenameToUidService=y.PropertyCleanupService=y.LoggingService=y.LabelToAliasService=y.FolderRepairService=y.EffortVotingService=y.EffortStatusWorkflow=y.ConceptCreationService=y.ClassCreationService=y.AreaHierarchyBuilder=y.AreaCreationService=y.TaskStatusService=y.ProjectCreationService=y.TaskCreationService=y.extractPropertyLabel=y.uriToPropertyName=y.propertyNameToUri=y.rangeToFieldType=y.PropertyFieldType=void 0;y.SPARQLResultCache=y.QueryPlanCache=y.createDoubleLiteral=y.createDecimalLiteral=y.getNumericValue=y.createPercentileAggregate=y.modeAggregate=y.stddevAggregate=y.varianceAggregate=y.medianAggregate=y.EXO_AGGREGATE_NS=y.BUILT_IN_AGGREGATES=y.CustomAggregateError=y.CustomAggregateRegistry=y.AggregateFunctions=y.BuiltInFunctions=y.SolutionMapping=y.UpdateExecutorError=y.UpdateExecutor=y.QueryExecutor=y.DescribeExecutor=y.ConstructExecutor=y.UnionExecutor=y.OptionalExecutor=y.FilterExecutor=y.BGPExecutor=y.AlgebraSerializer=y.AlgebraOptimizer=y.AlgebraTranslator=y.DescribeOptionsTransformerError=y.DescribeOptionsTransformer=y.SPARQLParseError=y.SPARQLParser=y.NoteToRDFConverter=y.RDFVocabularyMapper=y.InMemoryTripleStore=y.RDFSerializer=y.FilenameValidator=y.EffortSortingHelpers=y.MetadataExtractor=y.MetadataHelpers=y.WikiLinkHelpers=y.DateFormatter=y.FrontmatterService=y.DailyReviewService=y.DEFAULT_AUTOCOMPLETE_CONFIG=y.AutocompleteService=y.TrendDetectionService=y.AnalyticsService=y.getTemplateByName=void 0;y.createStreamingSource=y.StreamingLoader=y.resetGlobalPool=y.getGlobalPool=y.MemoryPool=y.CompactGraphStore=y.StringTable=y.DEFAULT_COLORS=y.NODE_FLAGS=y.container=y.resetContainer=y.getContainer=y.createChildContainer=y.registerCoreServices=y.HeadlessError=y.DI_TOKENS=y.TransactionError=y.TripleNotFoundError=y.TripleAlreadyExistsError=y.FileAlreadyExistsError=y.FileNotFoundError=y.FilterContainsOptimizer=y.CaseWhenTransformerError=y.CaseWhenTransformer=y.ResultSerializer=y.createIncrementalIndexer=y.IncrementalIndexer=y.createSPARQLResultCache=void 0;un(Xd(),y);un(Jd(),y);un(j2(),y);un($2(),y);un(Zd(),y);un(ep(),y);un(U2(),y);un(G2(),y);un(Lp(),y);un(Fv(),y);var Pb=$p();Object.defineProperty(y,"PropertyFieldType",{enumerable:!0,get:o(function(){return Pb.PropertyFieldType},"get")});Object.defineProperty(y,"rangeToFieldType",{enumerable:!0,get:o(function(){return Pb.rangeToFieldType},"get")});var C0=kv();Object.defineProperty(y,"propertyNameToUri",{enumerable:!0,get:o(function(){return C0.propertyNameToUri},"get")});Object.defineProperty(y,"uriToPropertyName",{enumerable:!0,get:o(function(){return C0.uriToPropertyName},"get")});Object.defineProperty(y,"extractPropertyLabel",{enumerable:!0,get:o(function(){return C0.extractPropertyLabel},"get")});var XN=Om();Object.defineProperty(y,"TaskCreationService",{enumerable:!0,get:o(function(){return XN.TaskCreationService},"get")});var JN=Dm();Object.defineProperty(y,"ProjectCreationService",{enumerable:!0,get:o(function(){return JN.ProjectCreationService},"get")});var ZN=Lm();Object.defineProperty(y,"TaskStatusService",{enumerable:!0,get:o(function(){return ZN.TaskStatusService},"get")});var e5=Mm();Object.defineProperty(y,"AreaCreationService",{enumerable:!0,get:o(function(){return e5.AreaCreationService},"get")});var t5=$m();Object.defineProperty(y,"AreaHierarchyBuilder",{enumerable:!0,get:o(function(){return t5.AreaHierarchyBuilder},"get")});var r5=Um();Object.defineProperty(y,"ClassCreationService",{enumerable:!0,get:o(function(){return r5.ClassCreationService},"get")});var n5=qm();Object.defineProperty(y,"ConceptCreationService",{enumerable:!0,get:o(function(){return n5.ConceptCreationService},"get")});var i5=Ql();Object.defineProperty(y,"EffortStatusWorkflow",{enumerable:!0,get:o(function(){return i5.EffortStatusWorkflow},"get")});var s5=Wm();Object.defineProperty(y,"EffortVotingService",{enumerable:!0,get:o(function(){return s5.EffortVotingService},"get")});var a5=zm();Object.defineProperty(y,"FolderRepairService",{enumerable:!0,get:o(function(){return a5.FolderRepairService},"get")});var o5=Ym();Object.defineProperty(y,"LabelToAliasService",{enumerable:!0,get:o(function(){return o5.LabelToAliasService},"get")});var c5=Ji();Object.defineProperty(y,"LoggingService",{enumerable:!0,get:o(function(){return c5.LoggingService},"get")});var u5=Jm();Object.defineProperty(y,"PropertyCleanupService",{enumerable:!0,get:o(function(){return u5.PropertyCleanupService},"get")});var l5=eg();Object.defineProperty(y,"RenameToUidService",{enumerable:!0,get:o(function(){return l5.RenameToUidService},"get")});var f5=Yl();Object.defineProperty(y,"StatusTimestampService",{enumerable:!0,get:o(function(){return f5.StatusTimestampService},"get")});var h5=rg();Object.defineProperty(y,"SupervisionCreationService",{enumerable:!0,get:o(function(){return h5.SupervisionCreationService},"get")});var d5=ig();Object.defineProperty(y,"FleetingNoteCreationService",{enumerable:!0,get:o(function(){return d5.FleetingNoteCreationService},"get")});var p5=Bl();Object.defineProperty(y,"TaskFrontmatterGenerator",{enumerable:!0,get:o(function(){return p5.TaskFrontmatterGenerator},"get")});var m5=ag();Object.defineProperty(y,"DynamicFrontmatterGenerator",{enumerable:!0,get:o(function(){return m5.DynamicFrontmatterGenerator},"get")});var g5=ql();Object.defineProperty(y,"AlgorithmExtractor",{enumerable:!0,get:o(function(){return g5.AlgorithmExtractor},"get")});var y5=cg();Object.defineProperty(y,"PlanningService",{enumerable:!0,get:o(function(){return y5.PlanningService},"get")});var v5=lg();Object.defineProperty(y,"AssetConversionService",{enumerable:!0,get:o(function(){return v5.AssetConversionService},"get")});var S5=hg();Object.defineProperty(y,"SessionEventService",{enumerable:!0,get:o(function(){return S5.SessionEventService},"get")});var _5=pg();Object.defineProperty(y,"URIConstructionService",{enumerable:!0,get:o(function(){return _5.URIConstructionService},"get")});var b5=$S();Object.defineProperty(y,"WebhookService",{enumerable:!0,get:o(function(){return b5.WebhookService},"get")});var w5=yg();Object.defineProperty(y,"GenericAssetCreationService",{enumerable:!0,get:o(function(){return w5.GenericAssetCreationService},"get")});var Db=Sg();Object.defineProperty(y,"EmbeddingService",{enumerable:!0,get:o(function(){return Db.EmbeddingService},"get")});Object.defineProperty(y,"DEFAULT_EMBEDDING_CONFIG",{enumerable:!0,get:o(function(){return Db.DEFAULT_EMBEDDING_CONFIG},"get")});var Rb=wg();Object.defineProperty(y,"VectorStore",{enumerable:!0,get:o(function(){return Rb.VectorStore},"get")});Object.defineProperty(y,"DEFAULT_VECTOR_STORE_CONFIG",{enumerable:!0,get:o(function(){return Rb.DEFAULT_VECTOR_STORE_CONFIG},"get")});var Fb=qS();Object.defineProperty(y,"SemanticSearchService",{enumerable:!0,get:o(function(){return Fb.SemanticSearchService},"get")});Object.defineProperty(y,"DEFAULT_SEMANTIC_SEARCH_CONFIG",{enumerable:!0,get:o(function(){return Fb.DEFAULT_SEMANTIC_SEARCH_CONFIG},"get")});var E5=GS();Object.defineProperty(y,"GraphQueryService",{enumerable:!0,get:o(function(){return E5.GraphQueryService},"get")});var T5=HS();Object.defineProperty(y,"TypeRegistry",{enumerable:!0,get:o(function(){return T5.TypeRegistry},"get")});var Nb=zS();Object.defineProperty(y,"NLToSPARQLService",{enumerable:!0,get:o(function(){return Nb.NLToSPARQLService},"get")});Object.defineProperty(y,"DEFAULT_NL_TO_SPARQL_CONFIG",{enumerable:!0,get:o(function(){return Nb.DEFAULT_NL_TO_SPARQL_CONFIG},"get")});var ci=xg();Object.defineProperty(y,"SPARQL_TEMPLATES",{enumerable:!0,get:o(function(){return ci.SPARQL_TEMPLATES},"get")});Object.defineProperty(y,"SPARQL_PREFIXES",{enumerable:!0,get:o(function(){return ci.SPARQL_PREFIXES},"get")});Object.defineProperty(y,"PREDICATES",{enumerable:!0,get:o(function(){return ci.PREDICATES},"get")});Object.defineProperty(y,"ASSET_CLASSES",{enumerable:!0,get:o(function(){return ci.ASSET_CLASSES},"get")});Object.defineProperty(y,"EFFORT_STATUSES",{enumerable:!0,get:o(function(){return ci.EFFORT_STATUSES},"get")});Object.defineProperty(y,"KNOWN_PROTOTYPES",{enumerable:!0,get:o(function(){return ci.KNOWN_PROTOTYPES},"get")});Object.defineProperty(y,"findMatchingTemplates",{enumerable:!0,get:o(function(){return ci.findMatchingTemplates},"get")});Object.defineProperty(y,"fillTemplate",{enumerable:!0,get:o(function(){return ci.fillTemplate},"get")});Object.defineProperty(y,"validateParameters",{enumerable:!0,get:o(function(){return ci.validateParameters},"get")});Object.defineProperty(y,"getTemplateByName",{enumerable:!0,get:o(function(){return ci.getTemplateByName},"get")});var A5=YS();Object.defineProperty(y,"AnalyticsService",{enumerable:!0,get:o(function(){return A5.AnalyticsService},"get")});var x5=KS();Object.defineProperty(y,"TrendDetectionService",{enumerable:!0,get:o(function(){return x5.TrendDetectionService},"get")});var Lb=JS();Object.defineProperty(y,"AutocompleteService",{enumerable:!0,get:o(function(){return Lb.AutocompleteService},"get")});Object.defineProperty(y,"DEFAULT_AUTOCOMPLETE_CONFIG",{enumerable:!0,get:o(function(){return Lb.DEFAULT_AUTOCOMPLETE_CONFIG},"get")});var C5=e_();Object.defineProperty(y,"DailyReviewService",{enumerable:!0,get:o(function(){return C5.DailyReviewService},"get")});var I5=Xi();Object.defineProperty(y,"FrontmatterService",{enumerable:!0,get:o(function(){return I5.FrontmatterService},"get")});var O5=Ht();Object.defineProperty(y,"DateFormatter",{enumerable:!0,get:o(function(){return O5.DateFormatter},"get")});var P5=Ls();Object.defineProperty(y,"WikiLinkHelpers",{enumerable:!0,get:o(function(){return P5.WikiLinkHelpers},"get")});var D5=en();Object.defineProperty(y,"MetadataHelpers",{enumerable:!0,get:o(function(){return D5.MetadataHelpers},"get")});var R5=bc();Object.defineProperty(y,"MetadataExtractor",{enumerable:!0,get:o(function(){return R5.MetadataExtractor},"get")});var F5=t_();Object.defineProperty(y,"EffortSortingHelpers",{enumerable:!0,get:o(function(){return F5.EffortSortingHelpers},"get")});var N5=r_();Object.defineProperty(y,"FilenameValidator",{enumerable:!0,get:o(function(){return N5.FilenameValidator},"get")});var L5=u_();Object.defineProperty(y,"RDFSerializer",{enumerable:!0,get:o(function(){return L5.RDFSerializer},"get")});var k5=l_();Object.defineProperty(y,"InMemoryTripleStore",{enumerable:!0,get:o(function(){return k5.InMemoryTripleStore},"get")});var M5=Xg();Object.defineProperty(y,"RDFVocabularyMapper",{enumerable:!0,get:o(function(){return M5.RDFVocabularyMapper},"get")});var j5=Zg();Object.defineProperty(y,"NoteToRDFConverter",{enumerable:!0,get:o(function(){return j5.NoteToRDFConverter},"get")});var kb=R_();Object.defineProperty(y,"SPARQLParser",{enumerable:!0,get:o(function(){return kb.SPARQLParser},"get")});Object.defineProperty(y,"SPARQLParseError",{enumerable:!0,get:o(function(){return kb.SPARQLParseError},"get")});var Mb=my();Object.defineProperty(y,"DescribeOptionsTransformer",{enumerable:!0,get:o(function(){return Mb.DescribeOptionsTransformer},"get")});Object.defineProperty(y,"DescribeOptionsTransformerError",{enumerable:!0,get:o(function(){return Mb.DescribeOptionsTransformerError},"get")});var $5=N_();Object.defineProperty(y,"AlgebraTranslator",{enumerable:!0,get:o(function(){return $5.AlgebraTranslator},"get")});var V5=L_();Object.defineProperty(y,"AlgebraOptimizer",{enumerable:!0,get:o(function(){return V5.AlgebraOptimizer},"get")});var U5=k_();Object.defineProperty(y,"AlgebraSerializer",{enumerable:!0,get:o(function(){return U5.AlgebraSerializer},"get")});var B5=Ry();Object.defineProperty(y,"BGPExecutor",{enumerable:!0,get:o(function(){return B5.BGPExecutor},"get")});var q5=jf();Object.defineProperty(y,"FilterExecutor",{enumerable:!0,get:o(function(){return q5.FilterExecutor},"get")});var G5=My();Object.defineProperty(y,"OptionalExecutor",{enumerable:!0,get:o(function(){return G5.OptionalExecutor},"get")});var W5=$y();Object.defineProperty(y,"UnionExecutor",{enumerable:!0,get:o(function(){return W5.UnionExecutor},"get")});var H5=qy();Object.defineProperty(y,"ConstructExecutor",{enumerable:!0,get:o(function(){return H5.ConstructExecutor},"get")});var z5=q_();Object.defineProperty(y,"DescribeExecutor",{enumerable:!0,get:o(function(){return z5.DescribeExecutor},"get")});var Q5=tb();Object.defineProperty(y,"QueryExecutor",{enumerable:!0,get:o(function(){return Q5.QueryExecutor},"get")});var jb=nb();Object.defineProperty(y,"UpdateExecutor",{enumerable:!0,get:o(function(){return jb.UpdateExecutor},"get")});Object.defineProperty(y,"UpdateExecutorError",{enumerable:!0,get:o(function(){return jb.UpdateExecutorError},"get")});var Y5=Ni();Object.defineProperty(y,"SolutionMapping",{enumerable:!0,get:o(function(){return Y5.SolutionMapping},"get")});var K5=Ny();Object.defineProperty(y,"BuiltInFunctions",{enumerable:!0,get:o(function(){return K5.BuiltInFunctions},"get")});var X5=sb();Object.defineProperty(y,"AggregateFunctions",{enumerable:!0,get:o(function(){return X5.AggregateFunctions},"get")});var $b=zy();Object.defineProperty(y,"CustomAggregateRegistry",{enumerable:!0,get:o(function(){return $b.CustomAggregateRegistry},"get")});Object.defineProperty(y,"CustomAggregateError",{enumerable:!0,get:o(function(){return $b.CustomAggregateError},"get")});var ui=Qy();Object.defineProperty(y,"BUILT_IN_AGGREGATES",{enumerable:!0,get:o(function(){return ui.BUILT_IN_AGGREGATES},"get")});Object.defineProperty(y,"EXO_AGGREGATE_NS",{enumerable:!0,get:o(function(){return ui.EXO_AGGREGATE_NS},"get")});Object.defineProperty(y,"medianAggregate",{enumerable:!0,get:o(function(){return ui.medianAggregate},"get")});Object.defineProperty(y,"varianceAggregate",{enumerable:!0,get:o(function(){return ui.varianceAggregate},"get")});Object.defineProperty(y,"stddevAggregate",{enumerable:!0,get:o(function(){return ui.stddevAggregate},"get")});Object.defineProperty(y,"modeAggregate",{enumerable:!0,get:o(function(){return ui.modeAggregate},"get")});Object.defineProperty(y,"createPercentileAggregate",{enumerable:!0,get:o(function(){return ui.createPercentileAggregate},"get")});Object.defineProperty(y,"getNumericValue",{enumerable:!0,get:o(function(){return ui.getNumericValue},"get")});Object.defineProperty(y,"createDecimalLiteral",{enumerable:!0,get:o(function(){return ui.createDecimalLiteral},"get")});Object.defineProperty(y,"createDoubleLiteral",{enumerable:!0,get:o(function(){return ui.createDoubleLiteral},"get")});var J5=ab();Object.defineProperty(y,"QueryPlanCache",{enumerable:!0,get:o(function(){return J5.QueryPlanCache},"get")});var Vb=ob();Object.defineProperty(y,"SPARQLResultCache",{enumerable:!0,get:o(function(){return Vb.SPARQLResultCache},"get")});Object.defineProperty(y,"createSPARQLResultCache",{enumerable:!0,get:o(function(){return Vb.createSPARQLResultCache},"get")});var Ub=cb();Object.defineProperty(y,"IncrementalIndexer",{enumerable:!0,get:o(function(){return Ub.IncrementalIndexer},"get")});Object.defineProperty(y,"createIncrementalIndexer",{enumerable:!0,get:o(function(){return Ub.createIncrementalIndexer},"get")});var Z5=ub();Object.defineProperty(y,"ResultSerializer",{enumerable:!0,get:o(function(){return Z5.ResultSerializer},"get")});var Bb=hy();Object.defineProperty(y,"CaseWhenTransformer",{enumerable:!0,get:o(function(){return Bb.CaseWhenTransformer},"get")});Object.defineProperty(y,"CaseWhenTransformerError",{enumerable:!0,get:o(function(){return Bb.CaseWhenTransformerError},"get")});var eL=Ay();Object.defineProperty(y,"FilterContainsOptimizer",{enumerable:!0,get:o(function(){return eL.FilterContainsOptimizer},"get")});var qb=lb();Object.defineProperty(y,"FileNotFoundError",{enumerable:!0,get:o(function(){return qb.FileNotFoundError},"get")});Object.defineProperty(y,"FileAlreadyExistsError",{enumerable:!0,get:o(function(){return qb.FileAlreadyExistsError},"get")});var I0=Hg();Object.defineProperty(y,"TripleAlreadyExistsError",{enumerable:!0,get:o(function(){return I0.TripleAlreadyExistsError},"get")});Object.defineProperty(y,"TripleNotFoundError",{enumerable:!0,get:o(function(){return I0.TripleNotFoundError},"get")});Object.defineProperty(y,"TransactionError",{enumerable:!0,get:o(function(){return I0.TransactionError},"get")});var tL=ct();Object.defineProperty(y,"DI_TOKENS",{enumerable:!0,get:o(function(){return tL.DI_TOKENS},"get")});var rL=fb();Object.defineProperty(y,"HeadlessError",{enumerable:!0,get:o(function(){return rL.HeadlessError},"get")});var Vc=hb();Object.defineProperty(y,"registerCoreServices",{enumerable:!0,get:o(function(){return Vc.registerCoreServices},"get")});Object.defineProperty(y,"createChildContainer",{enumerable:!0,get:o(function(){return Vc.createChildContainer},"get")});Object.defineProperty(y,"getContainer",{enumerable:!0,get:o(function(){return Vc.getContainer},"get")});Object.defineProperty(y,"resetContainer",{enumerable:!0,get:o(function(){return Vc.resetContainer},"get")});Object.defineProperty(y,"container",{enumerable:!0,get:o(function(){return Vc.container},"get")});var Li=vb();Object.defineProperty(y,"NODE_FLAGS",{enumerable:!0,get:o(function(){return Li.NODE_FLAGS},"get")});Object.defineProperty(y,"DEFAULT_COLORS",{enumerable:!0,get:o(function(){return Li.DEFAULT_COLORS},"get")});Object.defineProperty(y,"StringTable",{enumerable:!0,get:o(function(){return Li.StringTable},"get")});Object.defineProperty(y,"CompactGraphStore",{enumerable:!0,get:o(function(){return Li.CompactGraphStore},"get")});Object.defineProperty(y,"MemoryPool",{enumerable:!0,get:o(function(){return Li.MemoryPool},"get")});Object.defineProperty(y,"getGlobalPool",{enumerable:!0,get:o(function(){return Li.getGlobalPool},"get")});Object.defineProperty(y,"resetGlobalPool",{enumerable:!0,get:o(function(){return Li.resetGlobalPool},"get")});Object.defineProperty(y,"StreamingLoader",{enumerable:!0,get:o(function(){return Li.StreamingLoader},"get")});Object.defineProperty(y,"createStreamingSource",{enumerable:!0,get:o(function(){return Li.createStreamingSource},"get")});un(Cb(),y);un(Ob(),y)});var kt=v(O0=>{"use strict";O0.fromCallback=function(n){return Object.defineProperty(function(...e){if(typeof e[e.length-1]=="function")n.apply(this,e);else return new Promise((t,r)=>{e.push((i,s)=>i!=null?r(i):t(s)),n.apply(this,e)})},"name",{value:n.name})};O0.fromPromise=function(n){return Object.defineProperty(function(...e){let t=e[e.length-1];if(typeof t!="function")return n.apply(this,e);e.pop(),n.apply(this,e).then(r=>t(null,r),t)},"name",{value:n.name})}});var Wb=v((qW,Gb)=>{var os=require("constants"),nL=process.cwd,vh=null,iL=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return vh||(vh=nL.call(process)),vh};try{process.cwd()}catch{}typeof process.chdir=="function"&&(P0=process.chdir,process.chdir=function(n){vh=null,P0.call(process,n)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,P0));var P0;Gb.exports=sL;function sL(n){os.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(n),n.lutimes||t(n),n.chown=s(n.chown),n.fchown=s(n.fchown),n.lchown=s(n.lchown),n.chmod=r(n.chmod),n.fchmod=r(n.fchmod),n.lchmod=r(n.lchmod),n.chownSync=a(n.chownSync),n.fchownSync=a(n.fchownSync),n.lchownSync=a(n.lchownSync),n.chmodSync=i(n.chmodSync),n.fchmodSync=i(n.fchmodSync),n.lchmodSync=i(n.lchmodSync),n.stat=c(n.stat),n.fstat=c(n.fstat),n.lstat=c(n.lstat),n.statSync=u(n.statSync),n.fstatSync=u(n.fstatSync),n.lstatSync=u(n.lstatSync),n.chmod&&!n.lchmod&&(n.lchmod=function(f,h,d){d&&process.nextTick(d)},n.lchmodSync=function(){}),n.chown&&!n.lchown&&(n.lchown=function(f,h,d,p){p&&process.nextTick(p)},n.lchownSync=function(){}),iL==="win32"&&(n.rename=typeof n.rename!="function"?n.rename:(function(f){function h(d,p,S){var b=Date.now(),T=0;f(d,p,o(function I(O){if(O&&(O.code==="EACCES"||O.code==="EPERM"||O.code==="EBUSY")&&Date.now()-b<6e4){setTimeout(function(){n.stat(p,function(L,M){L&&L.code==="ENOENT"?f(d,p,I):S(O)})},T),T<100&&(T+=10);return}S&&S(O)},"CB"))}return o(h,"rename"),Object.setPrototypeOf&&Object.setPrototypeOf(h,f),h})(n.rename)),n.read=typeof n.read!="function"?n.read:(function(f){function h(d,p,S,b,T,I){var O;if(I&&typeof I=="function"){var L=0;O=o(function(M,G,Ee){if(M&&M.code==="EAGAIN"&&L<10)return L++,f.call(n,d,p,S,b,T,O);I.apply(this,arguments)},"callback")}return f.call(n,d,p,S,b,T,O)}return o(h,"read"),Object.setPrototypeOf&&Object.setPrototypeOf(h,f),h})(n.read),n.readSync=typeof n.readSync!="function"?n.readSync:(function(f){return function(h,d,p,S,b){for(var T=0;;)try{return f.call(n,h,d,p,S,b)}catch(I){if(I.code==="EAGAIN"&&T<10){T++;continue}throw I}}})(n.readSync);function e(f){f.lchmod=function(h,d,p){f.open(h,os.O_WRONLY|os.O_SYMLINK,d,function(S,b){if(S){p&&p(S);return}f.fchmod(b,d,function(T){f.close(b,function(I){p&&p(T||I)})})})},f.lchmodSync=function(h,d){var p=f.openSync(h,os.O_WRONLY|os.O_SYMLINK,d),S=!0,b;try{b=f.fchmodSync(p,d),S=!1}finally{if(S)try{f.closeSync(p)}catch{}else f.closeSync(p)}return b}}o(e,"patchLchmod");function t(f){os.hasOwnProperty("O_SYMLINK")&&f.futimes?(f.lutimes=function(h,d,p,S){f.open(h,os.O_SYMLINK,function(b,T){if(b){S&&S(b);return}f.futimes(T,d,p,function(I){f.close(T,function(O){S&&S(I||O)})})})},f.lutimesSync=function(h,d,p){var S=f.openSync(h,os.O_SYMLINK),b,T=!0;try{b=f.futimesSync(S,d,p),T=!1}finally{if(T)try{f.closeSync(S)}catch{}else f.closeSync(S)}return b}):f.futimes&&(f.lutimes=function(h,d,p,S){S&&process.nextTick(S)},f.lutimesSync=function(){})}o(t,"patchLutimes");function r(f){return f&&function(h,d,p){return f.call(n,h,d,function(S){l(S)&&(S=null),p&&p.apply(this,arguments)})}}o(r,"chmodFix");function i(f){return f&&function(h,d){try{return f.call(n,h,d)}catch(p){if(!l(p))throw p}}}o(i,"chmodFixSync");function s(f){return f&&function(h,d,p,S){return f.call(n,h,d,p,function(b){l(b)&&(b=null),S&&S.apply(this,arguments)})}}o(s,"chownFix");function a(f){return f&&function(h,d,p){try{return f.call(n,h,d,p)}catch(S){if(!l(S))throw S}}}o(a,"chownFixSync");function c(f){return f&&function(h,d,p){typeof d=="function"&&(p=d,d=null);function S(b,T){T&&(T.uid<0&&(T.uid+=4294967296),T.gid<0&&(T.gid+=4294967296)),p&&p.apply(this,arguments)}return o(S,"callback"),d?f.call(n,h,d,S):f.call(n,h,S)}}o(c,"statFix");function u(f){return f&&function(h,d){var p=d?f.call(n,h,d):f.call(n,h);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}o(u,"statFixSync");function l(f){if(!f||f.code==="ENOSYS")return!0;var h=!process.getuid||process.getuid()!==0;return!!(h&&(f.code==="EINVAL"||f.code==="EPERM"))}o(l,"chownErOk")}o(sL,"patch")});var Qb=v((WW,zb)=>{var Hb=require("stream").Stream;zb.exports=aL;function aL(n){return{ReadStream:e,WriteStream:t};function e(r,i){if(!(this instanceof e))return new e(r,i);Hb.call(this);var s=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var a=Object.keys(i),c=0,u=a.length;c<u;c++){var l=a[c];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){s._read()});return}n.open(this.path,this.flags,this.mode,function(f,h){if(f){s.emit("error",f),s.readable=!1;return}s.fd=h,s.emit("open",h),s._read()})}function t(r,i){if(!(this instanceof t))return new t(r,i);Hb.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var s=Object.keys(i),a=0,c=s.length;a<c;a++){var u=s[a];this[u]=i[u]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=n.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}o(aL,"legacy")});var Kb=v((zW,Yb)=>{"use strict";Yb.exports=cL;var oL=Object.getPrototypeOf||function(n){return n.__proto__};function cL(n){if(n===null||typeof n!="object")return n;if(n instanceof Object)var e={__proto__:oL(n)};else var e=Object.create(null);return Object.getOwnPropertyNames(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}o(cL,"clone")});var So=v((YW,F0)=>{var pt=require("fs"),uL=Wb(),lL=Qb(),fL=Kb(),Sh=require("util"),Yt,bh;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Yt=Symbol.for("graceful-fs.queue"),bh=Symbol.for("graceful-fs.previous")):(Yt="___graceful-fs.queue",bh="___graceful-fs.previous");function hL(){}o(hL,"noop");function Zb(n,e){Object.defineProperty(n,Yt,{get:o(function(){return e},"get")})}o(Zb,"publishQueue");var ca=hL;Sh.debuglog?ca=Sh.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ca=o(function(){var n=Sh.format.apply(Sh,arguments);n="GFS4: "+n.split(/\n/).join(`
|
|
357
|
+
GFS4: `),console.error(n)},"debug"));pt[Yt]||(Xb=global[Yt]||[],Zb(pt,Xb),pt.close=(function(n){function e(t,r){return n.call(pt,t,function(i){i||Jb(),typeof r=="function"&&r.apply(this,arguments)})}return o(e,"close"),Object.defineProperty(e,bh,{value:n}),e})(pt.close),pt.closeSync=(function(n){function e(t){n.apply(pt,arguments),Jb()}return o(e,"closeSync"),Object.defineProperty(e,bh,{value:n}),e})(pt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ca(pt[Yt]),require("assert").equal(pt[Yt].length,0)}));var Xb;global[Yt]||Zb(global,pt[Yt]);F0.exports=D0(fL(pt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!pt.__patched&&(F0.exports=D0(pt),pt.__patched=!0);function D0(n){uL(n),n.gracefulify=D0,n.createReadStream=G,n.createWriteStream=Ee;var e=n.readFile;n.readFile=t;function t(q,ie,Se){return typeof ie=="function"&&(Se=ie,ie=null),nt(q,ie,Se);function nt(Ke,at,Ue,Be){return e(Ke,at,function(ke){ke&&(ke.code==="EMFILE"||ke.code==="ENFILE")?vo([nt,[Ke,at,Ue],ke,Be||Date.now(),Date.now()]):typeof Ue=="function"&&Ue.apply(this,arguments)})}o(nt,"go$readFile")}o(t,"readFile");var r=n.writeFile;n.writeFile=i;function i(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=null),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return r(at,Ue,Be,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$writeFile")}o(i,"writeFile");var s=n.appendFile;s&&(n.appendFile=a);function a(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=null),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return s(at,Ue,Be,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$appendFile")}o(a,"appendFile");var c=n.copyFile;c&&(n.copyFile=u);function u(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=0),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return c(at,Ue,Be,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$copyFile")}o(u,"copyFile");var l=n.readdir;n.readdir=h;var f=/^v[0-5]\./;function h(q,ie,Se){typeof ie=="function"&&(Se=ie,ie=null);var nt=f.test(process.version)?o(function(Ue,Be,ke,Q){return l(Ue,Ke(Ue,Be,ke,Q))},"go$readdir"):o(function(Ue,Be,ke,Q){return l(Ue,Be,Ke(Ue,Be,ke,Q))},"go$readdir");return nt(q,ie,Se);function Ke(at,Ue,Be,ke){return function(Q,k){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?vo([nt,[at,Ue,Be],Q,ke||Date.now(),Date.now()]):(k&&k.sort&&k.sort(),typeof Be=="function"&&Be.call(this,Q,k))}}}if(o(h,"readdir"),process.version.substr(0,4)==="v0.8"){var d=lL(n);I=d.ReadStream,L=d.WriteStream}var p=n.ReadStream;p&&(I.prototype=Object.create(p.prototype),I.prototype.open=O);var S=n.WriteStream;S&&(L.prototype=Object.create(S.prototype),L.prototype.open=M),Object.defineProperty(n,"ReadStream",{get:o(function(){return I},"get"),set:o(function(q){I=q},"set"),enumerable:!0,configurable:!0}),Object.defineProperty(n,"WriteStream",{get:o(function(){return L},"get"),set:o(function(q){L=q},"set"),enumerable:!0,configurable:!0});var b=I;Object.defineProperty(n,"FileReadStream",{get:o(function(){return b},"get"),set:o(function(q){b=q},"set"),enumerable:!0,configurable:!0});var T=L;Object.defineProperty(n,"FileWriteStream",{get:o(function(){return T},"get"),set:o(function(q){T=q},"set"),enumerable:!0,configurable:!0});function I(q,ie){return this instanceof I?(p.apply(this,arguments),this):I.apply(Object.create(I.prototype),arguments)}o(I,"ReadStream");function O(){var q=this;Me(q.path,q.flags,q.mode,function(ie,Se){ie?(q.autoClose&&q.destroy(),q.emit("error",ie)):(q.fd=Se,q.emit("open",Se),q.read())})}o(O,"ReadStream$open");function L(q,ie){return this instanceof L?(S.apply(this,arguments),this):L.apply(Object.create(L.prototype),arguments)}o(L,"WriteStream");function M(){var q=this;Me(q.path,q.flags,q.mode,function(ie,Se){ie?(q.destroy(),q.emit("error",ie)):(q.fd=Se,q.emit("open",Se))})}o(M,"WriteStream$open");function G(q,ie){return new n.ReadStream(q,ie)}o(G,"createReadStream");function Ee(q,ie){return new n.WriteStream(q,ie)}o(Ee,"createWriteStream");var je=n.open;n.open=Me;function Me(q,ie,Se,nt){return typeof Se=="function"&&(nt=Se,Se=null),Ke(q,ie,Se,nt);function Ke(at,Ue,Be,ke,Q){return je(at,Ue,Be,function(k,qe){k&&(k.code==="EMFILE"||k.code==="ENFILE")?vo([Ke,[at,Ue,Be,ke],k,Q||Date.now(),Date.now()]):typeof ke=="function"&&ke.apply(this,arguments)})}o(Ke,"go$open")}return o(Me,"open"),n}o(D0,"patch");function vo(n){ca("ENQUEUE",n[0].name,n[1]),pt[Yt].push(n),R0()}o(vo,"enqueue");var _h;function Jb(){for(var n=Date.now(),e=0;e<pt[Yt].length;++e)pt[Yt][e].length>2&&(pt[Yt][e][3]=n,pt[Yt][e][4]=n);R0()}o(Jb,"resetQueue");function R0(){if(clearTimeout(_h),_h=void 0,pt[Yt].length!==0){var n=pt[Yt].shift(),e=n[0],t=n[1],r=n[2],i=n[3],s=n[4];if(i===void 0)ca("RETRY",e.name,t),e.apply(null,t);else if(Date.now()-i>=6e4){ca("TIMEOUT",e.name,t);var a=t.pop();typeof a=="function"&&a.call(null,r)}else{var c=Date.now()-s,u=Math.max(s-i,1),l=Math.min(u*1.2,100);c>=l?(ca("RETRY",e.name,t),e.apply(null,t.concat([i]))):pt[Yt].push(n)}_h===void 0&&(_h=setTimeout(R0,0))}}o(R0,"retry")});var wr=v(ki=>{"use strict";var ew=kt().fromCallback,br=So(),dL=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(n=>typeof br[n]=="function");Object.assign(ki,br);dL.forEach(n=>{ki[n]=ew(br[n])});ki.exists=function(n,e){return typeof e=="function"?br.exists(n,e):new Promise(t=>br.exists(n,t))};ki.read=function(n,e,t,r,i,s){return typeof s=="function"?br.read(n,e,t,r,i,s):new Promise((a,c)=>{br.read(n,e,t,r,i,(u,l,f)=>{if(u)return c(u);a({bytesRead:l,buffer:f})})})};ki.write=function(n,e,...t){return typeof t[t.length-1]=="function"?br.write(n,e,...t):new Promise((r,i)=>{br.write(n,e,...t,(s,a,c)=>{if(s)return i(s);r({bytesWritten:a,buffer:c})})})};ki.readv=function(n,e,...t){return typeof t[t.length-1]=="function"?br.readv(n,e,...t):new Promise((r,i)=>{br.readv(n,e,...t,(s,a,c)=>{if(s)return i(s);r({bytesRead:a,buffers:c})})})};ki.writev=function(n,e,...t){return typeof t[t.length-1]=="function"?br.writev(n,e,...t):new Promise((r,i)=>{br.writev(n,e,...t,(s,a,c)=>{if(s)return i(s);r({bytesWritten:a,buffers:c})})})};typeof br.realpath.native=="function"?ki.realpath.native=ew(br.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var rw=v((JW,tw)=>{"use strict";var pL=require("path");tw.exports.checkPath=o(function(e){if(process.platform==="win32"&&/[<>:"|?*]/.test(e.replace(pL.parse(e).root,""))){let r=new Error(`Path contains invalid characters: ${e}`);throw r.code="EINVAL",r}},"checkPath")});var aw=v((eH,N0)=>{"use strict";var nw=wr(),{checkPath:iw}=rw(),sw=o(n=>{let e={mode:511};return typeof n=="number"?n:{...e,...n}.mode},"getMode");N0.exports.makeDir=async(n,e)=>(iw(n),nw.mkdir(n,{mode:sw(e),recursive:!0}));N0.exports.makeDirSync=(n,e)=>(iw(n),nw.mkdirSync(n,{mode:sw(e),recursive:!0}))});var Vn=v((rH,ow)=>{"use strict";var mL=kt().fromPromise,{makeDir:gL,makeDirSync:L0}=aw(),k0=mL(gL);ow.exports={mkdirs:k0,mkdirsSync:L0,mkdirp:k0,mkdirpSync:L0,ensureDir:k0,ensureDirSync:L0}});var cs=v((nH,uw)=>{"use strict";var yL=kt().fromPromise,cw=wr();function vL(n){return cw.access(n).then(()=>!0).catch(()=>!1)}o(vL,"pathExists");uw.exports={pathExists:yL(vL),pathExistsSync:cw.existsSync}});var M0=v((sH,lw)=>{"use strict";var _o=wr(),SL=kt().fromPromise;async function _L(n,e,t){let r=await _o.open(n,"r+"),i=null;try{await _o.futimes(r,e,t)}finally{try{await _o.close(r)}catch(s){i=s}}if(i)throw i}o(_L,"utimesMillis");function bL(n,e,t){let r=_o.openSync(n,"r+");return _o.futimesSync(r,e,t),_o.closeSync(r)}o(bL,"utimesMillisSync");lw.exports={utimesMillis:SL(_L),utimesMillisSync:bL}});var ua=v((oH,pw)=>{"use strict";var bo=wr(),Mt=require("path"),fw=kt().fromPromise;function wL(n,e,t){let r=t.dereference?i=>bo.stat(i,{bigint:!0}):i=>bo.lstat(i,{bigint:!0});return Promise.all([r(n),r(e).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,s])=>({srcStat:i,destStat:s}))}o(wL,"getStats");function EL(n,e,t){let r,i=t.dereference?a=>bo.statSync(a,{bigint:!0}):a=>bo.lstatSync(a,{bigint:!0}),s=i(n);try{r=i(e)}catch(a){if(a.code==="ENOENT")return{srcStat:s,destStat:null};throw a}return{srcStat:s,destStat:r}}o(EL,"getStatsSync");async function TL(n,e,t,r){let{srcStat:i,destStat:s}=await wL(n,e,r);if(s){if(Uc(i,s)){let a=Mt.basename(n),c=Mt.basename(e);if(t==="move"&&a!==c&&a.toLowerCase()===c.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&j0(n,e))throw new Error(wh(n,e,t));return{srcStat:i,destStat:s}}o(TL,"checkPaths");function AL(n,e,t,r){let{srcStat:i,destStat:s}=EL(n,e,r);if(s){if(Uc(i,s)){let a=Mt.basename(n),c=Mt.basename(e);if(t==="move"&&a!==c&&a.toLowerCase()===c.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&j0(n,e))throw new Error(wh(n,e,t));return{srcStat:i,destStat:s}}o(AL,"checkPathsSync");async function hw(n,e,t,r){let i=Mt.resolve(Mt.dirname(n)),s=Mt.resolve(Mt.dirname(t));if(s===i||s===Mt.parse(s).root)return;let a;try{a=await bo.stat(s,{bigint:!0})}catch(c){if(c.code==="ENOENT")return;throw c}if(Uc(e,a))throw new Error(wh(n,t,r));return hw(n,e,s,r)}o(hw,"checkParentPaths");function dw(n,e,t,r){let i=Mt.resolve(Mt.dirname(n)),s=Mt.resolve(Mt.dirname(t));if(s===i||s===Mt.parse(s).root)return;let a;try{a=bo.statSync(s,{bigint:!0})}catch(c){if(c.code==="ENOENT")return;throw c}if(Uc(e,a))throw new Error(wh(n,t,r));return dw(n,e,s,r)}o(dw,"checkParentPathsSync");function Uc(n,e){return e.ino!==void 0&&e.dev!==void 0&&e.ino===n.ino&&e.dev===n.dev}o(Uc,"areIdentical");function j0(n,e){let t=Mt.resolve(n).split(Mt.sep).filter(i=>i),r=Mt.resolve(e).split(Mt.sep).filter(i=>i);return t.every((i,s)=>r[s]===i)}o(j0,"isSrcSubdir");function wh(n,e,t){return`Cannot ${t} '${n}' to a subdirectory of itself, '${e}'.`}o(wh,"errMsg");pw.exports={checkPaths:fw(TL),checkPathsSync:AL,checkParentPaths:fw(hw),checkParentPathsSync:dw,isSrcSubdir:j0,areIdentical:Uc}});var gw=v((uH,mw)=>{"use strict";async function xL(n,e){let t=[];for await(let r of n)t.push(e(r).then(()=>null,i=>i??new Error("unknown error")));await Promise.all(t.map(r=>r.then(i=>{if(i!==null)throw i})))}o(xL,"asyncIteratorConcurrentProcess");mw.exports={asyncIteratorConcurrentProcess:xL}});var bw=v((fH,_w)=>{"use strict";var or=wr(),Bc=require("path"),{mkdirs:CL}=Vn(),{pathExists:IL}=cs(),{utimesMillis:OL}=M0(),qc=ua(),{asyncIteratorConcurrentProcess:PL}=gw();async function DL(n,e,t={}){typeof t=="function"&&(t={filter:t}),t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
358
358
|
|
|
359
|
-
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:r,destStat:i}=await qc.checkPaths(n,e,"copy",t);if(await qc.checkParentPaths(n,r,e,"copy"),!await
|
|
359
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:r,destStat:i}=await qc.checkPaths(n,e,"copy",t);if(await qc.checkParentPaths(n,r,e,"copy"),!await vw(n,e,t))return;let a=Bc.dirname(e);await IL(a)||await CL(a),await Sw(i,n,e,t)}o(DL,"copy");async function vw(n,e,t){return t.filter?t.filter(n,e):!0}o(vw,"runFilter");async function Sw(n,e,t,r){let s=await(r.dereference?or.stat:or.lstat)(e);if(s.isDirectory())return LL(s,n,e,t,r);if(s.isFile()||s.isCharacterDevice()||s.isBlockDevice())return RL(s,n,e,t,r);if(s.isSymbolicLink())return kL(n,e,t,r);throw s.isSocket()?new Error(`Cannot copy a socket file: ${e}`):s.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}o(Sw,"getStatsAndPerformCopy");async function RL(n,e,t,r,i){if(!e)return yw(n,t,r,i);if(i.overwrite)return await or.unlink(r),yw(n,t,r,i);if(i.errorOnExist)throw new Error(`'${r}' already exists`)}o(RL,"onFile");async function yw(n,e,t,r){if(await or.copyFile(e,t),r.preserveTimestamps){FL(n.mode)&&await NL(t,n.mode);let i=await or.stat(e);await OL(t,i.atime,i.mtime)}return or.chmod(t,n.mode)}o(yw,"copyFile");function FL(n){return(n&128)===0}o(FL,"fileIsNotWritable");function NL(n,e){return or.chmod(n,e|128)}o(NL,"makeFileWritable");async function LL(n,e,t,r,i){e||await or.mkdir(r),await PL(await or.opendir(t),async s=>{let a=Bc.join(t,s.name),c=Bc.join(r,s.name);if(await vw(a,c,i)){let{destStat:l}=await qc.checkPaths(a,c,"copy",i);await Sw(l,a,c,i)}}),e||await or.chmod(r,n.mode)}o(LL,"onDir");async function kL(n,e,t,r){let i=await or.readlink(e);if(r.dereference&&(i=Bc.resolve(process.cwd(),i)),!n)return or.symlink(i,t);let s=null;try{s=await or.readlink(t)}catch(a){if(a.code==="EINVAL"||a.code==="UNKNOWN")return or.symlink(i,t);throw a}if(r.dereference&&(s=Bc.resolve(process.cwd(),s)),qc.isSrcSubdir(i,s))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${s}'.`);if(qc.isSrcSubdir(s,i))throw new Error(`Cannot overwrite '${s}' with '${i}'.`);return await or.unlink(t),or.symlink(i,t)}o(kL,"onLink");_w.exports=DL});var xw=v((dH,Aw)=>{"use strict";var Er=So(),Gc=require("path"),ML=Vn().mkdirsSync,jL=M0().utimesMillisSync,Wc=ua();function $L(n,e,t){typeof t=="function"&&(t={filter:t}),t=t||{},t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
360
360
|
|
|
361
|
-
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");let{srcStat:r,destStat:i}=Wc.checkPathsSync(n,e,"copy",t);if(Wc.checkParentPathsSync(n,r,e,"copy"),t.filter&&!t.filter(n,e))return;let s=Gc.dirname(e);return Er.existsSync(s)||
|
|
362
|
-
`,finalEOL:t=!0,replacer:r=null,spaces:i}={}){let s=t?e:"";return JSON.stringify(n,r,i).replace(/\n/g,e)+s}o(
|
|
361
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");let{srcStat:r,destStat:i}=Wc.checkPathsSync(n,e,"copy",t);if(Wc.checkParentPathsSync(n,r,e,"copy"),t.filter&&!t.filter(n,e))return;let s=Gc.dirname(e);return Er.existsSync(s)||ML(s),ww(i,n,e,t)}o($L,"copySync");function ww(n,e,t,r){let s=(r.dereference?Er.statSync:Er.lstatSync)(e);if(s.isDirectory())return HL(s,n,e,t,r);if(s.isFile()||s.isCharacterDevice()||s.isBlockDevice())return VL(s,n,e,t,r);if(s.isSymbolicLink())return YL(n,e,t,r);throw s.isSocket()?new Error(`Cannot copy a socket file: ${e}`):s.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}o(ww,"getStats");function VL(n,e,t,r,i){return e?UL(n,t,r,i):Ew(n,t,r,i)}o(VL,"onFile");function UL(n,e,t,r){if(r.overwrite)return Er.unlinkSync(t),Ew(n,e,t,r);if(r.errorOnExist)throw new Error(`'${t}' already exists`)}o(UL,"mayCopyFile");function Ew(n,e,t,r){return Er.copyFileSync(e,t),r.preserveTimestamps&&BL(n.mode,e,t),$0(t,n.mode)}o(Ew,"copyFile");function BL(n,e,t){return qL(n)&&GL(t,n),WL(e,t)}o(BL,"handleTimestamps");function qL(n){return(n&128)===0}o(qL,"fileIsNotWritable");function GL(n,e){return $0(n,e|128)}o(GL,"makeFileWritable");function $0(n,e){return Er.chmodSync(n,e)}o($0,"setDestMode");function WL(n,e){let t=Er.statSync(n);return jL(e,t.atime,t.mtime)}o(WL,"setDestTimestamps");function HL(n,e,t,r,i){return e?Tw(t,r,i):zL(n.mode,t,r,i)}o(HL,"onDir");function zL(n,e,t,r){return Er.mkdirSync(t),Tw(e,t,r),$0(t,n)}o(zL,"mkDirAndCopy");function Tw(n,e,t){let r=Er.opendirSync(n);try{let i;for(;(i=r.readSync())!==null;)QL(i.name,n,e,t)}finally{r.closeSync()}}o(Tw,"copyDir");function QL(n,e,t,r){let i=Gc.join(e,n),s=Gc.join(t,n);if(r.filter&&!r.filter(i,s))return;let{destStat:a}=Wc.checkPathsSync(i,s,"copy",r);return ww(a,i,s,r)}o(QL,"copyDirItem");function YL(n,e,t,r){let i=Er.readlinkSync(e);if(r.dereference&&(i=Gc.resolve(process.cwd(),i)),n){let s;try{s=Er.readlinkSync(t)}catch(a){if(a.code==="EINVAL"||a.code==="UNKNOWN")return Er.symlinkSync(i,t);throw a}if(r.dereference&&(s=Gc.resolve(process.cwd(),s)),Wc.isSrcSubdir(i,s))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${s}'.`);if(Wc.isSrcSubdir(s,i))throw new Error(`Cannot overwrite '${s}' with '${i}'.`);return KL(i,t)}else return Er.symlinkSync(i,t)}o(YL,"onLink");function KL(n,e){return Er.unlinkSync(e),Er.symlinkSync(n,e)}o(KL,"copyLink");Aw.exports=$L});var Eh=v((mH,Cw)=>{"use strict";var XL=kt().fromPromise;Cw.exports={copy:XL(bw()),copySync:xw()}});var Hc=v((gH,Ow)=>{"use strict";var Iw=So(),JL=kt().fromCallback;function ZL(n,e){Iw.rm(n,{recursive:!0,force:!0},e)}o(ZL,"remove");function e9(n){Iw.rmSync(n,{recursive:!0,force:!0})}o(e9,"removeSync");Ow.exports={remove:JL(ZL),removeSync:e9}});var Mw=v((vH,kw)=>{"use strict";var t9=kt().fromPromise,Rw=wr(),Fw=require("path"),Nw=Vn(),Lw=Hc(),Pw=t9(o(async function(e){let t;try{t=await Rw.readdir(e)}catch{return Nw.mkdirs(e)}return Promise.all(t.map(r=>Lw.remove(Fw.join(e,r))))},"emptyDir"));function Dw(n){let e;try{e=Rw.readdirSync(n)}catch{return Nw.mkdirsSync(n)}e.forEach(t=>{t=Fw.join(n,t),Lw.removeSync(t)})}o(Dw,"emptyDirSync");kw.exports={emptyDirSync:Dw,emptydirSync:Dw,emptyDir:Pw,emptydir:Pw}});var Uw=v((_H,Vw)=>{"use strict";var r9=kt().fromPromise,jw=require("path"),Mi=wr(),$w=Vn();async function n9(n){let e;try{e=await Mi.stat(n)}catch{}if(e&&e.isFile())return;let t=jw.dirname(n),r=null;try{r=await Mi.stat(t)}catch(i){if(i.code==="ENOENT"){await $w.mkdirs(t),await Mi.writeFile(n,"");return}else throw i}r.isDirectory()?await Mi.writeFile(n,""):await Mi.readdir(t)}o(n9,"createFile");function i9(n){let e;try{e=Mi.statSync(n)}catch{}if(e&&e.isFile())return;let t=jw.dirname(n);try{Mi.statSync(t).isDirectory()||Mi.readdirSync(t)}catch(r){if(r&&r.code==="ENOENT")$w.mkdirsSync(t);else throw r}Mi.writeFileSync(n,"")}o(i9,"createFileSync");Vw.exports={createFile:r9(n9),createFileSync:i9}});var Hw=v((wH,Ww)=>{"use strict";var s9=kt().fromPromise,Bw=require("path"),us=wr(),qw=Vn(),{pathExists:a9}=cs(),{areIdentical:Gw}=ua();async function o9(n,e){let t;try{t=await us.lstat(e)}catch{}let r;try{r=await us.lstat(n)}catch(a){throw a.message=a.message.replace("lstat","ensureLink"),a}if(t&&Gw(r,t))return;let i=Bw.dirname(e);await a9(i)||await qw.mkdirs(i),await us.link(n,e)}o(o9,"createLink");function c9(n,e){let t;try{t=us.lstatSync(e)}catch{}try{let s=us.lstatSync(n);if(t&&Gw(s,t))return}catch(s){throw s.message=s.message.replace("lstat","ensureLink"),s}let r=Bw.dirname(e);return us.existsSync(r)||qw.mkdirsSync(r),us.linkSync(n,e)}o(c9,"createLinkSync");Ww.exports={createLink:s9(o9),createLinkSync:c9}});var Qw=v((TH,zw)=>{"use strict";var ls=require("path"),zc=wr(),{pathExists:u9}=cs(),l9=kt().fromPromise;async function f9(n,e){if(ls.isAbsolute(n)){try{await zc.lstat(n)}catch(s){throw s.message=s.message.replace("lstat","ensureSymlink"),s}return{toCwd:n,toDst:n}}let t=ls.dirname(e),r=ls.join(t,n);if(await u9(r))return{toCwd:r,toDst:n};try{await zc.lstat(n)}catch(s){throw s.message=s.message.replace("lstat","ensureSymlink"),s}return{toCwd:n,toDst:ls.relative(t,n)}}o(f9,"symlinkPaths");function h9(n,e){if(ls.isAbsolute(n)){if(!zc.existsSync(n))throw new Error("absolute srcpath does not exist");return{toCwd:n,toDst:n}}let t=ls.dirname(e),r=ls.join(t,n);if(zc.existsSync(r))return{toCwd:r,toDst:n};if(!zc.existsSync(n))throw new Error("relative srcpath does not exist");return{toCwd:n,toDst:ls.relative(t,n)}}o(h9,"symlinkPathsSync");zw.exports={symlinkPaths:l9(f9),symlinkPathsSync:h9}});var Xw=v((xH,Kw)=>{"use strict";var Yw=wr(),d9=kt().fromPromise;async function p9(n,e){if(e)return e;let t;try{t=await Yw.lstat(n)}catch{return"file"}return t&&t.isDirectory()?"dir":"file"}o(p9,"symlinkType");function m9(n,e){if(e)return e;let t;try{t=Yw.lstatSync(n)}catch{return"file"}return t&&t.isDirectory()?"dir":"file"}o(m9,"symlinkTypeSync");Kw.exports={symlinkType:d9(p9),symlinkTypeSync:m9}});var tE=v((IH,eE)=>{"use strict";var g9=kt().fromPromise,Jw=require("path"),li=wr(),{mkdirs:y9,mkdirsSync:v9}=Vn(),{symlinkPaths:S9,symlinkPathsSync:_9}=Qw(),{symlinkType:b9,symlinkTypeSync:w9}=Xw(),{pathExists:E9}=cs(),{areIdentical:Zw}=ua();async function T9(n,e,t){let r;try{r=await li.lstat(e)}catch{}if(r&&r.isSymbolicLink()){let[c,u]=await Promise.all([li.stat(n),li.stat(e)]);if(Zw(c,u))return}let i=await S9(n,e);n=i.toDst;let s=await b9(i.toCwd,t),a=Jw.dirname(e);return await E9(a)||await y9(a),li.symlink(n,e,s)}o(T9,"createSymlink");function A9(n,e,t){let r;try{r=li.lstatSync(e)}catch{}if(r&&r.isSymbolicLink()){let c=li.statSync(n),u=li.statSync(e);if(Zw(c,u))return}let i=_9(n,e);n=i.toDst,t=w9(i.toCwd,t);let s=Jw.dirname(e);return li.existsSync(s)||v9(s),li.symlinkSync(n,e,t)}o(A9,"createSymlinkSync");eE.exports={createSymlink:g9(T9),createSymlinkSync:A9}});var uE=v((PH,cE)=>{"use strict";var{createFile:rE,createFileSync:nE}=Uw(),{createLink:iE,createLinkSync:sE}=Hw(),{createSymlink:aE,createSymlinkSync:oE}=tE();cE.exports={createFile:rE,createFileSync:nE,ensureFile:rE,ensureFileSync:nE,createLink:iE,createLinkSync:sE,ensureLink:iE,ensureLinkSync:sE,createSymlink:aE,createSymlinkSync:oE,ensureSymlink:aE,ensureSymlinkSync:oE}});var Th=v((DH,lE)=>{function x9(n,{EOL:e=`
|
|
362
|
+
`,finalEOL:t=!0,replacer:r=null,spaces:i}={}){let s=t?e:"";return JSON.stringify(n,r,i).replace(/\n/g,e)+s}o(x9,"stringify");function C9(n){return Buffer.isBuffer(n)&&(n=n.toString("utf8")),n.replace(/^\uFEFF/,"")}o(C9,"stripBom");lE.exports={stringify:x9,stripBom:C9}});var pE=v((FH,dE)=>{var wo;try{wo=So()}catch{wo=require("fs")}var Ah=kt(),{stringify:fE,stripBom:hE}=Th();async function I9(n,e={}){typeof e=="string"&&(e={encoding:e});let t=e.fs||wo,r="throws"in e?e.throws:!0,i=await Ah.fromCallback(t.readFile)(n,e);i=hE(i);let s;try{s=JSON.parse(i,e?e.reviver:null)}catch(a){if(r)throw a.message=`${n}: ${a.message}`,a;return null}return s}o(I9,"_readFile");var O9=Ah.fromPromise(I9);function P9(n,e={}){typeof e=="string"&&(e={encoding:e});let t=e.fs||wo,r="throws"in e?e.throws:!0;try{let i=t.readFileSync(n,e);return i=hE(i),JSON.parse(i,e.reviver)}catch(i){if(r)throw i.message=`${n}: ${i.message}`,i;return null}}o(P9,"readFileSync");async function D9(n,e,t={}){let r=t.fs||wo,i=fE(e,t);await Ah.fromCallback(r.writeFile)(n,i,t)}o(D9,"_writeFile");var R9=Ah.fromPromise(D9);function F9(n,e,t={}){let r=t.fs||wo,i=fE(e,t);return r.writeFileSync(n,i,t)}o(F9,"writeFileSync");dE.exports={readFile:O9,readFileSync:P9,writeFile:R9,writeFileSync:F9}});var gE=v((LH,mE)=>{"use strict";var xh=pE();mE.exports={readJson:xh.readFile,readJsonSync:xh.readFileSync,writeJson:xh.writeFile,writeJsonSync:xh.writeFileSync}});var Ch=v((kH,SE)=>{"use strict";var N9=kt().fromPromise,V0=wr(),yE=require("path"),vE=Vn(),L9=cs().pathExists;async function k9(n,e,t="utf-8"){let r=yE.dirname(n);return await L9(r)||await vE.mkdirs(r),V0.writeFile(n,e,t)}o(k9,"outputFile");function M9(n,...e){let t=yE.dirname(n);V0.existsSync(t)||vE.mkdirsSync(t),V0.writeFileSync(n,...e)}o(M9,"outputFileSync");SE.exports={outputFile:N9(k9),outputFileSync:M9}});var bE=v((jH,_E)=>{"use strict";var{stringify:j9}=Th(),{outputFile:$9}=Ch();async function V9(n,e,t={}){let r=j9(e,t);await $9(n,r,t)}o(V9,"outputJson");_E.exports=V9});var EE=v((VH,wE)=>{"use strict";var{stringify:U9}=Th(),{outputFileSync:B9}=Ch();function q9(n,e,t){let r=U9(e,t);B9(n,r,t)}o(q9,"outputJsonSync");wE.exports=q9});var AE=v((BH,TE)=>{"use strict";var G9=kt().fromPromise,Tr=gE();Tr.outputJson=G9(bE());Tr.outputJsonSync=EE();Tr.outputJSON=Tr.outputJson;Tr.outputJSONSync=Tr.outputJsonSync;Tr.writeJSON=Tr.writeJson;Tr.writeJSONSync=Tr.writeJsonSync;Tr.readJSON=Tr.readJson;Tr.readJSONSync=Tr.readJsonSync;TE.exports=Tr});var PE=v((qH,OE)=>{"use strict";var W9=wr(),xE=require("path"),{copy:H9}=Eh(),{remove:IE}=Hc(),{mkdirp:z9}=Vn(),{pathExists:Q9}=cs(),CE=ua();async function Y9(n,e,t={}){let r=t.overwrite||t.clobber||!1,{srcStat:i,isChangingCase:s=!1}=await CE.checkPaths(n,e,"move",t);await CE.checkParentPaths(n,i,e,"move");let a=xE.dirname(e);return xE.parse(a).root!==a&&await z9(a),K9(n,e,r,s)}o(Y9,"move");async function K9(n,e,t,r){if(!r){if(t)await IE(e);else if(await Q9(e))throw new Error("dest already exists.")}try{await W9.rename(n,e)}catch(i){if(i.code!=="EXDEV")throw i;await X9(n,e,t)}}o(K9,"doRename");async function X9(n,e,t){return await H9(n,e,{overwrite:t,errorOnExist:!0,preserveTimestamps:!0}),IE(n)}o(X9,"moveAcrossDevice");OE.exports=Y9});var LE=v((WH,NE)=>{"use strict";var RE=So(),B0=require("path"),J9=Eh().copySync,FE=Hc().removeSync,Z9=Vn().mkdirpSync,DE=ua();function e6(n,e,t){t=t||{};let r=t.overwrite||t.clobber||!1,{srcStat:i,isChangingCase:s=!1}=DE.checkPathsSync(n,e,"move",t);return DE.checkParentPathsSync(n,i,e,"move"),t6(e)||Z9(B0.dirname(e)),r6(n,e,r,s)}o(e6,"moveSync");function t6(n){let e=B0.dirname(n);return B0.parse(e).root===e}o(t6,"isParentRoot");function r6(n,e,t,r){if(r)return U0(n,e,t);if(t)return FE(e),U0(n,e,t);if(RE.existsSync(e))throw new Error("dest already exists.");return U0(n,e,t)}o(r6,"doRename");function U0(n,e,t){try{RE.renameSync(n,e)}catch(r){if(r.code!=="EXDEV")throw r;return n6(n,e,t)}}o(U0,"rename");function n6(n,e,t){return J9(n,e,{overwrite:t,errorOnExist:!0,preserveTimestamps:!0}),FE(n)}o(n6,"moveAcrossDevice");NE.exports=e6});var ME=v((zH,kE)=>{"use strict";var i6=kt().fromPromise;kE.exports={move:i6(PE()),moveSync:LE()}});var Eo=v((QH,jE)=>{"use strict";jE.exports={...wr(),...Eh(),...Mw(),...uE(),...AE(),...Vn(),...ME(),...Ch(),...cs(),...Hc()}});var Q3=v((xQ,z3)=>{"use strict";z3.exports=W3;function W3(n,e,t){n instanceof RegExp&&(n=G3(n,t)),e instanceof RegExp&&(e=G3(e,t));var r=H3(n,e,t);return r&&{start:r[0],end:r[1],pre:t.slice(0,r[0]),body:t.slice(r[0]+n.length,r[1]),post:t.slice(r[1]+e.length)}}o(W3,"balanced");function G3(n,e){var t=e.match(n);return t?t[0]:null}o(G3,"maybeMatch");W3.range=H3;function H3(n,e,t){var r,i,s,a,c,u=t.indexOf(n),l=t.indexOf(e,u+1),f=u;if(u>=0&&l>0){if(n===e)return[u,l];for(r=[],s=t.length;f>=0&&!c;)f==u?(r.push(f),u=t.indexOf(n,f+1)):r.length==1?c=[r.pop(),l]:(i=r.pop(),i<s&&(s=i,a=l),l=t.indexOf(e,f+1)),f=u<l&&u>=0?u:l;r.length&&(c=[s,a])}return c}o(H3,"range")});var rT=v((IQ,tT)=>{var Y3=Q3();tT.exports=Ok;var K3="\0SLASH"+Math.random()+"\0",X3="\0OPEN"+Math.random()+"\0",s1="\0CLOSE"+Math.random()+"\0",J3="\0COMMA"+Math.random()+"\0",Z3="\0PERIOD"+Math.random()+"\0";function i1(n){return parseInt(n,10)==n?parseInt(n,10):n.charCodeAt(0)}o(i1,"numeric");function Ck(n){return n.split("\\\\").join(K3).split("\\{").join(X3).split("\\}").join(s1).split("\\,").join(J3).split("\\.").join(Z3)}o(Ck,"escapeBraces");function Ik(n){return n.split(K3).join("\\").split(X3).join("{").split(s1).join("}").split(J3).join(",").split(Z3).join(".")}o(Ik,"unescapeBraces");function eT(n){if(!n)return[""];var e=[],t=Y3("{","}",n);if(!t)return n.split(",");var r=t.pre,i=t.body,s=t.post,a=r.split(",");a[a.length-1]+="{"+i+"}";var c=eT(s);return s.length&&(a[a.length-1]+=c.shift(),a.push.apply(a,c)),e.push.apply(e,a),e}o(eT,"parseCommaParts");function Ok(n){return n?(n.substr(0,2)==="{}"&&(n="\\{\\}"+n.substr(2)),nu(Ck(n),!0).map(Ik)):[]}o(Ok,"expandTop");function Pk(n){return"{"+n+"}"}o(Pk,"embrace");function Dk(n){return/^-?0\d/.test(n)}o(Dk,"isPadded");function Rk(n,e){return n<=e}o(Rk,"lte");function Fk(n,e){return n>=e}o(Fk,"gte");function nu(n,e){var t=[],r=Y3("{","}",n);if(!r)return[n];var i=r.pre,s=r.post.length?nu(r.post,!1):[""];if(/\$$/.test(r.pre))for(var a=0;a<s.length;a++){var c=i+"{"+r.body+"}"+s[a];t.push(c)}else{var u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),f=u||l,h=r.body.indexOf(",")>=0;if(!f&&!h)return r.post.match(/,(?!,).*\}/)?(n=r.pre+"{"+r.body+s1+r.post,nu(n)):[n];var d;if(f)d=r.body.split(/\.\./);else if(d=eT(r.body),d.length===1&&(d=nu(d[0],!1).map(Pk),d.length===1))return s.map(function(ie){return r.pre+d[0]+ie});var p;if(f){var S=i1(d[0]),b=i1(d[1]),T=Math.max(d[0].length,d[1].length),I=d.length==3?Math.abs(i1(d[2])):1,O=Rk,L=b<S;L&&(I*=-1,O=Fk);var M=d.some(Dk);p=[];for(var G=S;O(G,b);G+=I){var Ee;if(l)Ee=String.fromCharCode(G),Ee==="\\"&&(Ee="");else if(Ee=String(G),M){var je=T-Ee.length;if(je>0){var Me=new Array(je+1).join("0");G<0?Ee="-"+Me+Ee.slice(1):Ee=Me+Ee}}p.push(Ee)}}else{p=[];for(var q=0;q<d.length;q++)p.push.apply(p,nu(d[q],!1))}for(var q=0;q<p.length;q++)for(var a=0;a<s.length;a++){var c=i+p[q]+s[a];(!e||f||c)&&t.push(c)}}return t}o(nu,"expand")});var EJ=Ne(Qu());var L2=Ne(N2(),1),{program:_j,createCommand:bj,createArgument:wj,createOption:Ej,CommanderError:Tj,InvalidArgumentError:Aj,InvalidOptionArgumentError:xj,Command:Lt,Argument:Cj,Option:Ij,Help:Oj}=L2.default;var ru=require("fs"),n1=require("path"),Cr=Ne($n());var _t=Ne(Eo()),bt=Ne(require("path"));function e3(n){return typeof n>"u"||n===null}o(e3,"isNothing");function s6(n){return typeof n=="object"&&n!==null}o(s6,"isObject");function a6(n){return Array.isArray(n)?n:e3(n)?[]:[n]}o(a6,"toArray");function o6(n,e){var t,r,i,s;if(e)for(s=Object.keys(e),t=0,r=s.length;t<r;t+=1)i=s[t],n[i]=e[i];return n}o(o6,"extend");function c6(n,e){var t="",r;for(r=0;r<e;r+=1)t+=n;return t}o(c6,"repeat");function u6(n){return n===0&&Number.NEGATIVE_INFINITY===1/n}o(u6,"isNegativeZero");var l6=e3,f6=s6,h6=a6,d6=c6,p6=u6,m6=o6,Rt={isNothing:l6,isObject:f6,toArray:h6,repeat:d6,isNegativeZero:p6,extend:m6};function t3(n,e){var t="",r=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(t+='in "'+n.mark.name+'" '),t+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!e&&n.mark.snippet&&(t+=`
|
|
363
363
|
|
|
364
|
-
`+n.mark.snippet),r+" "+t):r}o(
|
|
365
|
-
`+c;for(l=
|
|
364
|
+
`+n.mark.snippet),r+" "+t):r}o(t3,"formatError");function Yc(n,e){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=e,this.message=t3(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}o(Yc,"YAMLException$1");Yc.prototype=Object.create(Error.prototype);Yc.prototype.constructor=Yc;Yc.prototype.toString=o(function(e){return this.name+": "+t3(this,e)},"toString");var Ar=Yc;function q0(n,e,t,r,i){var s="",a="",c=Math.floor(i/2)-1;return r-e>c&&(s=" ... ",e=r-c+s.length),t-r>c&&(a=" ...",t=r+c-a.length),{str:s+n.slice(e,t).replace(/\t/g,"\u2192")+a,pos:r-e+s.length}}o(q0,"getLine");function G0(n,e){return Rt.repeat(" ",e-n.length)+n}o(G0,"padStart");function g6(n,e){if(e=Object.create(e||null),!n.buffer)return null;e.maxLength||(e.maxLength=79),typeof e.indent!="number"&&(e.indent=1),typeof e.linesBefore!="number"&&(e.linesBefore=3),typeof e.linesAfter!="number"&&(e.linesAfter=2);for(var t=/\r?\n|\r|\0/g,r=[0],i=[],s,a=-1;s=t.exec(n.buffer);)i.push(s.index),r.push(s.index+s[0].length),n.position<=s.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var c="",u,l,f=Math.min(n.line+e.linesAfter,i.length).toString().length,h=e.maxLength-(e.indent+f+3);for(u=1;u<=e.linesBefore&&!(a-u<0);u++)l=q0(n.buffer,r[a-u],i[a-u],n.position-(r[a]-r[a-u]),h),c=Rt.repeat(" ",e.indent)+G0((n.line-u+1).toString(),f)+" | "+l.str+`
|
|
365
|
+
`+c;for(l=q0(n.buffer,r[a],i[a],n.position,h),c+=Rt.repeat(" ",e.indent)+G0((n.line+1).toString(),f)+" | "+l.str+`
|
|
366
366
|
`,c+=Rt.repeat("-",e.indent+f+3+l.pos)+`^
|
|
367
|
-
`,u=1;u<=e.linesAfter&&!(a+u>=i.length);u++)l=
|
|
368
|
-
`;return c.replace(/\n$/,"")}o(
|
|
369
|
-
\r`;function
|
|
370
|
-
`:n===118?"\v":n===102?"\f":n===114?"\r":n===101?"\x1B":n===32?" ":n===34?'"':n===47?"/":n===92?"\\":n===78?"\x85":n===95?"\xA0":n===76?"\u2028":n===80?"\u2029":""}o(
|
|
371
|
-
`,e-1))}o(
|
|
372
|
-
`,s?1+u:u):i===
|
|
367
|
+
`,u=1;u<=e.linesAfter&&!(a+u>=i.length);u++)l=q0(n.buffer,r[a+u],i[a+u],n.position-(r[a]-r[a+u]),h),c+=Rt.repeat(" ",e.indent)+G0((n.line+u+1).toString(),f)+" | "+l.str+`
|
|
368
|
+
`;return c.replace(/\n$/,"")}o(g6,"makeSnippet");var y6=g6,v6=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],S6=["scalar","sequence","mapping"];function _6(n){var e={};return n!==null&&Object.keys(n).forEach(function(t){n[t].forEach(function(r){e[String(r)]=t})}),e}o(_6,"compileStyleAliases");function b6(n,e){if(e=e||{},Object.keys(e).forEach(function(t){if(v6.indexOf(t)===-1)throw new Ar('Unknown option "'+t+'" is met in definition of "'+n+'" YAML type.')}),this.options=e,this.tag=n,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=_6(e.styleAliases||null),S6.indexOf(this.kind)===-1)throw new Ar('Unknown kind "'+this.kind+'" is specified for "'+n+'" YAML type.')}o(b6,"Type$1");var Kt=b6;function $E(n,e){var t=[];return n[e].forEach(function(r){var i=t.length;t.forEach(function(s,a){s.tag===r.tag&&s.kind===r.kind&&s.multi===r.multi&&(i=a)}),t[i]=r}),t}o($E,"compileList");function w6(){var n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},e,t;function r(i){i.multi?(n.multi[i.kind].push(i),n.multi.fallback.push(i)):n[i.kind][i.tag]=n.fallback[i.tag]=i}for(o(r,"collectType"),e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(r);return n}o(w6,"compileMap");function H0(n){return this.extend(n)}o(H0,"Schema$1");H0.prototype.extend=o(function(e){var t=[],r=[];if(e instanceof Kt)r.push(e);else if(Array.isArray(e))r=r.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(r=r.concat(e.explicit));else throw new Ar("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.forEach(function(s){if(!(s instanceof Kt))throw new Ar("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(s.loadKind&&s.loadKind!=="scalar")throw new Ar("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(s.multi)throw new Ar("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(s){if(!(s instanceof Kt))throw new Ar("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(H0.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(r),i.compiledImplicit=$E(i,"implicit"),i.compiledExplicit=$E(i,"explicit"),i.compiledTypeMap=w6(i.compiledImplicit,i.compiledExplicit),i},"extend");var r3=H0,n3=new Kt("tag:yaml.org,2002:str",{kind:"scalar",construct:o(function(n){return n!==null?n:""},"construct")}),i3=new Kt("tag:yaml.org,2002:seq",{kind:"sequence",construct:o(function(n){return n!==null?n:[]},"construct")}),s3=new Kt("tag:yaml.org,2002:map",{kind:"mapping",construct:o(function(n){return n!==null?n:{}},"construct")}),a3=new r3({explicit:[n3,i3,s3]});function E6(n){if(n===null)return!0;var e=n.length;return e===1&&n==="~"||e===4&&(n==="null"||n==="Null"||n==="NULL")}o(E6,"resolveYamlNull");function T6(){return null}o(T6,"constructYamlNull");function A6(n){return n===null}o(A6,"isNull");var o3=new Kt("tag:yaml.org,2002:null",{kind:"scalar",resolve:E6,construct:T6,predicate:A6,represent:{canonical:o(function(){return"~"},"canonical"),lowercase:o(function(){return"null"},"lowercase"),uppercase:o(function(){return"NULL"},"uppercase"),camelcase:o(function(){return"Null"},"camelcase"),empty:o(function(){return""},"empty")},defaultStyle:"lowercase"});function x6(n){if(n===null)return!1;var e=n.length;return e===4&&(n==="true"||n==="True"||n==="TRUE")||e===5&&(n==="false"||n==="False"||n==="FALSE")}o(x6,"resolveYamlBoolean");function C6(n){return n==="true"||n==="True"||n==="TRUE"}o(C6,"constructYamlBoolean");function I6(n){return Object.prototype.toString.call(n)==="[object Boolean]"}o(I6,"isBoolean");var c3=new Kt("tag:yaml.org,2002:bool",{kind:"scalar",resolve:x6,construct:C6,predicate:I6,represent:{lowercase:o(function(n){return n?"true":"false"},"lowercase"),uppercase:o(function(n){return n?"TRUE":"FALSE"},"uppercase"),camelcase:o(function(n){return n?"True":"False"},"camelcase")},defaultStyle:"lowercase"});function O6(n){return 48<=n&&n<=57||65<=n&&n<=70||97<=n&&n<=102}o(O6,"isHexCode");function P6(n){return 48<=n&&n<=55}o(P6,"isOctCode");function D6(n){return 48<=n&&n<=57}o(D6,"isDecCode");function R6(n){if(n===null)return!1;var e=n.length,t=0,r=!1,i;if(!e)return!1;if(i=n[t],(i==="-"||i==="+")&&(i=n[++t]),i==="0"){if(t+1===e)return!0;if(i=n[++t],i==="b"){for(t++;t<e;t++)if(i=n[t],i!=="_"){if(i!=="0"&&i!=="1")return!1;r=!0}return r&&i!=="_"}if(i==="x"){for(t++;t<e;t++)if(i=n[t],i!=="_"){if(!O6(n.charCodeAt(t)))return!1;r=!0}return r&&i!=="_"}if(i==="o"){for(t++;t<e;t++)if(i=n[t],i!=="_"){if(!P6(n.charCodeAt(t)))return!1;r=!0}return r&&i!=="_"}}if(i==="_")return!1;for(;t<e;t++)if(i=n[t],i!=="_"){if(!D6(n.charCodeAt(t)))return!1;r=!0}return!(!r||i==="_")}o(R6,"resolveYamlInteger");function F6(n){var e=n,t=1,r;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),r=e[0],(r==="-"||r==="+")&&(r==="-"&&(t=-1),e=e.slice(1),r=e[0]),e==="0")return 0;if(r==="0"){if(e[1]==="b")return t*parseInt(e.slice(2),2);if(e[1]==="x")return t*parseInt(e.slice(2),16);if(e[1]==="o")return t*parseInt(e.slice(2),8)}return t*parseInt(e,10)}o(F6,"constructYamlInteger");function N6(n){return Object.prototype.toString.call(n)==="[object Number]"&&n%1===0&&!Rt.isNegativeZero(n)}o(N6,"isInteger");var u3=new Kt("tag:yaml.org,2002:int",{kind:"scalar",resolve:R6,construct:F6,predicate:N6,represent:{binary:o(function(n){return n>=0?"0b"+n.toString(2):"-0b"+n.toString(2).slice(1)},"binary"),octal:o(function(n){return n>=0?"0o"+n.toString(8):"-0o"+n.toString(8).slice(1)},"octal"),decimal:o(function(n){return n.toString(10)},"decimal"),hexadecimal:o(function(n){return n>=0?"0x"+n.toString(16).toUpperCase():"-0x"+n.toString(16).toUpperCase().slice(1)},"hexadecimal")},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),L6=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function k6(n){return!(n===null||!L6.test(n)||n[n.length-1]==="_")}o(k6,"resolveYamlFloat");function M6(n){var e,t;return e=n.replace(/_/g,"").toLowerCase(),t=e[0]==="-"?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),e===".inf"?t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:e===".nan"?NaN:t*parseFloat(e,10)}o(M6,"constructYamlFloat");var j6=/^[-+]?[0-9]+e/;function $6(n,e){var t;if(isNaN(n))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===n)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===n)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Rt.isNegativeZero(n))return"-0.0";return t=n.toString(10),j6.test(t)?t.replace("e",".e"):t}o($6,"representYamlFloat");function V6(n){return Object.prototype.toString.call(n)==="[object Number]"&&(n%1!==0||Rt.isNegativeZero(n))}o(V6,"isFloat");var l3=new Kt("tag:yaml.org,2002:float",{kind:"scalar",resolve:k6,construct:M6,predicate:V6,represent:$6,defaultStyle:"lowercase"}),f3=a3.extend({implicit:[o3,c3,u3,l3]}),h3=f3,d3=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),p3=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function U6(n){return n===null?!1:d3.exec(n)!==null||p3.exec(n)!==null}o(U6,"resolveYamlTimestamp");function B6(n){var e,t,r,i,s,a,c,u=0,l=null,f,h,d;if(e=d3.exec(n),e===null&&(e=p3.exec(n)),e===null)throw new Error("Date resolve error");if(t=+e[1],r=+e[2]-1,i=+e[3],!e[4])return new Date(Date.UTC(t,r,i));if(s=+e[4],a=+e[5],c=+e[6],e[7]){for(u=e[7].slice(0,3);u.length<3;)u+="0";u=+u}return e[9]&&(f=+e[10],h=+(e[11]||0),l=(f*60+h)*6e4,e[9]==="-"&&(l=-l)),d=new Date(Date.UTC(t,r,i,s,a,c,u)),l&&d.setTime(d.getTime()-l),d}o(B6,"constructYamlTimestamp");function q6(n){return n.toISOString()}o(q6,"representYamlTimestamp");var m3=new Kt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:U6,construct:B6,instanceOf:Date,represent:q6});function G6(n){return n==="<<"||n===null}o(G6,"resolveYamlMerge");var g3=new Kt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:G6}),X0=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
369
|
+
\r`;function W6(n){if(n===null)return!1;var e,t,r=0,i=n.length,s=X0;for(t=0;t<i;t++)if(e=s.indexOf(n.charAt(t)),!(e>64)){if(e<0)return!1;r+=6}return r%8===0}o(W6,"resolveYamlBinary");function H6(n){var e,t,r=n.replace(/[\r\n=]/g,""),i=r.length,s=X0,a=0,c=[];for(e=0;e<i;e++)e%4===0&&e&&(c.push(a>>16&255),c.push(a>>8&255),c.push(a&255)),a=a<<6|s.indexOf(r.charAt(e));return t=i%4*6,t===0?(c.push(a>>16&255),c.push(a>>8&255),c.push(a&255)):t===18?(c.push(a>>10&255),c.push(a>>2&255)):t===12&&c.push(a>>4&255),new Uint8Array(c)}o(H6,"constructYamlBinary");function z6(n){var e="",t=0,r,i,s=n.length,a=X0;for(r=0;r<s;r++)r%3===0&&r&&(e+=a[t>>18&63],e+=a[t>>12&63],e+=a[t>>6&63],e+=a[t&63]),t=(t<<8)+n[r];return i=s%3,i===0?(e+=a[t>>18&63],e+=a[t>>12&63],e+=a[t>>6&63],e+=a[t&63]):i===2?(e+=a[t>>10&63],e+=a[t>>4&63],e+=a[t<<2&63],e+=a[64]):i===1&&(e+=a[t>>2&63],e+=a[t<<4&63],e+=a[64],e+=a[64]),e}o(z6,"representYamlBinary");function Q6(n){return Object.prototype.toString.call(n)==="[object Uint8Array]"}o(Q6,"isBinary");var y3=new Kt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:W6,construct:H6,predicate:Q6,represent:z6}),Y6=Object.prototype.hasOwnProperty,K6=Object.prototype.toString;function X6(n){if(n===null)return!0;var e=[],t,r,i,s,a,c=n;for(t=0,r=c.length;t<r;t+=1){if(i=c[t],a=!1,K6.call(i)!=="[object Object]")return!1;for(s in i)if(Y6.call(i,s))if(!a)a=!0;else return!1;if(!a)return!1;if(e.indexOf(s)===-1)e.push(s);else return!1}return!0}o(X6,"resolveYamlOmap");function J6(n){return n!==null?n:[]}o(J6,"constructYamlOmap");var v3=new Kt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:X6,construct:J6}),Z6=Object.prototype.toString;function e7(n){if(n===null)return!0;var e,t,r,i,s,a=n;for(s=new Array(a.length),e=0,t=a.length;e<t;e+=1){if(r=a[e],Z6.call(r)!=="[object Object]"||(i=Object.keys(r),i.length!==1))return!1;s[e]=[i[0],r[i[0]]]}return!0}o(e7,"resolveYamlPairs");function t7(n){if(n===null)return[];var e,t,r,i,s,a=n;for(s=new Array(a.length),e=0,t=a.length;e<t;e+=1)r=a[e],i=Object.keys(r),s[e]=[i[0],r[i[0]]];return s}o(t7,"constructYamlPairs");var S3=new Kt("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:e7,construct:t7}),r7=Object.prototype.hasOwnProperty;function n7(n){if(n===null)return!0;var e,t=n;for(e in t)if(r7.call(t,e)&&t[e]!==null)return!1;return!0}o(n7,"resolveYamlSet");function i7(n){return n!==null?n:{}}o(i7,"constructYamlSet");var _3=new Kt("tag:yaml.org,2002:set",{kind:"mapping",resolve:n7,construct:i7}),J0=h3.extend({implicit:[m3,g3],explicit:[y3,v3,S3,_3]}),hs=Object.prototype.hasOwnProperty,Ih=1,b3=2,w3=3,Oh=4,W0=1,s7=2,VE=3,a7=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,o7=/[\x85\u2028\u2029]/,c7=/[,\[\]\{\}]/,E3=/^(?:!|!!|![a-z\-]+!)$/i,T3=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function UE(n){return Object.prototype.toString.call(n)}o(UE,"_class");function fi(n){return n===10||n===13}o(fi,"is_EOL");function fa(n){return n===9||n===32}o(fa,"is_WHITE_SPACE");function Mr(n){return n===9||n===32||n===10||n===13}o(Mr,"is_WS_OR_EOL");function Ao(n){return n===44||n===91||n===93||n===123||n===125}o(Ao,"is_FLOW_INDICATOR");function u7(n){var e;return 48<=n&&n<=57?n-48:(e=n|32,97<=e&&e<=102?e-97+10:-1)}o(u7,"fromHexCode");function l7(n){return n===120?2:n===117?4:n===85?8:0}o(l7,"escapedHexLen");function f7(n){return 48<=n&&n<=57?n-48:-1}o(f7,"fromDecimalCode");function BE(n){return n===48?"\0":n===97?"\x07":n===98?"\b":n===116||n===9?" ":n===110?`
|
|
370
|
+
`:n===118?"\v":n===102?"\f":n===114?"\r":n===101?"\x1B":n===32?" ":n===34?'"':n===47?"/":n===92?"\\":n===78?"\x85":n===95?"\xA0":n===76?"\u2028":n===80?"\u2029":""}o(BE,"simpleEscapeSequence");function h7(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}o(h7,"charFromCodepoint");function A3(n,e,t){e==="__proto__"?Object.defineProperty(n,e,{configurable:!0,enumerable:!0,writable:!0,value:t}):n[e]=t}o(A3,"setProperty");var x3=new Array(256),C3=new Array(256);for(la=0;la<256;la++)x3[la]=BE(la)?1:0,C3[la]=BE(la);var la;function d7(n,e){this.input=n,this.filename=e.filename||null,this.schema=e.schema||J0,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}o(d7,"State$1");function I3(n,e){var t={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return t.snippet=y6(t),new Ar(e,t)}o(I3,"generateError");function J(n,e){throw I3(n,e)}o(J,"throwError");function Ph(n,e){n.onWarning&&n.onWarning.call(null,I3(n,e))}o(Ph,"throwWarning");var qE={YAML:o(function(e,t,r){var i,s,a;e.version!==null&&J(e,"duplication of %YAML directive"),r.length!==1&&J(e,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),i===null&&J(e,"ill-formed argument of the YAML directive"),s=parseInt(i[1],10),a=parseInt(i[2],10),s!==1&&J(e,"unacceptable YAML version of the document"),e.version=r[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&Ph(e,"unsupported YAML version of the document")},"handleYamlDirective"),TAG:o(function(e,t,r){var i,s;r.length!==2&&J(e,"TAG directive accepts exactly two arguments"),i=r[0],s=r[1],E3.test(i)||J(e,"ill-formed tag handle (first argument) of the TAG directive"),hs.call(e.tagMap,i)&&J(e,'there is a previously declared suffix for "'+i+'" tag handle'),T3.test(s)||J(e,"ill-formed tag prefix (second argument) of the TAG directive");try{s=decodeURIComponent(s)}catch{J(e,"tag prefix is malformed: "+s)}e.tagMap[i]=s},"handleTagDirective")};function fs(n,e,t,r){var i,s,a,c;if(e<t){if(c=n.input.slice(e,t),r)for(i=0,s=c.length;i<s;i+=1)a=c.charCodeAt(i),a===9||32<=a&&a<=1114111||J(n,"expected valid JSON character");else a7.test(c)&&J(n,"the stream contains non-printable characters");n.result+=c}}o(fs,"captureSegment");function GE(n,e,t,r){var i,s,a,c;for(Rt.isObject(t)||J(n,"cannot merge mappings; the provided source object is unacceptable"),i=Object.keys(t),a=0,c=i.length;a<c;a+=1)s=i[a],hs.call(e,s)||(A3(e,s,t[s]),r[s]=!0)}o(GE,"mergeMappings");function xo(n,e,t,r,i,s,a,c,u){var l,f;if(Array.isArray(i))for(i=Array.prototype.slice.call(i),l=0,f=i.length;l<f;l+=1)Array.isArray(i[l])&&J(n,"nested arrays are not supported inside keys"),typeof i=="object"&&UE(i[l])==="[object Object]"&&(i[l]="[object Object]");if(typeof i=="object"&&UE(i)==="[object Object]"&&(i="[object Object]"),i=String(i),e===null&&(e={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(s))for(l=0,f=s.length;l<f;l+=1)GE(n,e,s[l],t);else GE(n,e,s,t);else!n.json&&!hs.call(t,i)&&hs.call(e,i)&&(n.line=a||n.line,n.lineStart=c||n.lineStart,n.position=u||n.position,J(n,"duplicated mapping key")),A3(e,i,s),delete t[i];return e}o(xo,"storeMappingPair");function Z0(n){var e;e=n.input.charCodeAt(n.position),e===10?n.position++:e===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):J(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}o(Z0,"readLineBreak");function It(n,e,t){for(var r=0,i=n.input.charCodeAt(n.position);i!==0;){for(;fa(i);)i===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),i=n.input.charCodeAt(++n.position);if(e&&i===35)do i=n.input.charCodeAt(++n.position);while(i!==10&&i!==13&&i!==0);if(fi(i))for(Z0(n),i=n.input.charCodeAt(n.position),r++,n.lineIndent=0;i===32;)n.lineIndent++,i=n.input.charCodeAt(++n.position);else break}return t!==-1&&r!==0&&n.lineIndent<t&&Ph(n,"deficient indentation"),r}o(It,"skipSeparationSpace");function Fh(n){var e=n.position,t;return t=n.input.charCodeAt(e),!!((t===45||t===46)&&t===n.input.charCodeAt(e+1)&&t===n.input.charCodeAt(e+2)&&(e+=3,t=n.input.charCodeAt(e),t===0||Mr(t)))}o(Fh,"testDocumentSeparator");function e1(n,e){e===1?n.result+=" ":e>1&&(n.result+=Rt.repeat(`
|
|
371
|
+
`,e-1))}o(e1,"writeFoldedLines");function p7(n,e,t){var r,i,s,a,c,u,l,f,h=n.kind,d=n.result,p;if(p=n.input.charCodeAt(n.position),Mr(p)||Ao(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(i=n.input.charCodeAt(n.position+1),Mr(i)||t&&Ao(i)))return!1;for(n.kind="scalar",n.result="",s=a=n.position,c=!1;p!==0;){if(p===58){if(i=n.input.charCodeAt(n.position+1),Mr(i)||t&&Ao(i))break}else if(p===35){if(r=n.input.charCodeAt(n.position-1),Mr(r))break}else{if(n.position===n.lineStart&&Fh(n)||t&&Ao(p))break;if(fi(p))if(u=n.line,l=n.lineStart,f=n.lineIndent,It(n,!1,-1),n.lineIndent>=e){c=!0,p=n.input.charCodeAt(n.position);continue}else{n.position=a,n.line=u,n.lineStart=l,n.lineIndent=f;break}}c&&(fs(n,s,a,!1),e1(n,n.line-u),s=a=n.position,c=!1),fa(p)||(a=n.position+1),p=n.input.charCodeAt(++n.position)}return fs(n,s,a,!1),n.result?!0:(n.kind=h,n.result=d,!1)}o(p7,"readPlainScalar");function m7(n,e){var t,r,i;if(t=n.input.charCodeAt(n.position),t!==39)return!1;for(n.kind="scalar",n.result="",n.position++,r=i=n.position;(t=n.input.charCodeAt(n.position))!==0;)if(t===39)if(fs(n,r,n.position,!0),t=n.input.charCodeAt(++n.position),t===39)r=n.position,n.position++,i=n.position;else return!0;else fi(t)?(fs(n,r,i,!0),e1(n,It(n,!1,e)),r=i=n.position):n.position===n.lineStart&&Fh(n)?J(n,"unexpected end of the document within a single quoted scalar"):(n.position++,i=n.position);J(n,"unexpected end of the stream within a single quoted scalar")}o(m7,"readSingleQuotedScalar");function g7(n,e){var t,r,i,s,a,c;if(c=n.input.charCodeAt(n.position),c!==34)return!1;for(n.kind="scalar",n.result="",n.position++,t=r=n.position;(c=n.input.charCodeAt(n.position))!==0;){if(c===34)return fs(n,t,n.position,!0),n.position++,!0;if(c===92){if(fs(n,t,n.position,!0),c=n.input.charCodeAt(++n.position),fi(c))It(n,!1,e);else if(c<256&&x3[c])n.result+=C3[c],n.position++;else if((a=l7(c))>0){for(i=a,s=0;i>0;i--)c=n.input.charCodeAt(++n.position),(a=u7(c))>=0?s=(s<<4)+a:J(n,"expected hexadecimal character");n.result+=h7(s),n.position++}else J(n,"unknown escape sequence");t=r=n.position}else fi(c)?(fs(n,t,r,!0),e1(n,It(n,!1,e)),t=r=n.position):n.position===n.lineStart&&Fh(n)?J(n,"unexpected end of the document within a double quoted scalar"):(n.position++,r=n.position)}J(n,"unexpected end of the stream within a double quoted scalar")}o(g7,"readDoubleQuotedScalar");function y7(n,e){var t=!0,r,i,s,a=n.tag,c,u=n.anchor,l,f,h,d,p,S=Object.create(null),b,T,I,O;if(O=n.input.charCodeAt(n.position),O===91)f=93,p=!1,c=[];else if(O===123)f=125,p=!0,c={};else return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=c),O=n.input.charCodeAt(++n.position);O!==0;){if(It(n,!0,e),O=n.input.charCodeAt(n.position),O===f)return n.position++,n.tag=a,n.anchor=u,n.kind=p?"mapping":"sequence",n.result=c,!0;t?O===44&&J(n,"expected the node content, but found ','"):J(n,"missed comma between flow collection entries"),T=b=I=null,h=d=!1,O===63&&(l=n.input.charCodeAt(n.position+1),Mr(l)&&(h=d=!0,n.position++,It(n,!0,e))),r=n.line,i=n.lineStart,s=n.position,Co(n,e,Ih,!1,!0),T=n.tag,b=n.result,It(n,!0,e),O=n.input.charCodeAt(n.position),(d||n.line===r)&&O===58&&(h=!0,O=n.input.charCodeAt(++n.position),It(n,!0,e),Co(n,e,Ih,!1,!0),I=n.result),p?xo(n,c,S,T,b,I,r,i,s):h?c.push(xo(n,null,S,T,b,I,r,i,s)):c.push(b),It(n,!0,e),O=n.input.charCodeAt(n.position),O===44?(t=!0,O=n.input.charCodeAt(++n.position)):t=!1}J(n,"unexpected end of the stream within a flow collection")}o(y7,"readFlowCollection");function v7(n,e){var t,r,i=W0,s=!1,a=!1,c=e,u=0,l=!1,f,h;if(h=n.input.charCodeAt(n.position),h===124)r=!1;else if(h===62)r=!0;else return!1;for(n.kind="scalar",n.result="";h!==0;)if(h=n.input.charCodeAt(++n.position),h===43||h===45)W0===i?i=h===43?VE:s7:J(n,"repeat of a chomping mode identifier");else if((f=f7(h))>=0)f===0?J(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?J(n,"repeat of an indentation width identifier"):(c=e+f-1,a=!0);else break;if(fa(h)){do h=n.input.charCodeAt(++n.position);while(fa(h));if(h===35)do h=n.input.charCodeAt(++n.position);while(!fi(h)&&h!==0)}for(;h!==0;){for(Z0(n),n.lineIndent=0,h=n.input.charCodeAt(n.position);(!a||n.lineIndent<c)&&h===32;)n.lineIndent++,h=n.input.charCodeAt(++n.position);if(!a&&n.lineIndent>c&&(c=n.lineIndent),fi(h)){u++;continue}if(n.lineIndent<c){i===VE?n.result+=Rt.repeat(`
|
|
372
|
+
`,s?1+u:u):i===W0&&s&&(n.result+=`
|
|
373
373
|
`);break}for(r?fa(h)?(l=!0,n.result+=Rt.repeat(`
|
|
374
374
|
`,s?1+u:u)):l?(l=!1,n.result+=Rt.repeat(`
|
|
375
375
|
`,u+1)):u===0?s&&(n.result+=" "):n.result+=Rt.repeat(`
|
|
376
376
|
`,u):n.result+=Rt.repeat(`
|
|
377
|
-
`,s?1+u:u),s=!0,a=!0,u=0,t=n.position;!fi(h)&&h!==0;)h=n.input.charCodeAt(++n.position);fs(n,t,n.position,!1)}return!0}o(
|
|
378
|
-
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));var t=new
|
|
377
|
+
`,s?1+u:u),s=!0,a=!0,u=0,t=n.position;!fi(h)&&h!==0;)h=n.input.charCodeAt(++n.position);fs(n,t,n.position,!1)}return!0}o(v7,"readBlockScalar");function WE(n,e){var t,r=n.tag,i=n.anchor,s=[],a,c=!1,u;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=s),u=n.input.charCodeAt(n.position);u!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,J(n,"tab characters must not be used in indentation")),!(u!==45||(a=n.input.charCodeAt(n.position+1),!Mr(a))));){if(c=!0,n.position++,It(n,!0,-1)&&n.lineIndent<=e){s.push(null),u=n.input.charCodeAt(n.position);continue}if(t=n.line,Co(n,e,w3,!1,!0),s.push(n.result),It(n,!0,-1),u=n.input.charCodeAt(n.position),(n.line===t||n.lineIndent>e)&&u!==0)J(n,"bad indentation of a sequence entry");else if(n.lineIndent<e)break}return c?(n.tag=r,n.anchor=i,n.kind="sequence",n.result=s,!0):!1}o(WE,"readBlockSequence");function S7(n,e,t){var r,i,s,a,c,u,l=n.tag,f=n.anchor,h={},d=Object.create(null),p=null,S=null,b=null,T=!1,I=!1,O;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=h),O=n.input.charCodeAt(n.position);O!==0;){if(!T&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,J(n,"tab characters must not be used in indentation")),r=n.input.charCodeAt(n.position+1),s=n.line,(O===63||O===58)&&Mr(r))O===63?(T&&(xo(n,h,d,p,S,null,a,c,u),p=S=b=null),I=!0,T=!0,i=!0):T?(T=!1,i=!0):J(n,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),n.position+=1,O=r;else{if(a=n.line,c=n.lineStart,u=n.position,!Co(n,t,b3,!1,!0))break;if(n.line===s){for(O=n.input.charCodeAt(n.position);fa(O);)O=n.input.charCodeAt(++n.position);if(O===58)O=n.input.charCodeAt(++n.position),Mr(O)||J(n,"a whitespace character is expected after the key-value separator within a block mapping"),T&&(xo(n,h,d,p,S,null,a,c,u),p=S=b=null),I=!0,T=!1,i=!1,p=n.tag,S=n.result;else if(I)J(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=l,n.anchor=f,!0}else if(I)J(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=l,n.anchor=f,!0}if((n.line===s||n.lineIndent>e)&&(T&&(a=n.line,c=n.lineStart,u=n.position),Co(n,e,Oh,!0,i)&&(T?S=n.result:b=n.result),T||(xo(n,h,d,p,S,b,a,c,u),p=S=b=null),It(n,!0,-1),O=n.input.charCodeAt(n.position)),(n.line===s||n.lineIndent>e)&&O!==0)J(n,"bad indentation of a mapping entry");else if(n.lineIndent<e)break}return T&&xo(n,h,d,p,S,null,a,c,u),I&&(n.tag=l,n.anchor=f,n.kind="mapping",n.result=h),I}o(S7,"readBlockMapping");function _7(n){var e,t=!1,r=!1,i,s,a;if(a=n.input.charCodeAt(n.position),a!==33)return!1;if(n.tag!==null&&J(n,"duplication of a tag property"),a=n.input.charCodeAt(++n.position),a===60?(t=!0,a=n.input.charCodeAt(++n.position)):a===33?(r=!0,i="!!",a=n.input.charCodeAt(++n.position)):i="!",e=n.position,t){do a=n.input.charCodeAt(++n.position);while(a!==0&&a!==62);n.position<n.length?(s=n.input.slice(e,n.position),a=n.input.charCodeAt(++n.position)):J(n,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!Mr(a);)a===33&&(r?J(n,"tag suffix cannot contain exclamation marks"):(i=n.input.slice(e-1,n.position+1),E3.test(i)||J(n,"named tag handle cannot contain such characters"),r=!0,e=n.position+1)),a=n.input.charCodeAt(++n.position);s=n.input.slice(e,n.position),c7.test(s)&&J(n,"tag suffix cannot contain flow indicator characters")}s&&!T3.test(s)&&J(n,"tag name cannot contain such characters: "+s);try{s=decodeURIComponent(s)}catch{J(n,"tag name is malformed: "+s)}return t?n.tag=s:hs.call(n.tagMap,i)?n.tag=n.tagMap[i]+s:i==="!"?n.tag="!"+s:i==="!!"?n.tag="tag:yaml.org,2002:"+s:J(n,'undeclared tag handle "'+i+'"'),!0}o(_7,"readTagProperty");function b7(n){var e,t;if(t=n.input.charCodeAt(n.position),t!==38)return!1;for(n.anchor!==null&&J(n,"duplication of an anchor property"),t=n.input.charCodeAt(++n.position),e=n.position;t!==0&&!Mr(t)&&!Ao(t);)t=n.input.charCodeAt(++n.position);return n.position===e&&J(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice(e,n.position),!0}o(b7,"readAnchorProperty");function w7(n){var e,t,r;if(r=n.input.charCodeAt(n.position),r!==42)return!1;for(r=n.input.charCodeAt(++n.position),e=n.position;r!==0&&!Mr(r)&&!Ao(r);)r=n.input.charCodeAt(++n.position);return n.position===e&&J(n,"name of an alias node must contain at least one character"),t=n.input.slice(e,n.position),hs.call(n.anchorMap,t)||J(n,'unidentified alias "'+t+'"'),n.result=n.anchorMap[t],It(n,!0,-1),!0}o(w7,"readAlias");function Co(n,e,t,r,i){var s,a,c,u=1,l=!1,f=!1,h,d,p,S,b,T;if(n.listener!==null&&n.listener("open",n),n.tag=null,n.anchor=null,n.kind=null,n.result=null,s=a=c=Oh===t||w3===t,r&&It(n,!0,-1)&&(l=!0,n.lineIndent>e?u=1:n.lineIndent===e?u=0:n.lineIndent<e&&(u=-1)),u===1)for(;_7(n)||b7(n);)It(n,!0,-1)?(l=!0,c=s,n.lineIndent>e?u=1:n.lineIndent===e?u=0:n.lineIndent<e&&(u=-1)):c=!1;if(c&&(c=l||i),(u===1||Oh===t)&&(Ih===t||b3===t?b=e:b=e+1,T=n.position-n.lineStart,u===1?c&&(WE(n,T)||S7(n,T,b))||y7(n,b)?f=!0:(a&&v7(n,b)||m7(n,b)||g7(n,b)?f=!0:w7(n)?(f=!0,(n.tag!==null||n.anchor!==null)&&J(n,"alias node should not have any properties")):p7(n,b,Ih===t)&&(f=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&(n.anchorMap[n.anchor]=n.result)):u===0&&(f=c&&WE(n,T))),n.tag===null)n.anchor!==null&&(n.anchorMap[n.anchor]=n.result);else if(n.tag==="?"){for(n.result!==null&&n.kind!=="scalar"&&J(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"'),h=0,d=n.implicitTypes.length;h<d;h+=1)if(S=n.implicitTypes[h],S.resolve(n.result)){n.result=S.construct(n.result),n.tag=S.tag,n.anchor!==null&&(n.anchorMap[n.anchor]=n.result);break}}else if(n.tag!=="!"){if(hs.call(n.typeMap[n.kind||"fallback"],n.tag))S=n.typeMap[n.kind||"fallback"][n.tag];else for(S=null,p=n.typeMap.multi[n.kind||"fallback"],h=0,d=p.length;h<d;h+=1)if(n.tag.slice(0,p[h].tag.length)===p[h].tag){S=p[h];break}S||J(n,"unknown tag !<"+n.tag+">"),n.result!==null&&S.kind!==n.kind&&J(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+S.kind+'", not "'+n.kind+'"'),S.resolve(n.result,n.tag)?(n.result=S.construct(n.result,n.tag),n.anchor!==null&&(n.anchorMap[n.anchor]=n.result)):J(n,"cannot resolve a node with !<"+n.tag+"> explicit tag")}return n.listener!==null&&n.listener("close",n),n.tag!==null||n.anchor!==null||f}o(Co,"composeNode");function E7(n){var e=n.position,t,r,i,s=!1,a;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(a=n.input.charCodeAt(n.position))!==0&&(It(n,!0,-1),a=n.input.charCodeAt(n.position),!(n.lineIndent>0||a!==37));){for(s=!0,a=n.input.charCodeAt(++n.position),t=n.position;a!==0&&!Mr(a);)a=n.input.charCodeAt(++n.position);for(r=n.input.slice(t,n.position),i=[],r.length<1&&J(n,"directive name must not be less than one character in length");a!==0;){for(;fa(a);)a=n.input.charCodeAt(++n.position);if(a===35){do a=n.input.charCodeAt(++n.position);while(a!==0&&!fi(a));break}if(fi(a))break;for(t=n.position;a!==0&&!Mr(a);)a=n.input.charCodeAt(++n.position);i.push(n.input.slice(t,n.position))}a!==0&&Z0(n),hs.call(qE,r)?qE[r](n,r,i):Ph(n,'unknown document directive "'+r+'"')}if(It(n,!0,-1),n.lineIndent===0&&n.input.charCodeAt(n.position)===45&&n.input.charCodeAt(n.position+1)===45&&n.input.charCodeAt(n.position+2)===45?(n.position+=3,It(n,!0,-1)):s&&J(n,"directives end mark is expected"),Co(n,n.lineIndent-1,Oh,!1,!0),It(n,!0,-1),n.checkLineBreaks&&o7.test(n.input.slice(e,n.position))&&Ph(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&Fh(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,It(n,!0,-1));return}if(n.position<n.length-1)J(n,"end of the stream or a document separator is expected");else return}o(E7,"readDocument");function O3(n,e){n=String(n),e=e||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
|
|
378
|
+
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));var t=new d7(n,e),r=n.indexOf("\0");for(r!==-1&&(t.position=r,J(t,"null byte is not allowed in input")),t.input+="\0";t.input.charCodeAt(t.position)===32;)t.lineIndent+=1,t.position+=1;for(;t.position<t.length-1;)E7(t);return t.documents}o(O3,"loadDocuments");function T7(n,e,t){e!==null&&typeof e=="object"&&typeof t>"u"&&(t=e,e=null);var r=O3(n,t);if(typeof e!="function")return r;for(var i=0,s=r.length;i<s;i+=1)e(r[i])}o(T7,"loadAll$1");function A7(n,e){var t=O3(n,e);if(t.length!==0){if(t.length===1)return t[0];throw new Ar("expected a single document in the stream, but found more")}}o(A7,"load$1");var x7=T7,C7=A7,P3={loadAll:x7,load:C7},D3=Object.prototype.toString,R3=Object.prototype.hasOwnProperty,t1=65279,I7=9,Kc=10,O7=13,P7=32,D7=33,R7=34,z0=35,F7=37,N7=38,L7=39,k7=42,F3=44,M7=45,Dh=58,j7=61,$7=62,V7=63,U7=64,N3=91,L3=93,B7=96,k3=123,q7=124,M3=125,cr={};cr[0]="\\0";cr[7]="\\a";cr[8]="\\b";cr[9]="\\t";cr[10]="\\n";cr[11]="\\v";cr[12]="\\f";cr[13]="\\r";cr[27]="\\e";cr[34]='\\"';cr[92]="\\\\";cr[133]="\\N";cr[160]="\\_";cr[8232]="\\L";cr[8233]="\\P";var G7=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],W7=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function H7(n,e){var t,r,i,s,a,c,u;if(e===null)return{};for(t={},r=Object.keys(e),i=0,s=r.length;i<s;i+=1)a=r[i],c=String(e[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),u=n.compiledTypeMap.fallback[a],u&&R3.call(u.styleAliases,c)&&(c=u.styleAliases[c]),t[a]=c;return t}o(H7,"compileStyleMap");function z7(n){var e,t,r;if(e=n.toString(16).toUpperCase(),n<=255)t="x",r=2;else if(n<=65535)t="u",r=4;else if(n<=4294967295)t="U",r=8;else throw new Ar("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+t+Rt.repeat("0",r-e.length)+e}o(z7,"encodeHex");var Q7=1,Xc=2;function Y7(n){this.schema=n.schema||J0,this.indent=Math.max(1,n.indent||2),this.noArrayIndent=n.noArrayIndent||!1,this.skipInvalid=n.skipInvalid||!1,this.flowLevel=Rt.isNothing(n.flowLevel)?-1:n.flowLevel,this.styleMap=H7(this.schema,n.styles||null),this.sortKeys=n.sortKeys||!1,this.lineWidth=n.lineWidth||80,this.noRefs=n.noRefs||!1,this.noCompatMode=n.noCompatMode||!1,this.condenseFlow=n.condenseFlow||!1,this.quotingType=n.quotingType==='"'?Xc:Q7,this.forceQuotes=n.forceQuotes||!1,this.replacer=typeof n.replacer=="function"?n.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}o(Y7,"State");function HE(n,e){for(var t=Rt.repeat(" ",e),r=0,i=-1,s="",a,c=n.length;r<c;)i=n.indexOf(`
|
|
379
379
|
`,r),i===-1?(a=n.slice(r),r=c):(a=n.slice(r,i+1),r=i+1),a.length&&a!==`
|
|
380
|
-
`&&(s+=t),s+=a;return s}o(
|
|
381
|
-
`+Rt.repeat(" ",n.indent*e)}o(
|
|
380
|
+
`&&(s+=t),s+=a;return s}o(HE,"indentString");function Q0(n,e){return`
|
|
381
|
+
`+Rt.repeat(" ",n.indent*e)}o(Q0,"generateNextLine");function K7(n,e){var t,r,i;for(t=0,r=n.implicitTypes.length;t<r;t+=1)if(i=n.implicitTypes[t],i.resolve(e))return!0;return!1}o(K7,"testImplicitResolving");function Rh(n){return n===P7||n===I7}o(Rh,"isWhitespace");function Jc(n){return 32<=n&&n<=126||161<=n&&n<=55295&&n!==8232&&n!==8233||57344<=n&&n<=65533&&n!==t1||65536<=n&&n<=1114111}o(Jc,"isPrintable");function zE(n){return Jc(n)&&n!==t1&&n!==O7&&n!==Kc}o(zE,"isNsCharOrWhitespace");function QE(n,e,t){var r=zE(n),i=r&&!Rh(n);return(t?r:r&&n!==F3&&n!==N3&&n!==L3&&n!==k3&&n!==M3)&&n!==z0&&!(e===Dh&&!i)||zE(e)&&!Rh(e)&&n===z0||e===Dh&&i}o(QE,"isPlainSafe");function X7(n){return Jc(n)&&n!==t1&&!Rh(n)&&n!==M7&&n!==V7&&n!==Dh&&n!==F3&&n!==N3&&n!==L3&&n!==k3&&n!==M3&&n!==z0&&n!==N7&&n!==k7&&n!==D7&&n!==q7&&n!==j7&&n!==$7&&n!==L7&&n!==R7&&n!==F7&&n!==U7&&n!==B7}o(X7,"isPlainSafeFirst");function J7(n){return!Rh(n)&&n!==Dh}o(J7,"isPlainSafeLast");function Qc(n,e){var t=n.charCodeAt(e),r;return t>=55296&&t<=56319&&e+1<n.length&&(r=n.charCodeAt(e+1),r>=56320&&r<=57343)?(t-55296)*1024+r-56320+65536:t}o(Qc,"codePointAt");function j3(n){var e=/^\n* /;return e.test(n)}o(j3,"needIndentIndicator");var $3=1,Y0=2,V3=3,U3=4,To=5;function Z7(n,e,t,r,i,s,a,c){var u,l=0,f=null,h=!1,d=!1,p=r!==-1,S=-1,b=X7(Qc(n,0))&&J7(Qc(n,n.length-1));if(e||a)for(u=0;u<n.length;l>=65536?u+=2:u++){if(l=Qc(n,u),!Jc(l))return To;b=b&&QE(l,f,c),f=l}else{for(u=0;u<n.length;l>=65536?u+=2:u++){if(l=Qc(n,u),l===Kc)h=!0,p&&(d=d||u-S-1>r&&n[S+1]!==" ",S=u);else if(!Jc(l))return To;b=b&&QE(l,f,c),f=l}d=d||p&&u-S-1>r&&n[S+1]!==" "}return!h&&!d?b&&!a&&!i(n)?$3:s===Xc?To:Y0:t>9&&j3(n)?To:a?s===Xc?To:Y0:d?U3:V3}o(Z7,"chooseScalarStyle");function ek(n,e,t,r,i){n.dump=(function(){if(e.length===0)return n.quotingType===Xc?'""':"''";if(!n.noCompatMode&&(G7.indexOf(e)!==-1||W7.test(e)))return n.quotingType===Xc?'"'+e+'"':"'"+e+"'";var s=n.indent*Math.max(1,t),a=n.lineWidth===-1?-1:Math.max(Math.min(n.lineWidth,40),n.lineWidth-s),c=r||n.flowLevel>-1&&t>=n.flowLevel;function u(l){return K7(n,l)}switch(o(u,"testAmbiguity"),Z7(e,c,n.indent,a,u,n.quotingType,n.forceQuotes&&!r,i)){case $3:return e;case Y0:return"'"+e.replace(/'/g,"''")+"'";case V3:return"|"+YE(e,n.indent)+KE(HE(e,s));case U3:return">"+YE(e,n.indent)+KE(HE(tk(e,a),s));case To:return'"'+rk(e)+'"';default:throw new Ar("impossible error: invalid scalar style")}})()}o(ek,"writeScalar");function YE(n,e){var t=j3(n)?String(e):"",r=n[n.length-1]===`
|
|
382
382
|
`,i=r&&(n[n.length-2]===`
|
|
383
383
|
`||n===`
|
|
384
384
|
`),s=i?"+":r?"":"-";return t+s+`
|
|
385
|
-
`}o(
|
|
386
|
-
`?n.slice(0,-1):n}o(
|
|
387
|
-
`);return l=l!==-1?l:n.length,t.lastIndex=l,
|
|
385
|
+
`}o(YE,"blockHeader");function KE(n){return n[n.length-1]===`
|
|
386
|
+
`?n.slice(0,-1):n}o(KE,"dropEndingNewline");function tk(n,e){for(var t=/(\n+)([^\n]*)/g,r=(function(){var l=n.indexOf(`
|
|
387
|
+
`);return l=l!==-1?l:n.length,t.lastIndex=l,XE(n.slice(0,l),e)})(),i=n[0]===`
|
|
388
388
|
`||n[0]===" ",s,a;a=t.exec(n);){var c=a[1],u=a[2];s=u[0]===" ",r+=c+(!i&&!s&&u!==""?`
|
|
389
|
-
`:"")+
|
|
389
|
+
`:"")+XE(u,e),i=s}return r}o(tk,"foldString");function XE(n,e){if(n===""||n[0]===" ")return n;for(var t=/ [^ ]/g,r,i=0,s,a=0,c=0,u="";r=t.exec(n);)c=r.index,c-i>e&&(s=a>i?a:c,u+=`
|
|
390
390
|
`+n.slice(i,s),i=s+1),a=c;return u+=`
|
|
391
391
|
`,n.length-i>e&&a>i?u+=n.slice(i,a)+`
|
|
392
|
-
`+n.slice(a+1):u+=n.slice(i),u.slice(1)}o(
|
|
393
|
-
`:""}o(
|
|
392
|
+
`+n.slice(a+1):u+=n.slice(i),u.slice(1)}o(XE,"foldLine");function rk(n){for(var e="",t=0,r,i=0;i<n.length;t>=65536?i+=2:i++)t=Qc(n,i),r=cr[t],!r&&Jc(t)?(e+=n[i],t>=65536&&(e+=n[i+1])):e+=r||z7(t);return e}o(rk,"escapeString");function nk(n,e,t){var r="",i=n.tag,s,a,c;for(s=0,a=t.length;s<a;s+=1)c=t[s],n.replacer&&(c=n.replacer.call(t,String(s),c)),(ji(n,e,c,!1,!1)||typeof c>"u"&&ji(n,e,null,!1,!1))&&(r!==""&&(r+=","+(n.condenseFlow?"":" ")),r+=n.dump);n.tag=i,n.dump="["+r+"]"}o(nk,"writeFlowSequence");function JE(n,e,t,r){var i="",s=n.tag,a,c,u;for(a=0,c=t.length;a<c;a+=1)u=t[a],n.replacer&&(u=n.replacer.call(t,String(a),u)),(ji(n,e+1,u,!0,!0,!1,!0)||typeof u>"u"&&ji(n,e+1,null,!0,!0,!1,!0))&&((!r||i!=="")&&(i+=Q0(n,e)),n.dump&&Kc===n.dump.charCodeAt(0)?i+="-":i+="- ",i+=n.dump);n.tag=s,n.dump=i||"[]"}o(JE,"writeBlockSequence");function ik(n,e,t){var r="",i=n.tag,s=Object.keys(t),a,c,u,l,f;for(a=0,c=s.length;a<c;a+=1)f="",r!==""&&(f+=", "),n.condenseFlow&&(f+='"'),u=s[a],l=t[u],n.replacer&&(l=n.replacer.call(t,u,l)),ji(n,e,u,!1,!1)&&(n.dump.length>1024&&(f+="? "),f+=n.dump+(n.condenseFlow?'"':"")+":"+(n.condenseFlow?"":" "),ji(n,e,l,!1,!1)&&(f+=n.dump,r+=f));n.tag=i,n.dump="{"+r+"}"}o(ik,"writeFlowMapping");function sk(n,e,t,r){var i="",s=n.tag,a=Object.keys(t),c,u,l,f,h,d;if(n.sortKeys===!0)a.sort();else if(typeof n.sortKeys=="function")a.sort(n.sortKeys);else if(n.sortKeys)throw new Ar("sortKeys must be a boolean or a function");for(c=0,u=a.length;c<u;c+=1)d="",(!r||i!=="")&&(d+=Q0(n,e)),l=a[c],f=t[l],n.replacer&&(f=n.replacer.call(t,l,f)),ji(n,e+1,l,!0,!0,!0)&&(h=n.tag!==null&&n.tag!=="?"||n.dump&&n.dump.length>1024,h&&(n.dump&&Kc===n.dump.charCodeAt(0)?d+="?":d+="? "),d+=n.dump,h&&(d+=Q0(n,e)),ji(n,e+1,f,!0,h)&&(n.dump&&Kc===n.dump.charCodeAt(0)?d+=":":d+=": ",d+=n.dump,i+=d));n.tag=s,n.dump=i||"{}"}o(sk,"writeBlockMapping");function ZE(n,e,t){var r,i,s,a,c,u;for(i=t?n.explicitTypes:n.implicitTypes,s=0,a=i.length;s<a;s+=1)if(c=i[s],(c.instanceOf||c.predicate)&&(!c.instanceOf||typeof e=="object"&&e instanceof c.instanceOf)&&(!c.predicate||c.predicate(e))){if(t?c.multi&&c.representName?n.tag=c.representName(e):n.tag=c.tag:n.tag="?",c.represent){if(u=n.styleMap[c.tag]||c.defaultStyle,D3.call(c.represent)==="[object Function]")r=c.represent(e,u);else if(R3.call(c.represent,u))r=c.represent[u](e,u);else throw new Ar("!<"+c.tag+'> tag resolver accepts not "'+u+'" style');n.dump=r}return!0}return!1}o(ZE,"detectType");function ji(n,e,t,r,i,s,a){n.tag=null,n.dump=t,ZE(n,t,!1)||ZE(n,t,!0);var c=D3.call(n.dump),u=r,l;r&&(r=n.flowLevel<0||n.flowLevel>e);var f=c==="[object Object]"||c==="[object Array]",h,d;if(f&&(h=n.duplicates.indexOf(t),d=h!==-1),(n.tag!==null&&n.tag!=="?"||d||n.indent!==2&&e>0)&&(i=!1),d&&n.usedDuplicates[h])n.dump="*ref_"+h;else{if(f&&d&&!n.usedDuplicates[h]&&(n.usedDuplicates[h]=!0),c==="[object Object]")r&&Object.keys(n.dump).length!==0?(sk(n,e,n.dump,i),d&&(n.dump="&ref_"+h+n.dump)):(ik(n,e,n.dump),d&&(n.dump="&ref_"+h+" "+n.dump));else if(c==="[object Array]")r&&n.dump.length!==0?(n.noArrayIndent&&!a&&e>0?JE(n,e-1,n.dump,i):JE(n,e,n.dump,i),d&&(n.dump="&ref_"+h+n.dump)):(nk(n,e,n.dump),d&&(n.dump="&ref_"+h+" "+n.dump));else if(c==="[object String]")n.tag!=="?"&&ek(n,n.dump,e,s,u);else{if(c==="[object Undefined]")return!1;if(n.skipInvalid)return!1;throw new Ar("unacceptable kind of an object to dump "+c)}n.tag!==null&&n.tag!=="?"&&(l=encodeURI(n.tag[0]==="!"?n.tag.slice(1):n.tag).replace(/!/g,"%21"),n.tag[0]==="!"?l="!"+l:l.slice(0,18)==="tag:yaml.org,2002:"?l="!!"+l.slice(18):l="!<"+l+">",n.dump=l+" "+n.dump)}return!0}o(ji,"writeNode");function ak(n,e){var t=[],r=[],i,s;for(K0(n,t,r),i=0,s=r.length;i<s;i+=1)e.duplicates.push(t[r[i]]);e.usedDuplicates=new Array(s)}o(ak,"getDuplicateReferences");function K0(n,e,t){var r,i,s;if(n!==null&&typeof n=="object")if(i=e.indexOf(n),i!==-1)t.indexOf(i)===-1&&t.push(i);else if(e.push(n),Array.isArray(n))for(i=0,s=n.length;i<s;i+=1)K0(n[i],e,t);else for(r=Object.keys(n),i=0,s=r.length;i<s;i+=1)K0(n[r[i]],e,t)}o(K0,"inspectNode");function ok(n,e){e=e||{};var t=new Y7(e);t.noRefs||ak(n,t);var r=n;return t.replacer&&(r=t.replacer.call({"":r},"",r)),ji(t,0,r,!0,!0)?t.dump+`
|
|
393
|
+
`:""}o(ok,"dump$1");var ck=ok,uk={dump:ck};function r1(n,e){return function(){throw new Error("Function yaml."+n+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}o(r1,"renamed");var lk=Kt,fk=r3,hk=a3,dk=f3,pk=h3,mk=J0,gk=P3.load,yk=P3.loadAll,vk=uk.dump,Sk=Ar,_k={binary:y3,float:l3,map:s3,null:o3,pairs:S3,set:_3,timestamp:m3,bool:c3,int:u3,merge:g3,omap:v3,seq:i3,str:n3},bk=r1("safeLoad","load"),wk=r1("safeLoadAll","loadAll"),Ek=r1("safeDump","dump"),Zc={Type:lk,Schema:fk,FAILSAFE_SCHEMA:hk,JSON_SCHEMA:dk,CORE_SCHEMA:pk,DEFAULT_SCHEMA:mk,load:gk,loadAll:yk,dump:vk,YAMLException:Sk,types:_k,safeLoad:bk,safeLoadAll:wk,safeDump:Ek};var ds=class{constructor(e,t){this.rootPath=e;this.basenameCache=null;this.folderFilter=t}static{o(this,"FileSystemVaultAdapter")}buildBasenameCache(){this.basenameCache===null&&(this.basenameCache=new Map,this.walkDirectory(this.rootPath,e=>{let t=bt.default.basename(e);this.basenameCache.has(t)||this.basenameCache.set(t,bt.default.relative(this.rootPath,e))}))}async read(e){let t=this.resolvePath(e.path);if(!await _t.default.pathExists(t))throw new Error(`File not found: ${e.path}`);return _t.default.readFile(t,"utf-8")}async create(e,t){let r=this.resolvePath(e);if(await _t.default.pathExists(r))throw new Error(`File already exists: ${e}`);return await _t.default.ensureDir(bt.default.dirname(r)),await _t.default.writeFile(r,t,"utf-8"),this.createFileObject(e)}async modify(e,t){let r=this.resolvePath(e.path);if(!await _t.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await _t.default.writeFile(r,t,"utf-8")}async delete(e){let t=this.resolvePath(e.path);if(!await _t.default.pathExists(t))throw new Error(`File not found: ${e.path}`);await _t.default.remove(t)}async exists(e){let t=this.resolvePath(e);return _t.default.pathExists(t)}getAbstractFileByPath(e){let t=this.resolvePath(e);try{let r=_t.default.statSync(t);if(r.isFile())return this.createFileObject(e);if(r.isDirectory())return this.createFolderObject(e)}catch{return null}return null}getAllFiles(){let e=[],t=this.folderFilter?bt.default.join(this.rootPath,this.folderFilter):this.rootPath;if(this.folderFilter&&!_t.default.existsSync(t))throw new Error(`Folder not found: ${this.folderFilter}`);return this.walkDirectory(t,r=>{if(r.endsWith(".md")){let i=bt.default.relative(this.rootPath,r);e.push(this.createFileObject(i))}}),e}getFrontmatter(e){try{let t=_t.default.readFileSync(this.resolvePath(e.path),"utf-8");return this.extractFrontmatter(t)}catch{return null}}async updateFrontmatter(e,t){let r=await this.read(e),i=this.extractFrontmatter(r)||{},s=t(i),a=this.replaceFrontmatter(r,s);await this.modify(e,a)}async rename(e,t){let r=this.resolvePath(e.path),i=this.resolvePath(t);if(!await _t.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await _t.default.ensureDir(bt.default.dirname(i)),await _t.default.move(r,i)}async createFolder(e){let t=this.resolvePath(e);await _t.default.ensureDir(t)}getFirstLinkpathDest(e,t){let r=bt.default.dirname(this.resolvePath(t)),i=e.endsWith(".md")?e:`${e}.md`,s=bt.default.basename(i),a;if(bt.default.isAbsolute(e)?a=this.resolvePath(e):a=bt.default.resolve(r,e),e.endsWith(".md")||(a+=".md"),_t.default.existsSync(a)){let l=bt.default.relative(this.rootPath,a);return this.createFileObject(l)}let c=bt.default.join(this.rootPath,i);if(_t.default.existsSync(c))return this.createFileObject(i);let u=this.findFileByBasename(s);return u?this.createFileObject(u):null}findFileByBasename(e){return this.buildBasenameCache(),this.basenameCache.get(e)||null}async process(e,t){let r=await this.read(e),i=t(r);return await this.modify(e,i),i}getDefaultNewFileParent(){return{path:"",name:""}}async updateLinks(e,t,r){return Promise.resolve()}resolvePath(e){return bt.default.isAbsolute(e)?e:bt.default.join(this.rootPath,e)}createFileObject(e){let t=bt.default.basename(e),r=bt.default.basename(e,bt.default.extname(e)),i=bt.default.dirname(e);return{path:e,basename:t,name:r,parent:i!=="."?this.createFolderObject(i):null}}createFolderObject(e){return{path:e,name:bt.default.basename(e)}}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return null;try{let i=Zc.load(r[1]);return typeof i=="object"&&i!==null?i:null}catch{return null}}replaceFrontmatter(e,t){let r=Zc.dump(t,{lineWidth:-1,noRefs:!0,quotingType:'"'}),i=/^---\n([\s\S]*?)\n---/;return e.match(i)?e.replace(i,`---
|
|
394
394
|
${r.trim()}
|
|
395
395
|
---`):`---
|
|
396
396
|
${r.trim()}
|
|
@@ -398,7 +398,7 @@ ${r.trim()}
|
|
|
398
398
|
${e}`}walkDirectory(e,t){let r=_t.default.readdirSync(e,{withFileTypes:!0});for(let i of r){let s=bt.default.join(e,i.name);i.isDirectory()?this.walkDirectory(s,t):i.isFile()&&t(s)}}};var Io=class{static{o(this,"TableFormatter")}format(e){if(e.length===0)return"No results";let t=this.getAllVariables(e),r=e.map(i=>this.solutionToRow(i,t));return this.renderTable(t,r)}getAllVariables(e){let t=new Set;for(let r of e)for(let i of r.variables())t.add(i);return Array.from(t).sort()}solutionToRow(e,t){return t.map(r=>{let i=e.get(r);return i?this.formatValue(i.toString()):""})}formatValue(e){return e.length>50?e.substring(0,47)+"...":e}renderTable(e,t){let r=e.map((s,a)=>{let c=s.length+1,u=Math.max(...t.map(l=>l[a]?.length||0));return Math.max(c,u,10)}),i=[];i.push(this.renderSeparator(r,"top")),i.push(this.renderRow(e.map(s=>`?${s}`),r)),i.push(this.renderSeparator(r,"mid"));for(let s of t)i.push(this.renderRow(s,r));return i.push(this.renderSeparator(r,"bottom")),i.join(`
|
|
399
399
|
`)}renderRow(e,t){return`\u2502 ${e.map((i,s)=>i.padEnd(t[s])).join(" \u2502 ")} \u2502`}renderSeparator(e,t){let r=t==="top"?"\u250C":t==="mid"?"\u251C":"\u2514",i=t==="top"?"\u2510":t==="mid"?"\u2524":"\u2518",a=t==="mid"?"\u2500\u253C\u2500":"\u2500"+(t==="mid"?"\u253C":"\u2500")+"\u2500",c=e.map(u=>"\u2500".repeat(u+2));return`${r}${c.join(a)}${i}`}};var Oo=class{static{o(this,"JsonFormatter")}format(e){let t=e.map(r=>r.toJSON());return JSON.stringify(t,null,2)}};var eu=class{static{o(this,"TriplesFormatter")}formatNTriples(e){return e.map(t=>t.toString()).join(`
|
|
400
400
|
`)}formatTable(e){if(e.length===0)return"No triples generated.";let t=[];t.push("Subject | Predicate | Object"),t.push("------- | --------- | ------");for(let r of e){let i=this.formatNode(r.subject),s=this.formatNode(r.predicate),a=this.formatNode(r.object);t.push(`${i} | ${s} | ${a}`)}return t.join(`
|
|
401
|
-
`)}formatJson(e){let t=e.map(r=>({subject:this.nodeToJson(r.subject),predicate:this.nodeToJson(r.predicate),object:this.nodeToJson(r.object)}));return JSON.stringify(t,null,2)}formatNode(e){return e.value!==void 0?String(e.value):String(e)}nodeToJson(e){return"datatype"in e||"language"in e?{type:"literal",value:String(e.value),...e.datatype&&{datatype:e.datatype.value||String(e.datatype)},...e.language&&{language:e.language}}:"id"in e&&String(e.id).startsWith("_:")?{type:"bnode",value:String(e.id)}:{type:"uri",value:String(e.value)}}};function
|
|
401
|
+
`)}formatJson(e){let t=e.map(r=>({subject:this.nodeToJson(r.subject),predicate:this.nodeToJson(r.predicate),object:this.nodeToJson(r.object)}));return JSON.stringify(t,null,2)}formatNode(e){return e.value!==void 0?String(e.value):String(e)}nodeToJson(e){return"datatype"in e||"language"in e?{type:"literal",value:String(e.value),...e.datatype&&{datatype:e.datatype.value||String(e.datatype)},...e.language&&{language:e.language}}:"id"in e&&String(e.id).startsWith("_:")?{type:"bnode",value:String(e.id)}:{type:"uri",value:String(e.value)}}};function B3(n){return n.startsWith("VALIDATION_")?"validation":n.startsWith("PERMISSION_")?"permission":n.startsWith("STATE_")?"state":"internal"}o(B3,"getErrorCategory");var Ye=class{static{o(this,"ResponseBuilder")}static success(e,t){return{success:!0,data:e,...t&&{meta:t}}}static error(e,t,r,i){return{success:!1,error:{code:e,category:B3(e),message:t,exitCode:r,...i?.recovery&&{recovery:i.recovery},...i?.context&&{context:i.context},...i?.stack&&{stack:i.stack}}}}};var xr=class extends Error{static{o(this,"CLIError")}constructor(e,t,r){super(e),this.name=this.constructor.name,this.context=t,this.recoveryHint=r,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}format(){let e=`\u274C ${this.name}: ${this.message}`;if(this.guidance&&(e+=`
|
|
402
402
|
|
|
403
403
|
\u{1F4A1} ${this.guidance}`),this.context&&Object.keys(this.context).length>0){e+=`
|
|
404
404
|
|
|
@@ -413,40 +413,40 @@ Use: exocortex command --help for usage information.`;super(t,i,{message:r||"Che
|
|
|
413
413
|
Check:
|
|
414
414
|
\u2022 Path spelling and case sensitivity
|
|
415
415
|
\u2022 Directory exists and is accessible
|
|
416
|
-
\u2022 You have read permissions for the directory`}static{o(this,"VaultNotFoundError")}};function
|
|
416
|
+
\u2022 You have read permissions for the directory`}static{o(this,"VaultNotFoundError")}};function q3(){return new Lt("query").description("Execute SPARQL query against Obsidian vault").argument("<query>","SPARQL query string or path to .sparql file").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--folder <path>","Limit indexing to specific folder (relative to vault root)").option("--format <type>","Output format: table|json|csv|ntriples","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--explain","Show optimized query plan").option("--stats","Show execution statistics").option("--no-optimize","Disable query optimization").action(async(n,e)=>{let t=e.output||"text";K.setFormat(t);try{let r=Date.now(),i=Tk(n),s=(0,n1.resolve)(e.vault);if(!(0,ru.existsSync)(s))throw new Xt(s);if(t==="text"){let O=e.folder?` (folder: ${e.folder})`:"";console.log(`\u{1F4E6} Loading vault: ${s}${O}...`)}let a=Date.now(),c=new ds(s,e.folder),l=await new Cr.NoteToRDFConverter(c).convertVault(),f=new Cr.InMemoryTripleStore;await f.addAll(l);let h=Date.now()-a;t==="text"&&(console.log(`\u2705 Loaded ${l.length} triples in ${h}ms
|
|
417
417
|
`),console.log("\u{1F50D} Parsing SPARQL query..."));let p=new Cr.SPARQLParser().parse(i);t==="text"&&console.log("\u{1F504} Translating to algebra...");let b=new Cr.AlgebraTranslator().translate(p);if(!e.noOptimize&&b.type!=="construct")b=new Cr.AlgebraOptimizer().optimize(b);else if(!e.noOptimize&&b.type==="construct"){let O=new Cr.AlgebraOptimizer,L=b;b={...L,where:O.optimize(L.where)}}if(e.explain&&t==="text"){console.log("\u{1F4CA} Query Plan:");let O=new Cr.AlgebraSerializer;if(b.type==="construct"){let L=b;console.log("CONSTRUCT Template:"),console.log(" (template patterns)"),console.log("WHERE:"),console.log(O.toString(L.where))}else console.log(O.toString(b));console.log()}t==="text"&&console.log("\u{1F3AF} Executing query...");let T=Date.now(),I=new Cr.QueryExecutor(f);if(I.isConstructQuery(b)){let O=await I.executeConstruct(b),L=Date.now()-T,M=Date.now()-r;if(t==="json"){let G=new eu,Ee={query:i,count:O.length,triples:JSON.parse(G.formatJson(O))},je=Ye.success(Ee,{durationMs:M,itemCount:O.length,loadDurationMs:h,execDurationMs:L,triplesScanned:l.length});console.log(JSON.stringify(je,null,2))}else console.log(`\u2705 Generated ${O.length} triple(s) in ${L}ms
|
|
418
|
-
`),O.length>0?
|
|
418
|
+
`),O.length>0?xk(O,e.format):console.log("No triples generated."),e.stats&&(console.log(`
|
|
419
419
|
\u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${h}ms`),console.log(` Query execution: ${L}ms`),console.log(` Total time: ${M}ms`),console.log(` Triples scanned: ${l.length}`),console.log(` Triples generated: ${O.length}`))}else{let O=await I.executeAll(b),L=Date.now()-T,M=Date.now()-r;if(t==="json"){let G=O.map(Me=>Me.toJSON()),Ee={query:i,count:O.length,bindings:G},je=Ye.success(Ee,{durationMs:M,itemCount:O.length,loadDurationMs:h,execDurationMs:L,triplesScanned:l.length});console.log(JSON.stringify(je,null,2))}else console.log(`\u2705 Found ${O.length} result(s) in ${L}ms
|
|
420
|
-
`),O.length>0?
|
|
421
|
-
\u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${h}ms`),console.log(` Query execution: ${L}ms`),console.log(` Total time: ${M}ms`),console.log(` Triples scanned: ${l.length}`),console.log(` Results returned: ${O.length}`))}}catch(r){K.handle(r)}})}o(V3,"sparqlQueryCommand");function _k(n){if(n.includes("SELECT")||n.includes("CONSTRUCT"))return n;let e=(0,t1.resolve)(n);return(0,ru.existsSync)(e)?(0,ru.readFileSync)(e,"utf-8"):n}o(_k,"loadQuery");function bk(n,e){switch(e){case"json":let t=new Oo;console.log(t.format(n));break;case"table":default:let r=new Io;console.log(r.format(n));break}}o(bk,"formatSelectResults");function wk(n,e){let t=new eu;switch(e){case"json":console.log(t.formatJson(n));break;case"ntriples":console.log(t.formatNTriples(n));break;case"table":default:console.log(t.formatTable(n));break}}o(wk,"formatConstructResults");var HT=require("path");var Ft=Ne(Eo()),vs=Ne(require("path"));var oT=Ne(Z3(),1);var iu=o(n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Pk={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},su=o(n=>n.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Dk=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),eT=o(n=>n.join(""),"rangesToString"),tT=o((n,e)=>{let t=e;if(n.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=t+1,a=!1,c=!1,u=!1,l=!1,f=t,h="";e:for(;s<n.length;){let b=n.charAt(s);if((b==="!"||b==="^")&&s===t+1){l=!0,s++;continue}if(b==="]"&&a&&!u){f=s+1;break}if(a=!0,b==="\\"&&!u){u=!0,s++;continue}if(b==="["&&!u){for(let[T,[I,O,L]]of Object.entries(Pk))if(n.startsWith(T,s)){if(h)return["$.",!1,n.length-t,!0];s+=T.length,L?i.push(I):r.push(I),c=c||O;continue e}}if(u=!1,h){b>h?r.push(su(h)+"-"+su(b)):b===h&&r.push(su(b)),h="",s++;continue}if(n.startsWith("-]",s+1)){r.push(su(b+"-")),s+=2;continue}if(n.startsWith("-",s+1)){h=b,s+=2;continue}r.push(su(b)),s++}if(f<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,n.length-t,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let b=r[0].length===2?r[0].slice(-1):r[0];return[Dk(b),!1,f-t,!1]}let d="["+(l?"^":"")+eT(r)+"]",p="["+(l?"":"^")+eT(i)+"]";return[r.length&&i.length?"("+d+"|"+p+")":r.length?d:p,c,f-t,!0]},"parseClass");var Un=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),"unescape");var Rk=new Set(["!","?","+","*","@"]),rT=o(n=>Rk.has(n),"isExtglobType"),Fk="(?!(?:^|/)\\.\\.?(?:$|/))",Fh="(?!\\.)",Nk=new Set(["[","."]),Lk=new Set(["..","."]),kk=new Set("().*{}+?[]^$\\!"),Mk=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),i1="[^/]",nT=i1+"*?",iT=i1+"+?",Po=class n{static{o(this,"AST")}type;#e;#t;#s=!1;#n=[];#a;#_;#u;#f=!1;#o;#c;#i=!1;constructor(e,t,r={}){this.type=e,e&&(this.#t=!0),this.#a=t,this.#e=this.#a?this.#a.#e:this,this.#o=this.#e===this?r:this.#e.#o,this.#u=this.#e===this?[]:this.#e.#u,e==="!"&&!this.#e.#f&&this.#u.push(this),this.#_=this.#a?this.#a.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#n)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#n.map(e=>String(e)).join("|")+")":this.#c=this.#n.map(e=>String(e)).join("")}#g(){if(this!==this.#e)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let e;for(;e=this.#u.pop();){if(e.type!=="!")continue;let t=e,r=t.#a;for(;r;){for(let i=t.#_+1;!r.type&&i<r.#n.length;i++)for(let s of e.#n){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#n[i])}t=r,r=t.#a}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof n&&t.#a===this))throw new Error("invalid part: "+t);this.#n.push(t)}}toJSON(){let e=this.type===null?this.#n.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#n.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#f&&this.#a?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#a?.isStart())return!1;if(this.#_===0)return!0;let e=this.#a;for(let t=0;t<this.#_;t++){let r=e.#n[t];if(!(r instanceof n&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let e=this.#a?this.#a.#n.length:0;return this.#_===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new n(this.type,e);for(let r of this.#n)t.copyIn(r);return t}static#y(e,t,r,i){let s=!1,a=!1,c=-1,u=!1;if(t.type===null){let p=r,S="";for(;p<e.length;){let b=e.charAt(p++);if(s||b==="\\"){s=!s,S+=b;continue}if(a){p===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(p===c+2&&u)&&(a=!1),S+=b;continue}else if(b==="["){a=!0,c=p,u=!1,S+=b;continue}if(!i.noext&&rT(b)&&e.charAt(p)==="("){t.push(S),S="";let T=new n(b,t);p=n.#y(e,T,p,i),t.push(T);continue}S+=b}return t.push(S),p}let l=r+1,f=new n(null,t),h=[],d="";for(;l<e.length;){let p=e.charAt(l++);if(s||p==="\\"){s=!s,d+=p;continue}if(a){l===c+1?(p==="^"||p==="!")&&(u=!0):p==="]"&&!(l===c+2&&u)&&(a=!1),d+=p;continue}else if(p==="["){a=!0,c=l,u=!1,d+=p;continue}if(rT(p)&&e.charAt(l)==="("){f.push(d),d="";let S=new n(p,f);f.push(S),l=n.#y(e,S,l,i);continue}if(p==="|"){f.push(d),d="",h.push(f),f=new n(null,t);continue}if(p===")")return d===""&&t.#n.length===0&&(t.#i=!0),f.push(d),d="",t.push(...h,f),l;d+=p}return t.type=null,t.#t=void 0,t.#n=[e.substring(r-1)],l}static fromGlob(e,t={}){let r=new n(null,void 0,t);return n.#y(e,r,0,t),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,r,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#o.nocase&&!this.#o.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return r;let c=(this.#o.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,c),{_src:t,_glob:e})}get options(){return this.#o}toRegExpSource(e){let t=e??!!this.#o.dot;if(this.#e===this&&this.#g(),!this.type){let u=this.isStart()&&this.isEnd(),l=this.#n.map(p=>{let[S,b,T,I]=typeof p=="string"?n.#h(p,this.#t,u):p.toRegExpSource(e);return this.#t=this.#t||T,this.#s=this.#s||I,S}).join(""),f="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&Lk.has(this.#n[0]))){let S=Nk,b=t&&S.has(l.charAt(0))||l.startsWith("\\.")&&S.has(l.charAt(2))||l.startsWith("\\.\\.")&&S.has(l.charAt(4)),T=!t&&!e&&S.has(l.charAt(0));f=b?Fk:T?Fh:""}let h="";return this.isEnd()&&this.#e.#f&&this.#a?.type==="!"&&(h="(?:$|\\/)"),[f+l+h,Un(l),this.#t=!!this.#t,this.#s]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#d(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let u=this.toString();return this.#n=[u],this.type=null,this.#t=void 0,[u,Un(this.toString()),!1,!1]}let a=!r||e||t||!Fh?"":this.#d(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let c="";if(this.type==="!"&&this.#i)c=(this.isStart()&&!t?Fh:"")+iT;else{let u=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Fh:"")+nT+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;c=i+s+u}return[c,Un(s),this.#t=!!this.#t,this.#s]}#d(e){return this.#n.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[r,i,s,a]=t.toRegExpSource(e);return this.#s=this.#s||a,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#h(e,t,r=!1){let i=!1,s="",a=!1;for(let c=0;c<e.length;c++){let u=e.charAt(c);if(i){i=!1,s+=(kk.has(u)?"\\":"")+u;continue}if(u==="\\"){c===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[l,f,h,d]=tT(e,c);if(h){s+=l,a=a||f,c+=h-1,t=t||d;continue}}if(u==="*"){r&&e==="*"?s+=iT:s+=nT,t=!0;continue}if(u==="?"){s+=i1,t=!0;continue}s+=Mk(u)}return[s,Un(e),!!t,a]}};var Do=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Zt=o((n,e,t={})=>(iu(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Wr(e,t).match(n)),"minimatch"),jk=/^\*+([^+@!?\*\[\(]*)$/,$k=o(n=>e=>!e.startsWith(".")&&e.endsWith(n),"starDotExtTest"),Vk=o(n=>e=>e.endsWith(n),"starDotExtTestDot"),Uk=o(n=>(n=n.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(n)),"starDotExtTestNocase"),Bk=o(n=>(n=n.toLowerCase(),e=>e.toLowerCase().endsWith(n)),"starDotExtTestNocaseDot"),qk=/^\*+\.\*+$/,Gk=o(n=>!n.startsWith(".")&&n.includes("."),"starDotStarTest"),Wk=o(n=>n!=="."&&n!==".."&&n.includes("."),"starDotStarTestDot"),Hk=/^\.\*+$/,zk=o(n=>n!=="."&&n!==".."&&n.startsWith("."),"dotStarTest"),Qk=/^\*+$/,Yk=o(n=>n.length!==0&&!n.startsWith("."),"starTest"),Kk=o(n=>n.length!==0&&n!=="."&&n!=="..","starTestDot"),Xk=/^\?+([^+@!?\*\[\(]*)?$/,Jk=o(([n,e=""])=>{let t=cT([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),Zk=o(([n,e=""])=>{let t=uT([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),eM=o(([n,e=""])=>{let t=uT([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTestDot"),tM=o(([n,e=""])=>{let t=cT([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTest"),cT=o(([n])=>{let e=n.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),uT=o(([n])=>{let e=n.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),lT=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",sT={win32:{sep:"\\"},posix:{sep:"/"}},rM=lT==="win32"?sT.win32.sep:sT.posix.sep;Zt.sep=rM;var Jt=Symbol("globstar **");Zt.GLOBSTAR=Jt;var nM="[^/]",iM=nM+"*?",sM="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",aM="(?:(?!(?:\\/|^)\\.).)*?",oM=o((n,e={})=>t=>Zt(t,n,e),"filter");Zt.filter=oM;var ln=o((n,e={})=>Object.assign({},n,e),"ext"),cM=o(n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return Zt;let e=Zt;return Object.assign(o((r,i,s={})=>e(r,i,ln(n,s)),"m"),{Minimatch:class extends e.Minimatch{static{o(this,"Minimatch")}constructor(i,s={}){super(i,ln(n,s))}static defaults(i){return e.defaults(ln(n,i)).Minimatch}},AST:class extends e.AST{static{o(this,"AST")}constructor(i,s,a={}){super(i,s,ln(n,a))}static fromGlob(i,s={}){return e.AST.fromGlob(i,ln(n,s))}},unescape:o((r,i={})=>e.unescape(r,ln(n,i)),"unescape"),escape:o((r,i={})=>e.escape(r,ln(n,i)),"escape"),filter:o((r,i={})=>e.filter(r,ln(n,i)),"filter"),defaults:o(r=>e.defaults(ln(n,r)),"defaults"),makeRe:o((r,i={})=>e.makeRe(r,ln(n,i)),"makeRe"),braceExpand:o((r,i={})=>e.braceExpand(r,ln(n,i)),"braceExpand"),match:o((r,i,s={})=>e.match(r,i,ln(n,s)),"match"),sep:e.sep,GLOBSTAR:Jt})},"defaults");Zt.defaults=cM;var fT=o((n,e={})=>(iu(n),e.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,oT.default)(n)),"braceExpand");Zt.braceExpand=fT;var uM=o((n,e={})=>new Wr(n,e).makeRe(),"makeRe");Zt.makeRe=uM;var lM=o((n,e,t={})=>{let r=new Wr(e,t);return n=n.filter(i=>r.match(i)),r.options.nonull&&!n.length&&n.push(e),n},"match");Zt.match=lM;var aT=/[?*]|[+@!]\(.*?\)|\[|\]/,fM=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Wr=class{static{o(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){iu(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||lT,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let u=s[0]===""&&s[1]===""&&(s[2]==="?"||!aT.test(s[2]))&&!aT.test(s[3]),l=/^[a-z]:/i.test(s[0]);if(u)return[...s.slice(0,4),...s.slice(4).map(f=>this.parse(f))];if(l)return[s[0],...s.slice(1).map(f=>this.parse(f))]}return s.map(u=>this.parse(u))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let r=0;r<e.length;r++)for(let i=0;i<e[r].length;i++)e[r][i]==="**"&&(e[r][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let r=-1;for(;(r=t.indexOf("**",r+1))!==-1;){let i=r;for(;t[i+1]==="**";)i++;i!==r&&t.splice(r,i-r)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let r=0;for(;(r=e.indexOf("..",r+1))!==-1;){let i=e[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=!0,e.splice(r-1,2),r-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let r of e){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let a=i;for(;r[a+1]==="**";)a++;a>i&&r.splice(i+1,a-i);let c=r[i+1],u=r[i+2],l=r[i+3];if(c!==".."||!u||u==="."||u===".."||!l||l==="."||l==="..")continue;t=!0,r.splice(i,1);let f=r.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<r.length-1;a++){let c=r[a];a===1&&c===""&&r[0]===""||(c==="."||c==="")&&(t=!0,r.splice(a,1),a--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let a=r[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){t=!0;let u=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...u),r.length===0&&r.push(""),s-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let r=t+1;r<e.length;r++){let i=this.partsMatch(e[t],e[r],!this.preserveMultipleSlashes);if(i){e[t]=[],e[r]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,r=!1){let i=0,s=0,a=[],c="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])a.push(c==="b"?t[s]:e[i]),i++,s++;else if(r&&e[i]==="**"&&t[s]===e[i+1])a.push(e[i]),i++;else if(r&&t[s]==="**"&&e[i]===t[s+1])a.push(t[s]),s++;else if(e[i]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(c==="b")return!1;c="a",a.push(e[i]),i++,s++}else if(t[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(c==="a")return!1;c="b",a.push(t[s]),i++,s++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,r=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,r++;r&&(this.pattern=e.slice(r)),this.negate=t}matchOne(e,t,r=!1){let i=this.options;if(this.isWindows){let b=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),T=!b&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),I=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),O=!I&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),L=T?3:b?0:void 0,M=O?3:I?0:void 0;if(typeof L=="number"&&typeof M=="number"){let[G,Ee]=[e[L],t[M]];G.toLowerCase()===Ee.toLowerCase()&&(t[M]=G,M>L?t=t.slice(M):L>M&&(e=e.slice(L)))}}let{optimizationLevel:s=1}=this.options;s>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var a=0,c=0,u=e.length,l=t.length;a<u&&c<l;a++,c++){this.debug("matchOne loop");var f=t[c],h=e[a];if(this.debug(t,f,h),f===!1)return!1;if(f===Jt){this.debug("GLOBSTAR",[t,f,h]);var d=a,p=c+1;if(p===l){for(this.debug("** at the end");a<u;a++)if(e[a]==="."||e[a]===".."||!i.dot&&e[a].charAt(0)===".")return!1;return!0}for(;d<u;){var S=e[d];if(this.debug(`
|
|
420
|
+
`),O.length>0?Ak(O,e.format):console.log("No results found."),e.stats&&(console.log(`
|
|
421
|
+
\u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${h}ms`),console.log(` Query execution: ${L}ms`),console.log(` Total time: ${M}ms`),console.log(` Triples scanned: ${l.length}`),console.log(` Results returned: ${O.length}`))}}catch(r){K.handle(r)}})}o(q3,"sparqlQueryCommand");function Tk(n){if(n.includes("SELECT")||n.includes("CONSTRUCT"))return n;let e=(0,n1.resolve)(n);return(0,ru.existsSync)(e)?(0,ru.readFileSync)(e,"utf-8"):n}o(Tk,"loadQuery");function Ak(n,e){switch(e){case"json":let t=new Oo;console.log(t.format(n));break;case"table":default:let r=new Io;console.log(r.format(n));break}}o(Ak,"formatSelectResults");function xk(n,e){let t=new eu;switch(e){case"json":console.log(t.formatJson(n));break;case"ntriples":console.log(t.formatNTriples(n));break;case"table":default:console.log(t.formatTable(n));break}}o(xk,"formatConstructResults");var YT=require("path");var Ft=Ne(Eo()),vs=Ne(require("path"));var lT=Ne(rT(),1);var iu=o(n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Nk={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},su=o(n=>n.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Lk=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),nT=o(n=>n.join(""),"rangesToString"),iT=o((n,e)=>{let t=e;if(n.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=t+1,a=!1,c=!1,u=!1,l=!1,f=t,h="";e:for(;s<n.length;){let b=n.charAt(s);if((b==="!"||b==="^")&&s===t+1){l=!0,s++;continue}if(b==="]"&&a&&!u){f=s+1;break}if(a=!0,b==="\\"&&!u){u=!0,s++;continue}if(b==="["&&!u){for(let[T,[I,O,L]]of Object.entries(Nk))if(n.startsWith(T,s)){if(h)return["$.",!1,n.length-t,!0];s+=T.length,L?i.push(I):r.push(I),c=c||O;continue e}}if(u=!1,h){b>h?r.push(su(h)+"-"+su(b)):b===h&&r.push(su(b)),h="",s++;continue}if(n.startsWith("-]",s+1)){r.push(su(b+"-")),s+=2;continue}if(n.startsWith("-",s+1)){h=b,s+=2;continue}r.push(su(b)),s++}if(f<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,n.length-t,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let b=r[0].length===2?r[0].slice(-1):r[0];return[Lk(b),!1,f-t,!1]}let d="["+(l?"^":"")+nT(r)+"]",p="["+(l?"":"^")+nT(i)+"]";return[r.length&&i.length?"("+d+"|"+p+")":r.length?d:p,c,f-t,!0]},"parseClass");var Un=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),"unescape");var kk=new Set(["!","?","+","*","@"]),sT=o(n=>kk.has(n),"isExtglobType"),Mk="(?!(?:^|/)\\.\\.?(?:$|/))",Nh="(?!\\.)",jk=new Set(["[","."]),$k=new Set(["..","."]),Vk=new Set("().*{}+?[]^$\\!"),Uk=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),a1="[^/]",aT=a1+"*?",oT=a1+"+?",Po=class n{static{o(this,"AST")}type;#e;#t;#s=!1;#n=[];#a;#_;#u;#f=!1;#o;#c;#i=!1;constructor(e,t,r={}){this.type=e,e&&(this.#t=!0),this.#a=t,this.#e=this.#a?this.#a.#e:this,this.#o=this.#e===this?r:this.#e.#o,this.#u=this.#e===this?[]:this.#e.#u,e==="!"&&!this.#e.#f&&this.#u.push(this),this.#_=this.#a?this.#a.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#n)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#n.map(e=>String(e)).join("|")+")":this.#c=this.#n.map(e=>String(e)).join("")}#g(){if(this!==this.#e)throw new Error("should only call on root");if(this.#f)return this;this.toString(),this.#f=!0;let e;for(;e=this.#u.pop();){if(e.type!=="!")continue;let t=e,r=t.#a;for(;r;){for(let i=t.#_+1;!r.type&&i<r.#n.length;i++)for(let s of e.#n){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#n[i])}t=r,r=t.#a}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof n&&t.#a===this))throw new Error("invalid part: "+t);this.#n.push(t)}}toJSON(){let e=this.type===null?this.#n.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#n.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#f&&this.#a?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#a?.isStart())return!1;if(this.#_===0)return!0;let e=this.#a;for(let t=0;t<this.#_;t++){let r=e.#n[t];if(!(r instanceof n&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let e=this.#a?this.#a.#n.length:0;return this.#_===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new n(this.type,e);for(let r of this.#n)t.copyIn(r);return t}static#y(e,t,r,i){let s=!1,a=!1,c=-1,u=!1;if(t.type===null){let p=r,S="";for(;p<e.length;){let b=e.charAt(p++);if(s||b==="\\"){s=!s,S+=b;continue}if(a){p===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(p===c+2&&u)&&(a=!1),S+=b;continue}else if(b==="["){a=!0,c=p,u=!1,S+=b;continue}if(!i.noext&&sT(b)&&e.charAt(p)==="("){t.push(S),S="";let T=new n(b,t);p=n.#y(e,T,p,i),t.push(T);continue}S+=b}return t.push(S),p}let l=r+1,f=new n(null,t),h=[],d="";for(;l<e.length;){let p=e.charAt(l++);if(s||p==="\\"){s=!s,d+=p;continue}if(a){l===c+1?(p==="^"||p==="!")&&(u=!0):p==="]"&&!(l===c+2&&u)&&(a=!1),d+=p;continue}else if(p==="["){a=!0,c=l,u=!1,d+=p;continue}if(sT(p)&&e.charAt(l)==="("){f.push(d),d="";let S=new n(p,f);f.push(S),l=n.#y(e,S,l,i);continue}if(p==="|"){f.push(d),d="",h.push(f),f=new n(null,t);continue}if(p===")")return d===""&&t.#n.length===0&&(t.#i=!0),f.push(d),d="",t.push(...h,f),l;d+=p}return t.type=null,t.#t=void 0,t.#n=[e.substring(r-1)],l}static fromGlob(e,t={}){let r=new n(null,void 0,t);return n.#y(e,r,0,t),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,r,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#o.nocase&&!this.#o.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return r;let c=(this.#o.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,c),{_src:t,_glob:e})}get options(){return this.#o}toRegExpSource(e){let t=e??!!this.#o.dot;if(this.#e===this&&this.#g(),!this.type){let u=this.isStart()&&this.isEnd(),l=this.#n.map(p=>{let[S,b,T,I]=typeof p=="string"?n.#h(p,this.#t,u):p.toRegExpSource(e);return this.#t=this.#t||T,this.#s=this.#s||I,S}).join(""),f="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&$k.has(this.#n[0]))){let S=jk,b=t&&S.has(l.charAt(0))||l.startsWith("\\.")&&S.has(l.charAt(2))||l.startsWith("\\.\\.")&&S.has(l.charAt(4)),T=!t&&!e&&S.has(l.charAt(0));f=b?Mk:T?Nh:""}let h="";return this.isEnd()&&this.#e.#f&&this.#a?.type==="!"&&(h="(?:$|\\/)"),[f+l+h,Un(l),this.#t=!!this.#t,this.#s]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#d(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let u=this.toString();return this.#n=[u],this.type=null,this.#t=void 0,[u,Un(this.toString()),!1,!1]}let a=!r||e||t||!Nh?"":this.#d(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let c="";if(this.type==="!"&&this.#i)c=(this.isStart()&&!t?Nh:"")+oT;else{let u=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Nh:"")+aT+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;c=i+s+u}return[c,Un(s),this.#t=!!this.#t,this.#s]}#d(e){return this.#n.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[r,i,s,a]=t.toRegExpSource(e);return this.#s=this.#s||a,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#h(e,t,r=!1){let i=!1,s="",a=!1;for(let c=0;c<e.length;c++){let u=e.charAt(c);if(i){i=!1,s+=(Vk.has(u)?"\\":"")+u;continue}if(u==="\\"){c===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[l,f,h,d]=iT(e,c);if(h){s+=l,a=a||f,c+=h-1,t=t||d;continue}}if(u==="*"){r&&e==="*"?s+=oT:s+=aT,t=!0;continue}if(u==="?"){s+=a1,t=!0;continue}s+=Uk(u)}return[s,Un(e),!!t,a]}};var Do=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Zt=o((n,e,t={})=>(iu(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Wr(e,t).match(n)),"minimatch"),Bk=/^\*+([^+@!?\*\[\(]*)$/,qk=o(n=>e=>!e.startsWith(".")&&e.endsWith(n),"starDotExtTest"),Gk=o(n=>e=>e.endsWith(n),"starDotExtTestDot"),Wk=o(n=>(n=n.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(n)),"starDotExtTestNocase"),Hk=o(n=>(n=n.toLowerCase(),e=>e.toLowerCase().endsWith(n)),"starDotExtTestNocaseDot"),zk=/^\*+\.\*+$/,Qk=o(n=>!n.startsWith(".")&&n.includes("."),"starDotStarTest"),Yk=o(n=>n!=="."&&n!==".."&&n.includes("."),"starDotStarTestDot"),Kk=/^\.\*+$/,Xk=o(n=>n!=="."&&n!==".."&&n.startsWith("."),"dotStarTest"),Jk=/^\*+$/,Zk=o(n=>n.length!==0&&!n.startsWith("."),"starTest"),eM=o(n=>n.length!==0&&n!=="."&&n!=="..","starTestDot"),tM=/^\?+([^+@!?\*\[\(]*)?$/,rM=o(([n,e=""])=>{let t=fT([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),nM=o(([n,e=""])=>{let t=hT([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),iM=o(([n,e=""])=>{let t=hT([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTestDot"),sM=o(([n,e=""])=>{let t=fT([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTest"),fT=o(([n])=>{let e=n.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),hT=o(([n])=>{let e=n.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),dT=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",cT={win32:{sep:"\\"},posix:{sep:"/"}},aM=dT==="win32"?cT.win32.sep:cT.posix.sep;Zt.sep=aM;var Jt=Symbol("globstar **");Zt.GLOBSTAR=Jt;var oM="[^/]",cM=oM+"*?",uM="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",lM="(?:(?!(?:\\/|^)\\.).)*?",fM=o((n,e={})=>t=>Zt(t,n,e),"filter");Zt.filter=fM;var ln=o((n,e={})=>Object.assign({},n,e),"ext"),hM=o(n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return Zt;let e=Zt;return Object.assign(o((r,i,s={})=>e(r,i,ln(n,s)),"m"),{Minimatch:class extends e.Minimatch{static{o(this,"Minimatch")}constructor(i,s={}){super(i,ln(n,s))}static defaults(i){return e.defaults(ln(n,i)).Minimatch}},AST:class extends e.AST{static{o(this,"AST")}constructor(i,s,a={}){super(i,s,ln(n,a))}static fromGlob(i,s={}){return e.AST.fromGlob(i,ln(n,s))}},unescape:o((r,i={})=>e.unescape(r,ln(n,i)),"unescape"),escape:o((r,i={})=>e.escape(r,ln(n,i)),"escape"),filter:o((r,i={})=>e.filter(r,ln(n,i)),"filter"),defaults:o(r=>e.defaults(ln(n,r)),"defaults"),makeRe:o((r,i={})=>e.makeRe(r,ln(n,i)),"makeRe"),braceExpand:o((r,i={})=>e.braceExpand(r,ln(n,i)),"braceExpand"),match:o((r,i,s={})=>e.match(r,i,ln(n,s)),"match"),sep:e.sep,GLOBSTAR:Jt})},"defaults");Zt.defaults=hM;var pT=o((n,e={})=>(iu(n),e.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,lT.default)(n)),"braceExpand");Zt.braceExpand=pT;var dM=o((n,e={})=>new Wr(n,e).makeRe(),"makeRe");Zt.makeRe=dM;var pM=o((n,e,t={})=>{let r=new Wr(e,t);return n=n.filter(i=>r.match(i)),r.options.nonull&&!n.length&&n.push(e),n},"match");Zt.match=pM;var uT=/[?*]|[+@!]\(.*?\)|\[|\]/,mM=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Wr=class{static{o(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,t={}){iu(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||dT,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let u=s[0]===""&&s[1]===""&&(s[2]==="?"||!uT.test(s[2]))&&!uT.test(s[3]),l=/^[a-z]:/i.test(s[0]);if(u)return[...s.slice(0,4),...s.slice(4).map(f=>this.parse(f))];if(l)return[s[0],...s.slice(1).map(f=>this.parse(f))]}return s.map(u=>this.parse(u))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let r=0;r<e.length;r++)for(let i=0;i<e[r].length;i++)e[r][i]==="**"&&(e[r][i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let r=-1;for(;(r=t.indexOf("**",r+1))!==-1;){let i=r;for(;t[i+1]==="**";)i++;i!==r&&t.splice(r,i-r)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let r=0;for(;(r=e.indexOf("..",r+1))!==-1;){let i=e[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=!0,e.splice(r-1,2),r-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let r of e){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let a=i;for(;r[a+1]==="**";)a++;a>i&&r.splice(i+1,a-i);let c=r[i+1],u=r[i+2],l=r[i+3];if(c!==".."||!u||u==="."||u===".."||!l||l==="."||l==="..")continue;t=!0,r.splice(i,1);let f=r.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<r.length-1;a++){let c=r[a];a===1&&c===""&&r[0]===""||(c==="."||c==="")&&(t=!0,r.splice(a,1),a--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let a=r[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){t=!0;let u=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...u),r.length===0&&r.push(""),s-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let r=t+1;r<e.length;r++){let i=this.partsMatch(e[t],e[r],!this.preserveMultipleSlashes);if(i){e[t]=[],e[r]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,r=!1){let i=0,s=0,a=[],c="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])a.push(c==="b"?t[s]:e[i]),i++,s++;else if(r&&e[i]==="**"&&t[s]===e[i+1])a.push(e[i]),i++;else if(r&&t[s]==="**"&&e[i]===t[s+1])a.push(t[s]),s++;else if(e[i]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(c==="b")return!1;c="a",a.push(e[i]),i++,s++}else if(t[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(c==="a")return!1;c="b",a.push(t[s]),i++,s++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,r=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,r++;r&&(this.pattern=e.slice(r)),this.negate=t}matchOne(e,t,r=!1){let i=this.options;if(this.isWindows){let b=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),T=!b&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),I=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),O=!I&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),L=T?3:b?0:void 0,M=O?3:I?0:void 0;if(typeof L=="number"&&typeof M=="number"){let[G,Ee]=[e[L],t[M]];G.toLowerCase()===Ee.toLowerCase()&&(t[M]=G,M>L?t=t.slice(M):L>M&&(e=e.slice(L)))}}let{optimizationLevel:s=1}=this.options;s>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var a=0,c=0,u=e.length,l=t.length;a<u&&c<l;a++,c++){this.debug("matchOne loop");var f=t[c],h=e[a];if(this.debug(t,f,h),f===!1)return!1;if(f===Jt){this.debug("GLOBSTAR",[t,f,h]);var d=a,p=c+1;if(p===l){for(this.debug("** at the end");a<u;a++)if(e[a]==="."||e[a]===".."||!i.dot&&e[a].charAt(0)===".")return!1;return!0}for(;d<u;){var S=e[d];if(this.debug(`
|
|
422
422
|
globstar while`,e,d,t,p,S),this.matchOne(e.slice(d),t.slice(p),r))return this.debug("globstar found match!",d,u,S),!0;if(S==="."||S===".."||!i.dot&&S.charAt(0)==="."){this.debug("dot detected!",e,d,t,p);break}this.debug("globstar swallow a segment, and continue"),d++}return!!(r&&(this.debug(`
|
|
423
|
-
>>> no match, partial?`,e,d,t,p),d===u))}let b;if(typeof f=="string"?(b=h===f,this.debug("string match",f,h,b)):(b=f.test(h),this.debug("pattern match",f,h,b)),!b)return!1}if(a===u&&c===l)return!0;if(a===u)return r;if(c===l)return a===u-1&&e[a]==="";throw new Error("wtf?")}braceExpand(){return fT(this.pattern,this.options)}parse(e){iu(e);let t=this.options;if(e==="**")return Jt;if(e==="")return"";let r,i=null;(r=e.match(Qk))?i=t.dot?Kk:Yk:(r=e.match(jk))?i=(t.nocase?t.dot?Bk:Uk:t.dot?Vk:$k)(r[1]):(r=e.match(Xk))?i=(t.nocase?t.dot?Zk:Jk:t.dot?eM:tM)(r):(r=e.match(qk))?i=t.dot?Wk:Gk:(r=e.match(Hk))&&(i=zk);let s=Po.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,r=t.noglobstar?iM:t.dot?sM:aM,i=new Set(t.nocase?["i"]:[]),s=e.map(u=>{let l=u.map(f=>{if(f instanceof RegExp)for(let h of f.flags.split(""))i.add(h);return typeof f=="string"?fM(f):f===Jt?Jt:f._src});return l.forEach((f,h)=>{let d=l[h+1],p=l[h-1];f!==Jt||p===Jt||(p===void 0?d!==void 0&&d!==Jt?l[h+1]="(?:\\/|"+r+"\\/)?"+d:l[h]=r:d===void 0?l[h-1]=p+"(?:\\/|"+r+")?":d!==Jt&&(l[h-1]=p+"(?:\\/|\\/"+r+"\\/)"+d,l[h+1]=Jt))}),l.filter(f=>f!==Jt).join("/")}).join("|"),[a,c]=e.length>1?["(?:",")"]:["",""];s="^"+a+s+c+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let r=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let a=i[i.length-1];if(!a)for(let c=i.length-2;!a&&c>=0;c--)a=i[c];for(let c=0;c<s.length;c++){let u=s[c],l=i;if(r.matchBase&&u.length===1&&(l=[a]),this.matchOne(l,u,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Zt.defaults(e).Minimatch}};Zt.AST=Po;Zt.Minimatch=Wr;Zt.escape=Do;Zt.unescape=Un;var LT=require("node:url");var Ro=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,dT=new Set,s1=typeof process=="object"&&process?process:{},pT=o((n,e,t,r)=>{typeof s1.emitWarning=="function"?s1.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)},"emitWarning"),Nh=globalThis.AbortController,hT=globalThis.AbortSignal;if(typeof Nh>"u"){hT=class{static{o(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},Nh=class{static{o(this,"AbortController")}constructor(){e()}signal=new hT;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let i of this.signal._onabort)i(r);this.signal.onabort?.(r)}}};let n=s1.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=o(()=>{n&&(n=!1,pT("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))},"warnACPolyfill")}var hM=o(n=>!dT.has(n),"shouldWarn");var ps=o(n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),"isPosInt"),mT=o(n=>ps(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Fo:null:null,"getUintArray"),Fo=class extends Array{static{o(this,"ZeroArray")}constructor(e){super(e),this.fill(0)}},a1=class n{static{o(this,"Stack")}heap;length;static#e=!1;static create(e){let t=mT(e);if(!t)return[];n.#e=!0;let r=new n(e,t);return n.#e=!1,r}constructor(e,t){if(!n.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},au=class n{static{o(this,"LRUCache")}#e;#t;#s;#n;#a;#_;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#u;#f;#o;#c;#i;#g;#y;#d;#h;#E;#m;#T;#A;#S;#b;#w;#p;static unsafeExposeInternals(e){return{starts:e.#A,ttls:e.#S,sizes:e.#T,keyMap:e.#o,keyList:e.#c,valList:e.#i,next:e.#g,prev:e.#y,get head(){return e.#d},get tail(){return e.#h},free:e.#E,isBackgroundFetch:o(t=>e.#l(t),"isBackgroundFetch"),backgroundFetch:o((t,r,i,s)=>e.#j(t,r,i,s),"backgroundFetch"),moveToTail:o(t=>e.#V(t),"moveToTail"),indexes:o(t=>e.#C(t),"indexes"),rindexes:o(t=>e.#I(t),"rindexes"),isStale:o(t=>e.#v(t),"isStale")}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#f}get size(){return this.#u}get fetchMethod(){return this.#a}get memoMethod(){return this.#_}get dispose(){return this.#s}get disposeAfter(){return this.#n}constructor(e){let{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:c,allowStale:u,dispose:l,disposeAfter:f,noDisposeOnSet:h,noUpdateTTL:d,maxSize:p=0,maxEntrySize:S=0,sizeCalculation:b,fetchMethod:T,memoMethod:I,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:G,ignoreFetchAbort:Ee}=e;if(t!==0&&!ps(t))throw new TypeError("max option must be a nonnegative integer");let je=t?mT(t):Array;if(!je)throw new Error("invalid max value: "+t);if(this.#e=t,this.#t=p,this.maxEntrySize=S||this.#t,this.sizeCalculation=b,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(I!==void 0&&typeof I!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#_=I,T!==void 0&&typeof T!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#a=T,this.#w=!!T,this.#o=new Map,this.#c=new Array(t).fill(void 0),this.#i=new Array(t).fill(void 0),this.#g=new je(t),this.#y=new je(t),this.#d=0,this.#h=0,this.#E=a1.create(t),this.#u=0,this.#f=0,typeof l=="function"&&(this.#s=l),typeof f=="function"?(this.#n=f,this.#m=[]):(this.#n=void 0,this.#m=void 0),this.#b=!!this.#s,this.#p=!!this.#n,this.noDisposeOnSet=!!h,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!G,this.ignoreFetchAbort=!!Ee,this.maxEntrySize!==0){if(this.#t!==0&&!ps(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!ps(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!c,this.ttlResolution=ps(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!ps(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let Me="LRU_CACHE_UNBOUNDED";hM(Me)&&(dT.add(Me),pT("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Me,n))}}getRemainingTTL(e){return this.#o.has(e)?1/0:0}#O(){let e=new Fo(this.#e),t=new Fo(this.#e);this.#S=e,this.#A=t,this.#R=(s,a,c=Ro.now())=>{if(t[s]=a!==0?c:0,e[s]=a,a!==0&&this.ttlAutopurge){let u=setTimeout(()=>{this.#v(s)&&this.#D(this.#c[s],"expire")},a+1);u.unref&&u.unref()}},this.#x=s=>{t[s]=e[s]!==0?Ro.now():0},this.#r=(s,a)=>{if(e[a]){let c=e[a],u=t[a];if(!c||!u)return;s.ttl=c,s.start=u,s.now=r||i();let l=s.now-u;s.remainingTTL=c-l}};let r=0,i=o(()=>{let s=Ro.now();if(this.ttlResolution>0){r=s;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return s},"getNow");this.getRemainingTTL=s=>{let a=this.#o.get(s);if(a===void 0)return 0;let c=e[a],u=t[a];if(!c||!u)return 1/0;let l=(r||i())-u;return c-l},this.#v=s=>{let a=t[s],c=e[s];return!!c&&!!a&&(r||i())-a>c}}#x=o(()=>{},"#updateItemAge");#r=o(()=>{},"#statusTTL");#R=o(()=>{},"#setItemTTL");#v=o(()=>!1,"#isStale");#P(){let e=new Fo(this.#e);this.#f=0,this.#T=e,this.#F=t=>{this.#f-=e[t],e[t]=0},this.#L=(t,r,i,s)=>{if(this.#l(r))return 0;if(!ps(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!ps(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#N=(t,r,i)=>{if(e[t]=r,this.#t){let s=this.#t-e[t];for(;this.#f>s;)this.#M(!0)}this.#f+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#f)}}#F=o(e=>{},"#removeItemSize");#N=o((e,t,r)=>{},"#addItemSize");#L=o((e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#C({allowStale:e=this.allowStale}={}){if(this.#u)for(let t=this.#h;!(!this.#k(t)||((e||!this.#v(t))&&(yield t),t===this.#d));)t=this.#y[t]}*#I({allowStale:e=this.allowStale}={}){if(this.#u)for(let t=this.#d;!(!this.#k(t)||((e||!this.#v(t))&&(yield t),t===this.#h));)t=this.#g[t]}#k(e){return e!==void 0&&this.#o.get(this.#c[e])===e}*entries(){for(let e of this.#C())this.#i[e]!==void 0&&this.#c[e]!==void 0&&!this.#l(this.#i[e])&&(yield[this.#c[e],this.#i[e]])}*rentries(){for(let e of this.#I())this.#i[e]!==void 0&&this.#c[e]!==void 0&&!this.#l(this.#i[e])&&(yield[this.#c[e],this.#i[e]])}*keys(){for(let e of this.#C()){let t=this.#c[e];t!==void 0&&!this.#l(this.#i[e])&&(yield t)}}*rkeys(){for(let e of this.#I()){let t=this.#c[e];t!==void 0&&!this.#l(this.#i[e])&&(yield t)}}*values(){for(let e of this.#C())this.#i[e]!==void 0&&!this.#l(this.#i[e])&&(yield this.#i[e])}*rvalues(){for(let e of this.#I())this.#i[e]!==void 0&&!this.#l(this.#i[e])&&(yield this.#i[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#C()){let i=this.#i[r],s=this.#l(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#c[r],this))return this.get(this.#c[r],t)}}forEach(e,t=this){for(let r of this.#C()){let i=this.#i[r],s=this.#l(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}rforEach(e,t=this){for(let r of this.#I()){let i=this.#i[r],s=this.#l(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}purgeStale(){let e=!1;for(let t of this.#I({allowStale:!0}))this.#v(t)&&(this.#D(this.#c[t],"expire"),e=!0);return e}info(e){let t=this.#o.get(e);if(t===void 0)return;let r=this.#i[t],i=this.#l(r)?r.__staleWhileFetching:r;if(i===void 0)return;let s={value:i};if(this.#S&&this.#A){let a=this.#S[t],c=this.#A[t];if(a&&c){let u=a-(Ro.now()-c);s.ttl=u,s.start=Date.now()}}return this.#T&&(s.size=this.#T[t]),s}dump(){let e=[];for(let t of this.#C({allowStale:!0})){let r=this.#c[t],i=this.#i[t],s=this.#l(i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;let a={value:s};if(this.#S&&this.#A){a.ttl=this.#S[t];let c=Ro.now()-this.#A[t];a.start=Math.floor(Date.now()-c)}this.#T&&(a.size=this.#T[t]),e.unshift([r,a])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=Ro.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:u}=r,{noUpdateTTL:l=this.noUpdateTTL}=r,f=this.#L(e,t,r.size||0,c);if(this.maxEntrySize&&f>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this.#D(e,"set"),this;let h=this.#u===0?void 0:this.#o.get(e);if(h===void 0)h=this.#u===0?this.#h:this.#E.length!==0?this.#E.pop():this.#u===this.#e?this.#M(!1):this.#u,this.#c[h]=e,this.#i[h]=t,this.#o.set(e,h),this.#g[this.#h]=h,this.#y[h]=this.#h,this.#h=h,this.#u++,this.#N(h,f,u),u&&(u.set="add"),l=!1;else{this.#V(h);let d=this.#i[h];if(t!==d){if(this.#w&&this.#l(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=d;p!==void 0&&!a&&(this.#b&&this.#s?.(p,e,"set"),this.#p&&this.#m?.push([p,e,"set"]))}else a||(this.#b&&this.#s?.(d,e,"set"),this.#p&&this.#m?.push([d,e,"set"]));if(this.#F(h),this.#N(h,f,u),this.#i[h]=t,u){u.set="replace";let p=d&&this.#l(d)?d.__staleWhileFetching:d;p!==void 0&&(u.oldValue=p)}}else u&&(u.set="update")}if(i!==0&&!this.#S&&this.#O(),this.#S&&(l||this.#R(h,i,s),u&&this.#r(u,h)),!a&&this.#p&&this.#m){let d=this.#m,p;for(;p=d?.shift();)this.#n?.(...p)}return this}pop(){try{for(;this.#u;){let e=this.#i[this.#d];if(this.#M(!0),this.#l(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#p&&this.#m){let e=this.#m,t;for(;t=e?.shift();)this.#n?.(...t)}}}#M(e){let t=this.#d,r=this.#c[t],i=this.#i[t];return this.#w&&this.#l(i)?i.__abortController.abort(new Error("evicted")):(this.#b||this.#p)&&(this.#b&&this.#s?.(i,r,"evict"),this.#p&&this.#m?.push([i,r,"evict"])),this.#F(t),e&&(this.#c[t]=void 0,this.#i[t]=void 0,this.#E.push(t)),this.#u===1?(this.#d=this.#h=0,this.#E.length=0):this.#d=this.#g[t],this.#o.delete(r),this.#u--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,s=this.#o.get(e);if(s!==void 0){let a=this.#i[s];if(this.#l(a)&&a.__staleWhileFetching===void 0)return!1;if(this.#v(s))i&&(i.has="stale",this.#r(i,s));else return r&&this.#x(s),i&&(i.has="hit",this.#r(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,i=this.#o.get(e);if(i===void 0||!r&&this.#v(i))return;let s=this.#i[i];return this.#l(s)?s.__staleWhileFetching:s}#j(e,t,r,i){let s=t===void 0?void 0:this.#i[t];if(this.#l(s))return s;let a=new Nh,{signal:c}=r;c?.addEventListener("abort",()=>a.abort(c.reason),{signal:a.signal});let u={signal:a.signal,options:r,context:i},l=o((b,T=!1)=>{let{aborted:I}=a.signal,O=r.ignoreFetchAbort&&b!==void 0;if(r.status&&(I&&!T?(r.status.fetchAborted=!0,r.status.fetchError=a.signal.reason,O&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),I&&!O&&!T)return h(a.signal.reason);let L=p;return this.#i[t]===p&&(b===void 0?L.__staleWhileFetching?this.#i[t]=L.__staleWhileFetching:this.#D(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,b,u.options))),b},"cb"),f=o(b=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=b),h(b)),"eb"),h=o(b=>{let{aborted:T}=a.signal,I=T&&r.allowStaleOnFetchAbort,O=I||r.allowStaleOnFetchRejection,L=O||r.noDeleteOnFetchRejection,M=p;if(this.#i[t]===p&&(!L||M.__staleWhileFetching===void 0?this.#D(e,"fetch"):I||(this.#i[t]=M.__staleWhileFetching)),O)return r.status&&M.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),M.__staleWhileFetching;if(M.__returned===M)throw b},"fetchFail"),d=o((b,T)=>{let I=this.#a?.(e,s,u);I&&I instanceof Promise&&I.then(O=>b(O===void 0?void 0:O),T),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(b(void 0),r.allowStaleOnFetchAbort&&(b=o(O=>l(O,!0),"res")))})},"pcall");r.status&&(r.status.fetchDispatched=!0);let p=new Promise(d).then(l,f),S=Object.assign(p,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,S,{...u.options,status:void 0}),t=this.#o.get(e)):this.#i[t]=S,S}#l(e){if(!this.#w)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Nh}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:u=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:S=this.allowStaleOnFetchAbort,context:b,forceRefresh:T=!1,status:I,signal:O}=t;if(!this.#w)return I&&(I.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:I});let L={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:c,size:u,sizeCalculation:l,noUpdateTTL:f,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:S,ignoreFetchAbort:p,status:I,signal:O},M=this.#o.get(e);if(M===void 0){I&&(I.fetch="miss");let G=this.#j(e,M,L,b);return G.__returned=G}else{let G=this.#i[M];if(this.#l(G)){let ie=r&&G.__staleWhileFetching!==void 0;return I&&(I.fetch="inflight",ie&&(I.returnedStale=!0)),ie?G.__staleWhileFetching:G.__returned=G}let Ee=this.#v(M);if(!T&&!Ee)return I&&(I.fetch="hit"),this.#V(M),i&&this.#x(M),I&&this.#r(I,M),G;let je=this.#j(e,M,L,b),q=je.__staleWhileFetching!==void 0&&r;return I&&(I.fetch=Ee?"stale":"refresh",q&&Ee&&(I.returnedStale=!0)),q?je.__staleWhileFetching:je.__returned=je}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#_;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...a}=t,c=this.get(e,a);if(!s&&c!==void 0)return c;let u=r(e,c,{options:a,context:i});return this.set(e,u,a),u}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,c=this.#o.get(e);if(c!==void 0){let u=this.#i[c],l=this.#l(u);return a&&this.#r(a,c),this.#v(c)?(a&&(a.get="stale"),l?(a&&r&&u.__staleWhileFetching!==void 0&&(a.returnedStale=!0),r?u.__staleWhileFetching:void 0):(s||this.#D(e,"expire"),a&&r&&(a.returnedStale=!0),r?u:void 0)):(a&&(a.get="hit"),l?u.__staleWhileFetching:(this.#V(c),i&&this.#x(c),u))}else a&&(a.get="miss")}#$(e,t){this.#y[t]=e,this.#g[e]=t}#V(e){e!==this.#h&&(e===this.#d?this.#d=this.#g[e]:this.#$(this.#y[e],this.#g[e]),this.#$(this.#h,e),this.#h=e)}delete(e){return this.#D(e,"delete")}#D(e,t){let r=!1;if(this.#u!==0){let i=this.#o.get(e);if(i!==void 0)if(r=!0,this.#u===1)this.#U(t);else{this.#F(i);let s=this.#i[i];if(this.#l(s)?s.__abortController.abort(new Error("deleted")):(this.#b||this.#p)&&(this.#b&&this.#s?.(s,e,t),this.#p&&this.#m?.push([s,e,t])),this.#o.delete(e),this.#c[i]=void 0,this.#i[i]=void 0,i===this.#h)this.#h=this.#y[i];else if(i===this.#d)this.#d=this.#g[i];else{let a=this.#y[i];this.#g[a]=this.#g[i];let c=this.#g[i];this.#y[c]=this.#y[i]}this.#u--,this.#E.push(i)}}if(this.#p&&this.#m?.length){let i=this.#m,s;for(;s=i?.shift();)this.#n?.(...s)}return r}clear(){return this.#U("delete")}#U(e){for(let t of this.#I({allowStale:!0})){let r=this.#i[t];if(this.#l(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#c[t];this.#b&&this.#s?.(r,i,e),this.#p&&this.#m?.push([r,i,e])}}if(this.#o.clear(),this.#i.fill(void 0),this.#c.fill(void 0),this.#S&&this.#A&&(this.#S.fill(0),this.#A.fill(0)),this.#T&&this.#T.fill(0),this.#d=0,this.#h=0,this.#E.length=0,this.#f=0,this.#u=0,this.#p&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#n?.(...r)}}};var ko=require("node:path"),AT=require("node:url"),mi=require("fs"),wM=Ne(require("node:fs"),1),ys=require("node:fs/promises");var Uh=require("node:events"),d1=Ne(require("node:stream"),1),_T=require("node:string_decoder");var gT=typeof process=="object"&&process?process:{stdout:null,stderr:null},dM=o(n=>!!n&&typeof n=="object"&&(n instanceof gs||n instanceof d1.default||pM(n)||mM(n)),"isStream"),pM=o(n=>!!n&&typeof n=="object"&&n instanceof Uh.EventEmitter&&typeof n.pipe=="function"&&n.pipe!==d1.default.Writable.prototype.pipe,"isReadable"),mM=o(n=>!!n&&typeof n=="object"&&n instanceof Uh.EventEmitter&&typeof n.write=="function"&&typeof n.end=="function","isWritable"),$i=Symbol("EOF"),Vi=Symbol("maybeEmitEnd"),ms=Symbol("emittedEnd"),Lh=Symbol("emittingEnd"),ou=Symbol("emittedError"),kh=Symbol("closed"),yT=Symbol("read"),Mh=Symbol("flush"),vT=Symbol("flushChunk"),Bn=Symbol("encoding"),No=Symbol("decoder"),jt=Symbol("flowing"),cu=Symbol("paused"),Lo=Symbol("resume"),$t=Symbol("buffer"),Ir=Symbol("pipes"),Vt=Symbol("bufferLength"),o1=Symbol("bufferPush"),jh=Symbol("bufferShift"),lr=Symbol("objectMode"),wt=Symbol("destroyed"),c1=Symbol("error"),u1=Symbol("emitData"),ST=Symbol("emitEnd"),l1=Symbol("emitEnd2"),di=Symbol("async"),f1=Symbol("abort"),$h=Symbol("aborted"),uu=Symbol("signal"),ha=Symbol("dataListeners"),Hr=Symbol("discarded"),lu=o(n=>Promise.resolve().then(n),"defer"),gM=o(n=>n(),"nodefer"),yM=o(n=>n==="end"||n==="finish"||n==="prefinish","isEndish"),vM=o(n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,"isArrayBufferLike"),SM=o(n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),"isArrayBufferView"),Vh=class{static{o(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[Lo](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},h1=class extends Vh{static{o(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,r){super(e,t,r),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},_M=o(n=>!!n.objectMode,"isObjectModeOptions"),bM=o(n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer","isEncodingOptions"),gs=class extends Uh.EventEmitter{static{o(this,"Minipass")}[jt]=!1;[cu]=!1;[Ir]=[];[$t]=[];[lr];[Bn];[di];[No];[$i]=!1;[ms]=!1;[Lh]=!1;[kh]=!1;[ou]=null;[Vt]=0;[wt]=!1;[uu];[$h]=!1;[ha]=0;[Hr]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");_M(t)?(this[lr]=!0,this[Bn]=null):bM(t)?(this[Bn]=t.encoding,this[lr]=!1):(this[lr]=!1,this[Bn]=null),this[di]=!!t.async,this[No]=this[Bn]?new _T.StringDecoder(this[Bn]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:o(()=>this[$t],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:o(()=>this[Ir],"get")});let{signal:r}=t;r&&(this[uu]=r,r.aborted?this[f1]():r.addEventListener("abort",()=>this[f1]()))}get bufferLength(){return this[Vt]}get encoding(){return this[Bn]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[lr]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[di]}set async(e){this[di]=this[di]||!!e}[f1](){this[$h]=!0,this.emit("abort",this[uu]?.reason),this.destroy(this[uu]?.reason)}get aborted(){return this[$h]}set aborted(e){}write(e,t,r){if(this[$h])return!1;if(this[$i])throw new Error("write after end");if(this[wt])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(r=t,t="utf8"),t||(t="utf8");let i=this[di]?lu:gM;if(!this[lr]&&!Buffer.isBuffer(e)){if(SM(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(vM(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[lr]?(this[jt]&&this[Vt]!==0&&this[Mh](!0),this[jt]?this.emit("data",e):this[o1](e),this[Vt]!==0&&this.emit("readable"),r&&i(r),this[jt]):e.length?(typeof e=="string"&&!(t===this[Bn]&&!this[No]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Bn]&&(e=this[No].write(e)),this[jt]&&this[Vt]!==0&&this[Mh](!0),this[jt]?this.emit("data",e):this[o1](e),this[Vt]!==0&&this.emit("readable"),r&&i(r),this[jt]):(this[Vt]!==0&&this.emit("readable"),r&&i(r),this[jt])}read(e){if(this[wt])return null;if(this[Hr]=!1,this[Vt]===0||e===0||e&&e>this[Vt])return this[Vi](),null;this[lr]&&(e=null),this[$t].length>1&&!this[lr]&&(this[$t]=[this[Bn]?this[$t].join(""):Buffer.concat(this[$t],this[Vt])]);let t=this[yT](e||null,this[$t][0]);return this[Vi](),t}[yT](e,t){if(this[lr])this[jh]();else{let r=t;e===r.length||e===null?this[jh]():typeof r=="string"?(this[$t][0]=r.slice(e),t=r.slice(0,e),this[Vt]-=e):(this[$t][0]=r.subarray(e),t=r.subarray(0,e),this[Vt]-=e)}return this.emit("data",t),!this[$t].length&&!this[$i]&&this.emit("drain"),t}end(e,t,r){return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t="utf8"),e!==void 0&&this.write(e,t),r&&this.once("end",r),this[$i]=!0,this.writable=!1,(this[jt]||!this[cu])&&this[Vi](),this}[Lo](){this[wt]||(!this[ha]&&!this[Ir].length&&(this[Hr]=!0),this[cu]=!1,this[jt]=!0,this.emit("resume"),this[$t].length?this[Mh]():this[$i]?this[Vi]():this.emit("drain"))}resume(){return this[Lo]()}pause(){this[jt]=!1,this[cu]=!0,this[Hr]=!1}get destroyed(){return this[wt]}get flowing(){return this[jt]}get paused(){return this[cu]}[o1](e){this[lr]?this[Vt]+=1:this[Vt]+=e.length,this[$t].push(e)}[jh](){return this[lr]?this[Vt]-=1:this[Vt]-=this[$t][0].length,this[$t].shift()}[Mh](e=!1){do;while(this[vT](this[jh]())&&this[$t].length);!e&&!this[$t].length&&!this[$i]&&this.emit("drain")}[vT](e){return this.emit("data",e),this[jt]}pipe(e,t){if(this[wt])return e;this[Hr]=!1;let r=this[ms];return t=t||{},e===gT.stdout||e===gT.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[Ir].push(t.proxyErrors?new h1(this,e,t):new Vh(this,e,t)),this[di]?lu(()=>this[Lo]()):this[Lo]()),e}unpipe(e){let t=this[Ir].find(r=>r.dest===e);t&&(this[Ir].length===1?(this[jt]&&this[ha]===0&&(this[jt]=!1),this[Ir]=[]):this[Ir].splice(this[Ir].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let r=super.on(e,t);if(e==="data")this[Hr]=!1,this[ha]++,!this[Ir].length&&!this[jt]&&this[Lo]();else if(e==="readable"&&this[Vt]!==0)super.emit("readable");else if(yM(e)&&this[ms])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ou]){let i=t;this[di]?lu(()=>i.call(this,this[ou])):i.call(this,this[ou])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[ha]=this.listeners("data").length,this[ha]===0&&!this[Hr]&&!this[Ir].length&&(this[jt]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[ha]=0,!this[Hr]&&!this[Ir].length&&(this[jt]=!1)),t}get emittedEnd(){return this[ms]}[Vi](){!this[Lh]&&!this[ms]&&!this[wt]&&this[$t].length===0&&this[$i]&&(this[Lh]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[kh]&&this.emit("close"),this[Lh]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==wt&&this[wt])return!1;if(e==="data")return!this[lr]&&!r?!1:this[di]?(lu(()=>this[u1](r)),!0):this[u1](r);if(e==="end")return this[ST]();if(e==="close"){if(this[kh]=!0,!this[ms]&&!this[wt])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[ou]=r,super.emit(c1,r);let s=!this[uu]||this.listeners("error").length?super.emit("error",r):!1;return this[Vi](),s}else if(e==="resume"){let s=super.emit("resume");return this[Vi](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let i=super.emit(e,...t);return this[Vi](),i}[u1](e){for(let r of this[Ir])r.dest.write(e)===!1&&this.pause();let t=this[Hr]?!1:super.emit("data",e);return this[Vi](),t}[ST](){return this[ms]?!1:(this[ms]=!0,this.readable=!1,this[di]?(lu(()=>this[l1]()),!0):this[l1]())}[l1](){if(this[No]){let t=this[No].end();if(t){for(let r of this[Ir])r.dest.write(t);this[Hr]||super.emit("data",t)}}for(let t of this[Ir])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[lr]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[lr]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[lr])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Bn]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(wt,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Hr]=!1;let e=!1,t=o(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:o(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[$i])return t();let s,a,c=o(h=>{this.off("data",u),this.off("end",l),this.off(wt,f),t(),a(h)},"onerr"),u=o(h=>{this.off("error",c),this.off("end",l),this.off(wt,f),this.pause(),s({value:h,done:!!this[$i]})},"ondata"),l=o(()=>{this.off("error",c),this.off("data",u),this.off(wt,f),t(),s({done:!0,value:void 0})},"onend"),f=o(()=>c(new Error("stream destroyed")),"ondestroy");return new Promise((h,d)=>{a=d,s=h,this.once(wt,f),this.once("error",c),this.once("end",l),this.once("data",u)})},"next"),throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Hr]=!1;let e=!1,t=o(()=>(this.pause(),this.off(c1,t),this.off(wt,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),r=o(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(c1,t),this.once(wt,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[wt])return e?this.emit("error",e):this.emit(wt),this;this[wt]=!0,this[Hr]=!0,this[$t].length=0,this[Vt]=0;let t=this;return typeof t.close=="function"&&!this[kh]&&t.close(),e?this.emit("error",e):this.emit(wt),this}static get isStream(){return dM}};var EM=mi.realpathSync.native,hu={lstatSync:mi.lstatSync,readdir:mi.readdir,readdirSync:mi.readdirSync,readlinkSync:mi.readlinkSync,realpathSync:EM,promises:{lstat:ys.lstat,readdir:ys.readdir,readlink:ys.readlink,realpath:ys.realpath}},xT=o(n=>!n||n===hu||n===wM?hu:{...hu,...n,promises:{...hu.promises,...n.promises||{}}},"fsFromOption"),CT=/^\\\\\?\\([a-z]:)\\?$/i,TM=o(n=>n.replace(/\//g,"\\").replace(CT,"$1\\"),"uncToDrive"),AM=/[\\\/]/,hn=0,IT=1,OT=2,pi=4,PT=6,DT=8,da=10,RT=12,fn=15,fu=~fn,p1=16,bT=32,du=64,qn=128,Bh=256,Gh=512,wT=du|qn|Gh,xM=1023,m1=o(n=>n.isFile()?DT:n.isDirectory()?pi:n.isSymbolicLink()?da:n.isCharacterDevice()?OT:n.isBlockDevice()?PT:n.isSocket()?RT:n.isFIFO()?IT:hn,"entToType"),ET=new Map,pu=o(n=>{let e=ET.get(n);if(e)return e;let t=n.normalize("NFKD");return ET.set(n,t),t},"normalize"),TT=new Map,qh=o(n=>{let e=TT.get(n);if(e)return e;let t=pu(n.toLowerCase());return TT.set(n,t),t},"normalizeNocase"),Wh=class extends au{static{o(this,"ResolveCache")}constructor(){super({max:256})}},g1=class extends au{static{o(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:o(t=>t.length+1,"sizeCalculation")})}},FT=Symbol("PathScurry setAsCwd"),fr=class{static{o(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#s;get mode(){return this.#s}#n;get nlink(){return this.#n}#a;get uid(){return this.#a}#_;get gid(){return this.#_}#u;get rdev(){return this.#u}#f;get blksize(){return this.#f}#o;get ino(){return this.#o}#c;get size(){return this.#c}#i;get blocks(){return this.#i}#g;get atimeMs(){return this.#g}#y;get mtimeMs(){return this.#y}#d;get ctimeMs(){return this.#d}#h;get birthtimeMs(){return this.#h}#E;get atime(){return this.#E}#m;get mtime(){return this.#m}#T;get ctime(){return this.#T}#A;get birthtime(){return this.#A}#S;#b;#w;#p;#O;#x;#r;#R;#v;#P;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=hn,r,i,s,a,c){this.name=e,this.#S=s?qh(e):pu(e),this.#r=t&xM,this.nocase=s,this.roots=i,this.root=r||this,this.#R=a,this.#w=c.fullpath,this.#O=c.relative,this.#x=c.relativePosix,this.parent=c.parent,this.parent?this.#e=this.parent.#e:this.#e=xT(c.fs)}depth(){return this.#b!==void 0?this.#b:this.parent?this.#b=this.parent.depth()+1:this.#b=0}childrenCache(){return this.#R}resolve(e){if(!e)return this;let t=this.getRootString(e),i=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#F(i):this.#F(i)}#F(e){let t=this;for(let r of e)t=t.child(r);return t}children(){let e=this.#R.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#R.set(this,t),this.#r&=~p1,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?qh(e):pu(e);for(let u of r)if(u.#S===i)return u;let s=this.parent?this.sep:"",a=this.#w?this.#w+s+e:void 0,c=this.newChild(e,hn,{...t,parent:this,fullpath:a});return this.canReaddir()||(c.#r|=qn),r.push(c),c}relative(){if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let e=this.name,t=this.parent;if(!t)return this.#O=this.name;let r=t.relative();return r+(!r||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.fullpathPosix();let r=t.relativePosix();return r+(!r||!t.parent?"":"/")+e}fullpath(){if(this.#w!==void 0)return this.#w;let e=this.name,t=this.parent;if(!t)return this.#w=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#w=i}fullpathPosix(){if(this.#p!==void 0)return this.#p;if(this.sep==="/")return this.#p=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#p=`//?/${i}`:this.#p=i}let e=this.parent,t=e.fullpathPosix(),r=t+(!t||!e.parent?"":"/")+this.name;return this.#p=r}isUnknown(){return(this.#r&fn)===hn}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#r&fn)===DT}isDirectory(){return(this.#r&fn)===pi}isCharacterDevice(){return(this.#r&fn)===OT}isBlockDevice(){return(this.#r&fn)===PT}isFIFO(){return(this.#r&fn)===IT}isSocket(){return(this.#r&fn)===RT}isSymbolicLink(){return(this.#r&da)===da}lstatCached(){return this.#r&bT?this:void 0}readlinkCached(){return this.#v}realpathCached(){return this.#P}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#v)return!0;if(!this.parent)return!1;let e=this.#r&fn;return!(e!==hn&&e!==da||this.#r&Bh||this.#r&qn)}calledReaddir(){return!!(this.#r&p1)}isENOENT(){return!!(this.#r&qn)}isNamed(e){return this.nocase?this.#S===qh(e):this.#S===pu(e)}async readlink(){let e=this.#v;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),r=(await this.parent.realpath())?.resolve(t);if(r)return this.#v=r}catch(t){this.#l(t.code);return}}readlinkSync(){let e=this.#v;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),r=this.parent.realpathSync()?.resolve(t);if(r)return this.#v=r}catch(t){this.#l(t.code);return}}#N(e){this.#r|=p1;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#L()}}#L(){this.#r&qn||(this.#r=(this.#r|qn)&fu,this.#C())}#C(){let e=this.children();e.provisional=0;for(let t of e)t.#L()}#I(){this.#r|=Gh,this.#k()}#k(){if(this.#r&du)return;let e=this.#r;(e&fn)===pi&&(e&=fu),this.#r=e|du,this.#C()}#M(e=""){e==="ENOTDIR"||e==="EPERM"?this.#k():e==="ENOENT"?this.#L():this.children().provisional=0}#j(e=""){e==="ENOTDIR"?this.parent.#k():e==="ENOENT"&&this.#L()}#l(e=""){let t=this.#r;t|=Bh,e==="ENOENT"&&(t|=qn),(e==="EINVAL"||e==="UNKNOWN")&&(t&=fu),this.#r=t,e==="ENOTDIR"&&this.parent&&this.parent.#k()}#$(e,t){return this.#D(e,t)||this.#V(e,t)}#V(e,t){let r=m1(e),i=this.newChild(e.name,r,{parent:this}),s=i.#r&fn;return s!==pi&&s!==da&&s!==hn&&(i.#r|=du),t.unshift(i),t.provisional++,i}#D(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?qh(e.name):pu(e.name))===i.#S)return this.#U(e,i,r,t)}}#U(e,t,r,i){let s=t.name;return t.#r=t.#r&fu|m1(e),s!==e.name&&(t.name=e.name),r!==i.provisional&&(r===i.length-1?i.pop():i.splice(r,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#r&qn)===0)try{return this.#W(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#j(e.code)}}lstatSync(){if((this.#r&qn)===0)try{return this.#W(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#j(e.code)}}#W(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:s,blksize:a,blocks:c,ctime:u,ctimeMs:l,dev:f,gid:h,ino:d,mode:p,mtime:S,mtimeMs:b,nlink:T,rdev:I,size:O,uid:L}=e;this.#E=t,this.#g=r,this.#A=i,this.#h=s,this.#f=a,this.#i=c,this.#T=u,this.#d=l,this.#t=f,this.#_=h,this.#o=d,this.#s=p,this.#m=S,this.#y=b,this.#n=T,this.#u=I,this.#c=O,this.#a=L;let M=m1(e);this.#r=this.#r&fu|M|bT,M!==hn&&M!==pi&&M!==da&&(this.#r|=du)}#q=[];#G=!1;#H(e){this.#G=!1;let t=this.#q.slice();this.#q.length=0,t.forEach(r=>r(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let r=this.children();if(this.calledReaddir()){let s=r.slice(0,r.provisional);t?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#q.push(e),this.#G)return;this.#G=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,a)=>{if(s)this.#M(s.code),r.provisional=0;else{for(let c of a)this.#$(c,r);this.#N(r)}this.#H(r.slice(0,r.provisional))})}#B;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#B)await this.#B;else{let r=o(()=>{},"resolve");this.#B=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#$(i,e);this.#N(e)}catch(i){this.#M(i.code),e.provisional=0}this.#B=void 0,r()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let r of this.#e.readdirSync(t,{withFileTypes:!0}))this.#$(r,e);this.#N(e)}catch(r){this.#M(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#r&wT)return!1;let e=fn&this.#r;return e===hn||e===pi||e===da}shouldWalk(e,t){return(this.#r&pi)===pi&&!(this.#r&wT)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#P)return this.#P;if(!((Gh|Bh|qn)&this.#r))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#P=this.resolve(e)}catch{this.#I()}}realpathSync(){if(this.#P)return this.#P;if(!((Gh|Bh|qn)&this.#r))try{let e=this.#e.realpathSync(this.fullpath());return this.#P=this.resolve(e)}catch{this.#I()}}[FT](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),r=[],i=this;for(;i&&i.parent;)t.add(i),i.#O=r.join(this.sep),i.#x=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#O=void 0,i.#x=void 0,i=i.parent}},Hh=class n extends fr{static{o(this,"PathWin32")}sep="\\";splitSep=AM;constructor(e,t=hn,r,i,s,a,c){super(e,t,r,i,s,a,c)}newChild(e,t=hn,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return ko.win32.parse(e).root}getRoot(e){if(e=TM(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,r]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=r;return this.roots[e]=new Mo(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(CT,"$1\\"),e===t}},zh=class n extends fr{static{o(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=hn,r,i,s,a,c){super(e,t,r,i,s,a,c)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=hn,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Qh=class{static{o(this,"PathScurryBase")}root;rootPath;roots;cwd;#e;#t;#s;nocase;#n;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:s=16*1024,fs:a=hu}={}){this.#n=xT(a),(e instanceof URL||e.startsWith("file://"))&&(e=(0,AT.fileURLToPath)(e));let c=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(c),this.#e=new Wh,this.#t=new Wh,this.#s=new g1(s);let u=c.substring(this.rootPath.length).split(r);if(u.length===1&&!u[0]&&u.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#n),this.roots[this.rootPath]=this.root;let l=this.root,f=u.length-1,h=t.sep,d=this.rootPath,p=!1;for(let S of u){let b=f--;l=l.child(S,{relative:new Array(b).fill("..").join(h),relativePosix:new Array(b).fill("..").join("/"),fullpath:d+=(p?"":h)+S}),p=!0}this.cwd=l}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#s}resolve(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#e.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpath();return this.#e.set(t,i),i}resolvePosix(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#t.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpathPosix();return this.#t.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r}=t;if(e.canReaddir()){let i=await e.readdir();return r?i:i.map(s=>s.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0}=t;return e.canReaddir()?r?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=await e.readlink();return t?r:r?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=e.readlinkSync();return t?r:r?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=await e.realpath();return t?r:r?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=e.realpathSync();return t?r:r?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?e:e.fullpath());let u=new Set,l=o((h,d)=>{u.add(h),h.readdirCB((p,S)=>{if(p)return d(p);let b=S.length;if(!b)return d();let T=o(()=>{--b===0&&d()},"next");for(let I of S)(!s||s(I))&&c.push(r?I:I.fullpath()),i&&I.isSymbolicLink()?I.realpath().then(O=>O?.isUnknown()?O.lstat():O).then(O=>O?.shouldWalk(u,a)?l(O,T):T()):I.shouldWalk(u,a)?l(I,T):T()},!0)},"walk"),f=e;return new Promise((h,d)=>{l(f,p=>{if(p)return d(p);h(c)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?e:e.fullpath());let u=new Set([e]);for(let l of u){let f=l.readdirSync();for(let h of f){(!s||s(h))&&c.push(r?h:h.fullpath());let d=h;if(h.isSymbolicLink()){if(!(i&&(d=h.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(u,a)&&u.add(d)}}return c}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t;(!s||s(e))&&(yield r?e:e.fullpath());let c=new Set([e]);for(let u of c){let l=u.readdirSync();for(let f of l){(!s||s(f))&&(yield r?f:f.fullpath());let h=f;if(f.isSymbolicLink()){if(!(i&&(h=f.realpathSync())))continue;h.isUnknown()&&h.lstatSync()}h.shouldWalk(c,a)&&c.add(h)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new gs({objectMode:!0});(!s||s(e))&&c.write(r?e:e.fullpath());let u=new Set,l=[e],f=0,h=o(()=>{let d=!1;for(;!d;){let p=l.shift();if(!p){f===0&&c.end();return}f++,u.add(p);let S=o((T,I,O=!1)=>{if(T)return c.emit("error",T);if(i&&!O){let L=[];for(let M of I)M.isSymbolicLink()&&L.push(M.realpath().then(G=>G?.isUnknown()?G.lstat():G));if(L.length){Promise.all(L).then(()=>S(null,I,!0));return}}for(let L of I)L&&(!s||s(L))&&(c.write(r?L:L.fullpath())||(d=!0));f--;for(let L of I){let M=L.realpathCached()||L;M.shouldWalk(u,a)&&l.push(M)}d&&!c.flowing?c.once("drain",h):b||h()},"onReaddir"),b=!0;p.readdirCB(S,!0),b=!1}},"process");return h(),c}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new gs({objectMode:!0}),u=new Set;(!s||s(e))&&c.write(r?e:e.fullpath());let l=[e],f=0,h=o(()=>{let d=!1;for(;!d;){let p=l.shift();if(!p){f===0&&c.end();return}f++,u.add(p);let S=p.readdirSync();for(let b of S)(!s||s(b))&&(c.write(r?b:b.fullpath())||(d=!0));f--;for(let b of S){let T=b;if(b.isSymbolicLink()){if(!(i&&(T=b.realpathSync())))continue;T.isUnknown()&&T.lstatSync()}T.shouldWalk(u,a)&&l.push(T)}}d&&!c.flowing&&c.once("drain",h)},"process");return h(),c}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[FT](t)}},Mo=class extends Qh{static{o(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,ko.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return ko.win32.parse(e).root.toUpperCase()}newRoot(e){return new Hh(this.rootPath,pi,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},jo=class extends Qh{static{o(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,ko.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new zh(this.rootPath,pi,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},mu=class extends jo{static{o(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},tY=process.platform==="win32"?Hh:zh,NT=process.platform==="win32"?Mo:process.platform==="darwin"?mu:jo;var CM=o(n=>n.length>=1,"isPatternList"),IM=o(n=>n.length>=1,"isGlobList"),$o=class n{static{o(this,"Pattern")}#e;#t;#s;length;#n;#a;#_;#u;#f;#o;#c=!0;constructor(e,t,r,i){if(!CM(e))throw new TypeError("empty pattern list");if(!IM(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#t=t,this.#s=r,this.#n=i,this.#s===0){if(this.isUNC()){let[s,a,c,u,...l]=this.#e,[f,h,d,p,...S]=this.#t;l[0]===""&&(l.shift(),S.shift());let b=[s,a,c,u,""].join("/"),T=[f,h,d,p,""].join("/");this.#e=[b,...l],this.#t=[T,...S],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...a]=this.#e,[c,...u]=this.#t;a[0]===""&&(a.shift(),u.shift());let l=s+"/",f=c+"/";this.#e=[l,...a],this.#t=[f,...u],this.length=this.#e.length}}}pattern(){return this.#e[this.#s]}isString(){return typeof this.#e[this.#s]=="string"}isGlobstar(){return this.#e[this.#s]===Jt}isRegExp(){return this.#e[this.#s]instanceof RegExp}globString(){return this.#_=this.#_||(this.#s===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#s).join("/"))}hasMore(){return this.length>this.#s+1}rest(){return this.#a!==void 0?this.#a:this.hasMore()?(this.#a=new n(this.#e,this.#t,this.#s+1,this.#n),this.#a.#o=this.#o,this.#a.#f=this.#f,this.#a.#u=this.#u,this.#a):this.#a=null}isUNC(){let e=this.#e;return this.#f!==void 0?this.#f:this.#f=this.#n==="win32"&&this.#s===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#u!==void 0?this.#u:this.#u=this.#n==="win32"&&this.#s===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#o!==void 0?this.#o:this.#o=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#s===0?e:""}checkFollowGlobstar(){return!(this.#s===0||!this.isGlobstar()||!this.#c)}markFollowGlobstar(){return this.#s===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var OM=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Vo=class{static{o(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:s,platform:a=OM}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:s,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let c of e)this.add(c)}add(e){let t=new Wr(e,this.mmopts);for(let r=0;r<t.set.length;r++){let i=t.set[r],s=t.globParts[r];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let a=new $o(i,s,0,this.platform),c=new Wr(a.globString(),this.mmopts),u=s[s.length-1]==="**",l=a.isAbsolute();l?this.absolute.push(c):this.relative.push(c),u&&(l?this.absoluteChildren.push(c):this.relativeChildren.push(c))}}ignored(e){let t=e.fullpath(),r=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let a of this.relative)if(a.match(i)||a.match(s))return!0;for(let a of this.absolute)if(a.match(t)||a.match(r))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",r=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(r))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}};var y1=class n{static{o(this,"HasWalkedCache")}store;constructor(e=new Map){this.store=e}copy(){return new n(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let r=e.fullpath(),i=this.store.get(r);i?i.add(t.globString()):this.store.set(r,new Set([t.globString()]))}},v1=class{static{o(this,"MatchRecord")}store=new Map;add(e,t,r){let i=(t?2:0)|(r?1:0),s=this.store.get(e);this.store.set(e,s===void 0?i:i&s)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},S1=class{static{o(this,"SubWalks")}store=new Map;add(e,t){if(!e.canReaddir())return;let r=this.store.get(e);r?r.find(i=>i.globString()===t.globString())||r.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},gu=class n{static{o(this,"Processor")}hasWalkedCache;matches=new v1;subwalks=new S1;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new y1}processPatterns(e,t){this.patterns=t;let r=t.map(i=>[e,i]);for(let[i,s]of r){this.hasWalkedCache.storeWalked(i,s);let a=s.root(),c=s.isAbsolute()&&this.opts.absolute!==!1;if(a){i=i.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let h=s.rest();if(h)s=h;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let u,l,f=!1;for(;typeof(u=s.pattern())=="string"&&(l=s.rest());)i=i.resolve(u),s=l,f=!0;if(u=s.pattern(),l=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof u=="string"){let h=u===".."||u===""||u===".";this.matches.add(i.resolve(u),c,h);continue}else if(u===Jt){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let h=l?.pattern(),d=l?.rest();if(!l||(h===""||h===".")&&!d)this.matches.add(i,c,h===""||h===".");else if(h===".."){let p=i.parent||i;d?this.hasWalkedCache.hasWalked(p,d)||this.subwalks.add(p,d):this.matches.add(p,c,!0)}}else u instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new n(this.opts,this.hasWalkedCache)}filterEntries(e,t){let r=this.subwalks.get(e),i=this.child();for(let s of t)for(let a of r){let c=a.isAbsolute(),u=a.pattern(),l=a.rest();u===Jt?i.testGlobstar(s,a,l,c):u instanceof RegExp?i.testRegExp(s,u,l,c):i.testString(s,u,l,c)}return i}testGlobstar(e,t,r,i){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(r&&t.checkFollowGlobstar()?this.subwalks.add(e,r):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),r){let s=r.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,r.rest(),i);else if(s===".."){let a=e.parent||e;this.subwalks.add(a,r)}else s instanceof RegExp&&this.testRegExp(e,s,r.rest(),i)}}testRegExp(e,t,r,i){t.test(e.name)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}testString(e,t,r,i){e.isNamed(t)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}};var PM=o((n,e)=>typeof n=="string"?new Vo([n],e):Array.isArray(n)?new Vo(n,e):n,"makeIgnore"),Yh=class{static{o(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#s;signal;maxDepth;includeChildMatches;constructor(e,t,r){if(this.patterns=e,this.path=t,this.opts=r,this.#s=!r.posix&&r.platform==="win32"?"\\":"/",this.includeChildMatches=r.includeChildMatches!==!1,(r.ignore||!this.includeChildMatches)&&(this.#t=PM(r.ignore??[],r),!this.includeChildMatches&&typeof this.#t.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=r.maxDepth||1/0,r.signal&&(this.signal=r.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#n(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#a(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||await e.realpath(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=await s.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.lstat()}return this.matchCheckTest(s,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#n(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||e.realpathSync(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=s.realpathSync();a&&(a?.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(s,t)}matchFinish(e,t){if(this.#n(e))return;if(!this.includeChildMatches&&this.#t?.add){let s=`${e.relativePosix()}/**`;this.#t.add(s)}let r=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#s:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(r){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),a=this.opts.dotRelative&&!s.startsWith(".."+this.#s)?"."+this.#s:"";this.matchEmit(s?a+s+i:"."+i)}}async match(e,t,r){let i=await this.matchCheck(e,r);i&&this.matchFinish(i,t)}matchSync(e,t,r){let i=this.matchCheckSync(e,r);i&&this.matchFinish(i,t)}walkCB(e,t,r){this.signal?.aborted&&r(),this.walkCB2(e,t,new gu(this.opts),r)}walkCB2(e,t,r,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||(s++,this.match(c,u,l).then(()=>a()));for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let u=c.readdirCached();c.calledReaddir()?this.walkCB3(c,u,r,a):c.readdirCB((l,f)=>this.walkCB3(c,f,r,a),!0)}a()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||(s++,this.match(c,u,l).then(()=>a()));for(let[c,u]of r.subwalks.entries())s++,this.walkCB2(c,u,r.child(),a);a()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new gu(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||this.matchSync(c,u,l);for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let u=c.readdirSync();this.walkCB3Sync(c,u,r,a)}a()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||this.matchSync(c,u,l);for(let[c,u]of r.subwalks.entries())s++,this.walkCB2Sync(c,u,r.child(),a);a()}},yu=class extends Yh{static{o(this,"GlobWalker")}matches=new Set;constructor(e,t,r){super(e,t,r)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},vu=class extends Yh{static{o(this,"GlobStream")}results;constructor(e,t,r){super(e,t,r),this.results=new gs({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var DM=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Gn=class{static{o(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,LT.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(u=>u.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(u=>u.includes("/")?u:`./**/${u}`)}if(this.pattern=e,this.platform=t.platform||DM,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let u=t.platform==="win32"?Mo:t.platform==="darwin"?mu:t.platform?jo:NT;this.scurry=new u(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let r=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:r,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},s=this.pattern.map(u=>new Wr(u,i)),[a,c]=s.reduce((u,l)=>(u[0].push(...l.set),u[1].push(...l.globParts),u),[[],[]]);this.patterns=a.map((u,l)=>{let f=c[l];if(!f)throw new Error("invalid pattern object");return new $o(u,f,0,this.platform)})}async walk(){return[...await new yu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new yu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new vu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new vu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var _1=o((n,e={})=>{Array.isArray(n)||(n=[n]);for(let t of n)if(new Wr(t,e).hasMagic())return!0;return!1},"hasMagic");function Xh(n,e={}){return new Gn(n,e).streamSync()}o(Xh,"globStreamSync");function MT(n,e={}){return new Gn(n,e).stream()}o(MT,"globStream");function jT(n,e={}){return new Gn(n,e).walkSync()}o(jT,"globSync");async function kT(n,e={}){return new Gn(n,e).walk()}o(kT,"glob_");function Jh(n,e={}){return new Gn(n,e).iterateSync()}o(Jh,"globIterateSync");function $T(n,e={}){return new Gn(n,e).iterate()}o($T,"globIterate");var RM=Xh,FM=Object.assign(MT,{sync:Xh}),NM=Jh,LM=Object.assign($T,{sync:Jh}),kM=Object.assign(jT,{stream:Xh,iterate:Jh}),Kh=Object.assign(kT,{glob:kT,globSync:jT,sync:kM,globStream:MT,stream:FM,globStreamSync:Xh,streamSync:RM,globIterate:$T,iterate:LM,globIterateSync:Jh,iterateSync:NM,Glob:Gn,hasMagic:_1,escape:Do,unescape:Un});Kh.glob=Kh;var pa=Ne($n());var Ss=class{constructor(e){this.rootPath=e}static{o(this,"NodeFsAdapter")}async readFile(e){let t=this.resolvePath(e);if(!await Ft.default.pathExists(t))throw new pa.FileNotFoundError(e);return Ft.default.readFile(t,"utf-8")}async fileExists(e){let t=this.resolvePath(e);return Ft.default.pathExists(t)}async getFileMetadata(e){let t=await this.readFile(e);return this.extractFrontmatter(t)}async createFile(e,t){let r=this.resolvePath(e);if(await Ft.default.pathExists(r))throw new pa.FileAlreadyExistsError(e);return await Ft.default.ensureDir(vs.default.dirname(r)),await Ft.default.writeFile(r,t,"utf-8"),e}async updateFile(e,t){let r=this.resolvePath(e);if(!await Ft.default.pathExists(r))throw new pa.FileNotFoundError(e);await Ft.default.writeFile(r,t,"utf-8")}async writeFile(e,t){let r=this.resolvePath(e);await Ft.default.ensureDir(vs.default.dirname(r)),await Ft.default.writeFile(r,t,"utf-8")}async deleteFile(e){let t=this.resolvePath(e);if(!await Ft.default.pathExists(t))throw new pa.FileNotFoundError(e);await Ft.default.remove(t)}async renameFile(e,t){let r=this.resolvePath(e),i=this.resolvePath(t);if(!await Ft.default.pathExists(r))throw new pa.FileNotFoundError(e);await Ft.default.ensureDir(vs.default.dirname(i)),await Ft.default.move(r,i)}async createDirectory(e){let t=this.resolvePath(e);await Ft.default.ensureDir(t)}async directoryExists(e){let t=this.resolvePath(e);return await Ft.default.pathExists(t)?(await Ft.default.stat(t)).isDirectory():!1}async getMarkdownFiles(e){let t=e?this.resolvePath(e):this.rootPath,r=vs.default.join(t,"**/*.md");return(await Kh(r,{nodir:!0})).map(a=>vs.default.relative(this.rootPath,a))}async findFilesByMetadata(e){let t=await this.getMarkdownFiles(),r=[];for(let i of t)try{let s=await this.getFileMetadata(i);this.matchesQuery(s,e)&&r.push(i)}catch{continue}return r}async findFileByUID(e){let t=await this.findFilesByMetadata({exo__Asset_uid:e});return t.length>0?t[0]:null}resolvePath(e){return vs.default.isAbsolute(e)?e:vs.default.join(this.rootPath,e)}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return{};try{let i=Zc.load(r[1]);return typeof i=="object"&&i!==null?i:{}}catch{return{}}}matchesQuery(e,t){for(let[r,i]of Object.entries(t)){let s=e[r];if(Array.isArray(s)){if(!s.some(a=>this.normalizeValue(a)===this.normalizeValue(i)))return!1}else if(this.normalizeValue(s)!==this.normalizeValue(i))return!1}return!0}normalizeValue(e){return e==null?"":String(e).replace(/["'[\]]/g,"").trim()}};var Su=Ne(require("path")),b1=Ne(Eo());var Uo=class{constructor(e){this.vaultRoot=e}static{o(this,"PathResolver")}resolve(e){if(!Su.default.isAbsolute(e))return Su.default.resolve(this.vaultRoot,e);let t=Su.default.resolve(e),r=Su.default.resolve(this.vaultRoot);if(!t.startsWith(r))throw new rt(`File path ${e} is outside vault root ${this.vaultRoot}`,"Provide a file path within the vault directory.",{filepath:e,vaultRoot:this.vaultRoot});return t}validate(e){if(!b1.default.existsSync(e))throw new tu(e);if(!b1.default.statSync(e).isFile())throw new rt(`Not a file: ${e}`,"Provide a path to a file, not a directory.",{filepath:e});if(!e.endsWith(".md"))throw new rt(`Not a Markdown file: ${e}`,"Provide a path to a .md file.",{filepath:e})}getVaultRoot(){return this.vaultRoot}};var WT=Ne($n());var VT=Ne($n());var Wn=class{static{o(this,"BaseCommandExecutor")}constructor(e){this.pathResolver=e.pathResolver,this.fsAdapter=e.fsAdapter,this.frontmatterService=e.frontmatterService,this.dryRun=e.dryRun}resolveAndValidate(e){let t=this.pathResolver.resolve(e);this.pathResolver.validate(t);let r=t.replace(this.pathResolver.getVaultRoot()+"/","");return{resolvedPath:t,relativePath:r}}getCurrentTimestamp(){return VT.DateFormatter.toLocalTimestamp(new Date)}isAssetArchived(e){if(e?.exo__Asset_isArchived===!0)return!0;let t=e?.archived;if(t==null)return!1;if(typeof t=="boolean")return t;if(typeof t=="number")return t!==0;if(typeof t=="string"){let r=t.toLowerCase().trim();return r==="true"||r==="yes"||r==="1"}return!1}extractAliasesFromFrontmatter(e){let t=e.match(/aliases:\s*\n((?: - .*\n?)*)/);return t?t[1].split(`
|
|
424
|
-
`).filter(i=>i.trim()).map(i=>i.replace(/^\s*-\s*/,"").trim()):[]}};var _u=class extends Wn{static{o(this,"StatusCommandExecutor")}constructor(e){super(e)}async executeStart(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDoing]]"');s=this.frontmatterService.updateProperty(s,"ems__Effort_startTimestamp",i),await this.fsAdapter.updateFile(t,s),console.log(`\u2705 Started: ${e}`),console.log(" Status: Doing"),console.log(` Start time: ${i}`),process.exit(0)}catch(t){K.handle(t)}}async executeComplete(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');s=this.frontmatterService.updateProperty(s,"ems__Effort_endTimestamp",i),s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(t,s),console.log(`\u2705 Completed: ${e}`),console.log(" Status: Done"),console.log(` Completion time: ${i}`),process.exit(0)}catch(t){K.handle(t)}}async executeTrash(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusTrashed]]"');s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(t,s),console.log(`\u2705 Trashed: ${e}`),console.log(" Status: Trashed"),console.log(` Resolution time: ${i}`),process.exit(0)}catch(t){K.handle(t)}}async executeArchive(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.frontmatterService.updateProperty(r,"archived","true");i=this.frontmatterService.removeProperty(i,"aliases"),await this.fsAdapter.updateFile(t,i),console.log(`\u2705 Archived: ${e}`),console.log(" Archived: true"),console.log(" Aliases removed"),process.exit(0)}catch(t){K.handle(t)}}async executeMoveToBacklog(e){try{await this.updateStatus(e,"ems__EffortStatusBacklog","Backlog"),process.exit(0)}catch(t){K.handle(t)}}async executeMoveToAnalysis(e){try{await this.updateStatus(e,"ems__EffortStatusAnalysis","Analysis"),process.exit(0)}catch(t){K.handle(t)}}async executeMoveToToDo(e){try{await this.updateStatus(e,"ems__EffortStatusToDo","ToDo"),process.exit(0)}catch(t){K.handle(t)}}async updateStatus(e,t,r){let{relativePath:i}=this.resolveAndValidate(e),s=await this.fsAdapter.readFile(i),a=this.frontmatterService.updateProperty(s,"ems__Effort_status",`"[[${t}]]"`);await this.fsAdapter.updateFile(i,a),console.log(`\u2705 Moved to ${r}: ${e}`),console.log(` Status: ${r}`)}};var er=[];for(let n=0;n<256;++n)er.push((n+256).toString(16).slice(1));function
|
|
425
|
-
- ${i}`)),await this.fsAdapter.updateFile(t,h),console.log(` Updated label: "${i}"`)}let a=
|
|
423
|
+
>>> no match, partial?`,e,d,t,p),d===u))}let b;if(typeof f=="string"?(b=h===f,this.debug("string match",f,h,b)):(b=f.test(h),this.debug("pattern match",f,h,b)),!b)return!1}if(a===u&&c===l)return!0;if(a===u)return r;if(c===l)return a===u-1&&e[a]==="";throw new Error("wtf?")}braceExpand(){return pT(this.pattern,this.options)}parse(e){iu(e);let t=this.options;if(e==="**")return Jt;if(e==="")return"";let r,i=null;(r=e.match(Jk))?i=t.dot?eM:Zk:(r=e.match(Bk))?i=(t.nocase?t.dot?Hk:Wk:t.dot?Gk:qk)(r[1]):(r=e.match(tM))?i=(t.nocase?t.dot?nM:rM:t.dot?iM:sM)(r):(r=e.match(zk))?i=t.dot?Yk:Qk:(r=e.match(Kk))&&(i=Xk);let s=Po.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,r=t.noglobstar?cM:t.dot?uM:lM,i=new Set(t.nocase?["i"]:[]),s=e.map(u=>{let l=u.map(f=>{if(f instanceof RegExp)for(let h of f.flags.split(""))i.add(h);return typeof f=="string"?mM(f):f===Jt?Jt:f._src});return l.forEach((f,h)=>{let d=l[h+1],p=l[h-1];f!==Jt||p===Jt||(p===void 0?d!==void 0&&d!==Jt?l[h+1]="(?:\\/|"+r+"\\/)?"+d:l[h]=r:d===void 0?l[h-1]=p+"(?:\\/|"+r+")?":d!==Jt&&(l[h-1]=p+"(?:\\/|\\/"+r+"\\/)"+d,l[h+1]=Jt))}),l.filter(f=>f!==Jt).join("/")}).join("|"),[a,c]=e.length>1?["(?:",")"]:["",""];s="^"+a+s+c+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let r=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let a=i[i.length-1];if(!a)for(let c=i.length-2;!a&&c>=0;c--)a=i[c];for(let c=0;c<s.length;c++){let u=s[c],l=i;if(r.matchBase&&u.length===1&&(l=[a]),this.matchOne(l,u,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Zt.defaults(e).Minimatch}};Zt.AST=Po;Zt.Minimatch=Wr;Zt.escape=Do;Zt.unescape=Un;var jT=require("node:url");var Ro=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,gT=new Set,o1=typeof process=="object"&&process?process:{},yT=o((n,e,t,r)=>{typeof o1.emitWarning=="function"?o1.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)},"emitWarning"),Lh=globalThis.AbortController,mT=globalThis.AbortSignal;if(typeof Lh>"u"){mT=class{static{o(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},Lh=class{static{o(this,"AbortController")}constructor(){e()}signal=new mT;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let i of this.signal._onabort)i(r);this.signal.onabort?.(r)}}};let n=o1.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=o(()=>{n&&(n=!1,yT("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))},"warnACPolyfill")}var gM=o(n=>!gT.has(n),"shouldWarn");var ps=o(n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),"isPosInt"),vT=o(n=>ps(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Fo:null:null,"getUintArray"),Fo=class extends Array{static{o(this,"ZeroArray")}constructor(e){super(e),this.fill(0)}},c1=class n{static{o(this,"Stack")}heap;length;static#e=!1;static create(e){let t=vT(e);if(!t)return[];n.#e=!0;let r=new n(e,t);return n.#e=!1,r}constructor(e,t){if(!n.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},au=class n{static{o(this,"LRUCache")}#e;#t;#s;#n;#a;#_;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#u;#f;#o;#c;#i;#g;#y;#d;#h;#E;#m;#T;#A;#S;#b;#w;#p;static unsafeExposeInternals(e){return{starts:e.#A,ttls:e.#S,sizes:e.#T,keyMap:e.#o,keyList:e.#c,valList:e.#i,next:e.#g,prev:e.#y,get head(){return e.#d},get tail(){return e.#h},free:e.#E,isBackgroundFetch:o(t=>e.#l(t),"isBackgroundFetch"),backgroundFetch:o((t,r,i,s)=>e.#j(t,r,i,s),"backgroundFetch"),moveToTail:o(t=>e.#V(t),"moveToTail"),indexes:o(t=>e.#C(t),"indexes"),rindexes:o(t=>e.#I(t),"rindexes"),isStale:o(t=>e.#v(t),"isStale")}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#f}get size(){return this.#u}get fetchMethod(){return this.#a}get memoMethod(){return this.#_}get dispose(){return this.#s}get disposeAfter(){return this.#n}constructor(e){let{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:c,allowStale:u,dispose:l,disposeAfter:f,noDisposeOnSet:h,noUpdateTTL:d,maxSize:p=0,maxEntrySize:S=0,sizeCalculation:b,fetchMethod:T,memoMethod:I,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:G,ignoreFetchAbort:Ee}=e;if(t!==0&&!ps(t))throw new TypeError("max option must be a nonnegative integer");let je=t?vT(t):Array;if(!je)throw new Error("invalid max value: "+t);if(this.#e=t,this.#t=p,this.maxEntrySize=S||this.#t,this.sizeCalculation=b,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(I!==void 0&&typeof I!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#_=I,T!==void 0&&typeof T!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#a=T,this.#w=!!T,this.#o=new Map,this.#c=new Array(t).fill(void 0),this.#i=new Array(t).fill(void 0),this.#g=new je(t),this.#y=new je(t),this.#d=0,this.#h=0,this.#E=c1.create(t),this.#u=0,this.#f=0,typeof l=="function"&&(this.#s=l),typeof f=="function"?(this.#n=f,this.#m=[]):(this.#n=void 0,this.#m=void 0),this.#b=!!this.#s,this.#p=!!this.#n,this.noDisposeOnSet=!!h,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!G,this.ignoreFetchAbort=!!Ee,this.maxEntrySize!==0){if(this.#t!==0&&!ps(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!ps(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!c,this.ttlResolution=ps(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!ps(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let Me="LRU_CACHE_UNBOUNDED";gM(Me)&&(gT.add(Me),yT("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Me,n))}}getRemainingTTL(e){return this.#o.has(e)?1/0:0}#O(){let e=new Fo(this.#e),t=new Fo(this.#e);this.#S=e,this.#A=t,this.#R=(s,a,c=Ro.now())=>{if(t[s]=a!==0?c:0,e[s]=a,a!==0&&this.ttlAutopurge){let u=setTimeout(()=>{this.#v(s)&&this.#D(this.#c[s],"expire")},a+1);u.unref&&u.unref()}},this.#x=s=>{t[s]=e[s]!==0?Ro.now():0},this.#r=(s,a)=>{if(e[a]){let c=e[a],u=t[a];if(!c||!u)return;s.ttl=c,s.start=u,s.now=r||i();let l=s.now-u;s.remainingTTL=c-l}};let r=0,i=o(()=>{let s=Ro.now();if(this.ttlResolution>0){r=s;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return s},"getNow");this.getRemainingTTL=s=>{let a=this.#o.get(s);if(a===void 0)return 0;let c=e[a],u=t[a];if(!c||!u)return 1/0;let l=(r||i())-u;return c-l},this.#v=s=>{let a=t[s],c=e[s];return!!c&&!!a&&(r||i())-a>c}}#x=o(()=>{},"#updateItemAge");#r=o(()=>{},"#statusTTL");#R=o(()=>{},"#setItemTTL");#v=o(()=>!1,"#isStale");#P(){let e=new Fo(this.#e);this.#f=0,this.#T=e,this.#F=t=>{this.#f-=e[t],e[t]=0},this.#L=(t,r,i,s)=>{if(this.#l(r))return 0;if(!ps(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!ps(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#N=(t,r,i)=>{if(e[t]=r,this.#t){let s=this.#t-e[t];for(;this.#f>s;)this.#M(!0)}this.#f+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#f)}}#F=o(e=>{},"#removeItemSize");#N=o((e,t,r)=>{},"#addItemSize");#L=o((e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#C({allowStale:e=this.allowStale}={}){if(this.#u)for(let t=this.#h;!(!this.#k(t)||((e||!this.#v(t))&&(yield t),t===this.#d));)t=this.#y[t]}*#I({allowStale:e=this.allowStale}={}){if(this.#u)for(let t=this.#d;!(!this.#k(t)||((e||!this.#v(t))&&(yield t),t===this.#h));)t=this.#g[t]}#k(e){return e!==void 0&&this.#o.get(this.#c[e])===e}*entries(){for(let e of this.#C())this.#i[e]!==void 0&&this.#c[e]!==void 0&&!this.#l(this.#i[e])&&(yield[this.#c[e],this.#i[e]])}*rentries(){for(let e of this.#I())this.#i[e]!==void 0&&this.#c[e]!==void 0&&!this.#l(this.#i[e])&&(yield[this.#c[e],this.#i[e]])}*keys(){for(let e of this.#C()){let t=this.#c[e];t!==void 0&&!this.#l(this.#i[e])&&(yield t)}}*rkeys(){for(let e of this.#I()){let t=this.#c[e];t!==void 0&&!this.#l(this.#i[e])&&(yield t)}}*values(){for(let e of this.#C())this.#i[e]!==void 0&&!this.#l(this.#i[e])&&(yield this.#i[e])}*rvalues(){for(let e of this.#I())this.#i[e]!==void 0&&!this.#l(this.#i[e])&&(yield this.#i[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#C()){let i=this.#i[r],s=this.#l(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#c[r],this))return this.get(this.#c[r],t)}}forEach(e,t=this){for(let r of this.#C()){let i=this.#i[r],s=this.#l(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}rforEach(e,t=this){for(let r of this.#I()){let i=this.#i[r],s=this.#l(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}purgeStale(){let e=!1;for(let t of this.#I({allowStale:!0}))this.#v(t)&&(this.#D(this.#c[t],"expire"),e=!0);return e}info(e){let t=this.#o.get(e);if(t===void 0)return;let r=this.#i[t],i=this.#l(r)?r.__staleWhileFetching:r;if(i===void 0)return;let s={value:i};if(this.#S&&this.#A){let a=this.#S[t],c=this.#A[t];if(a&&c){let u=a-(Ro.now()-c);s.ttl=u,s.start=Date.now()}}return this.#T&&(s.size=this.#T[t]),s}dump(){let e=[];for(let t of this.#C({allowStale:!0})){let r=this.#c[t],i=this.#i[t],s=this.#l(i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;let a={value:s};if(this.#S&&this.#A){a.ttl=this.#S[t];let c=Ro.now()-this.#A[t];a.start=Math.floor(Date.now()-c)}this.#T&&(a.size=this.#T[t]),e.unshift([r,a])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=Ro.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:u}=r,{noUpdateTTL:l=this.noUpdateTTL}=r,f=this.#L(e,t,r.size||0,c);if(this.maxEntrySize&&f>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this.#D(e,"set"),this;let h=this.#u===0?void 0:this.#o.get(e);if(h===void 0)h=this.#u===0?this.#h:this.#E.length!==0?this.#E.pop():this.#u===this.#e?this.#M(!1):this.#u,this.#c[h]=e,this.#i[h]=t,this.#o.set(e,h),this.#g[this.#h]=h,this.#y[h]=this.#h,this.#h=h,this.#u++,this.#N(h,f,u),u&&(u.set="add"),l=!1;else{this.#V(h);let d=this.#i[h];if(t!==d){if(this.#w&&this.#l(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=d;p!==void 0&&!a&&(this.#b&&this.#s?.(p,e,"set"),this.#p&&this.#m?.push([p,e,"set"]))}else a||(this.#b&&this.#s?.(d,e,"set"),this.#p&&this.#m?.push([d,e,"set"]));if(this.#F(h),this.#N(h,f,u),this.#i[h]=t,u){u.set="replace";let p=d&&this.#l(d)?d.__staleWhileFetching:d;p!==void 0&&(u.oldValue=p)}}else u&&(u.set="update")}if(i!==0&&!this.#S&&this.#O(),this.#S&&(l||this.#R(h,i,s),u&&this.#r(u,h)),!a&&this.#p&&this.#m){let d=this.#m,p;for(;p=d?.shift();)this.#n?.(...p)}return this}pop(){try{for(;this.#u;){let e=this.#i[this.#d];if(this.#M(!0),this.#l(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#p&&this.#m){let e=this.#m,t;for(;t=e?.shift();)this.#n?.(...t)}}}#M(e){let t=this.#d,r=this.#c[t],i=this.#i[t];return this.#w&&this.#l(i)?i.__abortController.abort(new Error("evicted")):(this.#b||this.#p)&&(this.#b&&this.#s?.(i,r,"evict"),this.#p&&this.#m?.push([i,r,"evict"])),this.#F(t),e&&(this.#c[t]=void 0,this.#i[t]=void 0,this.#E.push(t)),this.#u===1?(this.#d=this.#h=0,this.#E.length=0):this.#d=this.#g[t],this.#o.delete(r),this.#u--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,s=this.#o.get(e);if(s!==void 0){let a=this.#i[s];if(this.#l(a)&&a.__staleWhileFetching===void 0)return!1;if(this.#v(s))i&&(i.has="stale",this.#r(i,s));else return r&&this.#x(s),i&&(i.has="hit",this.#r(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,i=this.#o.get(e);if(i===void 0||!r&&this.#v(i))return;let s=this.#i[i];return this.#l(s)?s.__staleWhileFetching:s}#j(e,t,r,i){let s=t===void 0?void 0:this.#i[t];if(this.#l(s))return s;let a=new Lh,{signal:c}=r;c?.addEventListener("abort",()=>a.abort(c.reason),{signal:a.signal});let u={signal:a.signal,options:r,context:i},l=o((b,T=!1)=>{let{aborted:I}=a.signal,O=r.ignoreFetchAbort&&b!==void 0;if(r.status&&(I&&!T?(r.status.fetchAborted=!0,r.status.fetchError=a.signal.reason,O&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),I&&!O&&!T)return h(a.signal.reason);let L=p;return this.#i[t]===p&&(b===void 0?L.__staleWhileFetching?this.#i[t]=L.__staleWhileFetching:this.#D(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,b,u.options))),b},"cb"),f=o(b=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=b),h(b)),"eb"),h=o(b=>{let{aborted:T}=a.signal,I=T&&r.allowStaleOnFetchAbort,O=I||r.allowStaleOnFetchRejection,L=O||r.noDeleteOnFetchRejection,M=p;if(this.#i[t]===p&&(!L||M.__staleWhileFetching===void 0?this.#D(e,"fetch"):I||(this.#i[t]=M.__staleWhileFetching)),O)return r.status&&M.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),M.__staleWhileFetching;if(M.__returned===M)throw b},"fetchFail"),d=o((b,T)=>{let I=this.#a?.(e,s,u);I&&I instanceof Promise&&I.then(O=>b(O===void 0?void 0:O),T),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(b(void 0),r.allowStaleOnFetchAbort&&(b=o(O=>l(O,!0),"res")))})},"pcall");r.status&&(r.status.fetchDispatched=!0);let p=new Promise(d).then(l,f),S=Object.assign(p,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,S,{...u.options,status:void 0}),t=this.#o.get(e)):this.#i[t]=S,S}#l(e){if(!this.#w)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Lh}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:u=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:S=this.allowStaleOnFetchAbort,context:b,forceRefresh:T=!1,status:I,signal:O}=t;if(!this.#w)return I&&(I.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:I});let L={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:c,size:u,sizeCalculation:l,noUpdateTTL:f,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:S,ignoreFetchAbort:p,status:I,signal:O},M=this.#o.get(e);if(M===void 0){I&&(I.fetch="miss");let G=this.#j(e,M,L,b);return G.__returned=G}else{let G=this.#i[M];if(this.#l(G)){let ie=r&&G.__staleWhileFetching!==void 0;return I&&(I.fetch="inflight",ie&&(I.returnedStale=!0)),ie?G.__staleWhileFetching:G.__returned=G}let Ee=this.#v(M);if(!T&&!Ee)return I&&(I.fetch="hit"),this.#V(M),i&&this.#x(M),I&&this.#r(I,M),G;let je=this.#j(e,M,L,b),q=je.__staleWhileFetching!==void 0&&r;return I&&(I.fetch=Ee?"stale":"refresh",q&&Ee&&(I.returnedStale=!0)),q?je.__staleWhileFetching:je.__returned=je}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#_;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...a}=t,c=this.get(e,a);if(!s&&c!==void 0)return c;let u=r(e,c,{options:a,context:i});return this.set(e,u,a),u}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,c=this.#o.get(e);if(c!==void 0){let u=this.#i[c],l=this.#l(u);return a&&this.#r(a,c),this.#v(c)?(a&&(a.get="stale"),l?(a&&r&&u.__staleWhileFetching!==void 0&&(a.returnedStale=!0),r?u.__staleWhileFetching:void 0):(s||this.#D(e,"expire"),a&&r&&(a.returnedStale=!0),r?u:void 0)):(a&&(a.get="hit"),l?u.__staleWhileFetching:(this.#V(c),i&&this.#x(c),u))}else a&&(a.get="miss")}#$(e,t){this.#y[t]=e,this.#g[e]=t}#V(e){e!==this.#h&&(e===this.#d?this.#d=this.#g[e]:this.#$(this.#y[e],this.#g[e]),this.#$(this.#h,e),this.#h=e)}delete(e){return this.#D(e,"delete")}#D(e,t){let r=!1;if(this.#u!==0){let i=this.#o.get(e);if(i!==void 0)if(r=!0,this.#u===1)this.#U(t);else{this.#F(i);let s=this.#i[i];if(this.#l(s)?s.__abortController.abort(new Error("deleted")):(this.#b||this.#p)&&(this.#b&&this.#s?.(s,e,t),this.#p&&this.#m?.push([s,e,t])),this.#o.delete(e),this.#c[i]=void 0,this.#i[i]=void 0,i===this.#h)this.#h=this.#y[i];else if(i===this.#d)this.#d=this.#g[i];else{let a=this.#y[i];this.#g[a]=this.#g[i];let c=this.#g[i];this.#y[c]=this.#y[i]}this.#u--,this.#E.push(i)}}if(this.#p&&this.#m?.length){let i=this.#m,s;for(;s=i?.shift();)this.#n?.(...s)}return r}clear(){return this.#U("delete")}#U(e){for(let t of this.#I({allowStale:!0})){let r=this.#i[t];if(this.#l(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#c[t];this.#b&&this.#s?.(r,i,e),this.#p&&this.#m?.push([r,i,e])}}if(this.#o.clear(),this.#i.fill(void 0),this.#c.fill(void 0),this.#S&&this.#A&&(this.#S.fill(0),this.#A.fill(0)),this.#T&&this.#T.fill(0),this.#d=0,this.#h=0,this.#E.length=0,this.#f=0,this.#u=0,this.#p&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#n?.(...r)}}};var ko=require("node:path"),IT=require("node:url"),mi=require("fs"),xM=Ne(require("node:fs"),1),ys=require("node:fs/promises");var Bh=require("node:events"),m1=Ne(require("node:stream"),1),ET=require("node:string_decoder");var ST=typeof process=="object"&&process?process:{stdout:null,stderr:null},yM=o(n=>!!n&&typeof n=="object"&&(n instanceof gs||n instanceof m1.default||vM(n)||SM(n)),"isStream"),vM=o(n=>!!n&&typeof n=="object"&&n instanceof Bh.EventEmitter&&typeof n.pipe=="function"&&n.pipe!==m1.default.Writable.prototype.pipe,"isReadable"),SM=o(n=>!!n&&typeof n=="object"&&n instanceof Bh.EventEmitter&&typeof n.write=="function"&&typeof n.end=="function","isWritable"),$i=Symbol("EOF"),Vi=Symbol("maybeEmitEnd"),ms=Symbol("emittedEnd"),kh=Symbol("emittingEnd"),ou=Symbol("emittedError"),Mh=Symbol("closed"),_T=Symbol("read"),jh=Symbol("flush"),bT=Symbol("flushChunk"),Bn=Symbol("encoding"),No=Symbol("decoder"),jt=Symbol("flowing"),cu=Symbol("paused"),Lo=Symbol("resume"),$t=Symbol("buffer"),Ir=Symbol("pipes"),Vt=Symbol("bufferLength"),u1=Symbol("bufferPush"),$h=Symbol("bufferShift"),lr=Symbol("objectMode"),wt=Symbol("destroyed"),l1=Symbol("error"),f1=Symbol("emitData"),wT=Symbol("emitEnd"),h1=Symbol("emitEnd2"),di=Symbol("async"),d1=Symbol("abort"),Vh=Symbol("aborted"),uu=Symbol("signal"),ha=Symbol("dataListeners"),Hr=Symbol("discarded"),lu=o(n=>Promise.resolve().then(n),"defer"),_M=o(n=>n(),"nodefer"),bM=o(n=>n==="end"||n==="finish"||n==="prefinish","isEndish"),wM=o(n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,"isArrayBufferLike"),EM=o(n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),"isArrayBufferView"),Uh=class{static{o(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[Lo](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},p1=class extends Uh{static{o(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,r){super(e,t,r),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},TM=o(n=>!!n.objectMode,"isObjectModeOptions"),AM=o(n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer","isEncodingOptions"),gs=class extends Bh.EventEmitter{static{o(this,"Minipass")}[jt]=!1;[cu]=!1;[Ir]=[];[$t]=[];[lr];[Bn];[di];[No];[$i]=!1;[ms]=!1;[kh]=!1;[Mh]=!1;[ou]=null;[Vt]=0;[wt]=!1;[uu];[Vh]=!1;[ha]=0;[Hr]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");TM(t)?(this[lr]=!0,this[Bn]=null):AM(t)?(this[Bn]=t.encoding,this[lr]=!1):(this[lr]=!1,this[Bn]=null),this[di]=!!t.async,this[No]=this[Bn]?new ET.StringDecoder(this[Bn]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:o(()=>this[$t],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:o(()=>this[Ir],"get")});let{signal:r}=t;r&&(this[uu]=r,r.aborted?this[d1]():r.addEventListener("abort",()=>this[d1]()))}get bufferLength(){return this[Vt]}get encoding(){return this[Bn]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[lr]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[di]}set async(e){this[di]=this[di]||!!e}[d1](){this[Vh]=!0,this.emit("abort",this[uu]?.reason),this.destroy(this[uu]?.reason)}get aborted(){return this[Vh]}set aborted(e){}write(e,t,r){if(this[Vh])return!1;if(this[$i])throw new Error("write after end");if(this[wt])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(r=t,t="utf8"),t||(t="utf8");let i=this[di]?lu:_M;if(!this[lr]&&!Buffer.isBuffer(e)){if(EM(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(wM(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[lr]?(this[jt]&&this[Vt]!==0&&this[jh](!0),this[jt]?this.emit("data",e):this[u1](e),this[Vt]!==0&&this.emit("readable"),r&&i(r),this[jt]):e.length?(typeof e=="string"&&!(t===this[Bn]&&!this[No]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Bn]&&(e=this[No].write(e)),this[jt]&&this[Vt]!==0&&this[jh](!0),this[jt]?this.emit("data",e):this[u1](e),this[Vt]!==0&&this.emit("readable"),r&&i(r),this[jt]):(this[Vt]!==0&&this.emit("readable"),r&&i(r),this[jt])}read(e){if(this[wt])return null;if(this[Hr]=!1,this[Vt]===0||e===0||e&&e>this[Vt])return this[Vi](),null;this[lr]&&(e=null),this[$t].length>1&&!this[lr]&&(this[$t]=[this[Bn]?this[$t].join(""):Buffer.concat(this[$t],this[Vt])]);let t=this[_T](e||null,this[$t][0]);return this[Vi](),t}[_T](e,t){if(this[lr])this[$h]();else{let r=t;e===r.length||e===null?this[$h]():typeof r=="string"?(this[$t][0]=r.slice(e),t=r.slice(0,e),this[Vt]-=e):(this[$t][0]=r.subarray(e),t=r.subarray(0,e),this[Vt]-=e)}return this.emit("data",t),!this[$t].length&&!this[$i]&&this.emit("drain"),t}end(e,t,r){return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t="utf8"),e!==void 0&&this.write(e,t),r&&this.once("end",r),this[$i]=!0,this.writable=!1,(this[jt]||!this[cu])&&this[Vi](),this}[Lo](){this[wt]||(!this[ha]&&!this[Ir].length&&(this[Hr]=!0),this[cu]=!1,this[jt]=!0,this.emit("resume"),this[$t].length?this[jh]():this[$i]?this[Vi]():this.emit("drain"))}resume(){return this[Lo]()}pause(){this[jt]=!1,this[cu]=!0,this[Hr]=!1}get destroyed(){return this[wt]}get flowing(){return this[jt]}get paused(){return this[cu]}[u1](e){this[lr]?this[Vt]+=1:this[Vt]+=e.length,this[$t].push(e)}[$h](){return this[lr]?this[Vt]-=1:this[Vt]-=this[$t][0].length,this[$t].shift()}[jh](e=!1){do;while(this[bT](this[$h]())&&this[$t].length);!e&&!this[$t].length&&!this[$i]&&this.emit("drain")}[bT](e){return this.emit("data",e),this[jt]}pipe(e,t){if(this[wt])return e;this[Hr]=!1;let r=this[ms];return t=t||{},e===ST.stdout||e===ST.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[Ir].push(t.proxyErrors?new p1(this,e,t):new Uh(this,e,t)),this[di]?lu(()=>this[Lo]()):this[Lo]()),e}unpipe(e){let t=this[Ir].find(r=>r.dest===e);t&&(this[Ir].length===1?(this[jt]&&this[ha]===0&&(this[jt]=!1),this[Ir]=[]):this[Ir].splice(this[Ir].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let r=super.on(e,t);if(e==="data")this[Hr]=!1,this[ha]++,!this[Ir].length&&!this[jt]&&this[Lo]();else if(e==="readable"&&this[Vt]!==0)super.emit("readable");else if(bM(e)&&this[ms])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ou]){let i=t;this[di]?lu(()=>i.call(this,this[ou])):i.call(this,this[ou])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[ha]=this.listeners("data").length,this[ha]===0&&!this[Hr]&&!this[Ir].length&&(this[jt]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[ha]=0,!this[Hr]&&!this[Ir].length&&(this[jt]=!1)),t}get emittedEnd(){return this[ms]}[Vi](){!this[kh]&&!this[ms]&&!this[wt]&&this[$t].length===0&&this[$i]&&(this[kh]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Mh]&&this.emit("close"),this[kh]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==wt&&this[wt])return!1;if(e==="data")return!this[lr]&&!r?!1:this[di]?(lu(()=>this[f1](r)),!0):this[f1](r);if(e==="end")return this[wT]();if(e==="close"){if(this[Mh]=!0,!this[ms]&&!this[wt])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[ou]=r,super.emit(l1,r);let s=!this[uu]||this.listeners("error").length?super.emit("error",r):!1;return this[Vi](),s}else if(e==="resume"){let s=super.emit("resume");return this[Vi](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let i=super.emit(e,...t);return this[Vi](),i}[f1](e){for(let r of this[Ir])r.dest.write(e)===!1&&this.pause();let t=this[Hr]?!1:super.emit("data",e);return this[Vi](),t}[wT](){return this[ms]?!1:(this[ms]=!0,this.readable=!1,this[di]?(lu(()=>this[h1]()),!0):this[h1]())}[h1](){if(this[No]){let t=this[No].end();if(t){for(let r of this[Ir])r.dest.write(t);this[Hr]||super.emit("data",t)}}for(let t of this[Ir])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[lr]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[lr]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[lr])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Bn]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(wt,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Hr]=!1;let e=!1,t=o(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:o(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[$i])return t();let s,a,c=o(h=>{this.off("data",u),this.off("end",l),this.off(wt,f),t(),a(h)},"onerr"),u=o(h=>{this.off("error",c),this.off("end",l),this.off(wt,f),this.pause(),s({value:h,done:!!this[$i]})},"ondata"),l=o(()=>{this.off("error",c),this.off("data",u),this.off(wt,f),t(),s({done:!0,value:void 0})},"onend"),f=o(()=>c(new Error("stream destroyed")),"ondestroy");return new Promise((h,d)=>{a=d,s=h,this.once(wt,f),this.once("error",c),this.once("end",l),this.once("data",u)})},"next"),throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Hr]=!1;let e=!1,t=o(()=>(this.pause(),this.off(l1,t),this.off(wt,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),r=o(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(l1,t),this.once(wt,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[wt])return e?this.emit("error",e):this.emit(wt),this;this[wt]=!0,this[Hr]=!0,this[$t].length=0,this[Vt]=0;let t=this;return typeof t.close=="function"&&!this[Mh]&&t.close(),e?this.emit("error",e):this.emit(wt),this}static get isStream(){return yM}};var CM=mi.realpathSync.native,hu={lstatSync:mi.lstatSync,readdir:mi.readdir,readdirSync:mi.readdirSync,readlinkSync:mi.readlinkSync,realpathSync:CM,promises:{lstat:ys.lstat,readdir:ys.readdir,readlink:ys.readlink,realpath:ys.realpath}},OT=o(n=>!n||n===hu||n===xM?hu:{...hu,...n,promises:{...hu.promises,...n.promises||{}}},"fsFromOption"),PT=/^\\\\\?\\([a-z]:)\\?$/i,IM=o(n=>n.replace(/\//g,"\\").replace(PT,"$1\\"),"uncToDrive"),OM=/[\\\/]/,hn=0,DT=1,RT=2,pi=4,FT=6,NT=8,da=10,LT=12,fn=15,fu=~fn,g1=16,TT=32,du=64,qn=128,qh=256,Wh=512,AT=du|qn|Wh,PM=1023,y1=o(n=>n.isFile()?NT:n.isDirectory()?pi:n.isSymbolicLink()?da:n.isCharacterDevice()?RT:n.isBlockDevice()?FT:n.isSocket()?LT:n.isFIFO()?DT:hn,"entToType"),xT=new Map,pu=o(n=>{let e=xT.get(n);if(e)return e;let t=n.normalize("NFKD");return xT.set(n,t),t},"normalize"),CT=new Map,Gh=o(n=>{let e=CT.get(n);if(e)return e;let t=pu(n.toLowerCase());return CT.set(n,t),t},"normalizeNocase"),Hh=class extends au{static{o(this,"ResolveCache")}constructor(){super({max:256})}},v1=class extends au{static{o(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:o(t=>t.length+1,"sizeCalculation")})}},kT=Symbol("PathScurry setAsCwd"),fr=class{static{o(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#s;get mode(){return this.#s}#n;get nlink(){return this.#n}#a;get uid(){return this.#a}#_;get gid(){return this.#_}#u;get rdev(){return this.#u}#f;get blksize(){return this.#f}#o;get ino(){return this.#o}#c;get size(){return this.#c}#i;get blocks(){return this.#i}#g;get atimeMs(){return this.#g}#y;get mtimeMs(){return this.#y}#d;get ctimeMs(){return this.#d}#h;get birthtimeMs(){return this.#h}#E;get atime(){return this.#E}#m;get mtime(){return this.#m}#T;get ctime(){return this.#T}#A;get birthtime(){return this.#A}#S;#b;#w;#p;#O;#x;#r;#R;#v;#P;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=hn,r,i,s,a,c){this.name=e,this.#S=s?Gh(e):pu(e),this.#r=t&PM,this.nocase=s,this.roots=i,this.root=r||this,this.#R=a,this.#w=c.fullpath,this.#O=c.relative,this.#x=c.relativePosix,this.parent=c.parent,this.parent?this.#e=this.parent.#e:this.#e=OT(c.fs)}depth(){return this.#b!==void 0?this.#b:this.parent?this.#b=this.parent.depth()+1:this.#b=0}childrenCache(){return this.#R}resolve(e){if(!e)return this;let t=this.getRootString(e),i=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#F(i):this.#F(i)}#F(e){let t=this;for(let r of e)t=t.child(r);return t}children(){let e=this.#R.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#R.set(this,t),this.#r&=~g1,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?Gh(e):pu(e);for(let u of r)if(u.#S===i)return u;let s=this.parent?this.sep:"",a=this.#w?this.#w+s+e:void 0,c=this.newChild(e,hn,{...t,parent:this,fullpath:a});return this.canReaddir()||(c.#r|=qn),r.push(c),c}relative(){if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let e=this.name,t=this.parent;if(!t)return this.#O=this.name;let r=t.relative();return r+(!r||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.fullpathPosix();let r=t.relativePosix();return r+(!r||!t.parent?"":"/")+e}fullpath(){if(this.#w!==void 0)return this.#w;let e=this.name,t=this.parent;if(!t)return this.#w=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#w=i}fullpathPosix(){if(this.#p!==void 0)return this.#p;if(this.sep==="/")return this.#p=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#p=`//?/${i}`:this.#p=i}let e=this.parent,t=e.fullpathPosix(),r=t+(!t||!e.parent?"":"/")+this.name;return this.#p=r}isUnknown(){return(this.#r&fn)===hn}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#r&fn)===NT}isDirectory(){return(this.#r&fn)===pi}isCharacterDevice(){return(this.#r&fn)===RT}isBlockDevice(){return(this.#r&fn)===FT}isFIFO(){return(this.#r&fn)===DT}isSocket(){return(this.#r&fn)===LT}isSymbolicLink(){return(this.#r&da)===da}lstatCached(){return this.#r&TT?this:void 0}readlinkCached(){return this.#v}realpathCached(){return this.#P}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#v)return!0;if(!this.parent)return!1;let e=this.#r&fn;return!(e!==hn&&e!==da||this.#r&qh||this.#r&qn)}calledReaddir(){return!!(this.#r&g1)}isENOENT(){return!!(this.#r&qn)}isNamed(e){return this.nocase?this.#S===Gh(e):this.#S===pu(e)}async readlink(){let e=this.#v;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),r=(await this.parent.realpath())?.resolve(t);if(r)return this.#v=r}catch(t){this.#l(t.code);return}}readlinkSync(){let e=this.#v;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),r=this.parent.realpathSync()?.resolve(t);if(r)return this.#v=r}catch(t){this.#l(t.code);return}}#N(e){this.#r|=g1;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#L()}}#L(){this.#r&qn||(this.#r=(this.#r|qn)&fu,this.#C())}#C(){let e=this.children();e.provisional=0;for(let t of e)t.#L()}#I(){this.#r|=Wh,this.#k()}#k(){if(this.#r&du)return;let e=this.#r;(e&fn)===pi&&(e&=fu),this.#r=e|du,this.#C()}#M(e=""){e==="ENOTDIR"||e==="EPERM"?this.#k():e==="ENOENT"?this.#L():this.children().provisional=0}#j(e=""){e==="ENOTDIR"?this.parent.#k():e==="ENOENT"&&this.#L()}#l(e=""){let t=this.#r;t|=qh,e==="ENOENT"&&(t|=qn),(e==="EINVAL"||e==="UNKNOWN")&&(t&=fu),this.#r=t,e==="ENOTDIR"&&this.parent&&this.parent.#k()}#$(e,t){return this.#D(e,t)||this.#V(e,t)}#V(e,t){let r=y1(e),i=this.newChild(e.name,r,{parent:this}),s=i.#r&fn;return s!==pi&&s!==da&&s!==hn&&(i.#r|=du),t.unshift(i),t.provisional++,i}#D(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?Gh(e.name):pu(e.name))===i.#S)return this.#U(e,i,r,t)}}#U(e,t,r,i){let s=t.name;return t.#r=t.#r&fu|y1(e),s!==e.name&&(t.name=e.name),r!==i.provisional&&(r===i.length-1?i.pop():i.splice(r,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#r&qn)===0)try{return this.#W(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#j(e.code)}}lstatSync(){if((this.#r&qn)===0)try{return this.#W(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#j(e.code)}}#W(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:s,blksize:a,blocks:c,ctime:u,ctimeMs:l,dev:f,gid:h,ino:d,mode:p,mtime:S,mtimeMs:b,nlink:T,rdev:I,size:O,uid:L}=e;this.#E=t,this.#g=r,this.#A=i,this.#h=s,this.#f=a,this.#i=c,this.#T=u,this.#d=l,this.#t=f,this.#_=h,this.#o=d,this.#s=p,this.#m=S,this.#y=b,this.#n=T,this.#u=I,this.#c=O,this.#a=L;let M=y1(e);this.#r=this.#r&fu|M|TT,M!==hn&&M!==pi&&M!==da&&(this.#r|=du)}#q=[];#G=!1;#H(e){this.#G=!1;let t=this.#q.slice();this.#q.length=0,t.forEach(r=>r(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let r=this.children();if(this.calledReaddir()){let s=r.slice(0,r.provisional);t?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#q.push(e),this.#G)return;this.#G=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,a)=>{if(s)this.#M(s.code),r.provisional=0;else{for(let c of a)this.#$(c,r);this.#N(r)}this.#H(r.slice(0,r.provisional))})}#B;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#B)await this.#B;else{let r=o(()=>{},"resolve");this.#B=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#$(i,e);this.#N(e)}catch(i){this.#M(i.code),e.provisional=0}this.#B=void 0,r()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let r of this.#e.readdirSync(t,{withFileTypes:!0}))this.#$(r,e);this.#N(e)}catch(r){this.#M(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#r&AT)return!1;let e=fn&this.#r;return e===hn||e===pi||e===da}shouldWalk(e,t){return(this.#r&pi)===pi&&!(this.#r&AT)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#P)return this.#P;if(!((Wh|qh|qn)&this.#r))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#P=this.resolve(e)}catch{this.#I()}}realpathSync(){if(this.#P)return this.#P;if(!((Wh|qh|qn)&this.#r))try{let e=this.#e.realpathSync(this.fullpath());return this.#P=this.resolve(e)}catch{this.#I()}}[kT](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),r=[],i=this;for(;i&&i.parent;)t.add(i),i.#O=r.join(this.sep),i.#x=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#O=void 0,i.#x=void 0,i=i.parent}},zh=class n extends fr{static{o(this,"PathWin32")}sep="\\";splitSep=OM;constructor(e,t=hn,r,i,s,a,c){super(e,t,r,i,s,a,c)}newChild(e,t=hn,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return ko.win32.parse(e).root}getRoot(e){if(e=IM(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,r]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=r;return this.roots[e]=new Mo(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(PT,"$1\\"),e===t}},Qh=class n extends fr{static{o(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=hn,r,i,s,a,c){super(e,t,r,i,s,a,c)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=hn,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Yh=class{static{o(this,"PathScurryBase")}root;rootPath;roots;cwd;#e;#t;#s;nocase;#n;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:s=16*1024,fs:a=hu}={}){this.#n=OT(a),(e instanceof URL||e.startsWith("file://"))&&(e=(0,IT.fileURLToPath)(e));let c=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(c),this.#e=new Hh,this.#t=new Hh,this.#s=new v1(s);let u=c.substring(this.rootPath.length).split(r);if(u.length===1&&!u[0]&&u.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#n),this.roots[this.rootPath]=this.root;let l=this.root,f=u.length-1,h=t.sep,d=this.rootPath,p=!1;for(let S of u){let b=f--;l=l.child(S,{relative:new Array(b).fill("..").join(h),relativePosix:new Array(b).fill("..").join("/"),fullpath:d+=(p?"":h)+S}),p=!0}this.cwd=l}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#s}resolve(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#e.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpath();return this.#e.set(t,i),i}resolvePosix(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#t.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpathPosix();return this.#t.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r}=t;if(e.canReaddir()){let i=await e.readdir();return r?i:i.map(s=>s.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0}=t;return e.canReaddir()?r?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=await e.readlink();return t?r:r?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=e.readlinkSync();return t?r:r?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=await e.realpath();return t?r:r?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e.withFileTypes,e=this.cwd);let r=e.realpathSync();return t?r:r?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?e:e.fullpath());let u=new Set,l=o((h,d)=>{u.add(h),h.readdirCB((p,S)=>{if(p)return d(p);let b=S.length;if(!b)return d();let T=o(()=>{--b===0&&d()},"next");for(let I of S)(!s||s(I))&&c.push(r?I:I.fullpath()),i&&I.isSymbolicLink()?I.realpath().then(O=>O?.isUnknown()?O.lstat():O).then(O=>O?.shouldWalk(u,a)?l(O,T):T()):I.shouldWalk(u,a)?l(I,T):T()},!0)},"walk"),f=e;return new Promise((h,d)=>{l(f,p=>{if(p)return d(p);h(c)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?e:e.fullpath());let u=new Set([e]);for(let l of u){let f=l.readdirSync();for(let h of f){(!s||s(h))&&c.push(r?h:h.fullpath());let d=h;if(h.isSymbolicLink()){if(!(i&&(d=h.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(u,a)&&u.add(d)}}return c}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t;(!s||s(e))&&(yield r?e:e.fullpath());let c=new Set([e]);for(let u of c){let l=u.readdirSync();for(let f of l){(!s||s(f))&&(yield r?f:f.fullpath());let h=f;if(f.isSymbolicLink()){if(!(i&&(h=f.realpathSync())))continue;h.isUnknown()&&h.lstatSync()}h.shouldWalk(c,a)&&c.add(h)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new gs({objectMode:!0});(!s||s(e))&&c.write(r?e:e.fullpath());let u=new Set,l=[e],f=0,h=o(()=>{let d=!1;for(;!d;){let p=l.shift();if(!p){f===0&&c.end();return}f++,u.add(p);let S=o((T,I,O=!1)=>{if(T)return c.emit("error",T);if(i&&!O){let L=[];for(let M of I)M.isSymbolicLink()&&L.push(M.realpath().then(G=>G?.isUnknown()?G.lstat():G));if(L.length){Promise.all(L).then(()=>S(null,I,!0));return}}for(let L of I)L&&(!s||s(L))&&(c.write(r?L:L.fullpath())||(d=!0));f--;for(let L of I){let M=L.realpathCached()||L;M.shouldWalk(u,a)&&l.push(M)}d&&!c.flowing?c.once("drain",h):b||h()},"onReaddir"),b=!0;p.readdirCB(S,!0),b=!1}},"process");return h(),c}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new gs({objectMode:!0}),u=new Set;(!s||s(e))&&c.write(r?e:e.fullpath());let l=[e],f=0,h=o(()=>{let d=!1;for(;!d;){let p=l.shift();if(!p){f===0&&c.end();return}f++,u.add(p);let S=p.readdirSync();for(let b of S)(!s||s(b))&&(c.write(r?b:b.fullpath())||(d=!0));f--;for(let b of S){let T=b;if(b.isSymbolicLink()){if(!(i&&(T=b.realpathSync())))continue;T.isUnknown()&&T.lstatSync()}T.shouldWalk(u,a)&&l.push(T)}}d&&!c.flowing&&c.once("drain",h)},"process");return h(),c}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[kT](t)}},Mo=class extends Yh{static{o(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,ko.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return ko.win32.parse(e).root.toUpperCase()}newRoot(e){return new zh(this.rootPath,pi,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},jo=class extends Yh{static{o(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,ko.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new Qh(this.rootPath,pi,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},mu=class extends jo{static{o(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},oY=process.platform==="win32"?zh:Qh,MT=process.platform==="win32"?Mo:process.platform==="darwin"?mu:jo;var DM=o(n=>n.length>=1,"isPatternList"),RM=o(n=>n.length>=1,"isGlobList"),$o=class n{static{o(this,"Pattern")}#e;#t;#s;length;#n;#a;#_;#u;#f;#o;#c=!0;constructor(e,t,r,i){if(!DM(e))throw new TypeError("empty pattern list");if(!RM(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#t=t,this.#s=r,this.#n=i,this.#s===0){if(this.isUNC()){let[s,a,c,u,...l]=this.#e,[f,h,d,p,...S]=this.#t;l[0]===""&&(l.shift(),S.shift());let b=[s,a,c,u,""].join("/"),T=[f,h,d,p,""].join("/");this.#e=[b,...l],this.#t=[T,...S],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...a]=this.#e,[c,...u]=this.#t;a[0]===""&&(a.shift(),u.shift());let l=s+"/",f=c+"/";this.#e=[l,...a],this.#t=[f,...u],this.length=this.#e.length}}}pattern(){return this.#e[this.#s]}isString(){return typeof this.#e[this.#s]=="string"}isGlobstar(){return this.#e[this.#s]===Jt}isRegExp(){return this.#e[this.#s]instanceof RegExp}globString(){return this.#_=this.#_||(this.#s===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#s).join("/"))}hasMore(){return this.length>this.#s+1}rest(){return this.#a!==void 0?this.#a:this.hasMore()?(this.#a=new n(this.#e,this.#t,this.#s+1,this.#n),this.#a.#o=this.#o,this.#a.#f=this.#f,this.#a.#u=this.#u,this.#a):this.#a=null}isUNC(){let e=this.#e;return this.#f!==void 0?this.#f:this.#f=this.#n==="win32"&&this.#s===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#u!==void 0?this.#u:this.#u=this.#n==="win32"&&this.#s===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#o!==void 0?this.#o:this.#o=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#s===0?e:""}checkFollowGlobstar(){return!(this.#s===0||!this.isGlobstar()||!this.#c)}markFollowGlobstar(){return this.#s===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var FM=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Vo=class{static{o(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:s,platform:a=FM}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:s,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let c of e)this.add(c)}add(e){let t=new Wr(e,this.mmopts);for(let r=0;r<t.set.length;r++){let i=t.set[r],s=t.globParts[r];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let a=new $o(i,s,0,this.platform),c=new Wr(a.globString(),this.mmopts),u=s[s.length-1]==="**",l=a.isAbsolute();l?this.absolute.push(c):this.relative.push(c),u&&(l?this.absoluteChildren.push(c):this.relativeChildren.push(c))}}ignored(e){let t=e.fullpath(),r=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let a of this.relative)if(a.match(i)||a.match(s))return!0;for(let a of this.absolute)if(a.match(t)||a.match(r))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",r=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(r))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}};var S1=class n{static{o(this,"HasWalkedCache")}store;constructor(e=new Map){this.store=e}copy(){return new n(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let r=e.fullpath(),i=this.store.get(r);i?i.add(t.globString()):this.store.set(r,new Set([t.globString()]))}},_1=class{static{o(this,"MatchRecord")}store=new Map;add(e,t,r){let i=(t?2:0)|(r?1:0),s=this.store.get(e);this.store.set(e,s===void 0?i:i&s)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},b1=class{static{o(this,"SubWalks")}store=new Map;add(e,t){if(!e.canReaddir())return;let r=this.store.get(e);r?r.find(i=>i.globString()===t.globString())||r.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},gu=class n{static{o(this,"Processor")}hasWalkedCache;matches=new _1;subwalks=new b1;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new S1}processPatterns(e,t){this.patterns=t;let r=t.map(i=>[e,i]);for(let[i,s]of r){this.hasWalkedCache.storeWalked(i,s);let a=s.root(),c=s.isAbsolute()&&this.opts.absolute!==!1;if(a){i=i.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let h=s.rest();if(h)s=h;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let u,l,f=!1;for(;typeof(u=s.pattern())=="string"&&(l=s.rest());)i=i.resolve(u),s=l,f=!0;if(u=s.pattern(),l=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof u=="string"){let h=u===".."||u===""||u===".";this.matches.add(i.resolve(u),c,h);continue}else if(u===Jt){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let h=l?.pattern(),d=l?.rest();if(!l||(h===""||h===".")&&!d)this.matches.add(i,c,h===""||h===".");else if(h===".."){let p=i.parent||i;d?this.hasWalkedCache.hasWalked(p,d)||this.subwalks.add(p,d):this.matches.add(p,c,!0)}}else u instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new n(this.opts,this.hasWalkedCache)}filterEntries(e,t){let r=this.subwalks.get(e),i=this.child();for(let s of t)for(let a of r){let c=a.isAbsolute(),u=a.pattern(),l=a.rest();u===Jt?i.testGlobstar(s,a,l,c):u instanceof RegExp?i.testRegExp(s,u,l,c):i.testString(s,u,l,c)}return i}testGlobstar(e,t,r,i){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(r&&t.checkFollowGlobstar()?this.subwalks.add(e,r):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),r){let s=r.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,r.rest(),i);else if(s===".."){let a=e.parent||e;this.subwalks.add(a,r)}else s instanceof RegExp&&this.testRegExp(e,s,r.rest(),i)}}testRegExp(e,t,r,i){t.test(e.name)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}testString(e,t,r,i){e.isNamed(t)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}};var NM=o((n,e)=>typeof n=="string"?new Vo([n],e):Array.isArray(n)?new Vo(n,e):n,"makeIgnore"),Kh=class{static{o(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#s;signal;maxDepth;includeChildMatches;constructor(e,t,r){if(this.patterns=e,this.path=t,this.opts=r,this.#s=!r.posix&&r.platform==="win32"?"\\":"/",this.includeChildMatches=r.includeChildMatches!==!1,(r.ignore||!this.includeChildMatches)&&(this.#t=NM(r.ignore??[],r),!this.includeChildMatches&&typeof this.#t.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=r.maxDepth||1/0,r.signal&&(this.signal=r.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#n(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#a(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||await e.realpath(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=await s.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.lstat()}return this.matchCheckTest(s,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#n(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||e.realpathSync(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=s.realpathSync();a&&(a?.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(s,t)}matchFinish(e,t){if(this.#n(e))return;if(!this.includeChildMatches&&this.#t?.add){let s=`${e.relativePosix()}/**`;this.#t.add(s)}let r=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#s:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(r){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),a=this.opts.dotRelative&&!s.startsWith(".."+this.#s)?"."+this.#s:"";this.matchEmit(s?a+s+i:"."+i)}}async match(e,t,r){let i=await this.matchCheck(e,r);i&&this.matchFinish(i,t)}matchSync(e,t,r){let i=this.matchCheckSync(e,r);i&&this.matchFinish(i,t)}walkCB(e,t,r){this.signal?.aborted&&r(),this.walkCB2(e,t,new gu(this.opts),r)}walkCB2(e,t,r,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||(s++,this.match(c,u,l).then(()=>a()));for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let u=c.readdirCached();c.calledReaddir()?this.walkCB3(c,u,r,a):c.readdirCB((l,f)=>this.walkCB3(c,f,r,a),!0)}a()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||(s++,this.match(c,u,l).then(()=>a()));for(let[c,u]of r.subwalks.entries())s++,this.walkCB2(c,u,r.child(),a);a()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new gu(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#a(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||this.matchSync(c,u,l);for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let u=c.readdirSync();this.walkCB3Sync(c,u,r,a)}a()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,u,l]of r.matches.entries())this.#n(c)||this.matchSync(c,u,l);for(let[c,u]of r.subwalks.entries())s++,this.walkCB2Sync(c,u,r.child(),a);a()}},yu=class extends Kh{static{o(this,"GlobWalker")}matches=new Set;constructor(e,t,r){super(e,t,r)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},vu=class extends Kh{static{o(this,"GlobStream")}results;constructor(e,t,r){super(e,t,r),this.results=new gs({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var LM=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Gn=class{static{o(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,jT.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(u=>u.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(u=>u.includes("/")?u:`./**/${u}`)}if(this.pattern=e,this.platform=t.platform||LM,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let u=t.platform==="win32"?Mo:t.platform==="darwin"?mu:t.platform?jo:MT;this.scurry=new u(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let r=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:r,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},s=this.pattern.map(u=>new Wr(u,i)),[a,c]=s.reduce((u,l)=>(u[0].push(...l.set),u[1].push(...l.globParts),u),[[],[]]);this.patterns=a.map((u,l)=>{let f=c[l];if(!f)throw new Error("invalid pattern object");return new $o(u,f,0,this.platform)})}async walk(){return[...await new yu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new yu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new vu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new vu(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var w1=o((n,e={})=>{Array.isArray(n)||(n=[n]);for(let t of n)if(new Wr(t,e).hasMagic())return!0;return!1},"hasMagic");function Jh(n,e={}){return new Gn(n,e).streamSync()}o(Jh,"globStreamSync");function VT(n,e={}){return new Gn(n,e).stream()}o(VT,"globStream");function UT(n,e={}){return new Gn(n,e).walkSync()}o(UT,"globSync");async function $T(n,e={}){return new Gn(n,e).walk()}o($T,"glob_");function Zh(n,e={}){return new Gn(n,e).iterateSync()}o(Zh,"globIterateSync");function BT(n,e={}){return new Gn(n,e).iterate()}o(BT,"globIterate");var kM=Jh,MM=Object.assign(VT,{sync:Jh}),jM=Zh,$M=Object.assign(BT,{sync:Zh}),VM=Object.assign(UT,{stream:Jh,iterate:Zh}),Xh=Object.assign($T,{glob:$T,globSync:UT,sync:VM,globStream:VT,stream:MM,globStreamSync:Jh,streamSync:kM,globIterate:BT,iterate:$M,globIterateSync:Zh,iterateSync:jM,Glob:Gn,hasMagic:w1,escape:Do,unescape:Un});Xh.glob=Xh;var pa=Ne($n());var Ss=class{constructor(e){this.rootPath=e}static{o(this,"NodeFsAdapter")}async readFile(e){let t=this.resolvePath(e);if(!await Ft.default.pathExists(t))throw new pa.FileNotFoundError(e);return Ft.default.readFile(t,"utf-8")}async fileExists(e){let t=this.resolvePath(e);return Ft.default.pathExists(t)}async getFileMetadata(e){let t=await this.readFile(e);return this.extractFrontmatter(t)}async createFile(e,t){let r=this.resolvePath(e);if(await Ft.default.pathExists(r))throw new pa.FileAlreadyExistsError(e);return await Ft.default.ensureDir(vs.default.dirname(r)),await Ft.default.writeFile(r,t,"utf-8"),e}async updateFile(e,t){let r=this.resolvePath(e);if(!await Ft.default.pathExists(r))throw new pa.FileNotFoundError(e);await Ft.default.writeFile(r,t,"utf-8")}async writeFile(e,t){let r=this.resolvePath(e);await Ft.default.ensureDir(vs.default.dirname(r)),await Ft.default.writeFile(r,t,"utf-8")}async deleteFile(e){let t=this.resolvePath(e);if(!await Ft.default.pathExists(t))throw new pa.FileNotFoundError(e);await Ft.default.remove(t)}async renameFile(e,t){let r=this.resolvePath(e),i=this.resolvePath(t);if(!await Ft.default.pathExists(r))throw new pa.FileNotFoundError(e);await Ft.default.ensureDir(vs.default.dirname(i)),await Ft.default.move(r,i)}async createDirectory(e){let t=this.resolvePath(e);await Ft.default.ensureDir(t)}async directoryExists(e){let t=this.resolvePath(e);return await Ft.default.pathExists(t)?(await Ft.default.stat(t)).isDirectory():!1}async getMarkdownFiles(e){let t=e?this.resolvePath(e):this.rootPath,r=vs.default.join(t,"**/*.md");return(await Xh(r,{nodir:!0})).map(a=>vs.default.relative(this.rootPath,a))}async findFilesByMetadata(e){let t=await this.getMarkdownFiles(),r=[];for(let i of t)try{let s=await this.getFileMetadata(i);this.matchesQuery(s,e)&&r.push(i)}catch{continue}return r}async findFileByUID(e){let t=await this.findFilesByMetadata({exo__Asset_uid:e});return t.length>0?t[0]:null}resolvePath(e){return vs.default.isAbsolute(e)?e:vs.default.join(this.rootPath,e)}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return{};try{let i=Zc.load(r[1]);return typeof i=="object"&&i!==null?i:{}}catch{return{}}}matchesQuery(e,t){for(let[r,i]of Object.entries(t)){let s=e[r];if(Array.isArray(s)){if(!s.some(a=>this.normalizeValue(a)===this.normalizeValue(i)))return!1}else if(this.normalizeValue(s)!==this.normalizeValue(i))return!1}return!0}normalizeValue(e){return e==null?"":String(e).replace(/["'[\]]/g,"").trim()}};var Su=Ne(require("path")),E1=Ne(Eo());var Uo=class{constructor(e){this.vaultRoot=e}static{o(this,"PathResolver")}resolve(e){if(!Su.default.isAbsolute(e))return Su.default.resolve(this.vaultRoot,e);let t=Su.default.resolve(e),r=Su.default.resolve(this.vaultRoot);if(!t.startsWith(r))throw new rt(`File path ${e} is outside vault root ${this.vaultRoot}`,"Provide a file path within the vault directory.",{filepath:e,vaultRoot:this.vaultRoot});return t}validate(e){if(!E1.default.existsSync(e))throw new tu(e);if(!E1.default.statSync(e).isFile())throw new rt(`Not a file: ${e}`,"Provide a path to a file, not a directory.",{filepath:e});if(!e.endsWith(".md"))throw new rt(`Not a Markdown file: ${e}`,"Provide a path to a .md file.",{filepath:e})}getVaultRoot(){return this.vaultRoot}};var QT=Ne($n());var qT=Ne($n());var Wn=class{static{o(this,"BaseCommandExecutor")}constructor(e){this.pathResolver=e.pathResolver,this.fsAdapter=e.fsAdapter,this.frontmatterService=e.frontmatterService,this.dryRun=e.dryRun}resolveAndValidate(e){let t=this.pathResolver.resolve(e);this.pathResolver.validate(t);let r=t.replace(this.pathResolver.getVaultRoot()+"/","");return{resolvedPath:t,relativePath:r}}getCurrentTimestamp(){return qT.DateFormatter.toLocalTimestamp(new Date)}isAssetArchived(e){if(e?.exo__Asset_isArchived===!0)return!0;let t=e?.archived;if(t==null)return!1;if(typeof t=="boolean")return t;if(typeof t=="number")return t!==0;if(typeof t=="string"){let r=t.toLowerCase().trim();return r==="true"||r==="yes"||r==="1"}return!1}extractAliasesFromFrontmatter(e){let t=e.match(/aliases:\s*\n((?: - .*\n?)*)/);return t?t[1].split(`
|
|
424
|
+
`).filter(i=>i.trim()).map(i=>i.replace(/^\s*-\s*/,"").trim()):[]}};var _u=class extends Wn{static{o(this,"StatusCommandExecutor")}constructor(e){super(e)}async executeStart(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDoing]]"');s=this.frontmatterService.updateProperty(s,"ems__Effort_startTimestamp",i),await this.fsAdapter.updateFile(t,s),console.log(`\u2705 Started: ${e}`),console.log(" Status: Doing"),console.log(` Start time: ${i}`),process.exit(0)}catch(t){K.handle(t)}}async executeComplete(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');s=this.frontmatterService.updateProperty(s,"ems__Effort_endTimestamp",i),s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(t,s),console.log(`\u2705 Completed: ${e}`),console.log(" Status: Done"),console.log(` Completion time: ${i}`),process.exit(0)}catch(t){K.handle(t)}}async executeTrash(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusTrashed]]"');s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(t,s),console.log(`\u2705 Trashed: ${e}`),console.log(" Status: Trashed"),console.log(` Resolution time: ${i}`),process.exit(0)}catch(t){K.handle(t)}}async executeArchive(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.readFile(t),i=this.frontmatterService.updateProperty(r,"archived","true");i=this.frontmatterService.removeProperty(i,"aliases"),await this.fsAdapter.updateFile(t,i),console.log(`\u2705 Archived: ${e}`),console.log(" Archived: true"),console.log(" Aliases removed"),process.exit(0)}catch(t){K.handle(t)}}async executeMoveToBacklog(e){try{await this.updateStatus(e,"ems__EffortStatusBacklog","Backlog"),process.exit(0)}catch(t){K.handle(t)}}async executeMoveToAnalysis(e){try{await this.updateStatus(e,"ems__EffortStatusAnalysis","Analysis"),process.exit(0)}catch(t){K.handle(t)}}async executeMoveToToDo(e){try{await this.updateStatus(e,"ems__EffortStatusToDo","ToDo"),process.exit(0)}catch(t){K.handle(t)}}async updateStatus(e,t,r){let{relativePath:i}=this.resolveAndValidate(e),s=await this.fsAdapter.readFile(i),a=this.frontmatterService.updateProperty(s,"ems__Effort_status",`"[[${t}]]"`);await this.fsAdapter.updateFile(i,a),console.log(`\u2705 Moved to ${r}: ${e}`),console.log(` Status: ${r}`)}};var er=[];for(let n=0;n<256;++n)er.push((n+256).toString(16).slice(1));function GT(n,e=0){return(er[n[e+0]]+er[n[e+1]]+er[n[e+2]]+er[n[e+3]]+"-"+er[n[e+4]]+er[n[e+5]]+"-"+er[n[e+6]]+er[n[e+7]]+"-"+er[n[e+8]]+er[n[e+9]]+"-"+er[n[e+10]]+er[n[e+11]]+er[n[e+12]]+er[n[e+13]]+er[n[e+14]]+er[n[e+15]]).toLowerCase()}o(GT,"unsafeStringify");var WT=require("node:crypto");var td=new Uint8Array(256),ed=td.length;function T1(){return ed>td.length-16&&((0,WT.randomFillSync)(td),ed=0),td.slice(ed,ed+=16)}o(T1,"rng");var HT=require("node:crypto"),A1={randomUUID:HT.randomUUID};function BM(n,e,t){n=n||{};let r=n.random??n.rng?.()??T1();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=r[i];return e}return GT(r)}o(BM,"_v4");function qM(n,e,t){return A1.randomUUID&&!e&&!n?A1.randomUUID():BM(n,e,t)}o(qM,"v4");var x1=qM;var Bo=Ne($n());var bu=class extends Wn{static{o(this,"AssetCreationExecutor")}constructor(e){super(e)}async executeCreateTask(e,t,r={}){try{await this.createAsset(e,t,"ems__Task",r),process.exit(0)}catch(i){K.handle(i)}}async executeCreateMeeting(e,t,r={}){try{await this.createAsset(e,t,"ems__Meeting",r),process.exit(0)}catch(i){K.handle(i)}}async executeCreateProject(e,t,r={}){try{await this.createAsset(e,t,"ems__Project",r),process.exit(0)}catch(i){K.handle(i)}}async executeCreateArea(e,t,r={}){try{await this.createAsset(e,t,"ems__Area",r),process.exit(0)}catch(i){K.handle(i)}}async createAsset(e,t,r,i={}){if(!t||t.trim().length===0)throw new Error("Label cannot be empty");let s=t.trim(),{relativePath:a}=this.resolveAndValidate(e);if(await this.fsAdapter.fileExists(a))throw new Bo.FileAlreadyExistsError(e);let u=x1(),l=this.buildAssetFrontmatter(r,u,s,i),f=Bo.MetadataHelpers.buildFileContent(l);await this.fsAdapter.createFile(a,f),console.log(`\u2705 Created ${this.getAssetTypeName(r)}: ${e}`),console.log(` UID: ${u}`),console.log(` Label: ${s}`),console.log(` Class: ${r}`)}buildAssetFrontmatter(e,t,r,i={}){let s=Bo.DateFormatter.toLocalTimestamp(new Date),a={exo__Asset_isDefinedBy:'"[[Ontology/EMS]]"',exo__Asset_uid:t,exo__Asset_label:r,exo__Asset_createdAt:s,exo__Instance_class:[`"[[${e}]]"`],aliases:[r]};return(e==="ems__Task"||e==="ems__Project"||e==="ems__Meeting")&&(a.ems__Effort_status='"[[ems__EffortStatusDraft]]"'),i.prototype&&(a.ems__Effort_prototype=`"[[${i.prototype}]]"`),i.area&&(a.ems__Effort_area=`"[[${i.area}]]"`),i.parent&&(a.ems__Effort_parent=`"[[${i.parent}]]"`),a}getAssetTypeName(e){return{ems__Task:"task",ems__Meeting:"meeting",ems__Project:"project",ems__Area:"area"}[e]||"asset"}};var C1=Ne(require("path"));var zT=Ne($n());var wu=class extends Wn{static{o(this,"PropertyCommandExecutor")}constructor(e){super(e)}async executeRenameToUid(e){try{let{relativePath:t}=this.resolveAndValidate(e),r=await this.fsAdapter.getFileMetadata(t);if(!r.exo__Asset_uid)throw new Error("Asset missing exo__Asset_uid property");let i=C1.default.basename(t,".md"),s=r.exo__Asset_uid;if(i===s&&(console.log(`\u2705 Already renamed: ${e}`),console.log(` Current filename matches UID: ${s}.md`),process.exit(0)),!r.exo__Asset_label||r.exo__Asset_label.trim()===""){let u=await this.fsAdapter.readFile(t),l=this.frontmatterService.updateProperty(u,"exo__Asset_label",i),f=this.isAssetArchived(r),h=l;f||(h=this.frontmatterService.updateProperty(l,"aliases",`
|
|
425
|
+
- ${i}`)),await this.fsAdapter.updateFile(t,h),console.log(` Updated label: "${i}"`)}let a=C1.default.dirname(t),c=a!=="."?`${a}/${s}.md`:`${s}.md`;await this.fsAdapter.renameFile(t,c),console.log("\u2705 Renamed to UID format"),console.log(` Old: ${t}`),console.log(` New: ${c}`),process.exit(0)}catch(t){K.handle(t)}}async executeUpdateLabel(e,t){try{if(!t||t.trim().length===0)throw new Error("Label cannot be empty");let r=t.trim(),{relativePath:i}=this.resolveAndValidate(e),s=await this.fsAdapter.readFile(i),a=this.frontmatterService.updateProperty(s,"exo__Asset_label",r),c=this.frontmatterService.parse(a),u=this.extractAliasesFromFrontmatter(c.content);if(u.includes(r)||(u.length===0?a=this.frontmatterService.updateProperty(a,"aliases",`
|
|
426
426
|
- ${r}`):a=this.frontmatterService.updateProperty(a,"aliases",`${u.map(l=>`
|
|
427
427
|
- ${l}`).join("")}
|
|
428
428
|
- ${r}`)),this.dryRun){if(console.log("\u{1F50D} DRY RUN: Preview of changes (not applied)"),console.log(` File: ${e}`),console.log(" Changes:"),console.log(` \u2022 exo__Asset_label: "${r}"`),u.includes(r))console.log(" \u2022 aliases: unchanged (label already present)");else{let l=u.length===0?[r]:[...u,r];console.log(` \u2022 aliases: [${l.map(f=>`"${f}"`).join(", ")}]`)}console.log(`
|
|
429
|
-
\u{1F4A1} Run without --dry-run to apply changes`),process.exit(0)}await this.fsAdapter.updateFile(i,a),console.log("\u2705 Updated label"),console.log(` File: ${e}`),console.log(` New label: "${r}"`),console.log(" Aliases synchronized"),process.exit(0)}catch(r){K.handle(r)}}async executeSchedule(e,t){try{await this.updatePlannedTimestamp(e,t,"ems__Effort_plannedStartTimestamp"),process.exit(0)}catch(r){K.handle(r)}}async executeSetDeadline(e,t){try{await this.updatePlannedTimestamp(e,t,"ems__Effort_plannedEndTimestamp"),process.exit(0)}catch(r){K.handle(r)}}async updatePlannedTimestamp(e,t,r){let{relativePath:i}=this.resolveAndValidate(e);if(!await this.fsAdapter.fileExists(i))throw new Error(`File not found: ${e}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t))throw new Error(`Invalid date format: ${t}. Expected YYYY-MM-DD (e.g., 2025-11-25)`);let a=
|
|
430
|
-
\u{1F4A1} Run without --dry-run to apply changes`),process.exit(0),{moved:!1,oldPath:t,newPath:b,expectedFolder:u}}let h=_s.default.basename(t),d=u?`${u}/${h}`:h;if(await this.fsAdapter.fileExists(d))throw new Error(`Cannot move file: ${d} already exists`);return u&&(await this.fsAdapter.directoryExists(u)||await this.fsAdapter.createDirectory(u)),await this.fsAdapter.renameFile(t,d),console.log("\u2705 Moved to correct folder"),console.log(` Old path: ${t}`),console.log(` New path: ${d}`),console.log(` Expected folder: ${u||"(root)"}`),process.exit(0),{moved:!0,oldPath:t,newPath:d,expectedFolder:u}}catch(t){K.handle(t)}}extractReference(e){if(typeof e!="string")return null;let t=e.trim().replace(/^["']|["']$/g,"");return t=t.replace(/^\[\[|\]\]$/g,""),t||null}async findReferencedFile(e,t){let r=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await this.fsAdapter.fileExists(r))return r;let i=_s.default.dirname(t),s=i?`${i}/${r}`:r;if(await this.fsAdapter.fileExists(s))return s;let c=await this.fsAdapter.findFileByUID(e);return c||(await this.fsAdapter.getMarkdownFiles()).find(f=>{let h=_s.default.basename(f,".md"),d=_s.default.basename(r,".md");return h===d})||null}normalizePath(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}};var
|
|
431
|
-
\u{1F4DD} Note: Actual command execution will be implemented in follow-up issues.`),console.log(" This PR establishes the infrastructure foundation."),process.exit(0)}catch(i){K.handle(i)}}getVaultRoot(){return this.context.pathResolver.getVaultRoot()}async executeStart(e){return this.statusExecutor.executeStart(e)}async executeComplete(e){return this.statusExecutor.executeComplete(e)}async executeTrash(e){return this.statusExecutor.executeTrash(e)}async executeArchive(e){return this.statusExecutor.executeArchive(e)}async executeMoveToBacklog(e){return this.statusExecutor.executeMoveToBacklog(e)}async executeMoveToAnalysis(e){return this.statusExecutor.executeMoveToAnalysis(e)}async executeMoveToToDo(e){return this.statusExecutor.executeMoveToToDo(e)}async executeCreateTask(e,t,r={}){return this.creationExecutor.executeCreateTask(e,t,r)}async executeCreateMeeting(e,t,r={}){return this.creationExecutor.executeCreateMeeting(e,t,r)}async executeCreateProject(e,t,r={}){return this.creationExecutor.executeCreateProject(e,t,r)}async executeCreateArea(e,t,r={}){return this.creationExecutor.executeCreateArea(e,t,r)}async executeRenameToUid(e){return this.propertyExecutor.executeRenameToUid(e)}async executeUpdateLabel(e,t){return this.propertyExecutor.executeUpdateLabel(e,t)}async executeSchedule(e,t){return this.propertyExecutor.executeSchedule(e,t)}async executeSetDeadline(e,t){return this.propertyExecutor.executeSetDeadline(e,t)}async executeRepairFolder(e){return this.folderRepairExecutor.executeRepairFolder(e)}};function tr(n,e,t,r,i){if(n==="json"){let s={command:e,filepath:t,action:r,...i&&{changes:i}},a=Ye.success(s);console.log(JSON.stringify(a,null,2))}else console.log(`\u2705 ${r}`)}o(tr,"outputResult");function ma(n,e,t,r){let i=new rt(`--${e} option is required for ${t} command`,r,{command:t,missingOption:e});K.handle(i)}o(ma,"handleMissingOption");function zT(){return new Lt("command").description("Execute plugin command on single asset").argument("<command-name>","Command to execute (rename-to-uid, start, complete, schedule, set-deadline, etc.)").argument("<filepath>","Path to asset file (relative to vault root or absolute)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--label <value>","Asset label (required for update-label and creation commands)").option("--prototype <uid>","Prototype UID for inheritance (creation commands)").option("--area <uid>","Area UID for effort linkage (creation commands)").option("--parent <uid>","Parent UID for effort linkage (creation commands)").option("--date <value>","Date in YYYY-MM-DD format (required for schedule and set-deadline commands)").option("--dry-run","Preview changes without modifying files").option("--format <type>","Output format: text|json (default: text)","text").action(async(n,e,t)=>{let r=t.format||"text";K.setFormat(r);try{let i=(0,HT.resolve)(t.vault),s=new td(i,t.dryRun);switch(n){case"rename-to-uid":await s.executeRenameToUid(e),tr(r,n,e,"Renamed file to UID-based name");break;case"update-label":t.label||ma(r,"label","update-label",'exocortex command update-label <filepath> --label "<value>"'),await s.executeUpdateLabel(e,t.label),tr(r,n,e,`Updated label to "${t.label}"`,{label:t.label});break;case"start":await s.executeStart(e),tr(r,n,e,"Started task");break;case"complete":await s.executeComplete(e),tr(r,n,e,"Completed task");break;case"trash":await s.executeTrash(e),tr(r,n,e,"Moved task to trash");break;case"archive":await s.executeArchive(e),tr(r,n,e,"Archived task");break;case"move-to-backlog":await s.executeMoveToBacklog(e),tr(r,n,e,"Moved task to backlog");break;case"move-to-analysis":await s.executeMoveToAnalysis(e),tr(r,n,e,"Moved task to analysis");break;case"move-to-todo":await s.executeMoveToToDo(e),tr(r,n,e,"Moved task to todo");break;case"create-task":t.label||ma(r,"label","create-task",'exocortex command create-task <filepath> --label "<value>"'),await s.executeCreateTask(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created task "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-meeting":t.label||ma(r,"label","create-meeting",'exocortex command create-meeting <filepath> --label "<value>"'),await s.executeCreateMeeting(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created meeting "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-project":t.label||ma(r,"label","create-project",'exocortex command create-project <filepath> --label "<value>"'),await s.executeCreateProject(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created project "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-area":t.label||ma(r,"label","create-area",'exocortex command create-area <filepath> --label "<value>"'),await s.executeCreateArea(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created area "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"schedule":t.date||ma(r,"date","schedule",'exocortex command schedule <filepath> --date "YYYY-MM-DD"'),await s.executeSchedule(e,t.date),tr(r,n,e,`Scheduled task for ${t.date}`,{date:t.date});break;case"set-deadline":t.date||ma(r,"date","set-deadline",'exocortex command set-deadline <filepath> --date "YYYY-MM-DD"'),await s.executeSetDeadline(e,t.date),tr(r,n,e,`Set deadline to ${t.date}`,{date:t.date});break;case"repair-folder":{let a=await s.executeRepairFolder(e);tr(r,n,e,a.moved?`Moved to correct folder: ${a.newPath}`:"Already in correct folder",{moved:a.moved,oldPath:a.oldPath,newPath:a.newPath,expectedFolder:a.expectedFolder});break}default:await s.execute(n,e,t),tr(r,n,e,`Executed ${n}`);break}}catch(i){K.handle(i)}})}o(zT,"commandCommand");var YT=require("path");var Ui=Ne(require("fs")),x1=Ne(require("path")),QT=require("events");var VM={watch:Ui.default.watch.bind(Ui.default),existsSync:Ui.default.existsSync.bind(Ui.default),statSync:Ui.default.statSync.bind(Ui.default),readFileSync:Ui.default.readFileSync.bind(Ui.default)},rd=class extends QT.EventEmitter{constructor(t,r={}){super();this.watcher=null;this.debounceTimers=new Map;this.isRunning=!1;this.vaultPath=x1.default.resolve(t),this.fsAdapter=r.fsAdapter??VM,this.options={pattern:r.pattern??"**/*.md",assetType:r.assetType??"",debounceMs:r.debounceMs??100,recursive:r.recursive??!0}}static{o(this,"FileSystemWatcher")}start(){this.isRunning||(this.watcher=this.fsAdapter.watch(this.vaultPath,{recursive:this.options.recursive},(t,r)=>{r&&this.handleFileEvent(t,r.toString())}),this.watcher.on("error",t=>{this.emit("error",t)}),this.isRunning=!0,this.emit("started"))}stop(){if(this.isRunning){for(let t of this.debounceTimers.values())clearTimeout(t);this.debounceTimers.clear(),this.watcher&&(this.watcher.close(),this.watcher=null),this.isRunning=!1,this.emit("stopped")}}isWatching(){return this.isRunning}handleFileEvent(t,r){let i=x1.default.join(this.vaultPath,r),s=r;if(!this.matchesPattern(s))return;let a=this.debounceTimers.get(i);a&&clearTimeout(a);let c=setTimeout(()=>{this.debounceTimers.delete(i),this.processFileEvent(i,s)},this.options.debounceMs);this.debounceTimers.set(i,c)}processFileEvent(t,r){let i=this.fsAdapter.existsSync(t),s;if(!i)s="delete";else{let u=this.fsAdapter.statSync(t);s=Date.now()-u.birthtimeMs<1e3?"create":"modify"}let a;if(i&&t.endsWith(".md")&&(a=this.extractAssetType(t)),this.options.assetType&&a!==this.options.assetType)return;let c={type:s,path:t,relativePath:r,timestamp:new Date().toISOString(),assetType:a};this.emit("change",c)}matchesPattern(t){return this.options.pattern?Zt(t,this.options.pattern):!0}extractAssetType(t){try{let i=this.fsAdapter.readFileSync(t,"utf-8").match(/^---\n([\s\S]*?)\n---/);if(!i)return;let a=i[1].match(/exo__Instance_class:\s*(?:\[?"?\[\[([^\]]+)\]\]"?\]?|"?\[\[([^\]]+)\]\]"?)/);return a?a[1]||a[2]:void 0}catch{return}}};var C1=Ne(require("fs"));function KT(){return new Lt("watch").description("Watch vault for file changes and emit NDJSON events").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--pattern <glob>","Glob pattern to filter files (e.g., '*.md', 'tasks/**')").option("--asset-type <type>","Filter by asset type (e.g., 'ems__Task', 'ems__Project')").option("--debounce <ms>","Debounce interval in milliseconds","100").action(async n=>{K.setFormat("json");try{let e=(0,YT.resolve)(n.vault);if(!C1.default.existsSync(e))throw new Xt(e);if(!C1.default.statSync(e).isDirectory())throw new rt(`Vault path is not a directory: ${e}`,"Provide a path to a directory, not a file",{vaultPath:e});let t=parseInt(n.debounce?.toString()??"100",10);if(isNaN(t)||t<0)throw new rt("--debounce must be a non-negative integer","Use a positive integer value for debounce",{debounce:n.debounce});let r=new rd(e,{pattern:n.pattern,assetType:n.assetType,debounceMs:t});r.on("change",s=>{console.log(JSON.stringify(s))}),r.on("error",s=>{let a=Ye.error("INTERNAL_OPERATION_FAILED",s.message,5,{recovery:{message:"Check file permissions and vault access",suggestion:"Ensure the vault directory is accessible"}});console.log(JSON.stringify(a))});let i=o(()=>{r.stop(),process.exit(0)},"shutdown");process.on("SIGINT",i),process.on("SIGTERM",i),console.error(`Watching vault: ${e}`),n.pattern&&console.error(` Pattern filter: ${n.pattern}`),n.assetType&&console.error(` Asset type filter: ${n.assetType}`),console.error(` Debounce: ${t}ms`),console.error("Press Ctrl+C to stop"),r.start()}catch(e){K.handle(e)}})}o(KT,"watchCommand");var O1=require("path"),P1=Ne(Eo());var ga=Ne(require("path"));var qo=Ne($n());var Hn=Ne(Eo()),I1=Ne(require("crypto"));var nd=class{constructor(){this.backups=new Map;this.fileHashes=new Map}static{o(this,"TransactionManager")}async begin(e){if(!Hn.default.existsSync(e))throw new Error(`Cannot backup non-existent file: ${e}`);let t=await Hn.default.readFile(e,"utf-8"),r=I1.default.createHash("sha256").update(t).digest("hex");this.fileHashes.set(e,r);let i=`${e}.backup.${Date.now()}`;await Hn.default.writeFile(i,t,"utf-8"),this.backups.set(e,i)}async verify(e){let t=this.fileHashes.get(e);if(!t)return!0;if(!Hn.default.existsSync(e))return!1;let r=await Hn.default.readFile(e,"utf-8");return I1.default.createHash("sha256").update(r).digest("hex")===t}async commit(){for(let e of this.backups.values())Hn.default.existsSync(e)&&await Hn.default.remove(e);this.backups.clear(),this.fileHashes.clear()}async rollback(){for(let[e,t]of this.backups.entries())Hn.default.existsSync(t)&&(await Hn.default.copy(t,e,{overwrite:!0}),await Hn.default.remove(t));this.backups.clear(),this.fileHashes.clear()}getTrackedFiles(){return Array.from(this.backups.keys())}};var ya=class{static{o(this,"BatchExecutor")}constructor(e,t=!1){this.pathResolver=new Uo(e),this.fsAdapter=new Ss(e),this.frontmatterService=new qo.FrontmatterService,this.transactionManager=new nd,this.dryRun=t}async executeBatch(e,t=!1){let r=Date.now(),i=[],s=0,a=0;if(e.length===0)return{success:!0,total:0,succeeded:0,failed:0,results:[],durationMs:Date.now()-r,atomic:t};if(t&&!this.dryRun)try{await this.backupAllFiles(e)}catch(u){return{success:!1,total:e.length,succeeded:0,failed:e.length,results:e.map(l=>({success:!1,command:l.command,filepath:l.filepath,error:`Backup failed: ${u.message}`})),durationMs:Date.now()-r,atomic:t}}for(let u of e){let l=await this.executeSingleOperation(u);if(i.push(l),l.success)s++;else if(a++,t&&!this.dryRun){await this.transactionManager.rollback();let f=i.length;for(let h=f;h<e.length;h++)i.push({success:!1,command:e[h].command,filepath:e[h].filepath,error:"Not executed due to atomic rollback"}),a++;return{success:!1,total:e.length,succeeded:0,failed:e.length,results:i,durationMs:Date.now()-r,atomic:t,rolledBack:!0}}}return t&&!this.dryRun&&await this.transactionManager.commit(),{success:a===0,total:e.length,succeeded:s,failed:a,results:i,durationMs:Date.now()-r,atomic:t,...t&&{rolledBack:!1}}}static parseInput(e){try{let t=JSON.parse(e);if(!Array.isArray(t))throw new rt("Batch input must be a JSON array of operations",`exo batch --input '[{"command":"start","filepath":"task.md"}]'`);for(let r of t){if(!r.command||typeof r.command!="string")throw new rt('Each operation must have a "command" string property','{"command":"start","filepath":"task.md"}');if(!r.filepath||typeof r.filepath!="string")throw new rt('Each operation must have a "filepath" string property','{"command":"start","filepath":"task.md"}')}return t}catch(t){throw t instanceof rt?t:new rt(`Failed to parse batch input: ${t.message}`,`exo batch --input '[{"command":"start","filepath":"task.md"}]'`)}}async backupAllFiles(e){let t=new Set;for(let r of e){let i=this.pathResolver.resolve(r.filepath);t.add(i)}for(let r of t)await this.transactionManager.begin(r)}async executeSingleOperation(e){try{let t=this.pathResolver.resolve(e.filepath);this.pathResolver.validate(t);let r=t.replace(this.pathResolver.getVaultRoot()+"/","");if(await this.fsAdapter.readFile(r),this.dryRun)return{success:!0,command:e.command,filepath:e.filepath,action:`Would execute ${e.command} (dry-run)`};switch(e.command){case"start":return await this.executeStart(r,e);case"complete":return await this.executeComplete(r,e);case"trash":return await this.executeTrash(r,e);case"archive":return await this.executeArchive(r,e);case"move-to-backlog":return await this.executeStatusUpdate(r,e,"ems__EffortStatusBacklog","Moved to backlog");case"move-to-analysis":return await this.executeStatusUpdate(r,e,"ems__EffortStatusAnalysis","Moved to analysis");case"move-to-todo":return await this.executeStatusUpdate(r,e,"ems__EffortStatusToDo","Moved to todo");case"update-label":return await this.executeUpdateLabel(r,e);case"schedule":return await this.executeSchedule(r,e);case"set-deadline":return await this.executeSetDeadline(r,e);case"repair-folder":return await this.executeRepairFolder(r,e);default:return{success:!1,command:e.command,filepath:e.filepath,error:`Unknown command: ${e.command}`}}}catch(t){return{success:!1,command:e.command,filepath:e.filepath,error:t.message}}}getCurrentTimestamp(){return qo.DateFormatter.toLocalTimestamp(new Date)}async executeStart(e,t){let r=await this.fsAdapter.readFile(e),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDoing]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_startTimestamp",i),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Started task",changes:{status:"Doing",startTimestamp:i}}}async executeComplete(e,t){let r=await this.fsAdapter.readFile(e),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_endTimestamp",i),s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Completed task",changes:{status:"Done",endTimestamp:i,resolutionTimestamp:i}}}async executeTrash(e,t){let r=await this.fsAdapter.readFile(e),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusTrashed]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Trashed task",changes:{status:"Trashed",resolutionTimestamp:i}}}async executeArchive(e,t){let r=await this.fsAdapter.readFile(e),i=this.frontmatterService.updateProperty(r,"archived","true");return i=this.frontmatterService.removeProperty(i,"aliases"),await this.fsAdapter.updateFile(e,i),{success:!0,command:t.command,filepath:t.filepath,action:"Archived task",changes:{archived:!0,aliasesRemoved:!0}}}async executeStatusUpdate(e,t,r,i){let s=await this.fsAdapter.readFile(e),a=this.frontmatterService.updateProperty(s,"ems__Effort_status",`"[[${r}]]"`);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:i,changes:{status:r.replace("ems__EffortStatus","")}}}async executeUpdateLabel(e,t){let r=t.options?.label;if(!r||r.trim()==="")return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "label"'};let i=r.trim(),s=await this.fsAdapter.readFile(e),a=this.frontmatterService.updateProperty(s,"exo__Asset_label",`"${i}"`);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Updated label to "${i}"`,changes:{label:i}}}async executeSchedule(e,t){let r=t.options?.date;if(!r)return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "date"'};if(!/^\d{4}-\d{2}-\d{2}$/.test(r))return{success:!1,command:t.command,filepath:t.filepath,error:`Invalid date format: ${r}. Expected YYYY-MM-DD`};let i=await this.fsAdapter.readFile(e),s=qo.DateFormatter.toTimestampAtStartOfDay(r),a=this.frontmatterService.updateProperty(i,"ems__Effort_scheduledTimestamp",s);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Scheduled for ${r}`,changes:{scheduledTimestamp:s}}}async executeSetDeadline(e,t){let r=t.options?.date;if(!r)return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "date"'};if(!/^\d{4}-\d{2}-\d{2}$/.test(r))return{success:!1,command:t.command,filepath:t.filepath,error:`Invalid date format: ${r}. Expected YYYY-MM-DD`};let i=await this.fsAdapter.readFile(e),s=qo.DateFormatter.toTimestampAtStartOfDay(r),a=this.frontmatterService.updateProperty(i,"ems__Effort_deadlineTimestamp",s);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Set deadline to ${r}`,changes:{deadlineTimestamp:s}}}async executeRepairFolder(e,t){let i=(await this.fsAdapter.getFileMetadata(e))?.exo__Asset_isDefinedBy;if(!i)return{success:!1,command:t.command,filepath:t.filepath,error:"Cannot determine expected folder: missing exo__Asset_isDefinedBy"};let s=this.extractReference(i);if(!s)return{success:!1,command:t.command,filepath:t.filepath,error:"Cannot determine expected folder: invalid exo__Asset_isDefinedBy format"};let a=await this.findReferencedFile(s,e);if(!a)return{success:!1,command:t.command,filepath:t.filepath,error:`Cannot determine expected folder: referenced asset not found: ${s}`};let c=ga.default.dirname(a),u=c==="."?"":c,l=ga.default.dirname(e),f=l==="."?"":l;if(this.normalizePath(f)===this.normalizePath(u))return{success:!0,command:t.command,filepath:t.filepath,action:"Already in correct folder",changes:{moved:!1,folder:u||"(root)"}};let h=ga.default.basename(e),d=u?`${u}/${h}`:h;return await this.fsAdapter.fileExists(d)?{success:!1,command:t.command,filepath:t.filepath,error:`Cannot move file: ${d} already exists`}:(await this.fsAdapter.renameFile(e,d),{success:!0,command:t.command,filepath:t.filepath,action:`Moved to ${u||"(root)"}`,changes:{moved:!0,oldPath:e,newPath:d,expectedFolder:u||"(root)"}})}extractReference(e){if(typeof e!="string")return null;let t=e.trim().replace(/^["']|["']$/g,"");return t=t.replace(/^\[\[|\]\]$/g,""),t||null}async findReferencedFile(e,t){let r=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await this.fsAdapter.fileExists(r))return r;let i=ga.default.dirname(t),s=i!=="."?`${i}/${r}`:r;if(await this.fsAdapter.fileExists(s))return s;let c=await this.fsAdapter.findFileByUID(e);return c||(await this.fsAdapter.getMarkdownFiles()).find(f=>{let h=ga.default.basename(f,".md"),d=ga.default.basename(r,".md");return h===d})||null}normalizePath(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}};function UM(n,e){if(n==="json"){let t=Ye.success(e,{durationMs:e.durationMs,itemCount:e.total});console.log(JSON.stringify(t,null,2))}else{if(console.log(`
|
|
429
|
+
\u{1F4A1} Run without --dry-run to apply changes`),process.exit(0)}await this.fsAdapter.updateFile(i,a),console.log("\u2705 Updated label"),console.log(` File: ${e}`),console.log(` New label: "${r}"`),console.log(" Aliases synchronized"),process.exit(0)}catch(r){K.handle(r)}}async executeSchedule(e,t){try{await this.updatePlannedTimestamp(e,t,"ems__Effort_plannedStartTimestamp"),process.exit(0)}catch(r){K.handle(r)}}async executeSetDeadline(e,t){try{await this.updatePlannedTimestamp(e,t,"ems__Effort_plannedEndTimestamp"),process.exit(0)}catch(r){K.handle(r)}}async updatePlannedTimestamp(e,t,r){let{relativePath:i}=this.resolveAndValidate(e);if(!await this.fsAdapter.fileExists(i))throw new Error(`File not found: ${e}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t))throw new Error(`Invalid date format: ${t}. Expected YYYY-MM-DD (e.g., 2025-11-25)`);let a=zT.DateFormatter.toTimestampAtStartOfDay(t),c=await this.fsAdapter.readFile(i),u=this.frontmatterService.updateProperty(c,r,a);await this.fsAdapter.writeFile(i,u),console.log(`\u2705 ${r==="ems__Effort_plannedStartTimestamp"?"Scheduled":"Set deadline for"}: ${e}`),console.log(` Date: ${t}`),console.log(` Timestamp: ${a}`)}};var _s=Ne(require("path"));var Eu=class extends Wn{static{o(this,"FolderRepairExecutor")}constructor(e){super(e)}async executeRepairFolder(e){try{let{relativePath:t}=this.resolveAndValidate(e),i=(await this.fsAdapter.getFileMetadata(t))?.exo__Asset_isDefinedBy;if(!i)throw new Error("Cannot determine expected folder: missing exo__Asset_isDefinedBy");let s=this.extractReference(i);if(!s)throw new Error("Cannot determine expected folder: invalid exo__Asset_isDefinedBy format");let a=await this.findReferencedFile(s,t);if(!a)throw new Error(`Cannot determine expected folder: referenced asset not found: ${s}`);let c=_s.default.dirname(a),u=c==="."?"":c,l=_s.default.dirname(t),f=l==="."?"":l;if(this.normalizePath(f)===this.normalizePath(u))return console.log("\u2705 Already in correct folder"),console.log(` File: ${e}`),console.log(` Folder: ${u||"(root)"}`),process.exit(0),{moved:!1,oldPath:t,newPath:t,expectedFolder:u};if(this.dryRun){let S=_s.default.basename(t),b=u?`${u}/${S}`:S;return console.log("\u{1F50D} DRY RUN: Preview of changes (not applied)"),console.log(` File: ${e}`),console.log(` Current folder: ${f||"(root)"}`),console.log(` Expected folder: ${u||"(root)"}`),console.log(` Would move to: ${b}`),console.log(`
|
|
430
|
+
\u{1F4A1} Run without --dry-run to apply changes`),process.exit(0),{moved:!1,oldPath:t,newPath:b,expectedFolder:u}}let h=_s.default.basename(t),d=u?`${u}/${h}`:h;if(await this.fsAdapter.fileExists(d))throw new Error(`Cannot move file: ${d} already exists`);return u&&(await this.fsAdapter.directoryExists(u)||await this.fsAdapter.createDirectory(u)),await this.fsAdapter.renameFile(t,d),console.log("\u2705 Moved to correct folder"),console.log(` Old path: ${t}`),console.log(` New path: ${d}`),console.log(` Expected folder: ${u||"(root)"}`),process.exit(0),{moved:!0,oldPath:t,newPath:d,expectedFolder:u}}catch(t){K.handle(t)}}extractReference(e){if(typeof e!="string")return null;let t=e.trim().replace(/^["']|["']$/g,"");return t=t.replace(/^\[\[|\]\]$/g,""),t||null}async findReferencedFile(e,t){let r=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await this.fsAdapter.fileExists(r))return r;let i=_s.default.dirname(t),s=i?`${i}/${r}`:r;if(await this.fsAdapter.fileExists(s))return s;let c=await this.fsAdapter.findFileByUID(e);return c||(await this.fsAdapter.getMarkdownFiles()).find(f=>{let h=_s.default.basename(f,".md"),d=_s.default.basename(r,".md");return h===d})||null}normalizePath(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}};var rd=class{static{o(this,"CommandExecutor")}constructor(e,t=!1){this.context={pathResolver:new Uo(e),fsAdapter:new Ss(e),frontmatterService:new QT.FrontmatterService,dryRun:t},this.statusExecutor=new _u(this.context),this.creationExecutor=new bu(this.context),this.propertyExecutor=new wu(this.context),this.folderRepairExecutor=new Eu(this.context)}async execute(e,t,r){try{let i=this.context.pathResolver.resolve(t);this.context.pathResolver.validate(i),await this.context.fsAdapter.readFile(i.replace(this.context.pathResolver.getVaultRoot()+"/","")),console.log("\u2705 Command infrastructure verified"),console.log(` Command: ${e}`),console.log(` File: ${i}`),console.log(` Vault: ${this.context.pathResolver.getVaultRoot()}`),Object.keys(r).length>0&&console.log(` Options: ${JSON.stringify(r,null,2)}`),console.log(`
|
|
431
|
+
\u{1F4DD} Note: Actual command execution will be implemented in follow-up issues.`),console.log(" This PR establishes the infrastructure foundation."),process.exit(0)}catch(i){K.handle(i)}}getVaultRoot(){return this.context.pathResolver.getVaultRoot()}async executeStart(e){return this.statusExecutor.executeStart(e)}async executeComplete(e){return this.statusExecutor.executeComplete(e)}async executeTrash(e){return this.statusExecutor.executeTrash(e)}async executeArchive(e){return this.statusExecutor.executeArchive(e)}async executeMoveToBacklog(e){return this.statusExecutor.executeMoveToBacklog(e)}async executeMoveToAnalysis(e){return this.statusExecutor.executeMoveToAnalysis(e)}async executeMoveToToDo(e){return this.statusExecutor.executeMoveToToDo(e)}async executeCreateTask(e,t,r={}){return this.creationExecutor.executeCreateTask(e,t,r)}async executeCreateMeeting(e,t,r={}){return this.creationExecutor.executeCreateMeeting(e,t,r)}async executeCreateProject(e,t,r={}){return this.creationExecutor.executeCreateProject(e,t,r)}async executeCreateArea(e,t,r={}){return this.creationExecutor.executeCreateArea(e,t,r)}async executeRenameToUid(e){return this.propertyExecutor.executeRenameToUid(e)}async executeUpdateLabel(e,t){return this.propertyExecutor.executeUpdateLabel(e,t)}async executeSchedule(e,t){return this.propertyExecutor.executeSchedule(e,t)}async executeSetDeadline(e,t){return this.propertyExecutor.executeSetDeadline(e,t)}async executeRepairFolder(e){return this.folderRepairExecutor.executeRepairFolder(e)}};function tr(n,e,t,r,i){if(n==="json"){let s={command:e,filepath:t,action:r,...i&&{changes:i}},a=Ye.success(s);console.log(JSON.stringify(a,null,2))}else console.log(`\u2705 ${r}`)}o(tr,"outputResult");function ma(n,e,t,r){let i=new rt(`--${e} option is required for ${t} command`,r,{command:t,missingOption:e});K.handle(i)}o(ma,"handleMissingOption");function KT(){return new Lt("command").description("Execute plugin command on single asset").argument("<command-name>","Command to execute (rename-to-uid, start, complete, schedule, set-deadline, etc.)").argument("<filepath>","Path to asset file (relative to vault root or absolute)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--label <value>","Asset label (required for update-label and creation commands)").option("--prototype <uid>","Prototype UID for inheritance (creation commands)").option("--area <uid>","Area UID for effort linkage (creation commands)").option("--parent <uid>","Parent UID for effort linkage (creation commands)").option("--date <value>","Date in YYYY-MM-DD format (required for schedule and set-deadline commands)").option("--dry-run","Preview changes without modifying files").option("--format <type>","Output format: text|json (default: text)","text").action(async(n,e,t)=>{let r=t.format||"text";K.setFormat(r);try{let i=(0,YT.resolve)(t.vault),s=new rd(i,t.dryRun);switch(n){case"rename-to-uid":await s.executeRenameToUid(e),tr(r,n,e,"Renamed file to UID-based name");break;case"update-label":t.label||ma(r,"label","update-label",'exocortex command update-label <filepath> --label "<value>"'),await s.executeUpdateLabel(e,t.label),tr(r,n,e,`Updated label to "${t.label}"`,{label:t.label});break;case"start":await s.executeStart(e),tr(r,n,e,"Started task");break;case"complete":await s.executeComplete(e),tr(r,n,e,"Completed task");break;case"trash":await s.executeTrash(e),tr(r,n,e,"Moved task to trash");break;case"archive":await s.executeArchive(e),tr(r,n,e,"Archived task");break;case"move-to-backlog":await s.executeMoveToBacklog(e),tr(r,n,e,"Moved task to backlog");break;case"move-to-analysis":await s.executeMoveToAnalysis(e),tr(r,n,e,"Moved task to analysis");break;case"move-to-todo":await s.executeMoveToToDo(e),tr(r,n,e,"Moved task to todo");break;case"create-task":t.label||ma(r,"label","create-task",'exocortex command create-task <filepath> --label "<value>"'),await s.executeCreateTask(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created task "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-meeting":t.label||ma(r,"label","create-meeting",'exocortex command create-meeting <filepath> --label "<value>"'),await s.executeCreateMeeting(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created meeting "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-project":t.label||ma(r,"label","create-project",'exocortex command create-project <filepath> --label "<value>"'),await s.executeCreateProject(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created project "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"create-area":t.label||ma(r,"label","create-area",'exocortex command create-area <filepath> --label "<value>"'),await s.executeCreateArea(e,t.label,{prototype:t.prototype,area:t.area,parent:t.parent}),tr(r,n,e,`Created area "${t.label}"`,{label:t.label,prototype:t.prototype,area:t.area,parent:t.parent});break;case"schedule":t.date||ma(r,"date","schedule",'exocortex command schedule <filepath> --date "YYYY-MM-DD"'),await s.executeSchedule(e,t.date),tr(r,n,e,`Scheduled task for ${t.date}`,{date:t.date});break;case"set-deadline":t.date||ma(r,"date","set-deadline",'exocortex command set-deadline <filepath> --date "YYYY-MM-DD"'),await s.executeSetDeadline(e,t.date),tr(r,n,e,`Set deadline to ${t.date}`,{date:t.date});break;case"repair-folder":{let a=await s.executeRepairFolder(e);tr(r,n,e,a.moved?`Moved to correct folder: ${a.newPath}`:"Already in correct folder",{moved:a.moved,oldPath:a.oldPath,newPath:a.newPath,expectedFolder:a.expectedFolder});break}default:await s.execute(n,e,t),tr(r,n,e,`Executed ${n}`);break}}catch(i){K.handle(i)}})}o(KT,"commandCommand");var JT=require("path");var Ui=Ne(require("fs")),I1=Ne(require("path")),XT=require("events");var GM={watch:Ui.default.watch.bind(Ui.default),existsSync:Ui.default.existsSync.bind(Ui.default),statSync:Ui.default.statSync.bind(Ui.default),readFileSync:Ui.default.readFileSync.bind(Ui.default)},nd=class extends XT.EventEmitter{constructor(t,r={}){super();this.watcher=null;this.debounceTimers=new Map;this.isRunning=!1;this.vaultPath=I1.default.resolve(t),this.fsAdapter=r.fsAdapter??GM,this.options={pattern:r.pattern??"**/*.md",assetType:r.assetType??"",debounceMs:r.debounceMs??100,recursive:r.recursive??!0}}static{o(this,"FileSystemWatcher")}start(){this.isRunning||(this.watcher=this.fsAdapter.watch(this.vaultPath,{recursive:this.options.recursive},(t,r)=>{r&&this.handleFileEvent(t,r.toString())}),this.watcher.on("error",t=>{this.emit("error",t)}),this.isRunning=!0,this.emit("started"))}stop(){if(this.isRunning){for(let t of this.debounceTimers.values())clearTimeout(t);this.debounceTimers.clear(),this.watcher&&(this.watcher.close(),this.watcher=null),this.isRunning=!1,this.emit("stopped")}}isWatching(){return this.isRunning}handleFileEvent(t,r){let i=I1.default.join(this.vaultPath,r),s=r;if(!this.matchesPattern(s))return;let a=this.debounceTimers.get(i);a&&clearTimeout(a);let c=setTimeout(()=>{this.debounceTimers.delete(i),this.processFileEvent(i,s)},this.options.debounceMs);this.debounceTimers.set(i,c)}processFileEvent(t,r){let i=this.fsAdapter.existsSync(t),s;if(!i)s="delete";else{let u=this.fsAdapter.statSync(t);s=Date.now()-u.birthtimeMs<1e3?"create":"modify"}let a;if(i&&t.endsWith(".md")&&(a=this.extractAssetType(t)),this.options.assetType&&a!==this.options.assetType)return;let c={type:s,path:t,relativePath:r,timestamp:new Date().toISOString(),assetType:a};this.emit("change",c)}matchesPattern(t){return this.options.pattern?Zt(t,this.options.pattern):!0}extractAssetType(t){try{let i=this.fsAdapter.readFileSync(t,"utf-8").match(/^---\n([\s\S]*?)\n---/);if(!i)return;let a=i[1].match(/exo__Instance_class:\s*(?:\[?"?\[\[([^\]]+)\]\]"?\]?|"?\[\[([^\]]+)\]\]"?)/);return a?a[1]||a[2]:void 0}catch{return}}};var O1=Ne(require("fs"));function ZT(){return new Lt("watch").description("Watch vault for file changes and emit NDJSON events").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--pattern <glob>","Glob pattern to filter files (e.g., '*.md', 'tasks/**')").option("--asset-type <type>","Filter by asset type (e.g., 'ems__Task', 'ems__Project')").option("--debounce <ms>","Debounce interval in milliseconds","100").action(async n=>{K.setFormat("json");try{let e=(0,JT.resolve)(n.vault);if(!O1.default.existsSync(e))throw new Xt(e);if(!O1.default.statSync(e).isDirectory())throw new rt(`Vault path is not a directory: ${e}`,"Provide a path to a directory, not a file",{vaultPath:e});let t=parseInt(n.debounce?.toString()??"100",10);if(isNaN(t)||t<0)throw new rt("--debounce must be a non-negative integer","Use a positive integer value for debounce",{debounce:n.debounce});let r=new nd(e,{pattern:n.pattern,assetType:n.assetType,debounceMs:t});r.on("change",s=>{console.log(JSON.stringify(s))}),r.on("error",s=>{let a=Ye.error("INTERNAL_OPERATION_FAILED",s.message,5,{recovery:{message:"Check file permissions and vault access",suggestion:"Ensure the vault directory is accessible"}});console.log(JSON.stringify(a))});let i=o(()=>{r.stop(),process.exit(0)},"shutdown");process.on("SIGINT",i),process.on("SIGTERM",i),console.error(`Watching vault: ${e}`),n.pattern&&console.error(` Pattern filter: ${n.pattern}`),n.assetType&&console.error(` Asset type filter: ${n.assetType}`),console.error(` Debounce: ${t}ms`),console.error("Press Ctrl+C to stop"),r.start()}catch(e){K.handle(e)}})}o(ZT,"watchCommand");var D1=require("path"),R1=Ne(Eo());var ga=Ne(require("path"));var qo=Ne($n());var Hn=Ne(Eo()),P1=Ne(require("crypto"));var id=class{constructor(){this.backups=new Map;this.fileHashes=new Map}static{o(this,"TransactionManager")}async begin(e){if(!Hn.default.existsSync(e))throw new Error(`Cannot backup non-existent file: ${e}`);let t=await Hn.default.readFile(e,"utf-8"),r=P1.default.createHash("sha256").update(t).digest("hex");this.fileHashes.set(e,r);let i=`${e}.backup.${Date.now()}`;await Hn.default.writeFile(i,t,"utf-8"),this.backups.set(e,i)}async verify(e){let t=this.fileHashes.get(e);if(!t)return!0;if(!Hn.default.existsSync(e))return!1;let r=await Hn.default.readFile(e,"utf-8");return P1.default.createHash("sha256").update(r).digest("hex")===t}async commit(){for(let e of this.backups.values())Hn.default.existsSync(e)&&await Hn.default.remove(e);this.backups.clear(),this.fileHashes.clear()}async rollback(){for(let[e,t]of this.backups.entries())Hn.default.existsSync(t)&&(await Hn.default.copy(t,e,{overwrite:!0}),await Hn.default.remove(t));this.backups.clear(),this.fileHashes.clear()}getTrackedFiles(){return Array.from(this.backups.keys())}};var ya=class{static{o(this,"BatchExecutor")}constructor(e,t=!1){this.pathResolver=new Uo(e),this.fsAdapter=new Ss(e),this.frontmatterService=new qo.FrontmatterService,this.transactionManager=new id,this.dryRun=t}async executeBatch(e,t=!1){let r=Date.now(),i=[],s=0,a=0;if(e.length===0)return{success:!0,total:0,succeeded:0,failed:0,results:[],durationMs:Date.now()-r,atomic:t};if(t&&!this.dryRun)try{await this.backupAllFiles(e)}catch(u){return{success:!1,total:e.length,succeeded:0,failed:e.length,results:e.map(l=>({success:!1,command:l.command,filepath:l.filepath,error:`Backup failed: ${u.message}`})),durationMs:Date.now()-r,atomic:t}}for(let u of e){let l=await this.executeSingleOperation(u);if(i.push(l),l.success)s++;else if(a++,t&&!this.dryRun){await this.transactionManager.rollback();let f=i.length;for(let h=f;h<e.length;h++)i.push({success:!1,command:e[h].command,filepath:e[h].filepath,error:"Not executed due to atomic rollback"}),a++;return{success:!1,total:e.length,succeeded:0,failed:e.length,results:i,durationMs:Date.now()-r,atomic:t,rolledBack:!0}}}return t&&!this.dryRun&&await this.transactionManager.commit(),{success:a===0,total:e.length,succeeded:s,failed:a,results:i,durationMs:Date.now()-r,atomic:t,...t&&{rolledBack:!1}}}static parseInput(e){try{let t=JSON.parse(e);if(!Array.isArray(t))throw new rt("Batch input must be a JSON array of operations",`exo batch --input '[{"command":"start","filepath":"task.md"}]'`);for(let r of t){if(!r.command||typeof r.command!="string")throw new rt('Each operation must have a "command" string property','{"command":"start","filepath":"task.md"}');if(!r.filepath||typeof r.filepath!="string")throw new rt('Each operation must have a "filepath" string property','{"command":"start","filepath":"task.md"}')}return t}catch(t){throw t instanceof rt?t:new rt(`Failed to parse batch input: ${t.message}`,`exo batch --input '[{"command":"start","filepath":"task.md"}]'`)}}async backupAllFiles(e){let t=new Set;for(let r of e){let i=this.pathResolver.resolve(r.filepath);t.add(i)}for(let r of t)await this.transactionManager.begin(r)}async executeSingleOperation(e){try{let t=this.pathResolver.resolve(e.filepath);this.pathResolver.validate(t);let r=t.replace(this.pathResolver.getVaultRoot()+"/","");if(await this.fsAdapter.readFile(r),this.dryRun)return{success:!0,command:e.command,filepath:e.filepath,action:`Would execute ${e.command} (dry-run)`};switch(e.command){case"start":return await this.executeStart(r,e);case"complete":return await this.executeComplete(r,e);case"trash":return await this.executeTrash(r,e);case"archive":return await this.executeArchive(r,e);case"move-to-backlog":return await this.executeStatusUpdate(r,e,"ems__EffortStatusBacklog","Moved to backlog");case"move-to-analysis":return await this.executeStatusUpdate(r,e,"ems__EffortStatusAnalysis","Moved to analysis");case"move-to-todo":return await this.executeStatusUpdate(r,e,"ems__EffortStatusToDo","Moved to todo");case"update-label":return await this.executeUpdateLabel(r,e);case"schedule":return await this.executeSchedule(r,e);case"set-deadline":return await this.executeSetDeadline(r,e);case"repair-folder":return await this.executeRepairFolder(r,e);default:return{success:!1,command:e.command,filepath:e.filepath,error:`Unknown command: ${e.command}`}}}catch(t){return{success:!1,command:e.command,filepath:e.filepath,error:t.message}}}getCurrentTimestamp(){return qo.DateFormatter.toLocalTimestamp(new Date)}async executeStart(e,t){let r=await this.fsAdapter.readFile(e),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDoing]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_startTimestamp",i),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Started task",changes:{status:"Doing",startTimestamp:i}}}async executeComplete(e,t){let r=await this.fsAdapter.readFile(e),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusDone]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_endTimestamp",i),s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Completed task",changes:{status:"Done",endTimestamp:i,resolutionTimestamp:i}}}async executeTrash(e,t){let r=await this.fsAdapter.readFile(e),i=this.getCurrentTimestamp(),s=this.frontmatterService.updateProperty(r,"ems__Effort_status",'"[[ems__EffortStatusTrashed]]"');return s=this.frontmatterService.updateProperty(s,"ems__Effort_resolutionTimestamp",i),await this.fsAdapter.updateFile(e,s),{success:!0,command:t.command,filepath:t.filepath,action:"Trashed task",changes:{status:"Trashed",resolutionTimestamp:i}}}async executeArchive(e,t){let r=await this.fsAdapter.readFile(e),i=this.frontmatterService.updateProperty(r,"archived","true");return i=this.frontmatterService.removeProperty(i,"aliases"),await this.fsAdapter.updateFile(e,i),{success:!0,command:t.command,filepath:t.filepath,action:"Archived task",changes:{archived:!0,aliasesRemoved:!0}}}async executeStatusUpdate(e,t,r,i){let s=await this.fsAdapter.readFile(e),a=this.frontmatterService.updateProperty(s,"ems__Effort_status",`"[[${r}]]"`);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:i,changes:{status:r.replace("ems__EffortStatus","")}}}async executeUpdateLabel(e,t){let r=t.options?.label;if(!r||r.trim()==="")return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "label"'};let i=r.trim(),s=await this.fsAdapter.readFile(e),a=this.frontmatterService.updateProperty(s,"exo__Asset_label",`"${i}"`);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Updated label to "${i}"`,changes:{label:i}}}async executeSchedule(e,t){let r=t.options?.date;if(!r)return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "date"'};if(!/^\d{4}-\d{2}-\d{2}$/.test(r))return{success:!1,command:t.command,filepath:t.filepath,error:`Invalid date format: ${r}. Expected YYYY-MM-DD`};let i=await this.fsAdapter.readFile(e),s=qo.DateFormatter.toTimestampAtStartOfDay(r),a=this.frontmatterService.updateProperty(i,"ems__Effort_scheduledTimestamp",s);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Scheduled for ${r}`,changes:{scheduledTimestamp:s}}}async executeSetDeadline(e,t){let r=t.options?.date;if(!r)return{success:!1,command:t.command,filepath:t.filepath,error:'Missing required option: "date"'};if(!/^\d{4}-\d{2}-\d{2}$/.test(r))return{success:!1,command:t.command,filepath:t.filepath,error:`Invalid date format: ${r}. Expected YYYY-MM-DD`};let i=await this.fsAdapter.readFile(e),s=qo.DateFormatter.toTimestampAtStartOfDay(r),a=this.frontmatterService.updateProperty(i,"ems__Effort_deadlineTimestamp",s);return await this.fsAdapter.updateFile(e,a),{success:!0,command:t.command,filepath:t.filepath,action:`Set deadline to ${r}`,changes:{deadlineTimestamp:s}}}async executeRepairFolder(e,t){let i=(await this.fsAdapter.getFileMetadata(e))?.exo__Asset_isDefinedBy;if(!i)return{success:!1,command:t.command,filepath:t.filepath,error:"Cannot determine expected folder: missing exo__Asset_isDefinedBy"};let s=this.extractReference(i);if(!s)return{success:!1,command:t.command,filepath:t.filepath,error:"Cannot determine expected folder: invalid exo__Asset_isDefinedBy format"};let a=await this.findReferencedFile(s,e);if(!a)return{success:!1,command:t.command,filepath:t.filepath,error:`Cannot determine expected folder: referenced asset not found: ${s}`};let c=ga.default.dirname(a),u=c==="."?"":c,l=ga.default.dirname(e),f=l==="."?"":l;if(this.normalizePath(f)===this.normalizePath(u))return{success:!0,command:t.command,filepath:t.filepath,action:"Already in correct folder",changes:{moved:!1,folder:u||"(root)"}};let h=ga.default.basename(e),d=u?`${u}/${h}`:h;return await this.fsAdapter.fileExists(d)?{success:!1,command:t.command,filepath:t.filepath,error:`Cannot move file: ${d} already exists`}:(await this.fsAdapter.renameFile(e,d),{success:!0,command:t.command,filepath:t.filepath,action:`Moved to ${u||"(root)"}`,changes:{moved:!0,oldPath:e,newPath:d,expectedFolder:u||"(root)"}})}extractReference(e){if(typeof e!="string")return null;let t=e.trim().replace(/^["']|["']$/g,"");return t=t.replace(/^\[\[|\]\]$/g,""),t||null}async findReferencedFile(e,t){let r=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await this.fsAdapter.fileExists(r))return r;let i=ga.default.dirname(t),s=i!=="."?`${i}/${r}`:r;if(await this.fsAdapter.fileExists(s))return s;let c=await this.fsAdapter.findFileByUID(e);return c||(await this.fsAdapter.getMarkdownFiles()).find(f=>{let h=ga.default.basename(f,".md"),d=ga.default.basename(r,".md");return h===d})||null}normalizePath(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}};function WM(n,e){if(n==="json"){let t=Ye.success(e,{durationMs:e.durationMs,itemCount:e.total});console.log(JSON.stringify(t,null,2))}else{if(console.log(`
|
|
432
432
|
\u{1F4E6} Batch Execution ${e.success?"Complete":"Failed"}`),console.log(` Total: ${e.total} operations`),console.log(` \u2705 Succeeded: ${e.succeeded}`),console.log(` \u274C Failed: ${e.failed}`),console.log(` \u23F1\uFE0F Duration: ${e.durationMs}ms`),e.atomic&&console.log(` \u{1F512} Atomic mode: ${e.rolledBack?"Rolled back":"Committed"}`),e.failed>0){console.log(`
|
|
433
433
|
\u{1F4CB} Failed Operations:`);for(let t of e.results.filter(r=>!r.success))console.log(` \u274C ${t.command} ${t.filepath}: ${t.error}`)}if(e.succeeded>0&&n==="text"){console.log(`
|
|
434
|
-
\u{1F4CB} Successful Operations:`);for(let t of e.results.filter(r=>r.success))console.log(` \u2705 ${t.command} ${t.filepath}: ${t.action}`)}}}o(
|
|
434
|
+
\u{1F4CB} Successful Operations:`);for(let t of e.results.filter(r=>r.success))console.log(` \u2705 ${t.command} ${t.filepath}: ${t.action}`)}}}o(WM,"outputResult");function eA(){return new Lt("batch").description("Execute multiple operations in a single CLI invocation").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>","JSON array of operations to execute").option("--file <path>","Path to JSON file containing operations").option("--atomic","All-or-nothing execution (rollback on any failure)").option("--dry-run","Preview changes without modifying files").option("--format <type>","Output format: text|json (default: text)","text").action(async n=>{let e=n.format||"text";K.setFormat(e);try{let t=(0,D1.resolve)(n.vault),r;if(n.input)r=n.input;else if(n.file){let c=(0,D1.resolve)(n.file);if(!R1.default.existsSync(c))throw new rt(`Batch file not found: ${c}`,"exocortex batch --file operations.json");r=await R1.default.readFile(c,"utf-8")}else throw new rt("Either --input or --file option is required",`exocortex batch --input '[{"command":"start","filepath":"task.md"}]' or exocortex batch --file operations.json`);let i=ya.parseInput(r);if(i.length===0)throw new rt("Batch input contains no operations",`exocortex batch --input '[{"command":"start","filepath":"task.md"}]'`);let a=await new ya(t,n.dryRun).executeBatch(i,n.atomic);WM(e,a),process.exit(a.success?0:5)}catch(t){K.handle(t)}})}o(eA,"batchCommand");var tA=require("path");function HM(n,e){if(n==="json"){let t=Ye.success(e,{durationMs:e.durationMs,itemCount:e.total});console.log(JSON.stringify(t,null,2))}else{if(console.log(`
|
|
435
435
|
\u{1F4E6} Batch Repair ${e.success?"Complete":"Completed with Errors"}`),console.log(` Total files: ${e.total}`),console.log(` \u{1F4C1} Moved: ${e.movedCount}`),console.log(` \u2705 Already correct: ${e.alreadyCorrectCount}`),console.log(` \u274C Errors: ${e.errorCount}`),console.log(` \u23F1\uFE0F Duration: ${e.durationMs}ms`),e.errorCount>0){console.log(`
|
|
436
436
|
\u{1F4CB} Failed Files:`);for(let t of e.results.filter(r=>!r.success))console.log(` \u274C ${t.filepath}: ${t.error}`)}if(e.movedCount>0&&n==="text"){console.log(`
|
|
437
|
-
\u{1F4CB} Moved Files:`);for(let t of e.results.filter(r=>r.success&&r.changes?.moved))console.log(` \u{1F4C1} ${t.filepath} \u2192 ${t.changes?.newPath}`)}}}o(
|
|
437
|
+
\u{1F4CB} Moved Files:`);for(let t of e.results.filter(r=>r.success&&r.changes?.moved))console.log(` \u{1F4C1} ${t.filepath} \u2192 ${t.changes?.newPath}`)}}}o(HM,"outputResult");function rA(){return new Lt("batch-repair").description("Batch repair folder locations for all markdown files in a directory").argument("<directory>","Directory to process (relative to vault root)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--dry-run","Preview changes without modifying files").option("--format <type>","Output format: text|json (default: text)","text").option("--progress","Show progress during processing (default: true)",!0).option("--no-progress","Disable progress output").action(async(n,e)=>{let t=e.format||"text";K.setFormat(t);try{let r=(0,tA.resolve)(e.vault),i=new Ss(r),s=n;if(!await i.directoryExists(s))throw new rt(`Directory not found: ${s}`,"exocortex batch-repair <existing-directory>");let c=await i.getMarkdownFiles(s);if(c.length===0){if(t==="json"){let I=Ye.success({success:!0,total:0,movedCount:0,alreadyCorrectCount:0,errorCount:0,results:[],durationMs:0,atomic:!1});console.log(JSON.stringify(I,null,2))}else console.log(`
|
|
438
438
|
\u{1F4C2} No markdown files found in ${s}`);process.exit(0)}let u=c.map(I=>({command:"repair-folder",filepath:I})),l=e.progress!==!1&&t==="text",f=0;l&&console.log(`
|
|
439
|
-
\u{1F50D} Processing ${c.length} files in ${s}...`);let d=await new ya(r,e.dryRun).executeBatch(u,!1),p=0,S=0,b=0;for(let I of d.results)if(I.success?I.changes?.moved?p++:S++:b++,l&&!e.dryRun){f++;let O=Math.round(f/c.length*100);process.stdout.write(`\r Processing ${f}/${c.length} (${O}%)...`)}l&&process.stdout.write("\r"+" ".repeat(60)+"\r");let T={...d,movedCount:p,alreadyCorrectCount:S,errorCount:b};
|
|
439
|
+
\u{1F50D} Processing ${c.length} files in ${s}...`);let d=await new ya(r,e.dryRun).executeBatch(u,!1),p=0,S=0,b=0;for(let I of d.results)if(I.success?I.changes?.moved?p++:S++:b++,l&&!e.dryRun){f++;let O=Math.round(f/c.length*100);process.stdout.write(`\r Processing ${f}/${c.length} (${O}%)...`)}l&&process.stdout.write("\r"+" ".repeat(60)+"\r");let T={...d,movedCount:p,alreadyCorrectCount:S,errorCount:b};HM(t,T),process.exit(T.success?0:5)}catch(r){K.handle(r)}})}o(rA,"batchRepairCommand");var sd=require("fs"),zn=require("path");function nA(){return new Lt("resolve").description("Resolve UUID to file path").argument("<uuid>","Full or partial UUID to resolve").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: uri|path|json (default: uri)","uri").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--partial","Match partial UUIDs (returns all matches)").action(async(n,e)=>{let t=e.output||"text";K.setFormat(t);try{let r=Date.now();if(!zM(n))throw new rt(`Invalid UUID format: ${n}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:n});let i=(0,zn.resolve)(e.vault);if(!(0,sd.existsSync)(i))throw new Xt(i);let s=QM(i,n,e.partial??!1),a=Date.now()-r;if(s.length===0){if(t==="json"){let c=Ye.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${n}`,3,{context:{uuid:n}});console.log(JSON.stringify(c,null,2))}else console.error(`UUID not found: ${n}`);process.exit(1)}e.partial||s.length>1?KM(s,i,e.format,t,n,a):YM(s[0],i,e.format,t,n,a)}catch(r){K.handle(r)}})}o(nA,"resolveCommand");function zM(n){if(n.length<4)return!1;let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,t=/^[0-9a-f-]+$/i;return e.test(n)||t.test(n)}o(zM,"isValidUuidFormat");function QM(n,e,t){let r=[],i=e.toLowerCase();function s(a){let c=(0,sd.readdirSync)(a,{withFileTypes:!0});for(let u of c){let l=(0,zn.join)(a,u.name);if(u.isDirectory())!u.name.startsWith(".")&&u.name!=="node_modules"&&s(l);else if(u.isFile()&&u.name.endsWith(".md")){let f=u.name.toLowerCase();t?f.includes(i)&&r.push(l):(f.startsWith(i+".md")||f.startsWith(i+" ")||f.startsWith(i+"-"))&&r.push(l)}}}return o(s,"walk"),s(n),r}o(QM,"findFilesWithUuid");function iA(n){return`obsidian://vault/${encodeURI(n)}`}o(iA,"pathToObsidianUri");function sA(n){let e=n.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);return e?e[1]:(0,zn.basename)(n,".md")}o(sA,"extractUuidFromFilename");function YM(n,e,t,r,i,s){let a=(0,zn.relative)(e,n),c=iA(a),u=sA((0,zn.basename)(n));if(r==="json"){let l={uuid:u,path:a,absolutePath:n,uri:c},f=Ye.success(l,{durationMs:s,searchUuid:i});console.log(JSON.stringify(f,null,2))}else switch(t){case"path":console.log(n);break;case"json":console.log(JSON.stringify({uuid:u,path:a,absolutePath:n,uri:c},null,2));break;case"uri":default:console.log(c);break}}o(YM,"outputSingleResult");function KM(n,e,t,r,i,s){let a=n.map(c=>{let u=(0,zn.relative)(e,c),l=iA(u);return{uuid:sA((0,zn.basename)(c)),path:u,absolutePath:c,uri:l}});if(r==="json"){let c=Ye.success({matches:a,count:a.length},{durationMs:s,searchUuid:i,itemCount:a.length});console.log(JSON.stringify(c,null,2))}else switch(t){case"path":for(let c of a)console.log(c.absolutePath);break;case"json":console.log(JSON.stringify(a,null,2));break;case"uri":default:for(let c of a)console.log(c.uri);break}}o(KM,"outputMultipleResults");var aA=require("fs"),oA=require("path"),jr=Ne($n());function cA(){return new Lt("ask").description("Ask a question in natural language about your vault").argument("<question>","Question in natural language (Russian or English)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--show-query","Show the generated SPARQL query").option("--explain","Show explanation of the query conversion").action(async(n,e)=>{let t=e.output||"text";K.setFormat(t);try{let r=Date.now(),i=(0,oA.resolve)(e.vault);if(!(0,aA.existsSync)(i))throw new Xt(i);let s=new jr.NLToSPARQLService;t==="text"&&console.log(`\u{1F9E0} Analyzing question: "${n}"
|
|
440
440
|
`);let a=s.convert(n);e.showQuery&&t==="text"&&(console.log("\u{1F4DD} Generated SPARQL Query:"),console.log("\u2500".repeat(50)),console.log(a.query),console.log("\u2500".repeat(50)),console.log()),e.explain&&t==="text"&&(console.log(`\u{1F4D6} Explanation: ${a.explanation}`),console.log(`\u{1F3AF} Confidence: ${(a.confidence*100).toFixed(0)}%`),a.templateName&&console.log(`\u{1F4CB} Template: ${a.templateName}`),a.isFallback&&console.log("\u26A0\uFE0F Using fallback generic search query"),console.log()),t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let c=Date.now(),u=new ds(i),f=await new jr.NoteToRDFConverter(u).convertVault(),h=new jr.InMemoryTripleStore;await h.addAll(f);let d=Date.now()-c;t==="text"&&console.log(`\u2705 Loaded ${f.length} triples in ${d}ms
|
|
441
441
|
`);let S=new jr.SPARQLParser().parse(a.query),T=new jr.AlgebraTranslator().translate(S);T=new jr.AlgebraOptimizer().optimize(T);let O=Date.now(),M=await new jr.QueryExecutor(h).executeAll(T),G=Date.now()-O,Ee=Date.now()-r,je=s.getSuggestions(n);if(t==="json"){let Me=M.map(Se=>Se.toJSON()),q={question:n,query:a.query,template:a.templateName,parameters:a.parameters,confidence:a.confidence,explanation:a.explanation,count:M.length,bindings:Me,suggestions:je.length>0?je:void 0},ie=Ye.success(q,{durationMs:Ee,itemCount:M.length,loadDurationMs:d,execDurationMs:G,triplesScanned:f.length});console.log(JSON.stringify(ie,null,2))}else{if(console.log(`\u2705 Found ${M.length} result(s) in ${G}ms
|
|
442
|
-
`),M.length>0?
|
|
442
|
+
`),M.length>0?XM(M,e.format):console.log("No results found."),je.length>0){console.log(`
|
|
443
443
|
\u{1F4A1} Suggestions:`);for(let Me of je)console.log(` \u2022 ${Me}`)}if(a.confidence<.6&&a.alternatives.length>0){console.log(`
|
|
444
444
|
\u{1F504} Alternative queries that might work better:`);for(let Me=0;Me<Math.min(2,a.alternatives.length);Me++)console.log(` ${Me+1}. ${a.alternatives[Me].split(`
|
|
445
|
-
`).slice(-3)[0]?.trim()||"..."}`)}}}catch(r){K.handle(r)}})}o(
|
|
445
|
+
`).slice(-3)[0]?.trim()||"..."}`)}}}catch(r){K.handle(r)}})}o(cA,"askCommand");function XM(n,e){let t=n;switch(e){case"json":let r=new Oo;console.log(r.format(t));break;case"table":default:let i=new Io;console.log(i.format(t));break}}o(XM,"formatResults");var Wo=require("path"),Ho=require("fs"),va=Ne(Le()),bs=Ne($n());var cJ=Ne(Qu()),Go=Ne(Le()),Tu=Ne($n());var ad=class{constructor(e="exocortex-cli"){this.appName=e}static{o(this,"NodeLogger")}debug(e,t){console.debug(`[${this.appName}]`,e,t||"")}info(e,t){console.info(`[${this.appName}]`,e,t||"")}warn(e,t){console.warn(`[${this.appName}]`,e,t||"")}error(e,t,r){console.error(`[${this.appName}]`,e,t||"",r||""),t?.stack&&console.error(t.stack)}};var od=class{constructor(){this.handlers=new Map}static{o(this,"NodeEventBus")}publish(e,t){let r=this.handlers.get(e);r&&r.forEach(i=>{try{i(t)}catch(s){console.error(`[EventBus] Error in handler for event "${e}":`,s)}})}subscribe(e,t){return this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let r=this.handlers.get(e);r&&(r.delete(t),r.size===0&&this.handlers.delete(e))}};var ud=Ne(require("fs/promises")),uA=Ne(require("path")),lA=Ne(require("os"));var cd=class{constructor(e=".exocortexrc"){this.config={};this.configPath=uA.join(lA.homedir(),e)}static{o(this,"NodeConfiguration")}async load(){try{let e=await ud.readFile(this.configPath,"utf-8");this.config=JSON.parse(e)}catch{this.config={}}}get(e){let t=e.split("."),r=this.config;for(let i of t)if(r&&typeof r=="object"&&i in r)r=r[i];else return;return r}async set(e,t){let r=e.split("."),i=r.pop(),s=this.config;for(let a of r)(!s[a]||typeof s[a]!="object")&&(s[a]={}),s=s[a];s[i]=t,await this.save()}getAll(){return{...this.config}}async save(){await ud.writeFile(this.configPath,JSON.stringify(this.config,null,2),"utf-8")}};var fA=Ne(require("readline"));var ld=class{static{o(this,"NodeNotificationService")}info(e,t){console.log(`\u2139 ${e}`)}success(e,t){console.log(`\u2713 ${e}`)}error(e,t){console.error(`\u2717 ${e}`)}warn(e,t){console.warn(`\u26A0 ${e}`)}async confirm(e,t){let r=fA.createInterface({input:process.stdin,output:process.stdout});return new Promise(i=>{r.question(`${e}
|
|
446
446
|
${t}
|
|
447
|
-
Continue? (y/n): `,s=>{r.close(),i(s.toLowerCase()==="y"||s.toLowerCase()==="yes")})})}};var
|
|
448
|
-
`)}o(
|
|
449
|
-
`)}o(
|
|
447
|
+
Continue? (y/n): `,s=>{r.close(),i(s.toLowerCase()==="y"||s.toLowerCase()==="yes")})})}};var fd=class{static{o(this,"CLIContainer")}static setup(){Go.container.register(Tu.DI_TOKENS.ILogger,{useFactory:o(()=>new ad("exocortex-cli"),"useFactory")}),Go.container.register(Tu.DI_TOKENS.IEventBus,{useClass:od}),Go.container.register(Tu.DI_TOKENS.IConfiguration,{useClass:cd}),Go.container.register(Tu.DI_TOKENS.INotificationService,{useClass:ld})}static reset(){Go.container.clearInstances()}};function Au(n){fd.setup(),va.container.register(bs.DI_TOKENS.IVaultAdapter,{useFactory:o(()=>new ds(n),"useFactory")})}o(Au,"setupContainer");function JM(n){if(n.length===0)return"No practices found.";let e=[];for(let t of n){let r="\u2B1C";t.doneToday?r="\u2705":t.inProgressToday&&(r="\u{1F504}");let i=t.estimatedDuration?` (${t.estimatedDuration}m)`:"";e.push(`${r} ${t.label}${i}`)}return e.join(`
|
|
448
|
+
`)}o(JM,"formatPractices");function ZM(n){let e=[`\u{1F4C5} Daily Review: ${n.date}`,"","\u{1F4CA} Tasks:",` Planned: ${n.plannedCount}`,` Completed: ${n.completedCount}`,` In Progress: ${n.inProgressCount}`,` Progress: ${n.completionPercentage}%`,"",`\u23F1\uFE0F Total time: ${Math.round(n.totalTimeMinutes)} minutes`];if(n.practicesDue.length>0){e.push(""),e.push(`\u{1F4CB} Practices due (${n.practicesDue.length}):`);for(let t of n.practicesDue){let r=t.estimatedDuration?` (${t.estimatedDuration}m)`:"";e.push(` \u2B1C ${t.label}${r}`)}}return e.join(`
|
|
449
|
+
`)}o(ZM,"formatSummary");function hA(){let n=new Lt("daily").description("Daily review operations for mobile-friendly workflow");return n.command("practices").description("List today's practices (recurring tasks)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: text|json","text").action(async e=>{let t=e.format||"text";K.setFormat(t);try{let r=(0,Wo.resolve)(e.vault);if(!(0,Ho.existsSync)(r))throw new Xt(r);Au(r);let s=await va.container.resolve(bs.DailyReviewService).getPractices();if(t==="json"){let a=Ye.success({practices:s,count:s.length});console.log(JSON.stringify(a,null,2))}else console.log(JM(s))}catch(r){K.handle(r)}}),n.command("summary").description("Show today's daily review summary").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: text|json","text").option("--date <value>","Date in YYYY-MM-DD format (default: today)").action(async e=>{let t=e.format||"text";K.setFormat(t);try{let r=(0,Wo.resolve)(e.vault);if(!(0,Ho.existsSync)(r))throw new Xt(r);Au(r);let i=va.container.resolve(bs.DailyReviewService),s;if(e.date&&(s=new Date(e.date),isNaN(s.getTime())))throw new rt(`Invalid date format: ${e.date}`,"exocortex daily summary --date YYYY-MM-DD",{date:e.date});let a=await i.getDailyReviewSummary(s);if(t==="json"){let c=Ye.success(a);console.log(JSON.stringify(c,null,2))}else console.log(ZM(a))}catch(r){K.handle(r)}}),n.command("log").description("Quick capture an activity").argument("<label>","Activity label/description").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: text|json","text").option("--start","Start the task immediately (default: true)").option("--no-start","Don't start the task immediately").action(async(e,t)=>{let r=t.format||"text";K.setFormat(r);try{let i=(0,Wo.resolve)(t.vault);if(!(0,Ho.existsSync)(i))throw new Xt(i);Au(i);let s=va.container.resolve(bs.DailyReviewService),a=t.start!==!1,c=await s.quickCapture(e,a);if(r==="json"){let u=Ye.success(c);console.log(JSON.stringify(u,null,2))}else{let u=c.started?"\u{1F504}":"\u2B1C";console.log(`${u} Created: ${c.label}`),console.log(` Path: ${c.path}`)}}catch(i){K.handle(i)}}),n.command("start").description("Start a practice (create task instance from prototype)").argument("<prototype-uid>","Practice/prototype UID to start").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: text|json","text").action(async(e,t)=>{let r=t.format||"text";K.setFormat(r);try{let i=(0,Wo.resolve)(t.vault);if(!(0,Ho.existsSync)(i))throw new Xt(i);Au(i);let a=await va.container.resolve(bs.DailyReviewService).createFromPractice({prototypeUid:e,startImmediately:!0});if(r==="json"){let c=Ye.success(a);console.log(JSON.stringify(c,null,2))}else console.log(`\u{1F504} Started: ${a.label}`),console.log(` Path: ${a.path}`)}catch(i){K.handle(i)}}),n.command("done").description("Mark a practice as done").argument("<prototype-uid>","Practice/prototype UID to mark as done").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: text|json","text").action(async(e,t)=>{let r=t.format||"text";K.setFormat(r);try{let i=(0,Wo.resolve)(t.vault);if(!(0,Ho.existsSync)(i))throw new Xt(i);if(Au(i),await va.container.resolve(bs.DailyReviewService).markPracticeDone(e),r==="json"){let a=Ye.success({prototypeUid:e,status:"done"});console.log(JSON.stringify(a,null,2))}else console.log(`\u2705 Marked as done: ${e}`)}catch(i){K.handle(i)}}),n}o(hA,"dailyReviewCommand");var gi=new Lt;gi.name("exocortex").description("CLI tool for Exocortex knowledge management system").version("13.272.0");gi.command("sparql").description("SPARQL query execution").addCommand(q3());gi.addCommand(KT());gi.addCommand(ZT());gi.addCommand(eA());gi.addCommand(rA());gi.addCommand(nA());gi.addCommand(cA());gi.addCommand(hA());gi.parse();
|
|
450
450
|
/*! Bundled license information:
|
|
451
451
|
|
|
452
452
|
reflect-metadata/Reflect.js:
|