@kitelev/exocortex-cli 15.96.2 → 15.98.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.
Files changed (2) hide show
  1. package/dist/index.js +8 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v15.96.2
2
+ // @kitelev/exocortex-cli v15.98.0
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -86,16 +86,16 @@ ${Object.entries(t).map(([a,c])=>this.serializeValue(a,c)).join(`
86
86
  ${r}`}return`${e}: ${String(t)}`}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};tp.FrontmatterService=Cu;Cu.FRONTMATTER_REGEX=/^---\n([\s\S]*?)\n---/;Cu.IRI_PREFIX_MAP={"https://exocortex.my/ontology/ems#":"ems__","https://exocortex.my/ontology/exo#":"exo__","https://exocortex.my/ontology/exocmd#":"exocmd__","https://exocortex.my/ontology/ims#":"ims__","https://exocortex.my/ontology/ztlk#":"ztlk__","https://exocortex.my/ontology/ptms#":"ptms__","https://exocortex.my/ontology/lit#":"lit__","https://exocortex.my/ontology/inbox#":"inbox__"}});var $r=v(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.DateFormatter=void 0;var Q1=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)}};rp.DateFormatter=Q1});var pa=v(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});np.LoggingService=void 0;var Iu=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?`
87
87
  Stack trace:
88
88
  ${t.stack}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`,t??"")}else{let a=t?.message?`
89
- Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`)}}};np.LoggingService=Iu;Iu.isVerbose=!1;Iu.isDevelopment=void 0});var n3=v(ti=>{"use strict";var IM=ti&&ti.__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},RM=ti&&ti.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(ti,"__esModule",{value:!0});ti.GroundingExecutor=ti.ServiceRegistry=void 0;var PM=ve(),OM=hn(),fo=ec(),DM=Hi(),FM=$r(),NM=pa(),ip=class{static{o(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};ti.ServiceRegistry=ip;var r3=20,Y1=class{static{o(this,"GroundingExecutor")}constructor(e,t,r){this.frontmatterService=new DM.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=r}async execute(e,t,r,i){try{switch(e.type){case fo.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,r);case fo.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,r);case fo.GroundingType.COMPOSITE:return await this.executeComposite(e,t,r,i,0);case fo.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,i);case fo.GroundingType.CREATE_INSTANCE:return await this.executeCreateInstance(e,t,i);case fo.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async executePropertySet(e,t,r){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};if(e.targetValue===void 0)return{success:!1,error:"property_set requires targetValue"};let i=this.substituteVariables(e.targetValue,t),s=await this.fileReader.readFile(r),a=this.frontmatterService.updateProperty(s,e.targetProperty,i);return await this.fileWriter.updateFile(r,a),{success:!0}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let r=await this.fileReader.readFile(t),i=this.frontmatterService.removeProperty(r,e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,r,i,s){if(s>=r3)return{success:!1,error:`Composite grounding exceeded maximum depth of ${r3}`};let a=e.steps??[];if(a.length===0)return{success:!0};let c;try{c=await this.fileReader.readFile(r)}catch{}let l=[];try{for(let u=0;u<a.length;u++){let f=a[u],d=await this.executeStep(f,t,r,i,s+1);if(!d.success)return await this.rollback(c,r,l),{success:!1,error:`Composite step ${u} failed: ${d.error}`};l.push(u)}return{success:!0}}catch(u){return await this.rollback(c,r,l),{success:!1,error:`Composite execution failed: ${u instanceof Error?u.message:String(u)}`}}}async executeServiceCall(e,t,r){let i=e.targetProperty;if(!i)return{success:!1,error:"service_call requires targetProperty as serviceId"};let s=this.serviceRegistry.get(i);if(!s)return{success:!1,error:`Service not found: "${i}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`};let a=r;if(e.targetValue)try{let c=JSON.parse(e.targetValue);typeof c=="object"&&c!==null&&(a={...c,...r??{}})}catch{}return await s.execute(t,a),{success:!0}}async executeCreateInstance(e,t,r){if(!e.targetFolder)return{success:!1,error:"create_instance requires targetFolder"};let i=(0,OM.v4)(),s=r?.label??"Untitled",a={exo__Asset_uid:i,exo__Asset_createdAt:new Date().toISOString(),exo__Asset_label:s};if(s!=="Untitled"&&(a.aliases=[s]),e.targetClass&&(a.exo__Instance_class=[`"[[${e.targetClass}]]"`]),e.targetPrototype&&(a.exo__Asset_prototype=`"[[${e.targetPrototype}]]"`),t&&(a.exo__Asset_source=`"[[${t}]]"`),r)for(let[u,f]of Object.entries(r))u!=="label"&&f!=null&&(a[u]=f);let c=this.frontmatterService.createFrontmatter("",a),l=`${e.targetFolder}/${i}.md`;return await this.fileWriter.createFile(l,c),{success:!0}}async executeStep(e,t,r,i,s){return e.type===fo.GroundingType.COMPOSITE?this.executeComposite(e,t,r,i,s):this.execute(e,t,r,i)}async rollback(e,t,r){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(i){NM.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,i instanceof Error?i:new Error(String(i)))}}substituteVariables(e,t){let r=new Date,i=r.toISOString(),s=FM.DateFormatter.toLocalTimestamp(r),a=i.slice(0,10);return e.replace(/\$target/g,t).replace(/\$nowLocal/g,s).replace(/\$now/g,i).replace(/\$today/g,a)}};ti.GroundingExecutor=Y1;ti.GroundingExecutor=Y1=IM([(0,PM.injectable)(),RM("design:paramtypes",[Object,Object,ip])],Y1)});var Ru=v(Os=>{"use strict";var LM=Os&&Os.__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},kM=Os&&Os.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Os,"__esModule",{value:!0});Os.WorkflowEngine=void 0;var MM=ve(),X1=class{static{o(this,"WorkflowEngine")}constructor(e){this.definition=e}getAvailableTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&!t.isRollback)}getRollbackTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&t.isRollback)}getAllTransitions(e){return this.definition.transitions.filter(t=>t.from===e)}canTransition(e,t){return this.definition.transitions.some(r=>r.from===e&&r.to===t)}getPreviousStatus(e){return this.definition.transitions.find(r=>r.from===e&&r.isRollback)?.to??null}getNextStates(e){return this.getAvailableTransitions(e).map(t=>t.to)}isTerminalState(e){return this.definition.terminalStates.includes(e)}isInitialState(e){return this.definition.initialState===e}getTimestampsForStatus(e){return this.definition.states.find(r=>r.status===e)?.timestampOnEnter??[]}getTransition(e,t){return this.definition.transitions.find(r=>r.from===e&&r.to===t)}getOrderedStates(){return this.definition.states.map(e=>e.status)}getDefinition(){return this.definition}validate(){let e=[],t=new Set(this.definition.states.map(i=>i.status));this.definition.states.length===0&&e.push("Workflow must have at least one state"),t.has(this.definition.initialState)||e.push(`Initial state "${this.definition.initialState}" is not in the states list`);for(let i of this.definition.terminalStates)t.has(i)||e.push(`Terminal state "${i}" is not in the states list`);for(let i of this.definition.transitions)t.has(i.from)||e.push(`Transition "${i.label}" references unknown source state "${i.from}"`),t.has(i.to)||e.push(`Transition "${i.label}" references unknown target state "${i.to}"`);for(let i of this.definition.states){if(this.definition.terminalStates.includes(i.status))continue;this.definition.transitions.filter(a=>a.from===i.status&&!a.isRollback).length===0&&e.push(`State "${i.status}" has no outgoing forward transitions (dead end)`)}let r=new Set;for(let i of this.definition.transitions){let s=`${i.from}\u2192${i.to}`;r.has(s)&&e.push(`Duplicate transition: ${s}`),r.add(s)}return{valid:e.length===0,errors:e}}};Os.WorkflowEngine=X1;Os.WorkflowEngine=X1=LM([(0,MM.injectable)(),kM("design:paramtypes",[Object])],X1)});var i3=v(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.EFFORT_WORKFLOW_PROPERTY=Qi.WorkflowTransitionProperty=Qi.WorkflowStateProperty=Qi.WorkflowProperty=void 0;Qi.WorkflowProperty={TARGET_CLASS:"ems__Workflow_targetClass",INITIAL_STATE:"ems__Workflow_initialState",TERMINAL_STATES:"ems__Workflow_terminalStates",IS_DEFAULT:"ems__Workflow_isDefault"};Qi.WorkflowStateProperty={WORKFLOW:"ems__WorkflowState_workflow",STATUS:"ems__WorkflowState_status",ORDER:"ems__WorkflowState_order",OPTIONAL:"ems__WorkflowState_optional",TIMESTAMP_ON_ENTER:"ems__WorkflowState_timestampOnEnter",BADGE_COLOR:"ems__WorkflowState_badgeColor"};Qi.WorkflowTransitionProperty={WORKFLOW:"ems__WorkflowTransition_workflow",FROM:"ems__WorkflowTransition_from",TO:"ems__WorkflowTransition_to",LABEL:"ems__WorkflowTransition_label",ICON:"ems__WorkflowTransition_icon",IS_ROLLBACK:"ems__WorkflowTransition_isRollback"};Qi.EFFORT_WORKFLOW_PROPERTY="ems__Effort_workflow"});var Yi=v(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});sp.MetadataHelpers=void 0;var K1=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(l=>` - ${l}`).join(`
90
- `);return`${s}:
91
- ${c}`}return`${s}: ${a}`}).join(`
92
- `),i=t?`
93
- ${t}
89
+ Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${a}`)}}};np.LoggingService=Iu;Iu.isVerbose=!1;Iu.isDevelopment=void 0});var n3=v(ti=>{"use strict";var IM=ti&&ti.__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},RM=ti&&ti.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(ti,"__esModule",{value:!0});ti.GroundingExecutor=ti.ServiceRegistry=void 0;var PM=ve(),OM=hn(),fo=ec(),DM=Hi(),FM=$r(),NM=pa(),ip=class{static{o(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};ti.ServiceRegistry=ip;var r3=20,Y1=class{static{o(this,"GroundingExecutor")}constructor(e,t,r){this.frontmatterService=new DM.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=r}async execute(e,t,r,i){try{switch(e.type){case fo.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,r);case fo.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,r);case fo.GroundingType.COMPOSITE:return await this.executeComposite(e,t,r,i,0);case fo.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,i);case fo.GroundingType.CREATE_INSTANCE:return await this.executeCreateInstance(e,t,i);case fo.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async executePropertySet(e,t,r){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};if(e.targetValue===void 0)return{success:!1,error:"property_set requires targetValue"};let i=this.substituteVariables(e.targetValue,t),s=await this.fileReader.readFile(r),a=this.frontmatterService.updateProperty(s,e.targetProperty,i);return await this.fileWriter.updateFile(r,a),{success:!0}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let r=await this.fileReader.readFile(t),i=this.frontmatterService.removeProperty(r,e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,r,i,s){if(s>=r3)return{success:!1,error:`Composite grounding exceeded maximum depth of ${r3}`};let a=e.steps??[];if(a.length===0)return{success:!0};let c;try{c=await this.fileReader.readFile(r)}catch{}let l=[];try{for(let u=0;u<a.length;u++){let f=a[u],d=await this.executeStep(f,t,r,i,s+1);if(!d.success)return await this.rollback(c,r,l),{success:!1,error:`Composite step ${u} failed: ${d.error}`};l.push(u)}return{success:!0}}catch(u){return await this.rollback(c,r,l),{success:!1,error:`Composite execution failed: ${u instanceof Error?u.message:String(u)}`}}}async executeServiceCall(e,t,r){let i=e.targetProperty;if(!i)return{success:!1,error:"service_call requires targetProperty as serviceId"};let s=this.serviceRegistry.get(i);if(!s)return{success:!1,error:`Service not found: "${i}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`};let a=r;if(e.targetValue)try{let c=JSON.parse(e.targetValue);typeof c=="object"&&c!==null&&(a={...c,...r??{}})}catch{}return await s.execute(t,a),{success:!0}}async executeCreateInstance(e,t,r){if(!e.targetFolder)return{success:!1,error:"create_instance requires targetFolder"};let i=(0,OM.v4)(),s=r?.label??"Untitled",a={exo__Asset_uid:i,exo__Asset_createdAt:new Date().toISOString(),exo__Asset_label:s};if(s!=="Untitled"&&(a.aliases=[s]),e.targetClass&&(a.exo__Instance_class=[`"[[${e.targetClass}]]"`]),e.targetPrototype&&(a.exo__Asset_prototype=`"[[${e.targetPrototype}]]"`),t&&(a.exo__Asset_source=`"[[${t}]]"`),r)for(let[u,f]of Object.entries(r))u!=="label"&&f!=null&&(a[u]=f);let c=this.frontmatterService.createFrontmatter("",a),l=`${e.targetFolder}/${i}.md`;return await this.fileWriter.createFile(l,c),{success:!0}}async executeStep(e,t,r,i,s){return e.type===fo.GroundingType.COMPOSITE?this.executeComposite(e,t,r,i,s):this.execute(e,t,r,i)}async rollback(e,t,r){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(i){NM.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,i instanceof Error?i:new Error(String(i)))}}substituteVariables(e,t){let r=new Date,i=r.toISOString(),s=FM.DateFormatter.toLocalTimestamp(r),a=i.slice(0,10);return e.replace(/\$target/g,t).replace(/\$nowLocal/g,s).replace(/\$now/g,i).replace(/\$today/g,a)}};ti.GroundingExecutor=Y1;ti.GroundingExecutor=Y1=IM([(0,PM.injectable)(),RM("design:paramtypes",[Object,Object,ip])],Y1)});var Ru=v(Os=>{"use strict";var LM=Os&&Os.__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},kM=Os&&Os.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Os,"__esModule",{value:!0});Os.WorkflowEngine=void 0;var MM=ve(),X1=class{static{o(this,"WorkflowEngine")}constructor(e){this.definition=e}getAvailableTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&!t.isRollback)}getRollbackTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&t.isRollback)}getAllTransitions(e){return this.definition.transitions.filter(t=>t.from===e)}canTransition(e,t){return this.definition.transitions.some(r=>r.from===e&&r.to===t)}getPreviousStatus(e){return this.definition.transitions.find(r=>r.from===e&&r.isRollback)?.to??null}getNextStates(e){return this.getAvailableTransitions(e).map(t=>t.to)}isTerminalState(e){return this.definition.terminalStates.includes(e)}isInitialState(e){return this.definition.initialState===e}getTimestampsForStatus(e){return this.definition.states.find(r=>r.status===e)?.timestampOnEnter??[]}getTransition(e,t){return this.definition.transitions.find(r=>r.from===e&&r.to===t)}getOrderedStates(){return this.definition.states.map(e=>e.status)}getDefinition(){return this.definition}validate(){let e=[],t=new Set(this.definition.states.map(i=>i.status));this.definition.states.length===0&&e.push("Workflow must have at least one state"),t.has(this.definition.initialState)||e.push(`Initial state "${this.definition.initialState}" is not in the states list`);for(let i of this.definition.terminalStates)t.has(i)||e.push(`Terminal state "${i}" is not in the states list`);for(let i of this.definition.transitions)t.has(i.from)||e.push(`Transition "${i.label}" references unknown source state "${i.from}"`),t.has(i.to)||e.push(`Transition "${i.label}" references unknown target state "${i.to}"`);for(let i of this.definition.states){if(this.definition.terminalStates.includes(i.status))continue;this.definition.transitions.filter(a=>a.from===i.status&&!a.isRollback).length===0&&e.push(`State "${i.status}" has no outgoing forward transitions (dead end)`)}let r=new Set;for(let i of this.definition.transitions){let s=`${i.from}\u2192${i.to}`;r.has(s)&&e.push(`Duplicate transition: ${s}`),r.add(s)}return{valid:e.length===0,errors:e}}};Os.WorkflowEngine=X1;Os.WorkflowEngine=X1=LM([(0,MM.injectable)(),kM("design:paramtypes",[Object])],X1)});var i3=v(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.EFFORT_WORKFLOW_PROPERTY=Qi.WorkflowTransitionProperty=Qi.WorkflowStateProperty=Qi.WorkflowProperty=void 0;Qi.WorkflowProperty={TARGET_CLASS:"ems__Workflow_targetClass",INITIAL_STATE:"ems__Workflow_initialState",TERMINAL_STATES:"ems__Workflow_terminalStates",IS_DEFAULT:"ems__Workflow_isDefault"};Qi.WorkflowStateProperty={WORKFLOW:"ems__WorkflowState_workflow",STATUS:"ems__WorkflowState_status",ORDER:"ems__WorkflowState_order",OPTIONAL:"ems__WorkflowState_optional",TIMESTAMP_ON_ENTER:"ems__WorkflowState_timestampOnEnter",BADGE_COLOR:"ems__WorkflowState_badgeColor"};Qi.WorkflowTransitionProperty={WORKFLOW:"ems__WorkflowTransition_workflow",FROM:"ems__WorkflowTransition_from",TO:"ems__WorkflowTransition_to",LABEL:"ems__WorkflowTransition_label",ICON:"ems__WorkflowTransition_icon",IS_ROLLBACK:"ems__WorkflowTransition_isRollback"};Qi.EFFORT_WORKFLOW_PROPERTY="ems__Effort_workflow"});var Yi=v(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});sp.MetadataHelpers=void 0;var K1=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(([a,c])=>{if(Array.isArray(c)){let l=c.map(u=>` - ${u}`).join(`
90
+ `);return`${a}:
91
+ ${l}`}return`${a}: ${c}`}).join(`
92
+ `),i=t;if(i===void 0){let a=e.exo__Asset_label;typeof a=="string"&&a.trim()!==""&&(i=`# ${a}`)}let s=i?`
93
+ ${i}
94
94
  `:`
95
95
  `;return`---
96
96
  ${r}
97
97
  ---
98
- ${i}`}};sp.MetadataHelpers=K1});var a3=v(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.TASK_DEFAULT_WORKFLOW=ho.PROJECT_DEFAULT_WORKFLOW=void 0;ho.buildWorkflowAssetContent=jM;var s3=hn(),Pu=Xl(),be=Zo(),Vr=i3(),J1=Yi();ho.PROJECT_DEFAULT_WORKFLOW={id:"a1b2c3d4-1111-4000-a000-000000000001",name:"Project Default Workflow",targetClass:Pu.AssetClass.PROJECT,initialState:be.EffortStatus.DRAFT,terminalStates:[be.EffortStatus.DONE,be.EffortStatus.TRASHED],isDefault:!0,states:[{status:be.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.ANALYSIS,order:3,optional:!0,timestampOnEnter:[]},{status:be.EffortStatus.TODO,order:4,optional:!0,timestampOnEnter:[]},{status:be.EffortStatus.DOING,order:5,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:be.EffortStatus.DONE,order:6,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:be.EffortStatus.TRASHED,order:7,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:be.EffortStatus.DRAFT,to:be.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.ANALYSIS,label:"\u2192 Analysis",isRollback:!1},{from:be.EffortStatus.ANALYSIS,to:be.EffortStatus.TODO,label:"\u2192 ToDo",isRollback:!1},{from:be.EffortStatus.TODO,to:be.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:be.EffortStatus.DOING,to:be.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:be.EffortStatus.ANALYSIS,to:be.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:be.EffortStatus.TODO,to:be.EffortStatus.ANALYSIS,label:"\u2190 Analysis",isRollback:!0},{from:be.EffortStatus.DOING,to:be.EffortStatus.TODO,label:"\u2190 ToDo",isRollback:!0},{from:be.EffortStatus.DONE,to:be.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};ho.TASK_DEFAULT_WORKFLOW={id:"a1b2c3d4-2222-4000-a000-000000000002",name:"Task Default Workflow",targetClass:Pu.AssetClass.TASK,initialState:be.EffortStatus.DRAFT,terminalStates:[be.EffortStatus.DONE,be.EffortStatus.TRASHED],isDefault:!0,states:[{status:be.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.DOING,order:3,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:be.EffortStatus.DONE,order:4,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:be.EffortStatus.TRASHED,order:5,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:be.EffortStatus.DRAFT,to:be.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:be.EffortStatus.DOING,to:be.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:be.EffortStatus.DOING,to:be.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:be.EffortStatus.DONE,to:be.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};function jM(n){let e=new Date().toISOString(),t=[],r=n.id,i={exo__Asset_uid:r,exo__Asset_label:`"${n.name}"`,exo__Asset_createdAt:e,exo__Instance_class:Pu.AssetClass.WORKFLOW,[Vr.WorkflowProperty.TARGET_CLASS]:`"[[${n.targetClass}]]"`,[Vr.WorkflowProperty.INITIAL_STATE]:`"[[${n.initialState}]]"`,[Vr.WorkflowProperty.TERMINAL_STATES]:n.terminalStates.map(s=>`"[[${s}]]"`),[Vr.WorkflowProperty.IS_DEFAULT]:n.isDefault};t.push({filename:`${r}.md`,content:J1.MetadataHelpers.buildFileContent(i)});for(let s of n.states){let a=(0,s3.v4)(),c={exo__Asset_uid:a,exo__Asset_label:`"${n.name} - ${s.status}"`,exo__Asset_createdAt:e,exo__Instance_class:Pu.AssetClass.WORKFLOW_STATE,[Vr.WorkflowStateProperty.WORKFLOW]:`"[[${r}]]"`,[Vr.WorkflowStateProperty.STATUS]:`"[[${s.status}]]"`,[Vr.WorkflowStateProperty.ORDER]:s.order,[Vr.WorkflowStateProperty.OPTIONAL]:s.optional};s.timestampOnEnter.length>0&&(c[Vr.WorkflowStateProperty.TIMESTAMP_ON_ENTER]=s.timestampOnEnter),s.badgeColor&&(c[Vr.WorkflowStateProperty.BADGE_COLOR]=`"${s.badgeColor}"`),t.push({filename:`${a}.md`,content:J1.MetadataHelpers.buildFileContent(c)})}for(let s of n.transitions){let a=(0,s3.v4)(),c={exo__Asset_uid:a,exo__Asset_label:`"${n.name} - ${s.label}"`,exo__Asset_createdAt:e,exo__Instance_class:Pu.AssetClass.WORKFLOW_TRANSITION,[Vr.WorkflowTransitionProperty.WORKFLOW]:`"[[${r}]]"`,[Vr.WorkflowTransitionProperty.FROM]:`"[[${s.from}]]"`,[Vr.WorkflowTransitionProperty.TO]:`"[[${s.to}]]"`,[Vr.WorkflowTransitionProperty.LABEL]:`"${s.label}"`,[Vr.WorkflowTransitionProperty.IS_ROLLBACK]:s.isRollback};s.icon&&(c[Vr.WorkflowTransitionProperty.ICON]=`"${s.icon}"`),t.push({filename:`${a}.md`,content:J1.MetadataHelpers.buildFileContent(c)})}return t}o(jM,"buildWorkflowAssetContent")});var e_=v(Ds=>{"use strict";var $M=Ds&&Ds.__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},VM=Ds&&Ds.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Ds,"__esModule",{value:!0});Ds.WorkflowResolver=void 0;var UM=ve(),Ou=xe(),nn=Ge(),_t=wr(),po=Xl(),ap=Zo(),o3=a3(),Z1=class{static{o(this,"WorkflowResolver")}constructor(e){this.tripleStore=e,this.cache=new Map}async resolveForClass(e){let t=`class:${e}`,r=this.cache.get(t);if(r)return r;let s=await this.findDefaultWorkflow(e)??this.getHardcodedFallback(e);return this.cache.set(t,s),s}async resolveForAsset(e,t){let r=await this.tripleStore.match(e,_t.Namespace.EMS.term("Effort_workflow"),void 0);if(r.length>0){let i=r[0].object;if(i instanceof Ou.IRI){let s=await this.loadWorkflowBySubject(i);if(s)return s}}return this.resolveForClass(t)}invalidateCache(){this.cache.clear()}async findDefaultWorkflow(e){let t=await this.tripleStore.match(void 0,_t.Namespace.RDF.term("type"),_t.Namespace.EMS.term("Workflow"));for(let r of t){let i=r.subject;if(!(!(await this.tripleStore.match(i,_t.Namespace.EMS.term("Workflow_targetClass"),void 0)).some(u=>{let f=u.object;return f instanceof Ou.IRI?f.value.endsWith(e.replace(/^ems__/,"")):f instanceof nn.Literal?this.normalizeWikilink(f.value)===e:!1})||!(await this.tripleStore.match(i,_t.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(u=>{let f=u.object instanceof nn.Literal?u.object.value:"";return f==="true"||f==="1"})))return this.loadWorkflowBySubject(i)}return null}async loadWorkflowBySubject(e){let t=await this.tripleStore.match(e,_t.Namespace.EXO.term("Asset_label"),void 0),r=t.length>0&&t[0].object instanceof nn.Literal?t[0].object.value:"Unknown Workflow",i=await this.tripleStore.match(e,_t.Namespace.EXO.term("Asset_uid"),void 0),s=i.length>0&&i[0].object instanceof nn.Literal?i[0].object.value:e.value,a=await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_targetClass"),void 0),c=this.resolveAssetClass(a),l=await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_initialState"),void 0),u=this.resolveEffortStatus(l)??ap.EffortStatus.DRAFT,f=await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_terminalStates"),void 0),d=this.resolveEffortStatuses(f),p=(await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(E=>{let w=E.object instanceof nn.Literal?E.object.value:"";return w==="true"||w==="1"}),_=await this.loadStates(e),b=await this.loadTransitions(e);return _.length===0&&b.length===0?null:{id:s,name:r,targetClass:c,states:_,transitions:b,initialState:u,terminalStates:d.length>0?d:[ap.EffortStatus.DONE,ap.EffortStatus.TRASHED],isDefault:p}}async loadStates(e){let t=await this.tripleStore.match(void 0,_t.Namespace.RDF.term("type"),_t.Namespace.EMS.term("WorkflowState")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_workflow"),void 0)).some(x=>this.isSameSubject(x.object,e)))continue;let l=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_status"),void 0),u=this.resolveEffortStatus(l);if(!u)continue;let f=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_order"),void 0),d=f.length>0&&f[0].object instanceof nn.Literal&&parseInt(f[0].object.value,10)||0,p=(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_optional"),void 0)).some(x=>{let R=x.object instanceof nn.Literal?x.object.value:"";return R==="true"||R==="1"}),b=(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_timestampOnEnter"),void 0)).map(x=>x.object instanceof nn.Literal?x.object.value:"").filter(x=>x.length>0),E=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_badgeColor"),void 0),w=E.length>0&&E[0].object instanceof nn.Literal?E[0].object.value:void 0;r.push({status:u,order:d,optional:p,timestampOnEnter:b,badgeColor:w})}return r.sort((i,s)=>i.order-s.order)}async loadTransitions(e){let t=await this.tripleStore.match(void 0,_t.Namespace.RDF.term("type"),_t.Namespace.EMS.term("WorkflowTransition")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_workflow"),void 0)).some(x=>this.isSameSubject(x.object,e)))continue;let l=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_from"),void 0),u=this.resolveEffortStatus(l),f=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_to"),void 0),d=this.resolveEffortStatus(f);if(!u||!d)continue;let h=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_label"),void 0),p=h.length>0&&h[0].object instanceof nn.Literal?h[0].object.value:`${u} \u2192 ${d}`,_=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_icon"),void 0),b=_.length>0&&_[0].object instanceof nn.Literal?_[0].object.value:void 0,w=(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_isRollback"),void 0)).some(x=>{let R=x.object instanceof nn.Literal?x.object.value:"";return R==="true"||R==="1"});r.push({from:u,to:d,label:p,icon:b,isRollback:w})}return r}normalizeWikilink(e){return e.replace(/["'[\]]/g,"").trim()}resolveAssetClass(e){if(e.length===0)return po.AssetClass.TASK;let t=e[0].object;if(t instanceof Ou.IRI){let i=`ems__${t.value.split("#").pop()??""}`;return Object.values(po.AssetClass).includes(i)?i:po.AssetClass.TASK}if(t instanceof nn.Literal){let r=this.normalizeWikilink(t.value);return Object.values(po.AssetClass).includes(r)?r:po.AssetClass.TASK}return po.AssetClass.TASK}resolveEffortStatus(e){if(e.length===0)return null;let t=e[0].object,r;if(t instanceof Ou.IRI)r=`ems__${t.value.split("#").pop()??""}`;else if(t instanceof nn.Literal)r=this.normalizeWikilink(t.value);else return null;return Object.values(ap.EffortStatus).includes(r)?r:null}resolveEffortStatuses(e){return e.map(t=>this.resolveEffortStatus([t])).filter(t=>t!==null)}isSameSubject(e,t){if(e instanceof Ou.IRI)return e.value===t.value;if(e instanceof nn.Literal){let r=this.normalizeWikilink(e.value);return t.value.includes(r)}return!1}getHardcodedFallback(e){return e===po.AssetClass.PROJECT?{...o3.PROJECT_DEFAULT_WORKFLOW}:{...o3.TASK_DEFAULT_WORKFLOW}}};Ds.WorkflowResolver=Z1;Ds.WorkflowResolver=Z1=$M([(0,UM.injectable)(),VM("design:paramtypes",[Object])],Z1)});var i_=v(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.TransactionError=ma.TripleNotFoundError=ma.TripleAlreadyExistsError=void 0;var t_=class extends Error{static{o(this,"TripleAlreadyExistsError")}constructor(e){super(`Triple already exists: ${e.toString()}`),this.name="TripleAlreadyExistsError"}};ma.TripleAlreadyExistsError=t_;var r_=class extends Error{static{o(this,"TripleNotFoundError")}constructor(e){super(`Triple not found: ${e.toString()}`),this.name="TripleNotFoundError"}};ma.TripleNotFoundError=r_;var n_=class extends Error{static{o(this,"TransactionError")}constructor(e){super(e),this.name="TransactionError"}};ma.TransactionError=n_});var cp=v(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.LRUCache=void 0;var s_=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}};op.LRUCache=s_});var c_=v(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.InMemoryTripleStore=void 0;var ga=i_(),lp=xe(),BM=Vt(),qM=Ge(),WM=wr(),GM=cp(),zM=WM.Namespace.XSD.term("string").value,HM=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,Lc="__default__",a_=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 GM.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 o_(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 lp.IRI(s));return i}addToUUIDIndex(e){if(!(e instanceof lp.IRI))return;let t=e.value,r=t.match(HM);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 l=c.get(s);if(!l)return[];if(l.has(a)){let u=this.buildTripleKey(i,s,a),f=this.triples.get(u);return f?[f]:[]}return[]}matchSP(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.spo.get(r);if(!s)return[];let 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 lp.IRI)return`i:${e.value}`;if(e instanceof BM.BlankNode)return`b:${e.id}`;if(e instanceof qM.Literal){let t=`l:${e.value}`;return e.datatype&&e.datatype.value!==zM?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:Lc}getOrCreateGraphStore(e){let t=this.getGraphKey(e);return t===Lc?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===Lc)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===Lc)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 lp.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===Lc){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===Lc)return this.count();let r=this.namedGraphs.get(t);return r?r.count():0}};up.InMemoryTripleStore=a_;var o_=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 ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.TransactionError("Transaction already rolled back");this.operations.push({type:"add",triple:e})}async remove(e){if(this.committed)throw new ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.TransactionError("Transaction already rolled back");return this.operations.push({type:"remove",triple:e}),!0}async commit(){if(this.committed)throw new ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.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 ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.TransactionError("Transaction already rolled back");this.operations=[],this.rolledBack=!0}}});var dp=v(Fs=>{"use strict";var QM=Fs&&Fs.__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},YM=Fs&&Fs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Fs,"__esModule",{value:!0});Fs.EffortStatusWorkflow=void 0;var XM=ve(),fp=xn(),KM=Ru(),JM=e_(),ZM=c_(),l_=class{static{o(this,"EffortStatusWorkflow")}constructor(){this.resolver=new JM.WorkflowResolver(new ZM.InMemoryTripleStore)}getPreviousStatus(e,t){let r=this.normalizeStatus(e),i=this.resolveDefinition(t),s=new KM.WorkflowEngine(i);if(s.isInitialState(r))return null;let a=s.getPreviousStatus(r);if(a!==null)return this.wrapStatus(a)}normalizeStatus(e){return e.replace(/["'[\]]/g,"").trim()}wrapStatus(e){return`"[[${e}]]"`}resolveDefinition(e){return this.hasInstanceClass(e,fp.AssetClass.TASK)||this.hasInstanceClass(e,fp.AssetClass.MEETING)?this.resolver.getHardcodedFallback(fp.AssetClass.TASK):this.resolver.getHardcodedFallback(fp.AssetClass.PROJECT)}hasInstanceClass(e,t){return e?(Array.isArray(e)?e:[e]).some(i=>i.replace(/["'[\]]/g,"").trim()===t):!1}};Fs.EffortStatusWorkflow=l_;Fs.EffortStatusWorkflow=l_=QM([(0,XM.injectable)(),YM("design:paramtypes",[])],l_)});var Tt=v(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.DI_TOKENS=void 0;hp.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),AreaCreationService:Symbol.for("AreaCreationService"),ClassCreationService:Symbol.for("ClassCreationService"),ConceptCreationService:Symbol.for("ConceptCreationService"),FleetingNoteCreationService:Symbol.for("FleetingNoteCreationService"),SupervisionCreationService:Symbol.for("SupervisionCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),DynamicFrontmatterGenerator:Symbol.for("DynamicFrontmatterGenerator"),AlgorithmExtractor:Symbol.for("AlgorithmExtractor"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),LabelToAliasService:Symbol.for("LabelToAliasService"),RenameToUidService:Symbol.for("RenameToUidService"),PlanningService:Symbol.for("PlanningService"),EffortVotingService:Symbol.for("EffortVotingService"),SessionEventService:Symbol.for("SessionEventService"),CriticalityZoneService:Symbol.for("CriticalityZoneService"),AssetConversionService:Symbol.for("AssetConversionService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),URIConstructionService:Symbol.for("URIConstructionService"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var pp=v(ri=>{"use strict";var e5=ri&&ri.__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},t5=ri&&ri.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},r5=ri&&ri.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ri,"__esModule",{value:!0});ri.StatusTimestampService=void 0;var c3=ve(),n5=Hi(),kc=$r(),i5=Tt(),u_=class{static{o(this,"StatusTimestampService")}constructor(e){this.vault=e,this.frontmatterService=new n5.FrontmatterService}async addStartTimestamp(e){let t=await this.vault.read(e),r=kc.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=kc.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=kc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_resolutionTimestamp",r);await this.vault.modify(e,i)}async addReviewTimestamp(e){let t=await this.vault.read(e),r=kc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_lastReviewTimestamp",r);await this.vault.modify(e,i)}async addEndAndResolutionTimestamps(e,t){let r=await this.vault.read(e),i=t||new Date,s=kc.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),l=kc.DateFormatter.toLocalTimestamp(c),u=this.frontmatterService.updateProperty(r,"ems__Effort_plannedEndTimestamp",l);await this.vault.modify(e,u)}};ri.StatusTimestampService=u_;ri.StatusTimestampService=u_=e5([(0,c3.injectable)(),r5(0,(0,c3.inject)(i5.DI_TOKENS.IVaultAdapter)),t5("design:paramtypes",[Object])],u_)});var d_=v(ni=>{"use strict";var s5=ni&&ni.__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},a5=ni&&ni.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},o5=ni&&ni.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ni,"__esModule",{value:!0});ni.TaskStatusService=void 0;var l3=ve(),c5=Hi(),mo=$r(),l5=dp(),u5=pp(),f5=Tt(),f_=class{static{o(this,"TaskStatusService")}constructor(e,t,r){this.vault=e,this.workflow=t,this.timestampService=r,this.frontmatterService=new c5.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=mo.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=mo.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=mo.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=`
98
+ ${s}`}};sp.MetadataHelpers=K1});var a3=v(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.TASK_DEFAULT_WORKFLOW=ho.PROJECT_DEFAULT_WORKFLOW=void 0;ho.buildWorkflowAssetContent=jM;var s3=hn(),Pu=Xl(),be=Zo(),Vr=i3(),J1=Yi();ho.PROJECT_DEFAULT_WORKFLOW={id:"a1b2c3d4-1111-4000-a000-000000000001",name:"Project Default Workflow",targetClass:Pu.AssetClass.PROJECT,initialState:be.EffortStatus.DRAFT,terminalStates:[be.EffortStatus.DONE,be.EffortStatus.TRASHED],isDefault:!0,states:[{status:be.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.ANALYSIS,order:3,optional:!0,timestampOnEnter:[]},{status:be.EffortStatus.TODO,order:4,optional:!0,timestampOnEnter:[]},{status:be.EffortStatus.DOING,order:5,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:be.EffortStatus.DONE,order:6,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:be.EffortStatus.TRASHED,order:7,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:be.EffortStatus.DRAFT,to:be.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.ANALYSIS,label:"\u2192 Analysis",isRollback:!1},{from:be.EffortStatus.ANALYSIS,to:be.EffortStatus.TODO,label:"\u2192 ToDo",isRollback:!1},{from:be.EffortStatus.TODO,to:be.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:be.EffortStatus.DOING,to:be.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:be.EffortStatus.ANALYSIS,to:be.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:be.EffortStatus.TODO,to:be.EffortStatus.ANALYSIS,label:"\u2190 Analysis",isRollback:!0},{from:be.EffortStatus.DOING,to:be.EffortStatus.TODO,label:"\u2190 ToDo",isRollback:!0},{from:be.EffortStatus.DONE,to:be.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};ho.TASK_DEFAULT_WORKFLOW={id:"a1b2c3d4-2222-4000-a000-000000000002",name:"Task Default Workflow",targetClass:Pu.AssetClass.TASK,initialState:be.EffortStatus.DRAFT,terminalStates:[be.EffortStatus.DONE,be.EffortStatus.TRASHED],isDefault:!0,states:[{status:be.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:be.EffortStatus.DOING,order:3,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:be.EffortStatus.DONE,order:4,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:be.EffortStatus.TRASHED,order:5,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:be.EffortStatus.DRAFT,to:be.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:be.EffortStatus.DOING,to:be.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:be.EffortStatus.BACKLOG,to:be.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:be.EffortStatus.DOING,to:be.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:be.EffortStatus.DONE,to:be.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};function jM(n){let e=new Date().toISOString(),t=[],r=n.id,i={exo__Asset_uid:r,exo__Asset_label:`"${n.name}"`,exo__Asset_createdAt:e,exo__Instance_class:Pu.AssetClass.WORKFLOW,[Vr.WorkflowProperty.TARGET_CLASS]:`"[[${n.targetClass}]]"`,[Vr.WorkflowProperty.INITIAL_STATE]:`"[[${n.initialState}]]"`,[Vr.WorkflowProperty.TERMINAL_STATES]:n.terminalStates.map(s=>`"[[${s}]]"`),[Vr.WorkflowProperty.IS_DEFAULT]:n.isDefault};t.push({filename:`${r}.md`,content:J1.MetadataHelpers.buildFileContent(i)});for(let s of n.states){let a=(0,s3.v4)(),c={exo__Asset_uid:a,exo__Asset_label:`"${n.name} - ${s.status}"`,exo__Asset_createdAt:e,exo__Instance_class:Pu.AssetClass.WORKFLOW_STATE,[Vr.WorkflowStateProperty.WORKFLOW]:`"[[${r}]]"`,[Vr.WorkflowStateProperty.STATUS]:`"[[${s.status}]]"`,[Vr.WorkflowStateProperty.ORDER]:s.order,[Vr.WorkflowStateProperty.OPTIONAL]:s.optional};s.timestampOnEnter.length>0&&(c[Vr.WorkflowStateProperty.TIMESTAMP_ON_ENTER]=s.timestampOnEnter),s.badgeColor&&(c[Vr.WorkflowStateProperty.BADGE_COLOR]=`"${s.badgeColor}"`),t.push({filename:`${a}.md`,content:J1.MetadataHelpers.buildFileContent(c)})}for(let s of n.transitions){let a=(0,s3.v4)(),c={exo__Asset_uid:a,exo__Asset_label:`"${n.name} - ${s.label}"`,exo__Asset_createdAt:e,exo__Instance_class:Pu.AssetClass.WORKFLOW_TRANSITION,[Vr.WorkflowTransitionProperty.WORKFLOW]:`"[[${r}]]"`,[Vr.WorkflowTransitionProperty.FROM]:`"[[${s.from}]]"`,[Vr.WorkflowTransitionProperty.TO]:`"[[${s.to}]]"`,[Vr.WorkflowTransitionProperty.LABEL]:`"${s.label}"`,[Vr.WorkflowTransitionProperty.IS_ROLLBACK]:s.isRollback};s.icon&&(c[Vr.WorkflowTransitionProperty.ICON]=`"${s.icon}"`),t.push({filename:`${a}.md`,content:J1.MetadataHelpers.buildFileContent(c)})}return t}o(jM,"buildWorkflowAssetContent")});var e_=v(Ds=>{"use strict";var $M=Ds&&Ds.__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},VM=Ds&&Ds.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Ds,"__esModule",{value:!0});Ds.WorkflowResolver=void 0;var UM=ve(),Ou=xe(),nn=Ge(),_t=wr(),po=Xl(),ap=Zo(),o3=a3(),Z1=class{static{o(this,"WorkflowResolver")}constructor(e){this.tripleStore=e,this.cache=new Map}async resolveForClass(e){let t=`class:${e}`,r=this.cache.get(t);if(r)return r;let s=await this.findDefaultWorkflow(e)??this.getHardcodedFallback(e);return this.cache.set(t,s),s}async resolveForAsset(e,t){let r=await this.tripleStore.match(e,_t.Namespace.EMS.term("Effort_workflow"),void 0);if(r.length>0){let i=r[0].object;if(i instanceof Ou.IRI){let s=await this.loadWorkflowBySubject(i);if(s)return s}}return this.resolveForClass(t)}invalidateCache(){this.cache.clear()}async findDefaultWorkflow(e){let t=await this.tripleStore.match(void 0,_t.Namespace.RDF.term("type"),_t.Namespace.EMS.term("Workflow"));for(let r of t){let i=r.subject;if(!(!(await this.tripleStore.match(i,_t.Namespace.EMS.term("Workflow_targetClass"),void 0)).some(u=>{let f=u.object;return f instanceof Ou.IRI?f.value.endsWith(e.replace(/^ems__/,"")):f instanceof nn.Literal?this.normalizeWikilink(f.value)===e:!1})||!(await this.tripleStore.match(i,_t.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(u=>{let f=u.object instanceof nn.Literal?u.object.value:"";return f==="true"||f==="1"})))return this.loadWorkflowBySubject(i)}return null}async loadWorkflowBySubject(e){let t=await this.tripleStore.match(e,_t.Namespace.EXO.term("Asset_label"),void 0),r=t.length>0&&t[0].object instanceof nn.Literal?t[0].object.value:"Unknown Workflow",i=await this.tripleStore.match(e,_t.Namespace.EXO.term("Asset_uid"),void 0),s=i.length>0&&i[0].object instanceof nn.Literal?i[0].object.value:e.value,a=await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_targetClass"),void 0),c=this.resolveAssetClass(a),l=await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_initialState"),void 0),u=this.resolveEffortStatus(l)??ap.EffortStatus.DRAFT,f=await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_terminalStates"),void 0),d=this.resolveEffortStatuses(f),p=(await this.tripleStore.match(e,_t.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(E=>{let w=E.object instanceof nn.Literal?E.object.value:"";return w==="true"||w==="1"}),_=await this.loadStates(e),b=await this.loadTransitions(e);return _.length===0&&b.length===0?null:{id:s,name:r,targetClass:c,states:_,transitions:b,initialState:u,terminalStates:d.length>0?d:[ap.EffortStatus.DONE,ap.EffortStatus.TRASHED],isDefault:p}}async loadStates(e){let t=await this.tripleStore.match(void 0,_t.Namespace.RDF.term("type"),_t.Namespace.EMS.term("WorkflowState")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_workflow"),void 0)).some(x=>this.isSameSubject(x.object,e)))continue;let l=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_status"),void 0),u=this.resolveEffortStatus(l);if(!u)continue;let f=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_order"),void 0),d=f.length>0&&f[0].object instanceof nn.Literal&&parseInt(f[0].object.value,10)||0,p=(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_optional"),void 0)).some(x=>{let R=x.object instanceof nn.Literal?x.object.value:"";return R==="true"||R==="1"}),b=(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_timestampOnEnter"),void 0)).map(x=>x.object instanceof nn.Literal?x.object.value:"").filter(x=>x.length>0),E=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowState_badgeColor"),void 0),w=E.length>0&&E[0].object instanceof nn.Literal?E[0].object.value:void 0;r.push({status:u,order:d,optional:p,timestampOnEnter:b,badgeColor:w})}return r.sort((i,s)=>i.order-s.order)}async loadTransitions(e){let t=await this.tripleStore.match(void 0,_t.Namespace.RDF.term("type"),_t.Namespace.EMS.term("WorkflowTransition")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_workflow"),void 0)).some(x=>this.isSameSubject(x.object,e)))continue;let l=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_from"),void 0),u=this.resolveEffortStatus(l),f=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_to"),void 0),d=this.resolveEffortStatus(f);if(!u||!d)continue;let h=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_label"),void 0),p=h.length>0&&h[0].object instanceof nn.Literal?h[0].object.value:`${u} \u2192 ${d}`,_=await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_icon"),void 0),b=_.length>0&&_[0].object instanceof nn.Literal?_[0].object.value:void 0,w=(await this.tripleStore.match(s,_t.Namespace.EMS.term("WorkflowTransition_isRollback"),void 0)).some(x=>{let R=x.object instanceof nn.Literal?x.object.value:"";return R==="true"||R==="1"});r.push({from:u,to:d,label:p,icon:b,isRollback:w})}return r}normalizeWikilink(e){return e.replace(/["'[\]]/g,"").trim()}resolveAssetClass(e){if(e.length===0)return po.AssetClass.TASK;let t=e[0].object;if(t instanceof Ou.IRI){let i=`ems__${t.value.split("#").pop()??""}`;return Object.values(po.AssetClass).includes(i)?i:po.AssetClass.TASK}if(t instanceof nn.Literal){let r=this.normalizeWikilink(t.value);return Object.values(po.AssetClass).includes(r)?r:po.AssetClass.TASK}return po.AssetClass.TASK}resolveEffortStatus(e){if(e.length===0)return null;let t=e[0].object,r;if(t instanceof Ou.IRI)r=`ems__${t.value.split("#").pop()??""}`;else if(t instanceof nn.Literal)r=this.normalizeWikilink(t.value);else return null;return Object.values(ap.EffortStatus).includes(r)?r:null}resolveEffortStatuses(e){return e.map(t=>this.resolveEffortStatus([t])).filter(t=>t!==null)}isSameSubject(e,t){if(e instanceof Ou.IRI)return e.value===t.value;if(e instanceof nn.Literal){let r=this.normalizeWikilink(e.value);return t.value.includes(r)}return!1}getHardcodedFallback(e){return e===po.AssetClass.PROJECT?{...o3.PROJECT_DEFAULT_WORKFLOW}:{...o3.TASK_DEFAULT_WORKFLOW}}};Ds.WorkflowResolver=Z1;Ds.WorkflowResolver=Z1=$M([(0,UM.injectable)(),VM("design:paramtypes",[Object])],Z1)});var i_=v(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.TransactionError=ma.TripleNotFoundError=ma.TripleAlreadyExistsError=void 0;var t_=class extends Error{static{o(this,"TripleAlreadyExistsError")}constructor(e){super(`Triple already exists: ${e.toString()}`),this.name="TripleAlreadyExistsError"}};ma.TripleAlreadyExistsError=t_;var r_=class extends Error{static{o(this,"TripleNotFoundError")}constructor(e){super(`Triple not found: ${e.toString()}`),this.name="TripleNotFoundError"}};ma.TripleNotFoundError=r_;var n_=class extends Error{static{o(this,"TransactionError")}constructor(e){super(e),this.name="TransactionError"}};ma.TransactionError=n_});var cp=v(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.LRUCache=void 0;var s_=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}};op.LRUCache=s_});var c_=v(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.InMemoryTripleStore=void 0;var ga=i_(),lp=xe(),BM=Vt(),qM=Ge(),WM=wr(),GM=cp(),zM=WM.Namespace.XSD.term("string").value,HM=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,Lc="__default__",a_=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 GM.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 o_(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 lp.IRI(s));return i}addToUUIDIndex(e){if(!(e instanceof lp.IRI))return;let t=e.value,r=t.match(HM);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 l=c.get(s);if(!l)return[];if(l.has(a)){let u=this.buildTripleKey(i,s,a),f=this.triples.get(u);return f?[f]:[]}return[]}matchSP(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.spo.get(r);if(!s)return[];let 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 lp.IRI)return`i:${e.value}`;if(e instanceof BM.BlankNode)return`b:${e.id}`;if(e instanceof qM.Literal){let t=`l:${e.value}`;return e.datatype&&e.datatype.value!==zM?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:Lc}getOrCreateGraphStore(e){let t=this.getGraphKey(e);return t===Lc?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===Lc)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===Lc)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 lp.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===Lc){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===Lc)return this.count();let r=this.namedGraphs.get(t);return r?r.count():0}};up.InMemoryTripleStore=a_;var o_=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 ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.TransactionError("Transaction already rolled back");this.operations.push({type:"add",triple:e})}async remove(e){if(this.committed)throw new ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.TransactionError("Transaction already rolled back");return this.operations.push({type:"remove",triple:e}),!0}async commit(){if(this.committed)throw new ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.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 ga.TransactionError("Transaction already committed");if(this.rolledBack)throw new ga.TransactionError("Transaction already rolled back");this.operations=[],this.rolledBack=!0}}});var dp=v(Fs=>{"use strict";var QM=Fs&&Fs.__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},YM=Fs&&Fs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Fs,"__esModule",{value:!0});Fs.EffortStatusWorkflow=void 0;var XM=ve(),fp=xn(),KM=Ru(),JM=e_(),ZM=c_(),l_=class{static{o(this,"EffortStatusWorkflow")}constructor(){this.resolver=new JM.WorkflowResolver(new ZM.InMemoryTripleStore)}getPreviousStatus(e,t){let r=this.normalizeStatus(e),i=this.resolveDefinition(t),s=new KM.WorkflowEngine(i);if(s.isInitialState(r))return null;let a=s.getPreviousStatus(r);if(a!==null)return this.wrapStatus(a)}normalizeStatus(e){return e.replace(/["'[\]]/g,"").trim()}wrapStatus(e){return`"[[${e}]]"`}resolveDefinition(e){return this.hasInstanceClass(e,fp.AssetClass.TASK)||this.hasInstanceClass(e,fp.AssetClass.MEETING)?this.resolver.getHardcodedFallback(fp.AssetClass.TASK):this.resolver.getHardcodedFallback(fp.AssetClass.PROJECT)}hasInstanceClass(e,t){return e?(Array.isArray(e)?e:[e]).some(i=>i.replace(/["'[\]]/g,"").trim()===t):!1}};Fs.EffortStatusWorkflow=l_;Fs.EffortStatusWorkflow=l_=QM([(0,XM.injectable)(),YM("design:paramtypes",[])],l_)});var Tt=v(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.DI_TOKENS=void 0;hp.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),AreaCreationService:Symbol.for("AreaCreationService"),ClassCreationService:Symbol.for("ClassCreationService"),ConceptCreationService:Symbol.for("ConceptCreationService"),FleetingNoteCreationService:Symbol.for("FleetingNoteCreationService"),SupervisionCreationService:Symbol.for("SupervisionCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),DynamicFrontmatterGenerator:Symbol.for("DynamicFrontmatterGenerator"),AlgorithmExtractor:Symbol.for("AlgorithmExtractor"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),LabelToAliasService:Symbol.for("LabelToAliasService"),RenameToUidService:Symbol.for("RenameToUidService"),PlanningService:Symbol.for("PlanningService"),EffortVotingService:Symbol.for("EffortVotingService"),SessionEventService:Symbol.for("SessionEventService"),CriticalityZoneService:Symbol.for("CriticalityZoneService"),AssetConversionService:Symbol.for("AssetConversionService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),URIConstructionService:Symbol.for("URIConstructionService"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var pp=v(ri=>{"use strict";var e5=ri&&ri.__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},t5=ri&&ri.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},r5=ri&&ri.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ri,"__esModule",{value:!0});ri.StatusTimestampService=void 0;var c3=ve(),n5=Hi(),kc=$r(),i5=Tt(),u_=class{static{o(this,"StatusTimestampService")}constructor(e){this.vault=e,this.frontmatterService=new n5.FrontmatterService}async addStartTimestamp(e){let t=await this.vault.read(e),r=kc.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=kc.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=kc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_resolutionTimestamp",r);await this.vault.modify(e,i)}async addReviewTimestamp(e){let t=await this.vault.read(e),r=kc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_lastReviewTimestamp",r);await this.vault.modify(e,i)}async addEndAndResolutionTimestamps(e,t){let r=await this.vault.read(e),i=t||new Date,s=kc.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),l=kc.DateFormatter.toLocalTimestamp(c),u=this.frontmatterService.updateProperty(r,"ems__Effort_plannedEndTimestamp",l);await this.vault.modify(e,u)}};ri.StatusTimestampService=u_;ri.StatusTimestampService=u_=e5([(0,c3.injectable)(),r5(0,(0,c3.inject)(i5.DI_TOKENS.IVaultAdapter)),t5("design:paramtypes",[Object])],u_)});var d_=v(ni=>{"use strict";var s5=ni&&ni.__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},a5=ni&&ni.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},o5=ni&&ni.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ni,"__esModule",{value:!0});ni.TaskStatusService=void 0;var l3=ve(),c5=Hi(),mo=$r(),l5=dp(),u5=pp(),f5=Tt(),f_=class{static{o(this,"TaskStatusService")}constructor(e,t,r){this.vault=e,this.workflow=t,this.timestampService=r,this.frontmatterService=new c5.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=mo.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=mo.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=mo.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=`
99
99
 
100
100
  ## Trash Reason
101
101
 
@@ -744,7 +744,7 @@ ${Pr.dump(i,{lineWidth:-1})}---
744
744
  \u{1F50D} Dry-run: command "${l.name}" on "${t.target}"
745
745
  `),console.log(" Precondition: passed \u2705"),console.log(" Grounding (would execute):"),SS(l.grounding," ");return}let h=new Mt.ServiceRegistry;HO(h);let p=new Ft(i),b=await new Mt.GroundingExecutor(p,p,h).execute(l.grounding,u,t.target);if(r==="json"){let E=Z.success({command:l.name,target:t.target,preconditionPassed:!0,executed:!0,success:b.success,...b.error&&{error:b.error},...l.successMessage&&b.success&&{message:l.successMessage}});console.log(JSON.stringify(E,null,2))}else if(b.success){let E=l.successMessage??`Command "${l.name}" executed successfully.`;console.log(`\u2705 ${E}`)}else console.log(`\u274C Command "${l.name}" failed: ${b.error}`),process.exitCode=5}catch(i){k.handle(i)}}),n.command("validate").description("Validate all dynamic command definitions in vault").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async e=>{let t=e.output||"text";k.setFormat(t);try{let r=(0,fs.resolve)(e.vault);if(!(0,us.existsSync)(r))throw new Ce(r);let i=rH(r);if(t==="json"){let s=Z.success({totalCommands:vS(r).length,totalIssues:i.reduce((a,c)=>a+c.issues.length,0),commandsWithIssues:i.length,issues:i});console.log(JSON.stringify(s,null,2))}else{let s=vS(r);if(i.length===0)console.log(`\u2705 All ${s.length} dynamic command(s) are valid.`);else{let a=i.reduce((c,l)=>c+l.issues.length,0);console.log(`\u274C Found ${a} issue(s) in ${i.length} command(s) out of ${s.length} total:
746
746
  `);for(let c of i){console.log(` \u{1F4C4} ${c.label} (${c.uid}):`);for(let l of c.issues)console.log(` \u2022 ${l}`);console.log()}process.exitCode=5}}}catch(r){k.handle(r)}}),n}o(QO,"dynamicCommandCommand");function vS(n){let e=[],t=[];wS(n,t);for(let{filePath:r,fm:i}of t){if(!Ml(i,"exocmd__Command"))continue;let s=i.exo__Asset_uid??"",a=i.exo__Asset_label??YO(r),c=i.exocmd__Command_category,l=i.exocmd__Command_icon,u=!!i.exocmd__Command_precondition,f=i.exocmd__Command_grounding,d;if(f){let h=Tg(String(f)),p=t.find(_=>_.fm.exo__Asset_uid===h&&Ml(_.fm,"exocmd__Grounding"));p&&(d=p.fm.exocmd__Grounding_type)}e.push({filePath:r,uid:s,label:a,category:c,icon:l,hasPrecondition:u,groundingType:d})}return e}o(vS,"scanCommands");async function tH(n,e){let{tripleStore:t}=await bS(n),r=new Mt.CommandResolver(t),i=await r.findBindings(),s=new Set;for(let c of i)s.add(c.commandRef);let a=[];for(let c of s){let l=await r.loadCommand(c);l&&a.push({filePath:"",uid:l.id,label:l.name,category:l.category,icon:l.icon,hasPrecondition:!!l.precondition,groundingType:l.grounding.type})}return a}o(tH,"listCommandsForTarget");function rH(n){let e=[],t=[];wS(n,t);let r=new Map;for(let i of t){let s=i.fm.exo__Asset_uid;s&&r.set(s,i)}for(let{filePath:i,fm:s}of t){if(!Ml(s,"exocmd__Command"))continue;let a=s.exo__Asset_uid??"",c=s.exo__Asset_label??YO(i),l=[];a||l.push("Missing exo__Asset_uid"),s.exo__Asset_label||l.push("Missing exo__Asset_label");let u=s.exocmd__Command_grounding;if(!u)l.push("Missing exocmd__Command_grounding (required)");else{let h=Tg(String(u)),p=r.get(h);if(!p)l.push(`Grounding reference "${h}" not found in vault`);else if(!Ml(p.fm,"exocmd__Grounding"))l.push(`Grounding reference "${h}" is not an exocmd__Grounding asset`);else{let _=p.fm,b=_.exocmd__Grounding_type;b?(Object.values(Mt.GroundingType).includes(b)||l.push(`Grounding "${h}" has invalid type "${b}"`),(b===Mt.GroundingType.PROPERTY_SET||b===Mt.GroundingType.PROPERTY_DELETE)&&!_.exocmd__Grounding_targetProperty&&l.push(`Grounding "${h}" (${b}) missing targetProperty`),b===Mt.GroundingType.PROPERTY_SET&&!_.exocmd__Grounding_targetValue&&l.push(`Grounding "${h}" (property_set) missing targetValue`),b===Mt.GroundingType.SERVICE_CALL&&((_.exocmd__Grounding_serviceId??_.exocmd__Grounding_targetProperty)||l.push(`Grounding "${h}" (service_call) missing serviceId and targetProperty`))):l.push(`Grounding "${h}" missing exocmd__Grounding_type`)}}let f=s.exocmd__Command_precondition;if(f){let h=Tg(String(f)),p=r.get(h);if(!p)l.push(`Precondition reference "${h}" not found in vault`);else if(!Ml(p.fm,"exocmd__Precondition"))l.push(`Precondition reference "${h}" is not an exocmd__Precondition asset`);else{let _=p.fm.exocmd__Precondition_sparqlAsk,b=p.fm.exocmd__Precondition_hostFunction;!_&&!b&&l.push(`Precondition "${h}" missing both sparqlAsk and hostFunction`)}}t.some(h=>Ml(h.fm,"exocmd__CommandBinding")?Tg(String(h.fm.exocmd__CommandBinding_command??""))===a:!1)||l.push("No CommandBinding references this command (command will be unused)"),l.length>0&&e.push({uid:a,label:c,filePath:i,issues:l})}return e}o(rH,"validateCommands");async function bS(n){let e=new hr(n),r=await new Mt.NoteToRDFConverter(e).convertVault(),i=new Mt.InMemoryTripleStore;return await i.addAll(r),{tripleStore:i}}o(bS,"buildTripleStore");function SS(n,e){if(console.log(`${e}ID: ${n.id}`),console.log(`${e}Label: ${n.label}`),console.log(`${e}Type: ${n.type}`),n.targetProperty&&console.log(`${e}Target property: ${n.targetProperty}`),n.targetValue!==void 0&&console.log(`${e}Target value: ${n.targetValue}`),n.sparqlUpdate&&console.log(`${e}SPARQL UPDATE: ${n.sparqlUpdate}`),n.steps&&n.steps.length>0){console.log(`${e}Steps (${n.steps.length}):`);for(let t=0;t<n.steps.length;t++)console.log(`${e} Step ${t+1}:`),SS(n.steps[t],e+" ")}}o(SS,"printGrounding");function wS(n,e){let t;try{t=(0,us.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,fs.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;wS(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,us.readFileSync)(i,"utf-8"),a=eH.parse(s);a.exists&&e.push({filePath:i,fm:nH(a.content)})}catch{}}}o(wS,"collectParsedFiles");function nH(n){let e={},t=n.split(`
747
- `),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(nH,"parseYamlFrontmatter");function Ml(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(Ml,"hasClass");function Tg(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.substring(0,t).trim():e}o(Tg,"normalizeWikilink");function YO(n){return(0,fs.basename)(n,".md")}o(YO,"extractLabelFromFilename");function XO(n){n.addCommand(GR()),n.addCommand(YR()),n.addCommand(XR())}o(XO,"addQuerySubcommands");function KO(n){let e=new Le;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.96.2");let t=e.command("exoql").description("ExoQL query execution and cache management");XO(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return XO(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(iO()),e.addCommand(oO()),e.addCommand(cO()),e.addCommand(uO()),e.addCommand(fO()),e.addCommand(gO()),e.addCommand(bO()),e.addCommand(IO()),e.addCommand(OO()),e.addCommand(kO()),e.addCommand($O()),e.addCommand(VO()),e.addCommand(BO()),e.addCommand(QO()),e}o(KO,"createProgram");KO().parse();0&&(module.exports={createProgram});
747
+ `),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let c=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(c),e[r]=i;continue}let a=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(a){r=a[1],i=null;let c=a[2].trim();if((c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),c==="true"?c=!0:c==="false"&&(c=!1),c===""){e[r]=[],i=e[r];continue}e[r]=c}}return e}o(nH,"parseYamlFrontmatter");function Ml(n,e){let t=n.exo__Instance_class;if(!t)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}o(Ml,"hasClass");function Tg(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.substring(0,t).trim():e}o(Tg,"normalizeWikilink");function YO(n){return(0,fs.basename)(n,".md")}o(YO,"extractLabelFromFilename");function XO(n){n.addCommand(GR()),n.addCommand(YR()),n.addCommand(XR())}o(XO,"addQuerySubcommands");function KO(n){let e=new Le;e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"15.98.0");let t=e.command("exoql").description("ExoQL query execution and cache management");XO(t);let r=e.command("sparql").description("(deprecated) Use 'exoql' instead");return XO(r),r.hook("preAction",()=>{console.error('\u26A0\uFE0F "sparql" is deprecated. Use "exoql" instead.')}),e.addCommand(iO()),e.addCommand(oO()),e.addCommand(cO()),e.addCommand(uO()),e.addCommand(fO()),e.addCommand(gO()),e.addCommand(bO()),e.addCommand(IO()),e.addCommand(OO()),e.addCommand(kO()),e.addCommand($O()),e.addCommand(VO()),e.addCommand(BO()),e.addCommand(QO()),e}o(KO,"createProgram");KO().parse();0&&(module.exports={createProgram});
748
748
  /*! Bundled license information:
749
749
 
750
750
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "15.96.2",
3
+ "version": "15.98.0",
4
4
  "description": "CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more",
5
5
  "main": "dist/index.js",
6
6
  "bin": {