epiq 0.6.12 → 0.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ ${m}
54
54
 
55
55
  ${l}
56
56
  `,Do.writeFileSync(t,n,"utf8"),ae.info(`Added ${i.join(", ")} to .gitignore (epiq local state)`),c("Local epiq paths ignored",!0)};var Yu=async e=>{let t=await k({cwd:e,args:["status","--porcelain"]});return d(t)?t:c("Checked git diff",t.value.stdout.trim().length>0)},j=(e,t)=>a(`[${e}] ${t}`),wa=async()=>{U("");let e=ti(),t=await Je(process.cwd());if(d(t))return j(1,t.message);let n=t.value,r=await Mn(n);if(d(r))return j(2,r.message);if(r.value)return j(2,"Cannot initialize Epiq while a git operation is in progress");let o=await Yu(n);if(d(o))return j(2.5,o.message);if(o.value)return j(3,"Cannot initialize Epiq with uncommitted changes. Commit or stash your changes first.");if(Br(n))return j(4,"Epiq project already initialized");let i=Ze();if(!i.isSetupDone||!i.userName)return j(5,"Missing Epiq user configuration (userId / userName). Run setup first.");let s=O(),l=s.userName,u=s.userId;if(!u||!l)return j(5,"Missing Epiq user id");let m=e.stateBranch,g=await Ln({repoRoot:n,branch:m});if(d(g))return j(6,g.message);if(g.value)return j(6,`State branch already exists: ${m}`);let y=await uo({repoRoot:n,stateBranchName:m});if(d(y))return j(6,y.message);let C=Fn();if(d(C))return j(7,C.message);let I=Ta.join(Dn(),e.projectId),S=await mo({repoRoot:n,stateBranchRoot:I,stateBranchName:m});if(d(S))return j(8,S.message);let A=Ta.join(I,".epiq");qu.mkdirSync(A,{recursive:!0});let R=xs({userId:u,userName:l});if(d(R))return j(9,R.message);for(let Fr of R.value){let Qo=Vn({event:Fr,rootDir:I});if(d(Qo))return j(9,Qo.message)}let M=await Yn({stateBranchRoot:I,eventFileName:on({userId:u,userName:l})});if(d(M))return j(10,M.message);let F=await Tt({cwd:I,message:"[epiq:init]"});if(d(F))return j(10,F.message);let Ie=await Aa(n);if(d(Ie))return j(11,Ie.message);let le=ri({repoRoot:n,fileContents:e});if(d(le))return j(12,le.message);let Vt=await G.stage({cwd:n,pathspec:[".epiq/project.json",".gitignore"]});if(d(Vt))return j(13,Vt.message);let bn=await G.commit({cwd:n,message:"[epiq:init-project]"});if(d(bn))return j(13,bn.message);let It="Project initialized!",Kt=await k({cwd:n,args:["push","-u","origin","HEAD"]});d(Kt)&&(It+=` Warn: [init:14] ${Kt.message}`);let re=await dn({repoRoot:n,stateBranchRoot:I});d(re)&&(It+=` Warn: [init:15] ${re.message}`);let Rt=ht(R.value).filter(d);if(Rt.length>0)return j(16,Rt.map(Fr=>Fr.message).join(`
57
- `));let ft=ot();if(d(ft))return j(16,ft.message);let{rootNodeId:_d,nodes:$d}=ft.value,Jo=$d[_d];return Jo?(T.navigate({contextNode:Jo,selectedIndex:0}),N({hasProjectDefinition:!0,mode:p.DEFAULT}),c(It,null)):j(16,"Unable to resolve initialized root node")};import{ulid as Ju}from"ulid";import{ulid as Xu}from"ulid";var Ma=null,ut=()=>structuredClone(Ma),pn=e=>{Ma=e},Pa=()=>{let{contextNode:e,selectedIndex:t}=v(),r=B(e.id)[t];return r?c("Resolved selected child",r):a("Target node not found")},Fo=({id:e,parentId:t,position:n={at:"end"}})=>{let r=B(t).filter(o=>o.id!==e);return Kn(r,n)},La=({id:e,parentId:t,position:n={at:"end"}})=>{let r=Y();if(d(r))return a("Unable to resolve user ID");let o=Fo({parentId:t,id:e,position:n});return d(o)?o:c("Created pending move state",{id:Xu(),...r.value,action:"move.node",payload:{id:e,parent:t,rank:o.value.rank}})},ka=e=>{pn(e);let t=tn(e,!0);return d(t)?t:c("Node moved successfully",t.value)};function Bo(e){let t=Pa();if(d(t))return t;let{contextNode:n,nodes:r}=v();if(!n.parentNodeId)return a("Missing parent node id");let o=r[n.parentNodeId];if(!o)return a("Missing parent node");let i=B(o.id),s=i.findIndex(({id:m})=>m===n.id);if(s<0)return a("Current node not found among siblings");let l=i[s+e];if(!l)return a("Missing sibling node");let u=La({id:t.value.id,parentId:l.id,position:{at:"end"}});return d(u)?u:ka(u.value)}function Oo(e){let t=Pa();if(d(t))return t;let{contextNode:n,selectedIndex:r}=v(),i=B(n.id)[r+e];if(!i)return a("Missing sibling node");let s=La({id:t.value.id,parentId:n.id,position:{at:e===1?"after":"before",sibling:i.id}});return d(s)?s:ka(s.value)}var Da=()=>{let e=ut();if(!e)return a("No pending move state");let t=e.payload.id,n=e.payload.parent,r=v().nodes[n];if(!r)return a("Move parent not found");let o=B(n).findIndex(i=>i.id===t);return o===-1?a("Moved node not found among rendered children"):(T.navigate({contextNode:r,selectedIndex:o}),c("Synchronized navigation to moved node",null))},fr=(e,t="Moved preview")=>{if(d(e))return e;let n=Da();return d(n)?n:(N({mode:p.MOVE}),c(t,null))},Fa=async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t}=V().commandMeta,{contextNode:n,selectedIndex:r}=v(),o=B(n.id)[r];if(!o)return N({mode:p.DEFAULT}),a("No move target");if(t==="start"){if(o.readonly)return a("Target node is read-only");if(r===-1)return a("No item selected");if(!o.parentNodeId)return a("Target has no parent");let i=B(o.parentNodeId),s=i.findIndex(({id:y})=>y===o.id);if(s===-1)return a("Target not found among siblings");let l=i[s-1],u=i[s+1],m=u!=null?{at:"before",sibling:u.id}:l!=null?{at:"after",sibling:l.id}:{at:"start"},g=Fo({parentId:o.parentNodeId,id:o.id,position:m});return d(g)?g:(pn({id:Ju(),action:"move.node",payload:{id:o.id,parent:o.parentNodeId,rank:g.value.rank},...e.value}),N({mode:p.MOVE}),c("Move initialized",null))}if(t==="next")return fr(Oo(1));if(t==="previous")return fr(Oo(-1));if(t==="to-next")return fr(Bo(1));if(t==="to-previous")return fr(Bo(-1));if(t==="confirm"){let i=ut();if(!i)return a("No pending move to confirm");let s=await Re();if(d(s))return s;let l=Te(i,s.value);if(d(l))return l;let u=Da();return d(u)?u:(pn(null),N({mode:p.DEFAULT}),c("Moved item",null))}return t==="cancel"?(pn(null),N({mode:p.DEFAULT}),c("Cancelling move",null)):a("Invalid move modifier")};import{ulid as vr}from"ulid";import{monotonicFactory as Qu,ulid as Zu}from"ulid";var em=Qu(),Ba=({name:e,parent:t,rank:n,user:{userId:r,userName:o}})=>{let i=em();return c("Created issue events",[{id:Zu(),userId:r,userName:o,action:"add.issue",payload:{id:i,parent:t,name:e,rank:n}}])};var Oa=async(e,t)=>{let n=Y();if(d(n))return a("Unable to resolve user ID");let r=await Re();if(d(r))return r;let o=r.value;if(!t.inputString)return a(`provide a name for your ${t.modifier}`);let{breadCrumb:i,contextNode:s,selectedIndex:l}=v(),u=m=>{let g=Te(m,o);if(d(g))return g;let y=b.getNode(g.value.result.id);if(!y)return a("Created node not found");if(!y.parentNodeId)return g;let C=b.getNode(y.parentNodeId);return C?(T.navigate({contextNode:C,selectedIndex:b.getSiblings(y.parentNodeId).findIndex(({id:I})=>I===y.id)}),g):a("Parent node not found")};if(t.modifier==="board"){let{rootNodeId:m}=v(),g=b.getNode(m);if(!g)return a("Workspace not found");let y=zn(g.id,n.value,o);return d(y)?y:u({id:vr(),action:"add.board",payload:{id:vr(),name:t.inputString,parent:g.id,rank:y.value},...n.value})}if(t.modifier==="swimlane"){let m=Ce(i,"BOARD");if(d(m))return a("Unable to add swimlane in this context");let g=zn(m.value.id,n.value,o);return d(g)?g:u({id:vr(),action:"add.swimlane",payload:{id:vr(),name:t.inputString,parent:m.value.id,rank:g.value},...n.value})}if(t.modifier==="issue"){let m=$(s.id)[l],g=s.context==="SWIMLANE"?s:s.context==="BOARD"&&m?.context==="SWIMLANE"?m:(()=>{let F=Ce(i,"SWIMLANE");return d(F)?null:F.value})();if(!g)return a("Unable to add issue in this context");let y=zn(g.id,n.value,o);if(d(y))return y;let C=Ba({name:t.inputString,parent:g.id,rank:y.value,user:n.value});if(d(C))return C;let I=C.value,S=ss(I,o);if(S.some(F=>d(F)))return a("Issue create failed: "+S.filter(d).map(F=>F.message).filter(Boolean).join(", "));let A=S[0];if(!A||d(A))return a("Issue creation failed");let M=I.find(F=>F.action==="add.issue")?.payload.id;return M?(T.navigate({contextNode:g,selectedIndex:b.getSiblings(g.id).findIndex(({id:F})=>F===M)}),c("Issue created",null)):a("Unable to determine ticket id")}return c("Success",null)};var Ua=async()=>{let e=Ce(v().breadCrumb,"BOARD");if(d(e))return e;let t=await Je(process.cwd());if(d(t))return a("Unable to locate repo root");let n=Xe({repoRoot:t.value});if(d(n))throw new Error(n.message);let{modifier:r}=V().commandMeta;if(r==="now"){let S=Lt(n.value);if(d(S))return a(S.message);let A=gn();if(d(A))return A;let M=ht(S.value).filter(d);return M.length>0?a(M.map(F=>F.message).join(", ")):(N({mode:p.DEFAULT,readOnly:!1,timeMode:"live",unappliedEvents:[]}),c("Peeking now",!0))}let o;if(r==="prev"){let S=v().eventLog.at(-1),A=to(S);if(A===null)return a("No previous event to peek");o=A}else if(r==="next"){let S=v().unappliedEvents.at(0),A=to(S);if(A===null)return a("No next event to peek");o=A+1}else{let S=er(r);if(!S)return a("Invalid peek date");o=S.getTime()}let i=v(),s=e.value.id,l=ts(n.value,o);if(d(l))return a(l.message);let{appliedEvents:u,unappliedEvents:m}=l.value,g=gn();if(d(g))return g;let C=ht(u).filter(d);if(C.length>0)return gn(),N(i),a(C.map(S=>S.message).join(", "));let I=v().nodes[s];return I?(T.navigate({contextNode:I,selectedIndex:0}),N({mode:p.DEFAULT,readOnly:!0,timeMode:"peek",unappliedEvents:m}),c("Peeking",!0)):(gn(),N(i),a("Board did not exist at peek date"))};import tm from"zod";var _a=()=>{let e=V().commandMeta.inputString,t=tm.coerce.number().int().min(3e3).safeParse(e);if(!t.success)return a("Auto sync duration must be a number of at least 3000 ms");let n=ze({autoSyncDebounceMs:t.data});return d(n)?n:(Ee({autoSyncIntervalMs:t.data}),N({mode:p.DEFAULT}),c(`Auto sync interval set to ${t.data}ms`,null))};var $a=()=>{let e=V().commandMeta.inputString.trim();if(e!=="on"&&e!=="off")return a("Invalid response");let t=Si(e),n=ze({autoSync:t});return d(n)?n:(Ee({autoSync:t}),N({mode:p.DEFAULT}),c(`Auto sync set to "${e}"`,null))};var Wa=()=>{let e=V().commandMeta.inputString.trim();if(!["debug","error","info"].includes(e))return a("Invalid response");let n=ze({logLevel:e});return d(n)?n:(Ee({logLevel:e}),N({mode:p.DEFAULT}),c(`Auto sync set to "${e}"`,null))};var Ha=async()=>{U(""),N({mode:p.DEFAULT});let e=ot();if(d(e))return a(e.message);if(e.value.syncStatus.status==="syncing")return a("Sync already in progress");N({syncStatus:{msg:"Syncing",status:"syncing"}});let t=await Xn();return d(t)?(N({syncStatus:{msg:t.message,status:"failed"}}),t):(N({mode:p.DEFAULT,syncStatus:{msg:"Synced",status:"synced"}}),t)};var ja=e=>Object.values(v().tags).find(t=>t.name===e),Va=e=>Object.values(v().contributors).find(t=>t.name===e),xr=[{systemOnly:!0,intent:P.Move,description:"Internal move-state command",mode:p.COMMAND_LINE,action:Fa},{intent:P.Delete,description:"Delete the currently selected node",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];return r?Se({id:fe(),action:"delete.node",payload:{id:r.id},...e.value}):a("Unable to resolve child to delete")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Filter,description:"Filter the board, for example `:filter tag urgent`",mode:p.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=V().commandMeta,n=/(!=|=)/,[r]=e.split(n);if(!r||!(s=>ee(x.FILTER).map(l=>l.split(n)[0]).includes(s))(r))return a("Invalid filter modifier");let i={target:r,operator:"=",value:t.trim()};return Ne(s=>({...s,filters:e==="clear"?[]:[...s.filters,i],mode:p.DEFAULT})),c("Filter updated",null)}},{intent:P.ViewHelp,description:"Open the help screen",mode:p.COMMAND_LINE,action:()=>{let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}=v();return lt({pendingNavTarget:{contextNode:e,breadCrumb:r,selectedIndex:t,selectedNode:n}}),N({mode:p.HELP}),c("Viewing help",null)}},{intent:P.CloseIssue,description:"Move the selected issue to the closed swimlane",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];if(!r)return a("Unable to close issue, no target found");if(!_(r))return a("Cannot close in this context");let o=v().nodes[He];if(!o)return a("Unable to locate closed swimlane");if(r.parentNodeId===o.id)return a("Issue is already closed");let i=await Re();if(d(i))return i;let s=i.value,l=ao(o.id,r.id,{at:"end"},e.value,s);if(d(l))return l;let u=await Se({id:fe(),action:"close.issue",payload:{id:r.id,parent:o.id,rank:l.value},...e.value});return d(u)?u:c("Issue closed",null)},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.ReopenIssue,description:"Move a closed issue back to its previous swimlane",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];if(!r)return a("Unable to reopen issue, no target found");let o=r.context==="TICKET"?c("Resolved ticket",r):nt(r.id,"TICKET");if(d(o))return a("Cannot reopen in this context");let i=o.value,s=v().nodes[He];if(!s)return a("Unable to locate closed swimlane");if(i.parentNodeId!==s.id)return a("Issue is not closed");if(!_(i))return a("Target node is not issue");let l=Ca(i);if(!l)return a("Unable to resolve previous parent from issue history");if(l===s.id)return a("Previous parent resolves to closed swimlane");let u=v().nodes[l];if(!u)return a("Previous parent no longer exists");let m=await Re();if(d(m))return m;let g=m.value,y=ao(u.id,i.id,{at:"end"},e.value,g);if(d(y))return y;let C=await Se({id:fe(),action:"reopen.issue",payload:{id:i.id,parent:u.id,rank:y.value},...e.value});return d(C)?C:c("Issue reopened",null)},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Init,description:"Initialize Epiq in the current git repository",mode:p.COMMAND_LINE,action:wa},{intent:P.NewItem,description:"Create a new board, swimlane, or issue",mode:p.COMMAND_LINE,action:Oa,onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Rename,description:"itle] Rename the currently selected node",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];if(!r)return a("Missing node");if(r.readonly)return a("Cannot rename readonly node");let o=Ys();return o?Se({id:fe(),action:"edit.title",payload:{id:r.id,name:o},...e.value}):a("Provide a title")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.UntagTicket,description:"Remove a tag from the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide a tag");let o=ja(r);if(!o)return a(`Tag "${r}" does not exist`);let{selectedNode:i}=v();if(!i)return a("Invalid untag target");let s=nt(i.id,"TICKET");if(d(s))return a("Unable to untag issue in this context");let l=s.value;return _(l)?(l.props.tags??[]).includes(o.id)?Se({id:fe(),action:"remove.issue.tag",payload:{id:l.id,tag:o.id},...e.value}):a("Issue is not tagged with that tag"):a("Target node is not issue")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.TagTicket,description:"Add or create a tag on the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide a tag");let{selectedNode:o}=v();if(!o)return a("Invalid tag target");let i=nt(o.id,"TICKET");if(d(i))return a("Unable to tag issue in this context");let s=i.value;if(!_(s))return a("Target node is not issue");let l=ja(r),u;if(l)u=l.id;else{let g=fe(),y=await Se({id:fe(),action:"create.tag",payload:{id:g,name:r},...e.value});if(d(y))return y;u=y.value.result.id}return(s.props.tags??[]).includes(u)?a("Already tagged with that tag"):Se({id:fe(),action:"add.issue.tag",payload:{id:s.id,tag:u},...e.value})},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.AssignUserToTicket,description:"Assign a user to the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide an assignee");let{selectedIndex:o,contextNode:i}=v(),s=$(i.id)[o];if(!s)return a("Invalid assign target");let l=nt(s.id,"TICKET");if(d(l))return a("Unable to assign issue in this context");let u=l.value;if(!_(u))return a("Target node is not issue");let m=Va(r),g;if(m)g=m.id;else{let C=fe(),I=await Se({id:fe(),action:"create.contributor",payload:{id:C,name:r},...e.value});if(d(I))return I;g=I.value.result.id}return(u.props.assignees??[]).includes(g)?a("Assignee already assigned"):Se({id:fe(),action:"add.issue.assignee",payload:{id:u.id,assignee:g},...e.value})},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.UnassignUserFromTicket,description:"Remove an assignee from the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide an assignee to remove");let o=Va(r);if(!o)return a(`Assignee "${r}" does not exist`);let{selectedNode:i}=v();if(!i)return a("Invalid unassign target");let s=nt(i.id,"TICKET");if(d(s))return a("Unable to unassign in this context");let l=s.value;return _(l)?(l.props.assignees??[]).includes(o.id)?Se({id:fe(),action:"remove.issue.assignee",payload:{id:l.id,assignee:o.id},...e.value}):a(`Issue is not assigned to "${r}"`):a("Target node is not issue")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Sync,description:"Pull, commit, and push Epiq state",mode:p.COMMAND_LINE,action:Ha},{intent:P.Peek,description:"View board state at another point in time",mode:p.COMMAND_LINE,action:Ua},{intent:P.Export,description:"Export the current board layout to markdown",mode:p.COMMAND_LINE,action:async()=>{let e=await ua();return d(e)?e:(N({mode:p.DEFAULT}),c("Export successful",!0))}},{intent:P.Exit,description:"Exit the application",mode:p.COMMAND_LINE,action:async()=>(T.exit(),c("Exit successful",!0))},{intent:P.Edit,description:"Edit title or description",mode:p.COMMAND_LINE,action:async(e,t)=>{if(t.modifier===it.DESCRIPTION)return Ra();if(t.modifier===it.TITLE){let n=Y();if(d(n))return a("Unable to resolve user ID");let{contextNode:r,selectedIndex:o}=v(),i=$(r.id)[o];if(!i)return a("Missing node");if(i.readonly)return a("Cannot rename readonly node");let s=t.inputString.trim();return s?Se({id:fe(),action:"edit.title",payload:{id:i.id,name:s},...n.value}):a("Provide a title")}return a("Unknown edit command")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Config,description:"Update editor, username, view, autosync, or sync debounce",mode:p.COMMAND_LINE,action:(e,t)=>{let n=t.inputString.trim();switch(t.modifier){case X.USERNAME:{let{userId:r,preferredEditor:o,userName:i}=O(),s=n||i,l=r??fe();if(!s||!l)return a("Unable to resolve user name or id");let u=ze({userName:s,userId:l,preferredEditor:o??""});return d(u)?u:(Ee({userName:s,userId:l}),N({mode:p.DEFAULT}),c(`Username set to "${s}"`,null))}case X.EDITOR:{if(!n)return a("No editor provided");let r=ze({preferredEditor:n});return d(r)?r:(Ee({preferredEditor:n}),N({mode:p.DEFAULT}),c(`Editor configuration set to "${n}"`,null))}case X.VIEW:return n!=="wide"&&n!=="dense"?a("Invalid view mode"):(Ee({viewMode:n}),c(`View set to "${n}"`,null));case X.AUTOSYNC:return $a();case X.LOG_LEVEL:return Wa();case X.SYNC_DEBOUNCE_MS:return _a();default:return a("Unknown config command")}}}];var nm=new Set(["peek","filter","view-help"]),Be=async({isForceExecutedBySystem:e=!1}={})=>{let{commandMeta:{command:t,validity:n,modifier:r,inputString:o}}=V();if(!t)return a("No command to confirm");if(!e&&n===Ct.Invalid)return a("Invalid command");let i=ir(t);Vs();let{readOnly:s}=v();if(s&&!nm.has(i))return un({status:qe.Fail,message:"Command not available in readonly state",value:null});let l=xr.filter(m=>e||m.systemOnly!==!0).find(m=>m.intent===i);if(!l)return un({status:qe.Fail,message:"Command not found",value:null});let u;try{u=await l.action(l,{command:t,inputString:o,modifier:r})}catch(m){return un({status:qe.Fail,message:m instanceof Error?m.message:"Command failed",value:null})}return d(u)?un(u):(Ks({addToHistory:!e}),l.onSuccess?.(),O().autoSync&&Jn(),u)};var yr=[{intent:f.Exit,mode:p.MOVE,description:"[<Esc>] exit context / cancel",action:()=>(N({mode:p.COMMAND_LINE}),U("move cancel"),Be({isForceExecutedBySystem:!0}))},{intent:f.InitMove,mode:p.DEFAULT,description:"[m] move (init/confirm)",action:()=>(N({mode:p.COMMAND_LINE}),U("move start"),Be({isForceExecutedBySystem:!0}))},{intent:f.ConfirmMove,mode:p.MOVE,action:()=>(N({mode:p.COMMAND_LINE}),U("move confirm"),Be({isForceExecutedBySystem:!0}))}],hr=[{intent:f.MovePreviousItem,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move previous"),Be({isForceExecutedBySystem:!0})):a("No pending move")},{intent:f.MoveNextItem,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move next"),Be({isForceExecutedBySystem:!0})):a("No pending move")}],Ka=[{intent:f.MoveToNextContainer,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move to-next"),Be({isForceExecutedBySystem:!0})):a("No pending move")},{intent:f.MoveToPreviousContainer,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move to-previous"),Be({isForceExecutedBySystem:!0})):a("No pending move")}];var za={[w.WORKSPACE]:[...yr,...hr],[w.BOARD]:[...yr,...hr],[w.SWIMLANE]:[...yr,...hr,...Ka],[w.TICKET]:[],[w.FIELD]:[],[w.FIELD_LIST]:[],[w.TEXT]:[]};var Ga=()=>{U("");let{pendingNavTarget:e}=ct();N({mode:p.DEFAULT}),e&&T.navigate(e),lt({pendingNavTarget:void 0})},qa=[{intent:f.ExitCommandLine,mode:p.HELP,action:()=>(Ga(),c("Exiting help",null))},{intent:f.Exit,mode:p.HELP,action:()=>(Ga(),c("Closed help",null))},{intent:f.NavPreviousItem,mode:p.HELP,description:"[arrows/hjkl] navigate",action:()=>(T.navigateToPreviousItem(),c("Navigating to previous help item",null))},{intent:f.NavNextItem,mode:p.HELP,action:()=>(T.navigateToNextItem(),c("Navigating to next help item",null))},{intent:f.NavToPreviousContainer,mode:p.HELP,action:()=>(T.navigateToPreviousContainer(),c("Navigating to previous help container",null))},{intent:f.NavToNextContainer,mode:p.HELP,action:()=>(T.navigateToNextContainer(),c("Navigating to next help container",null))}];var rm=e=>{N({mode:p.COMMAND_LINE});let{pendingNavTarget:t}=ct();t&&T.navigate(t),lt({pendingNavTarget:void 0}),U(`${e} `)},Ya=()=>{U("");let{pendingNavTarget:e}=ct();e&&T.navigate(e),lt({pendingNavTarget:void 0}),N({mode:p.DEFAULT})},Xa=[{intent:f.InitCommandPalette,mode:p.DEFAULT,description:"[?] view command palette (explore descriptions for every command)",action:()=>{U("");let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}=v();return lt({pendingNavTarget:{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}}),N({mode:p.PALETTE}),c("Opening command palette",null)}},{intent:f.Confirm,mode:p.PALETTE,action:()=>{let{selectedNode:e}=v();if(!e||!et(e))return a("Command only applicable on text nodes");if(e.props.disabled)return a("Command is not available in this context");let t=e.title;return t?(rm(t),c("Selected command",t)):c("No command selected",null)}},{intent:f.ExitCommandLine,mode:p.PALETTE,action:()=>(Ya(),c("Exiting palette",null))},{intent:f.Exit,mode:p.PALETTE,action:()=>(Ya(),c("Closed command palette",null))},{intent:f.NavPreviousItem,mode:p.PALETTE,description:"[arrows/hjkl] navigate",action:()=>(T.navigateToPreviousItem(),c("Navigating to previous item",null))},{intent:f.NavNextItem,mode:p.PALETTE,action:()=>(T.navigateToNextItem(),c("Navigating to next item",null))},{intent:f.NavToPreviousContainer,mode:p.PALETTE,action:()=>(T.navigateToPreviousContainer(),c("Navigating to previous container",null))},{intent:f.NavToNextContainer,mode:p.PALETTE,action:()=>(T.navigateToNextContainer(),c("Navigating to next container",null))}];var Ja=[...qa,...Xa,{intent:f.AddItem,mode:p.DEFAULT,description:"[n] new...",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.NEW} `),c("Adding new item",null))},{intent:f.Delete,mode:p.DEFAULT,description:"[d] delete",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.DELETE} `),c("Deleting item",null))},{intent:f.InitCommandLine,mode:p.DEFAULT,description:"[:] focus command line",action:()=>(N({mode:p.COMMAND_LINE}),U(""),c("Entering command line mode",null))},{intent:f.Confirm,mode:p.DEFAULT,description:"[<Enter>] confirm/enter",action:()=>{let{selectedNode:e,contextNode:t}=v();if(!B(e?.id??"")?.length){if(e?.title===Q.DESCRIPTION)return N({mode:p.COMMAND_LINE}),U(`${x.EDIT} description `),c("Propose command",!0);if(e?.title===Q.ASSIGNEES)return N({mode:p.COMMAND_LINE}),U(`${x.ASSIGN} `),c("Propose command",!0);if(e?.title===Q.TAGS)return N({mode:p.COMMAND_LINE}),U(`${x.TAG} `),c("Propose command",!0);if(t.title===Q.DESCRIPTION&&e?.context==="TEXT")return N({mode:p.COMMAND_LINE}),U(`${x.EDIT} description `),c("Propose command",!0)}return T.enterChildNode(),c("Entering context",null)}},{intent:f.EditTitle,mode:p.DEFAULT,description:"[r] rename title",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.EDIT} title ${v().selectedNode?.title}`),c("Exiting context",null))},{intent:f.EditDescription,mode:p.DEFAULT,description:"[e] edit description",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.EDIT} description `),c("Exiting context",null))},{intent:f.Exit,mode:p.DEFAULT,description:"[q] exit context",action:()=>(T.enterParentNode(),c("Exiting context",null))},{intent:f.NavPreviousItem,mode:p.DEFAULT,description:"[arrows/hjkl] navigate",action:()=>(T.navigateToPreviousItem(),c("Navigating to previous item",null))},{intent:f.NavNextItem,mode:p.DEFAULT,action:()=>(T.navigateToNextItem(),c("Navigating to next item",null))},{intent:f.NavToPreviousContainer,mode:p.DEFAULT,action:()=>(T.navigateToPreviousContainer(),c("Navigating to previous container",null))},{intent:f.NavToNextContainer,mode:p.DEFAULT,action:()=>(T.navigateToNextContainer(),c("Navigating to next container",null))}];var om=500,im=e=>e.replace(/[\r\n]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,""),Qa=e=>{let t=im(e);t&&or(n=>(n+t).slice(0,om))};var sm=[p.COMMAND_LINE,p.PALETTE],am=e=>[{intent:f.MoveCursorLeft,mode:e,action:()=>(So(-1),c("Moving cursor left",null))},{intent:f.MoveCursorRight,mode:e,action:()=>(So(1),c("Moving cursor right",null))},{intent:f.MoveCursorLeftOfWord,mode:e,action:()=>(Io("left"),c("Moving cursor left of word",null))},{intent:f.MoveCursorRightOfWord,mode:e,action:()=>(Io("right"),c("Moving cursor right of word",null))},{intent:f.AutoCompleteCommand,mode:e,action:()=>(or((t,{remainder:n})=>n?t+n:t),c("Auto-completing command",null))},{intent:f.CaptureInput,mode:e,action:(t,{sequence:n})=>(Qa(n??""),c("Capturing input",null))},{intent:f.EraseInput,mode:e,action:()=>(Hs(),c("Erasing input",null))},{intent:f.EraseInputWord,mode:e,action:()=>(js(),c("Erasing input word",null))}],Za=[{intent:f.Confirm,mode:p.COMMAND_LINE,action:()=>(Be(),c("Executing command",null))},{intent:f.ViewHelp,mode:p.DEFAULT,action:()=>(N({mode:p.HELP}),c("Viewing help",null))},...sm.flatMap(am),{intent:f.ExitCommandLine,mode:p.COMMAND_LINE,action:()=>(N({mode:p.DEFAULT}),c("Exiting command line",null))},{intent:f.GetLastCommandFromHistory,mode:p.COMMAND_LINE,action:()=>(zs(),c("Getting last command from history",null))},{intent:f.GetNextCommandFromHistory,mode:p.COMMAND_LINE,action:()=>(Gs(),c("Getting next command from history",null))}];import nd from"chalk";var Er=nd.dim.hex(h.secondary2)(": for command line"),ed="q to exit",td=`${nd.hex(h.accent)("m")} to confirm`,Uo={[w.WORKSPACE]:[Er],[w.BOARD]:[Er],[w.BOARD+p.COMMAND_LINE]:[Er],[w.SWIMLANE]:[Er],[w.TICKET+p.HELP]:[ed],[w.SWIMLANE+p.HELP]:[ed],[w.TICKET]:[],[w.FIELD]:[],[w.SWIMLANE+p.MOVE]:[td],[w.TICKET+p.MOVE]:[td]};var fn=e=>e.trim().toLocaleLowerCase(),dm=e=>{let{tags:t}=v();return(e.props.tags??[]).map(n=>t[n]?.name).filter(n=>!!n)},cm=e=>{let{contributors:t}=v();return(e.props.assignees??[]).map(n=>t[n]?.name).filter(n=>!!n)},rd=(e,t)=>{let n=fn(t.value);if(!n)return!0;switch(t.target){case"title":return fn(e.title??"").includes(n);case"description":return fn(e.props.description??"").includes(n);case"tag":return dm(e).map(fn).some(o=>o.includes(n));case"assignee":return cm(e).map(fn).some(o=>o.includes(n));default:return!0}};function od(e,t,n){let r=t[e];if(!r)return a("buildBreadCrumb(): current node not found");let o=[],i=r;for(;i&&(o.push(i),!(i.id===n||!i.parentNodeId));)i=t[i.parentNodeId];let s=o[o.length-1];return!s||s.id!==n?a("buildBreadCrumb(): node is not connected to root"):(o.reverse(),c("Breadcrumb built",o))}var id=e=>{let t={};for(let n of e)n.intent&&(t[n.mode]||(t[n.mode]={}),t[n.mode][n.intent]=n);return t};var bt,_o,$o=new Set,sd=()=>{for(let e of $o)e()},um=e=>($o.add(e),()=>$o.delete(e));function ad(e){let{contextNodeId:t,mode:n,rootNodeId:r,nodes:o,filters:i}=e;if(!t)return a("derive(): contextNodeId is missing");if(!r)return a("derive(): rootNode is missing");if(!o[r])return a("derive(): unable to find root node");let l=o[t];if(!l)return a("Unable to derive state, contextNode not found");let u=od(t,o,r);if(d(u))return logger.error(u.message),u;let m=u.value,{context:g}=l,y=Uo[g+n]??Uo[g]??[],C=[...Ja,...za[g]??[],...Za],I=id(C),S=mm(o,i),A=S[t]?.[e.selectedIndex]??null;return c("Derived successfully",{...e,contextNode:l,breadCrumb:m,availableHints:y,availableActions:C,actionIndex:I,selectedNode:A,renderedChildrenIndex:S})}var v=()=>{if(!bt)throw new Error("State not initialized. Call initWorkspaceState() first.");return bt},ot=()=>bt?c("Retrieved state",bt):a("State not initialized. Call initWorkspaceState() first.");function nn(e){_o=e;let t=Ye(process.cwd()),n=!1;if(!d(t)){let i=Qe(t.value);if(d(i))return a(i.message);n=!0}let r={readOnly:!1,filters:[],tags:{},contributors:{},mode:p.DEFAULT,nodes:{[e.id]:e},rootNodeId:e.id,contextNodeId:e.id,renderedChildrenIndex:{},selectedIndex:-1,syncStatus:{status:"synced",msg:""},eventLog:[],unappliedEvents:[],timeMode:"live",hasProjectDefinition:n,hasInitializingEvents:!1},o=ad(r);return d(o)?o:(bt=o.value,sd(),c("State initialized",null))}function Ne(e){let t=v(),n=e(t),r=ad(n);return d(r)?a(r.message??"Unable to update state"):(bt=r.value,sd(),c("State updated",null))}var N=e=>Ne(t=>({...t,...e}));var K=()=>lm(um,v,v),mm=(e,t)=>{let n={};for(let r of Object.values(e))_(r)&&t.length>0&&!t.every(o=>rd(r,o))||!r.parentNodeId||r.isDeleted||((!r.parentNodeId||!n[r.parentNodeId])&&(n[r.parentNodeId]=[]),n[r.parentNodeId].push(r));for(let r of Object.keys(n))n[r].sort((o,i)=>{let s=e[o.id],l=e[i.id];return!s||!l?0:s.rank.localeCompare(l.rank)});return n},$=e=>v()?.renderedChildrenIndex[e]??[],gn=()=>_o?nn(_o):a("Cannot reset state: no initial workspace found"),Dt=()=>bt!==void 0;import{Box as Wo,Text as vn}from"ink";import Me,{useEffect as pm,useMemo as gm}from"react";import{ulid as fm}from"ulid";var dd=({text:e,match:t,color:n,highlightColor:r=h.secondary,dimColor:o=!1})=>{if(!t)return Me.createElement(vn,{color:n,dimColor:o},e);let i=e.toLowerCase(),s=t.toLowerCase(),l=i.indexOf(s);return l===-1?Me.createElement(vn,{color:n,dimColor:o},e):Me.createElement(vn,{color:n,dimColor:o},e.slice(0,l),Me.createElement(vn,{backgroundColor:r,bold:!0},e.slice(l,l+t.length)),e.slice(l+t.length))},cd=fm(),vm=e=>`${e}`,xm=e=>{let{pendingNavTarget:t}=ct();if(!t)return[];let{breadCrumb:n,contextNode:r,selectedNode:o}=t,i=new Set(ee(x.NONE,{breadCrumb:n,contextNode:r,readOnly:v().readOnly,selectedNode:o}));return[...new Set(Object.values(x))].filter(s=>s!=="move").filter(s=>s.length>0).filter(s=>s!==x.PALETTE).map(s=>{let l=ir(s),u=xr.find(m=>m.intent===l);return{command:s,description:u?.description??`[${s}] Run command`,isAvailable:i.has(s)}}).filter(s=>s.command.toLowerCase().startsWith(e)||e.length>=2&&s.description.toLowerCase().includes(e)).sort((s,l)=>s.isAvailable!==l.isAvailable?s.isAvailable?-1:1:s.command.localeCompare(l.command))},ym=e=>q.text({id:cd,parentNodeId:e,rank:"000000",name:"Command Palette",props:{},readonly:!0,isVirtual:!0}),hm=(e,t,n)=>q.text({id:vm(e.command),parentNodeId:n,rank:String(t).padStart(6,"0"),name:e.command,props:{value:e.description,disabled:!e.isAvailable},readonly:!0,isVirtual:!0}),Ho=[],Em=e=>{ld();let t=b.createNode(ym(v().rootNodeId));d(t)||!et(t.value)||(Ho=[t.value,...e.map((n,r)=>hm(n,r,cd)).map(b.createNode).filter(J).map(({value:n})=>n).filter(et)],T.navigate({contextNode:t.value,selectedIndex:0}))},ld=()=>{let e=Ho.map(t=>t.id);Ho=[];for(let t of e)b.deleteNode(t)};function ud({width:e,height:t}){let r=qs().value.trim().toLowerCase(),o=gm(()=>xm(r),[r]);pm(()=>(Em(o),()=>{ld()}),[o]);let i=v().selectedIndex;return Me.createElement(Wo,{flexDirection:"column",width:e,height:t-2},Me.createElement(st,{height:t-4,itemHeight:3,selectedIndex:i},o.map((s,l)=>{let u=l===i,m=s.isAvailable?h.accent:h.secondary2,g=s.isAvailable?"":"[unavailable] ";return Me.createElement(Wo,{key:s.command,flexDirection:"column",paddingX:1,borderLeft:!1,borderBottom:!1,borderRight:!1,borderColor:h.secondary,borderStyle:"single"},Me.createElement(vn,{color:m,dimColor:!s.isAvailable},u?"\u276F ":" ",Me.createElement(dd,{text:Li(s.command),match:r,color:m,dimColor:!s.isAvailable})),Me.createElement(Wo,{paddingLeft:2},Me.createElement(dd,{text:g+s.description,match:r.length>=2?r:"",color:u&&s.isAvailable?h.primary:h.secondary2,dimColor:!s.isAvailable})))})))}import{Box as km}from"ink";import Vo from"react";import yn from"chalk";import{Box as jo,Text as md}from"ink";import xn,{useEffect as Cm,useMemo as Nm,useState as bm}from"react";var pd=yn.gray,Sm=yn.inverse,Im=yn.inverse.gray,Rm={hint:"",hints:[],overlap:0,remainder:""},fd=({value:e,command:t})=>{if(!t)return null;let n=e.trimStart(),o=e.length-n.length;return e.slice(o,o+t.length)!==t?null:{start:o,end:o+t.length}},Am=({command:e,modifier:t})=>{if(!t)return null;if(e==="tag"||e==="assign"){let n=be(t);return{bg:r=>yn.bgHex(n).black(r),bgCursor:r=>yn.bgHex(n).inverse.black(r)}}return eo(t)},Tm=({value:e,command:t,modifier:n})=>{if(!t||!n)return null;let r=fd({value:e,command:t});if(!r)return null;let i=e.slice(r.end).match(/^\s*/)?.[0].length??0,s=r.end+i;return e.slice(s,s+n.length)!==n?null:{start:s,end:s+n.length}},gd=()=>({value:ie.value,cursorPosition:ie.cursorPosition,commandIsPending:ie.commandIsPending,autoCompletion:ie.commandMeta.autoCompletion??Rm,infoMessage:ie.commandMeta.infoMessage,validationStatus:ie.commandMeta.validity,command:ie.commandMeta.command,inputString:ie.commandMeta.inputString,modifier:ie.commandMeta.modifier}),wm=(e,t)=>e.value===t.value&&e.cursorPosition===t.cursorPosition&&e.commandIsPending===t.commandIsPending&&e.infoMessage===t.infoMessage&&e.autoCompletion.hint===t.autoCompletion.hint&&e.autoCompletion.overlap===t.autoCompletion.overlap&&e.autoCompletion.remainder===t.autoCompletion.remainder&&e.validationStatus===t.validationStatus&&e.command===t.command&&e.modifier===t.modifier&&e.inputString===t.inputString,vd=({width:e,mode:t})=>{let[n,r]=bm(gd());Cm(()=>{let C=()=>{let S=gd();r(A=>wm(A,S)?A:S)},I=bo(C);return C(),()=>{I()}},[]);let{value:o,cursorPosition:i,infoMessage:s,commandIsPending:l,autoCompletion:u,command:m,modifier:g}=n,y=Nm(()=>{let C=Math.max(0,Math.min(i,o.length)),I=fd({value:o,command:m}),S=Tm({value:o,command:m,modifier:g}),A=m?eo(m):null,R=Am({command:m,modifier:g}),M=(re,ue)=>{let Rt=I&&ue>=I.start&&ue<I.end,ft=S&&ue>=S.start&&ue<S.end;return Rt&&A?A.fg(re):ft&&R?R.bg(re):re},F=(re,ue)=>{let Rt=I&&ue>=I.start&&ue<I.end,ft=S&&ue>=S.start&&ue<S.end;return Rt&&A?A.fgCursor(re):ft&&R?R.bgCursor(re):Sm(re)},Ie=o.slice(0,C),le=o[C]??" ",Vt=C<o.length?o.slice(C+1):"",bn=Array.from(Ie).map((re,ue)=>M(re,ue)).join(""),It=F(le,C),Kt=Array.from(Vt).map((re,ue)=>M(re,C+1+ue)).join("");if(u.hint){let re=u.hint[u.overlap]??le;It=Im(re),Kt=pd(u.remainder.slice(1)+Vt)}return pd(t===p.PALETTE?"?":":")+bn+It+Kt},[o,i,u,m,g]);return xn.createElement(jo,{flexDirection:"column",justifyContent:"flex-start"},xn.createElement(jo,{flexDirection:"column",paddingX:1,borderColor:h.secondary,borderStyle:"round",width:e},xn.createElement(jo,null,xn.createElement(md,null,y),s&&xn.createElement(md,{wrap:"truncate",color:l?h.red:h.secondary2},` ${s} `))))};import{Box as Mm,Text as Pm}from"ink";import xd from"react";var Lm=(e,t)=>{let n=[],r=0;for(let o of e){let s=(n.length>0?" | ":"").length+o.length;if(r+s>t-4)break;n.push(o),r+=s}return n},yd=({width:e,availableHints:t})=>{let n=Lm(t,e).join(" | ");return xd.createElement(Mm,{width:e,borderStyle:"round",borderColor:h.secondary,paddingX:1},xd.createElement(Pm,{color:h.secondary2},n.length?n:"\xA0"))};var hn=({width:e,mode:t,availableHints:n})=>{let r=[],o=0;for(let i of n){let l=(r.length>0?" | ":"").length+i.length;if(o+l>e+2)break;r.push(i),o+=l}return Vo.createElement(km,null,t===p.COMMAND_LINE||t===p.PALETTE?Vo.createElement(vd,{width:e,mode:t}):Vo.createElement(yd,{width:e,mode:t,availableHints:n}))};import{Box as mt,Text as Ht}from"ink";import ce,{useEffect as Dm,useMemo as Fm}from"react";import{ulid as hd}from"ulid";var Nr=hd(),Bm=()=>[...new Set([...v().availableActions].map(e=>e.description).filter(e=>e!==void 0))].map(e=>{let[t,n]=e.split("]"),r=t?.replace("[",""),o=n?.trim();return[r,o]}).filter(e=>e[0]!==void 0&&e[1]!==void 0).sort(([e],[t])=>e.length===1&&t.length!==1?-1:e.length!==1&&t.length===1?1:e.localeCompare(t,void 0,{sensitivity:"base"})).map(([e,t])=>({keys:e,action:t})),Om=e=>q.text({id:Nr,parentNodeId:e,rank:"000000",name:"Help",props:{},isVirtual:!0,readonly:!0}),Um=(e,t,n)=>q.text({id:hd(),parentNodeId:n,rank:String(t).padStart(6,"0"),name:e.keys,props:{value:e.action},readonly:!0,isVirtual:!0}),Cr=[],Ed=()=>{let e=Cr.filter(n=>n.id!==Nr).map(n=>n.id),t=Cr.filter(n=>n.id===Nr).map(n=>n.id);Cr=[];for(let n of[...e,...t])b.deleteNode(n)},_m=e=>{Ed();let t=b.createNode(Om(v().rootNodeId));if(d(t)||!et(t.value))return logger.error("Could not attach help nodes");Cr=[t.value,...e.map((n,r)=>Um(n,r,Nr)).map(b.createNode).filter(J).map(({value:n})=>n).filter(et)],T.navigate({contextNode:t.value,selectedIndex:0})},Cd=({width:e,height:t})=>{let n=Fm(()=>Bm(),[]);Dm(()=>(_m(n),()=>{Ed()}),[n]);let r=v().selectedIndex;return ce.createElement(mt,{flexDirection:"column",marginTop:3,borderColor:h.secondary,borderStyle:"round",width:e,height:t-2},ce.createElement(mt,{paddingX:1,justifyContent:"center"},ce.createElement(Ht,{color:h.accent},"Help"),ce.createElement(Ht,{dimColor:!0}," \u2014 navigate with arrows/hjkl, press q to close")),ce.createElement(mt,{paddingX:1,marginTop:1},ce.createElement(mt,{width:20,justifyContent:"flex-end"},ce.createElement(Ht,{color:h.secondary},"Key(s)")),ce.createElement(mt,{flexGrow:1,width:40,paddingLeft:2},ce.createElement(Ht,{color:h.secondary},"Action"))),ce.createElement(st,{height:t-7,itemHeight:1,selectedIndex:r},n.map(({keys:o,action:i},s)=>{let l=s===r;return ce.createElement(mt,{paddingX:1,key:`${o}-${i}-${s}`,flexDirection:"row"},ce.createElement(mt,{width:20,justifyContent:"flex-end"},ce.createElement(Ht,{color:h.accent},o)),ce.createElement(mt,{flexGrow:1,width:40,paddingLeft:2},ce.createElement(Ht,{color:l?h.primary:h.secondary2},i)))})))};import $m from"chalk";import{Box as br,Text as Ge}from"ink";import xe from"react";var Nd=({width:e,height:t})=>xe.createElement(br,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:h.secondary,rowGap:1},xe.createElement(Ge,{color:h.accent,bold:!0},"Initialize project"),xe.createElement(Ge,null,`This folder is not an ${$m.hex(h.accent)("epiq")} project yet.`),xe.createElement(Ge,{color:h.primary},"To start tracking issues here, we need to initialize a new",xe.createElement(Ge,{color:h.primary,backgroundColor:h.secondary}," .epiq/project.json "),"file in this repository."),xe.createElement(br,{marginTop:1,flexDirection:"column"},xe.createElement(br,null,xe.createElement(Ge,{color:h.accent}," "),xe.createElement(Ge,{color:h.primary},"Type "),xe.createElement(Ge,{backgroundColor:h.secondary}," :init "))),xe.createElement(br,{marginTop:1},xe.createElement(Ge,{color:h.secondary2},"This will create, commit and push "),xe.createElement(Ge,{color:h.primary,backgroundColor:h.secondary}," .epiq/project.json ")));import{Box as Sr,Text as Oe}from"ink";import ne from"react";var Wm=({isDone:e,command:t,value:n})=>ne.createElement(Sr,null,ne.createElement(Oe,{color:h.accent,dimColor:e},e?" \u2714 ":" "),ne.createElement(Oe,{dimColor:e},"Type "),ne.createElement(Oe,{backgroundColor:h.secondary,dimColor:e}," "+t+" "),n!==void 0&&ne.createElement(ne.Fragment,null,ne.createElement(Oe,{dimColor:e}," "),ne.createElement(Oe,{color:h.secondary,dimColor:e},"<"+n+">"))),Hm=e=>{if(typeof e=="string")return e;if(typeof e=="boolean")return e?"on":"off"};function Ko({width:e,height:t}){let{isSetPreferredEditor:n,isSetUserName:r,userName:o,preferredEditor:i,autoSync:s,isSetAutoSync:l}=Ze(),u=[{key:"username",done:r,command:":config username",value:o,message:"First, choose your username."},{key:"editor",done:n,command:":config editor",value:i,message:"Nice. Now pick your editor."},{key:"autosync",done:l,command:":config autosync",value:s,message:"Almost there. Configure auto sync."}],m=u.findIndex(y=>!y.done),g=m===-1?void 0:u[m];return ne.createElement(Sr,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:h.secondary,rowGap:1},ne.createElement(Oe,{color:h.accent,bold:!0},"Welcome! \u{1F539}"),ne.createElement(Oe,null,"Let's get you started - it's a breeze."),ne.createElement(Oe,{color:h.secondary2},"Remember - you can always search available commands by typing:",ne.createElement(Oe,{color:h.accent}," ? ")),g&&ne.createElement(Oe,{color:h.secondary2},g.message),ne.createElement(Sr,{flexDirection:"column"},u.map((y,C)=>m===-1||C<=m?ne.createElement(Sr,{key:y.key,marginBottom:1},ne.createElement(Wm,{isDone:y.done,command:y.command,value:y.done?Hm(y.value):void 0})):null)))}import wr from"chalk";import{Box as Tr,Text as jt}from"ink";import se from"react";var bd="0.6.12";import{Box as Ir,Text as jm}from"ink";import St from"react";var Sd=({width:e})=>{let{viewMode:t}=O(),n=K(),{breadCrumb:r,contextNode:o,selectedIndex:i,renderedChildrenIndex:s}=n,l=s[o.id]?.[i],u=nt(l?.id??o.id,"TICKET"),m=J(u)?u.value:void 0,g=m?.props.tags??[],y=m?.props.assignees??[],C=m?.parentNodeId?!Xr(o.id,m.parentNodeId)&&t==="dense":!1,I=r.map((R,M)=>{let F=M===r.length-1,Ie=B(R.id),le=F?Ie?.[i]?.title:void 0;return`${M?" / ":""}${R.title??""}${le?` \u25B8 ${le}`:""}`}).join(""),S=g.reduce((R,M)=>R+(b.getTag(M)?.name.length??0)+4,0)+y.reduce((R,M)=>R+(b.getContributor(M)?.name.length??0)+4,0),A=e-S;return St.createElement(Ir,{overflow:"hidden",justifyContent:"flex-start",alignItems:"flex-start"},St.createElement(Ir,{overflow:"hidden",width:A},St.createElement(jm,{wrap:"truncate-end",color:h.secondary2},I)),C?g.map(R=>St.createElement(Ir,{key:R,paddingLeft:1},St.createElement(_t,{id:R}))):null,C?y.map(R=>St.createElement(Ir,{key:R,paddingLeft:1},St.createElement(Ut,{id:R}))):null)};import{Box as Vm,Text as Id}from"ink";import Rr from"react";var Km=({filters:e})=>Rr.createElement(Vm,{columnGap:1},Rr.createElement(Id,{color:"red"},"APPLIED FILTERS:"),e.map(({value:t,target:n,operator:r})=>Rr.createElement(Id,{backgroundColor:"black",color:"white"},` ${n}${r}"${t}" `))),Rd=Rr.memo(Km);import{Box as zm,Text as Ar}from"ink";import En from"react";function Ad(){let{eventLog:e,unappliedEvents:t}=K(),n=e.at(-1)?.id,r=$n(n??""),o=J(r)?qi(r.value):"INVALID DATE";return En.createElement(zm,{paddingLeft:1},En.createElement(Ar,{backgroundColor:h.accent}," Readonly "),En.createElement(Ar,{color:h.accent}," "+t.length+" edits ago at "+o+"."),En.createElement(Ar,{color:h.accent}," Resume with "),En.createElement(Ar,{backgroundColor:h.accent}," :peek now "))}import zo from"chalk";import{Box as Gm,Text as Td}from"ink";import Go,{useEffect as qm,useState as Ym}from"react";var Xm=["#4c567a","#9d7cd8","#7aa2f7","#7dcfff","#9d7cd8"],wd=e=>{let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}},Jm=({r:e,g:t,b:n})=>{let r=o=>Math.round(Math.max(0,Math.min(255,o))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`},Qm=(e,t,n)=>{let r=wd(e),o=wd(t);return Jm({r:r.r+(o.r-r.r)*n,g:r.g+(o.g-r.g)*n,b:r.b+(o.b-r.b)*n})},Zm=(e,t)=>{if(e.length===1)return e[0];let n=t*(e.length-1),r=Math.floor(n),o=n-r,i=e[r],s=e[Math.min(r+1,e.length-1)];return Qm(i,s,o)};function Md({syncStatus:e,autoSync:t}){let[n,r]=Ym(0);qm(()=>{if(e.status!=="syncing"){r(0);return}let l=setInterval(()=>{r(u=>u+1)},50);return()=>clearInterval(l)},[e.status]);let o={synced:" ",failed:"retry",syncing:"...",pending:"wait"},s={synced:h.secondary2,failed:h.yellow,pending:h.secondary2,syncing:Zm(Xm,(Math.sin(n*.12)+1)/2)??""}[e.status];return Go.createElement(Gm,null,Go.createElement(Td,null,zo.hex(h.secondary2).dim(t?"AutoSync: ":"Sync: ")),Go.createElement(Td,null,zo.hex(s)("\u25CF")+zo.hex(h.secondary2).dim(` ${o[e.status].padEnd(4)} `)))}function Cn({filters:e,hideBreadCrumb:t=!1}){let{timeMode:n,syncStatus:r,mode:o}=K(),{userName:i,preferredEditor:s,autoSync:l}=O(),u=64,m=process.stdout.columns-u-8;return se.createElement(Tr,{justifyContent:"space-between",flexDirection:"row","max-width":process.stdout.columns-40,overflow:"hidden"},t?se.createElement(jt,null," "):o===p.PALETTE?se.createElement(Tr,null,se.createElement(jt,{color:h.accent},"Command Palette"),se.createElement(jt,{dimColor:!0,color:h.secondary2}," ","- search, select and press enter")):se.createElement(Tr,{paddingLeft:1},e.length>0?se.createElement(Rd,{filters:e}):se.createElement(Sd,{width:m})),n==="live"?se.createElement(Tr,{columnGap:1,paddingRight:2,"max-width":u,overflow:"hidden",justifyContent:"flex-end"},se.createElement(Md,{autoSync:!!l,syncStatus:r}),se.createElement(jt,null,wr.hex(h.secondary2).dim("Mode: ")+wr.hex(h.secondary2).dim(o.padEnd(8," "))," "),se.createElement(Pd,{icon:"@",value:i}),se.createElement(Pd,{icon:"\u276F",value:s}),se.createElement(jt,{dimColor:!0,color:h.secondary2},bd+" ")):"",n==="peek"?se.createElement(Ad,null):"")}function Pd({icon:e,value:t}){return se.createElement(jt,null,wr.dim(e)+wr.hex(h.accent)(` ${t??"-"} `))}import{Box as ep,Text as tp}from"ink";import Nn from"react";import{Box as Mr,Text as qo}from"ink";import pt from"react";function Yo(){let e=K(),t=e.nodes[e.rootNodeId],o=process.stdout.rows-1-3,i=process.stdout.columns||120,s=t?.id?$(t?.id):[];return pt.createElement(Mr,{flexDirection:"column",height:o,padding:1,borderStyle:"round",borderColor:h.secondary,width:i},pt.createElement(Mr,{padding:1,paddingTop:0,paddingBottom:0},pt.createElement(qo,null,"Select a board:")),pt.createElement(Mr,{padding:1,flexDirection:"column"},s.map((l,u)=>{let m=e.contextNode.context==="WORKSPACE"&&e.selectedIndex===u,y=$(l.id).flatMap(({id:C})=>B(C)).length;return pt.createElement(Mr,{key:l.id??u},pt.createElement(qo,{color:m?h.accent:h.secondary2},pt.createElement(ge,{isSelected:m})),pt.createElement(qo,{color:m?h.accent:h.secondary2},l.title," (",y," issues)",l.readonly?" \u{1F512}":""))})))}var np=({contextNode:e,selectedIndex:t,breadCrumb:n,mode:r,viewMode:o,height:i,width:s})=>{let{renderedChildrenIndex:l}=K(),u=n.find(({context:C})=>C==="BOARD"),y=i-1-3;return Nn.createElement(ep,{flexDirection:"row"},e.context==="WORKSPACE"?Nn.createElement(Yo,null):u?Nn.createElement(mr,{height:y,width:s,swimlanes:(l[u.id]??[]).filter(C=>C!==void 0&&wt(C)),contextNode:e,selectedIndex:t,breadCrumb:n,viewMode:o,mode:r}):Nn.createElement(tp,null))},Ld=Nn.memo(np);import{useEffect as rp}from"react";var op=e=>{rp(()=>{if(!e)return;let t,n=!1,r=()=>{if(n)return;let{autoSyncIntervalMs:o,userName:i,preferredEditor:s}=O();s&&i&&o&&(t=setTimeout(()=>{if(n)return;let{readOnly:l,mode:u}=v();u==="default"&&!l&&Jn(),r()},o))};return r(),()=>{n=!0,t&&clearTimeout(t)}},[e])},kd=({autoSync:e})=>(op(e),null);function Xo({width:e,height:t}){let n=K(),{autoSync:r,viewMode:o}=Ci(),i=n.filters;if(n.mode===p.HELP)return z.createElement(gt,{flexDirection:"column"},z.createElement(Cd,{width:e,height:t}));if(n.mode===p.PALETTE)return z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{filters:i}),z.createElement(ud,{width:e,height:t-2}),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}));let{isSetupDone:s}=Ze(),l=!s,u=s&&!n.hasProjectDefinition;if(l)return z.createElement(gt,{flexDirection:"column"},z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{hideBreadCrumb:!0,filters:i}),z.createElement(Ko,{height:t,width:e})),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}));if(u)return z.createElement(gt,{flexDirection:"column"},z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{hideBreadCrumb:!0,filters:i}),z.createElement(Nd,{height:t,width:e})),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}));let m=Ce(n.breadCrumb??[],"BOARD");if(J(m)){let g=m.value.id,y=$(g).length,C=3,I=Math.floor(e/C),S=Math.floor(e/Math.max(y,1));e=Math.min(S,I)*Math.max(y,C)}return z.createElement(gt,{flexDirection:"column"},z.createElement(kd,{autoSync:r}),z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{filters:i}),z.createElement(Ld,{width:e,height:t,contextNode:n.contextNode,selectedIndex:n.selectedIndex,breadCrumb:n.breadCrumb,viewMode:o??"dense",mode:n.mode})),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}))}import ip from"readline";var Pr,Lr,Ue,sp=new Set([f.MoveCursorLeft,f.EraseInputWord,f.MoveCursorLeftOfWord,f.MoveCursorRight,f.MoveCursorRightOfWord,f.NavToPreviousContainer,f.NavToNextContainer,f.NavPreviousItem,f.NavNextItem,f.SetViewDense,f.SetViewWide,f.Confirm,f.Exit,f.InitCommandLine,f.InitCommandPalette,f.ExitCommandLine,f.CaptureInput,f.EraseInput,f.EraseInputWord,f.HideHelp,f.ViewHelp,f.SetViewDense,f.SetViewWide,f.GetLastCommandFromHistory,f.GetNextCommandFromHistory,f.AutoCompleteCommand]),Dd=async e=>{if(e.ctrl&&e.name==="c")return T.exit();let{actionIndex:t,mode:n,readOnly:r}=v(),o=Xs(e,n);if(!o||r&&!sp.has(o))return;let i=t[n]?.[o];if(i?.action)try{await i.action(i,e)}catch(s){logger.error(s)}},ap=()=>async function(t,n){n.name!=="escape"&&(Ue&&(clearTimeout(Ue),Ue=void 0),await Dd(n))},dp=()=>async function(t){if(t.length===1&&t[0]===27){Ue&&clearTimeout(Ue),Ue=setTimeout(()=>{Dd({name:"escape",ctrl:!1,meta:!1,shift:!1,sequence:"\x1B"}),Ue=void 0},25);return}Ue&&(clearTimeout(Ue),Ue=void 0)};function Fd(){Pr&&process.stdin.removeListener("keypress",Pr),Lr&&process.stdin.removeListener("data",Lr),Pr=ap(),Lr=dp(),ip.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.on("data",Lr),process.stdin.on("keypress",Pr)}ba();lp(`${kr.bold("Epiq CLI")}
57
+ `));let ft=ot();if(d(ft))return j(16,ft.message);let{rootNodeId:_d,nodes:$d}=ft.value,Jo=$d[_d];return Jo?(T.navigate({contextNode:Jo,selectedIndex:0}),N({hasProjectDefinition:!0,mode:p.DEFAULT}),c(It,null)):j(16,"Unable to resolve initialized root node")};import{ulid as Ju}from"ulid";import{ulid as Xu}from"ulid";var Ma=null,ut=()=>structuredClone(Ma),pn=e=>{Ma=e},Pa=()=>{let{contextNode:e,selectedIndex:t}=v(),r=B(e.id)[t];return r?c("Resolved selected child",r):a("Target node not found")},Fo=({id:e,parentId:t,position:n={at:"end"}})=>{let r=B(t).filter(o=>o.id!==e);return Kn(r,n)},La=({id:e,parentId:t,position:n={at:"end"}})=>{let r=Y();if(d(r))return a("Unable to resolve user ID");let o=Fo({parentId:t,id:e,position:n});return d(o)?o:c("Created pending move state",{id:Xu(),...r.value,action:"move.node",payload:{id:e,parent:t,rank:o.value.rank}})},ka=e=>{pn(e);let t=tn(e,!0);return d(t)?t:c("Node moved successfully",t.value)};function Bo(e){let t=Pa();if(d(t))return t;let{contextNode:n,nodes:r}=v();if(!n.parentNodeId)return a("Missing parent node id");let o=r[n.parentNodeId];if(!o)return a("Missing parent node");let i=B(o.id),s=i.findIndex(({id:m})=>m===n.id);if(s<0)return a("Current node not found among siblings");let l=i[s+e];if(!l)return a("Missing sibling node");let u=La({id:t.value.id,parentId:l.id,position:{at:"end"}});return d(u)?u:ka(u.value)}function Oo(e){let t=Pa();if(d(t))return t;let{contextNode:n,selectedIndex:r}=v(),i=B(n.id)[r+e];if(!i)return a("Missing sibling node");let s=La({id:t.value.id,parentId:n.id,position:{at:e===1?"after":"before",sibling:i.id}});return d(s)?s:ka(s.value)}var Da=()=>{let e=ut();if(!e)return a("No pending move state");let t=e.payload.id,n=e.payload.parent,r=v().nodes[n];if(!r)return a("Move parent not found");let o=B(n).findIndex(i=>i.id===t);return o===-1?a("Moved node not found among rendered children"):(T.navigate({contextNode:r,selectedIndex:o}),c("Synchronized navigation to moved node",null))},fr=(e,t="Moved preview")=>{if(d(e))return e;let n=Da();return d(n)?n:(N({mode:p.MOVE}),c(t,null))},Fa=async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t}=V().commandMeta,{contextNode:n,selectedIndex:r}=v(),o=B(n.id)[r];if(!o)return N({mode:p.DEFAULT}),a("No move target");if(t==="start"){if(o.readonly)return a("Target node is read-only");if(r===-1)return a("No item selected");if(!o.parentNodeId)return a("Target has no parent");let i=B(o.parentNodeId),s=i.findIndex(({id:y})=>y===o.id);if(s===-1)return a("Target not found among siblings");let l=i[s-1],u=i[s+1],m=u!=null?{at:"before",sibling:u.id}:l!=null?{at:"after",sibling:l.id}:{at:"start"},g=Fo({parentId:o.parentNodeId,id:o.id,position:m});return d(g)?g:(pn({id:Ju(),action:"move.node",payload:{id:o.id,parent:o.parentNodeId,rank:g.value.rank},...e.value}),N({mode:p.MOVE}),c("Move initialized",null))}if(t==="next")return fr(Oo(1));if(t==="previous")return fr(Oo(-1));if(t==="to-next")return fr(Bo(1));if(t==="to-previous")return fr(Bo(-1));if(t==="confirm"){let i=ut();if(!i)return a("No pending move to confirm");let s=await Re();if(d(s))return s;let l=Te(i,s.value);if(d(l))return l;let u=Da();return d(u)?u:(pn(null),N({mode:p.DEFAULT}),c("Moved item",null))}return t==="cancel"?(pn(null),N({mode:p.DEFAULT}),c("Cancelling move",null)):a("Invalid move modifier")};import{ulid as vr}from"ulid";import{monotonicFactory as Qu,ulid as Zu}from"ulid";var em=Qu(),Ba=({name:e,parent:t,rank:n,user:{userId:r,userName:o}})=>{let i=em();return c("Created issue events",[{id:Zu(),userId:r,userName:o,action:"add.issue",payload:{id:i,parent:t,name:e,rank:n}}])};var Oa=async(e,t)=>{let n=Y();if(d(n))return a("Unable to resolve user ID");let r=await Re();if(d(r))return r;let o=r.value;if(!t.inputString)return a(`provide a name for your ${t.modifier}`);let{breadCrumb:i,contextNode:s,selectedIndex:l}=v(),u=m=>{let g=Te(m,o);if(d(g))return g;let y=b.getNode(g.value.result.id);if(!y)return a("Created node not found");if(!y.parentNodeId)return g;let C=b.getNode(y.parentNodeId);return C?(T.navigate({contextNode:C,selectedIndex:b.getSiblings(y.parentNodeId).findIndex(({id:I})=>I===y.id)}),g):a("Parent node not found")};if(t.modifier==="board"){let{rootNodeId:m}=v(),g=b.getNode(m);if(!g)return a("Workspace not found");let y=zn(g.id,n.value,o);return d(y)?y:u({id:vr(),action:"add.board",payload:{id:vr(),name:t.inputString,parent:g.id,rank:y.value},...n.value})}if(t.modifier==="swimlane"){let m=Ce(i,"BOARD");if(d(m))return a("Unable to add swimlane in this context");let g=zn(m.value.id,n.value,o);return d(g)?g:u({id:vr(),action:"add.swimlane",payload:{id:vr(),name:t.inputString,parent:m.value.id,rank:g.value},...n.value})}if(t.modifier==="issue"){let m=$(s.id)[l],g=s.context==="SWIMLANE"?s:s.context==="BOARD"&&m?.context==="SWIMLANE"?m:(()=>{let F=Ce(i,"SWIMLANE");return d(F)?null:F.value})();if(!g)return a("Unable to add issue in this context");let y=zn(g.id,n.value,o);if(d(y))return y;let C=Ba({name:t.inputString,parent:g.id,rank:y.value,user:n.value});if(d(C))return C;let I=C.value,S=ss(I,o);if(S.some(F=>d(F)))return a("Issue create failed: "+S.filter(d).map(F=>F.message).filter(Boolean).join(", "));let A=S[0];if(!A||d(A))return a("Issue creation failed");let M=I.find(F=>F.action==="add.issue")?.payload.id;return M?(T.navigate({contextNode:g,selectedIndex:b.getSiblings(g.id).findIndex(({id:F})=>F===M)}),c("Issue created",null)):a("Unable to determine ticket id")}return c("Success",null)};var Ua=async()=>{let e=Ce(v().breadCrumb,"BOARD");if(d(e))return e;let t=await Je(process.cwd());if(d(t))return a("Unable to locate repo root");let n=Xe({repoRoot:t.value});if(d(n))throw new Error(n.message);let{modifier:r}=V().commandMeta;if(r==="now"){let S=Lt(n.value);if(d(S))return a(S.message);let A=gn();if(d(A))return A;let M=ht(S.value).filter(d);return M.length>0?a(M.map(F=>F.message).join(", ")):(N({mode:p.DEFAULT,readOnly:!1,timeMode:"live",unappliedEvents:[]}),c("Peeking now",!0))}let o;if(r==="prev"){let S=v().eventLog.at(-1),A=to(S);if(A===null)return a("No previous event to peek");o=A}else if(r==="next"){let S=v().unappliedEvents.at(0),A=to(S);if(A===null)return a("No next event to peek");o=A+1}else{let S=er(r);if(!S)return a("Invalid peek date");o=S.getTime()}let i=v(),s=e.value.id,l=ts(n.value,o);if(d(l))return a(l.message);let{appliedEvents:u,unappliedEvents:m}=l.value,g=gn();if(d(g))return g;let C=ht(u).filter(d);if(C.length>0)return gn(),N(i),a(C.map(S=>S.message).join(", "));let I=v().nodes[s];return I?(T.navigate({contextNode:I,selectedIndex:0}),N({mode:p.DEFAULT,readOnly:!0,timeMode:"peek",unappliedEvents:m}),c("Peeking",!0)):(gn(),N(i),a("Board did not exist at peek date"))};import tm from"zod";var _a=()=>{let e=V().commandMeta.inputString,t=tm.coerce.number().int().min(3e3).safeParse(e);if(!t.success)return a("Auto sync duration must be a number of at least 3000 ms");let n=ze({autoSyncDebounceMs:t.data});return d(n)?n:(Ee({autoSyncIntervalMs:t.data}),N({mode:p.DEFAULT}),c(`Auto sync interval set to ${t.data}ms`,null))};var $a=()=>{let e=V().commandMeta.inputString.trim();if(e!=="on"&&e!=="off")return a("Invalid response");let t=Si(e),n=ze({autoSync:t});return d(n)?n:(Ee({autoSync:t}),N({mode:p.DEFAULT}),c(`Auto sync set to "${e}"`,null))};var Wa=()=>{let e=V().commandMeta.inputString.trim();if(!["debug","error","info"].includes(e))return a("Invalid response");let n=ze({logLevel:e});return d(n)?n:(Ee({logLevel:e}),N({mode:p.DEFAULT}),c(`Auto sync set to "${e}"`,null))};var Ha=async()=>{U(""),N({mode:p.DEFAULT});let e=ot();if(d(e))return a(e.message);if(e.value.syncStatus.status==="syncing")return a("Sync already in progress");N({syncStatus:{msg:"Syncing",status:"syncing"}});let t=await Xn();return d(t)?(N({syncStatus:{msg:t.message,status:"failed"}}),t):(N({mode:p.DEFAULT,syncStatus:{msg:"Synced",status:"synced"}}),t)};var ja=e=>Object.values(v().tags).find(t=>t.name===e),Va=e=>Object.values(v().contributors).find(t=>t.name===e),xr=[{systemOnly:!0,intent:P.Move,description:"Internal move-state command",mode:p.COMMAND_LINE,action:Fa},{intent:P.Delete,description:"Delete the currently selected node",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];return r?Se({id:fe(),action:"delete.node",payload:{id:r.id},...e.value}):a("Unable to resolve child to delete")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Filter,description:"Filter the board, for example `:filter tag urgent`",mode:p.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=V().commandMeta,n=/(!=|=)/,[r]=e.split(n);if(!r||!(s=>ee(x.FILTER).map(l=>l.split(n)[0]).includes(s))(r))return a("Invalid filter modifier");let i={target:r,operator:"=",value:t.trim()};return Ne(s=>({...s,filters:e==="clear"?[]:[...s.filters,i],mode:p.DEFAULT})),c("Filter updated",null)}},{intent:P.ViewHelp,description:"Open the help screen",mode:p.COMMAND_LINE,action:()=>{let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}=v();return lt({pendingNavTarget:{contextNode:e,breadCrumb:r,selectedIndex:t,selectedNode:n}}),N({mode:p.HELP}),c("Viewing help",null)}},{intent:P.CloseIssue,description:"Move the selected issue to the closed swimlane",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];if(!r)return a("Unable to close issue, no target found");if(!_(r))return a("Cannot close in this context");let o=v().nodes[He];if(!o)return a("Unable to locate closed swimlane");if(r.parentNodeId===o.id)return a("Issue is already closed");let i=await Re();if(d(i))return i;let s=i.value,l=ao(o.id,r.id,{at:"end"},e.value,s);if(d(l))return l;let u=await Se({id:fe(),action:"close.issue",payload:{id:r.id,parent:o.id,rank:l.value},...e.value});return d(u)?u:c("Issue closed",null)},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.ReopenIssue,description:"Move a closed issue back to its previous swimlane",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];if(!r)return a("Unable to reopen issue, no target found");let o=r.context==="TICKET"?c("Resolved ticket",r):nt(r.id,"TICKET");if(d(o))return a("Cannot reopen in this context");let i=o.value,s=v().nodes[He];if(!s)return a("Unable to locate closed swimlane");if(i.parentNodeId!==s.id)return a("Issue is not closed");if(!_(i))return a("Target node is not issue");let l=Ca(i);if(!l)return a("Unable to resolve previous parent from issue history");if(l===s.id)return a("Previous parent resolves to closed swimlane");let u=v().nodes[l];if(!u)return a("Previous parent no longer exists");let m=await Re();if(d(m))return m;let g=m.value,y=ao(u.id,i.id,{at:"end"},e.value,g);if(d(y))return y;let C=await Se({id:fe(),action:"reopen.issue",payload:{id:i.id,parent:u.id,rank:y.value},...e.value});return d(C)?C:c("Issue reopened",null)},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Init,description:"Initialize Epiq in the current git repository",mode:p.COMMAND_LINE,action:wa},{intent:P.NewItem,description:"Create a new board, swimlane, or issue",mode:p.COMMAND_LINE,action:Oa,onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Rename,description:"itle] Rename the currently selected node",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{contextNode:t,selectedIndex:n}=v(),r=$(t.id)[n];if(!r)return a("Missing node");if(r.readonly)return a("Cannot rename readonly node");let o=Ys();return o?Se({id:fe(),action:"edit.title",payload:{id:r.id,name:o},...e.value}):a("Provide a title")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.UntagTicket,description:"Remove a tag from the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide a tag");let o=ja(r);if(!o)return a(`Tag "${r}" does not exist`);let{selectedNode:i}=v();if(!i)return a("Invalid untag target");let s=nt(i.id,"TICKET");if(d(s))return a("Unable to untag issue in this context");let l=s.value;return _(l)?(l.props.tags??[]).includes(o.id)?Se({id:fe(),action:"remove.issue.tag",payload:{id:l.id,tag:o.id},...e.value}):a("Issue is not tagged with that tag"):a("Target node is not issue")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.TagTicket,description:"Add or create a tag on the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide a tag");let{selectedNode:o}=v();if(!o)return a("Invalid tag target");let i=nt(o.id,"TICKET");if(d(i))return a("Unable to tag issue in this context");let s=i.value;if(!_(s))return a("Target node is not issue");let l=ja(r),u;if(l)u=l.id;else{let g=fe(),y=await Se({id:fe(),action:"create.tag",payload:{id:g,name:r},...e.value});if(d(y))return y;u=y.value.result.id}return(s.props.tags??[]).includes(u)?a("Already tagged with that tag"):Se({id:fe(),action:"add.issue.tag",payload:{id:s.id,tag:u},...e.value})},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.AssignUserToTicket,description:"Assign a user to the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide an assignee");let{selectedIndex:o,contextNode:i}=v(),s=$(i.id)[o];if(!s)return a("Invalid assign target");let l=nt(s.id,"TICKET");if(d(l))return a("Unable to assign issue in this context");let u=l.value;if(!_(u))return a("Target node is not issue");let m=Va(r),g;if(m)g=m.id;else{let C=fe(),I=await Se({id:fe(),action:"create.contributor",payload:{id:C,name:r},...e.value});if(d(I))return I;g=I.value.result.id}return(u.props.assignees??[]).includes(g)?a("Assignee already assigned"):Se({id:fe(),action:"add.issue.assignee",payload:{id:u.id,assignee:g},...e.value})},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.UnassignUserFromTicket,description:"Remove an assignee from the selected issue",mode:p.COMMAND_LINE,action:async()=>{let e=Y();if(d(e))return a("Unable to resolve user ID");let{modifier:t,inputString:n}=V().commandMeta,r=(t||n).trim();if(!r)return a("Provide an assignee to remove");let o=Va(r);if(!o)return a(`Assignee "${r}" does not exist`);let{selectedNode:i}=v();if(!i)return a("Invalid unassign target");let s=nt(i.id,"TICKET");if(d(s))return a("Unable to unassign in this context");let l=s.value;return _(l)?(l.props.assignees??[]).includes(o.id)?Se({id:fe(),action:"remove.issue.assignee",payload:{id:l.id,assignee:o.id},...e.value}):a(`Issue is not assigned to "${r}"`):a("Target node is not issue")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Sync,description:"Pull, commit, and push Epiq state",mode:p.COMMAND_LINE,action:Ha},{intent:P.Peek,description:"View board state at another point in time",mode:p.COMMAND_LINE,action:Ua},{intent:P.Export,description:"Export the current board layout to markdown",mode:p.COMMAND_LINE,action:async()=>{let e=await ua();return d(e)?e:(N({mode:p.DEFAULT}),c("Export successful",!0))}},{intent:P.Exit,description:"Exit the application",mode:p.COMMAND_LINE,action:async()=>(T.exit(),c("Exit successful",!0))},{intent:P.Edit,description:"Edit title or description",mode:p.COMMAND_LINE,action:async(e,t)=>{if(t.modifier===it.DESCRIPTION)return Ra();if(t.modifier===it.TITLE){let n=Y();if(d(n))return a("Unable to resolve user ID");let{contextNode:r,selectedIndex:o}=v(),i=$(r.id)[o];if(!i)return a("Missing node");if(i.readonly)return a("Cannot rename readonly node");let s=t.inputString.trim();return s?Se({id:fe(),action:"edit.title",payload:{id:i.id,name:s},...n.value}):a("Provide a title")}return a("Unknown edit command")},onSuccess:()=>N({mode:p.DEFAULT})},{intent:P.Config,description:"Update editor, username, view, autosync, or sync debounce",mode:p.COMMAND_LINE,action:(e,t)=>{let n=t.inputString.trim();switch(t.modifier){case X.USERNAME:{let{userId:r,preferredEditor:o,userName:i}=O(),s=n||i,l=r??fe();if(!s||!l)return a("Unable to resolve user name or id");let u=ze({userName:s,userId:l,preferredEditor:o??""});return d(u)?u:(Ee({userName:s,userId:l}),N({mode:p.DEFAULT}),c(`Username set to "${s}"`,null))}case X.EDITOR:{if(!n)return a("No editor provided");let r=ze({preferredEditor:n});return d(r)?r:(Ee({preferredEditor:n}),N({mode:p.DEFAULT}),c(`Editor configuration set to "${n}"`,null))}case X.VIEW:return n!=="wide"&&n!=="dense"?a("Invalid view mode"):(Ee({viewMode:n}),c(`View set to "${n}"`,null));case X.AUTOSYNC:return $a();case X.LOG_LEVEL:return Wa();case X.SYNC_DEBOUNCE_MS:return _a();default:return a("Unknown config command")}}}];var nm=new Set(["peek","filter","view-help"]),Be=async({isForceExecutedBySystem:e=!1}={})=>{let{commandMeta:{command:t,validity:n,modifier:r,inputString:o}}=V();if(!t)return a("No command to confirm");if(!e&&n===Ct.Invalid)return a("Invalid command");let i=ir(t);Vs();let{readOnly:s}=v();if(s&&!nm.has(i))return un({status:qe.Fail,message:"Command not available in readonly state",value:null});let l=xr.filter(m=>e||m.systemOnly!==!0).find(m=>m.intent===i);if(!l)return un({status:qe.Fail,message:"Command not found",value:null});let u;try{u=await l.action(l,{command:t,inputString:o,modifier:r})}catch(m){return un({status:qe.Fail,message:m instanceof Error?m.message:"Command failed",value:null})}return d(u)?un(u):(Ks({addToHistory:!e}),l.onSuccess?.(),O().autoSync&&Jn(),u)};var yr=[{intent:f.Exit,mode:p.MOVE,description:"[<Esc>] exit context / cancel",action:()=>(N({mode:p.COMMAND_LINE}),U("move cancel"),Be({isForceExecutedBySystem:!0}))},{intent:f.InitMove,mode:p.DEFAULT,description:"[m] move (init/confirm)",action:()=>(N({mode:p.COMMAND_LINE}),U("move start"),Be({isForceExecutedBySystem:!0}))},{intent:f.ConfirmMove,mode:p.MOVE,action:()=>(N({mode:p.COMMAND_LINE}),U("move confirm"),Be({isForceExecutedBySystem:!0}))}],hr=[{intent:f.MovePreviousItem,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move previous"),Be({isForceExecutedBySystem:!0})):a("No pending move")},{intent:f.MoveNextItem,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move next"),Be({isForceExecutedBySystem:!0})):a("No pending move")}],Ka=[{intent:f.MoveToNextContainer,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move to-next"),Be({isForceExecutedBySystem:!0})):a("No pending move")},{intent:f.MoveToPreviousContainer,mode:p.MOVE,action:()=>ut()?(N({mode:p.COMMAND_LINE}),U("move to-previous"),Be({isForceExecutedBySystem:!0})):a("No pending move")}];var za={[w.WORKSPACE]:[...yr,...hr],[w.BOARD]:[...yr,...hr],[w.SWIMLANE]:[...yr,...hr,...Ka],[w.TICKET]:[],[w.FIELD]:[],[w.FIELD_LIST]:[],[w.TEXT]:[]};var Ga=()=>{U("");let{pendingNavTarget:e}=ct();N({mode:p.DEFAULT}),e&&T.navigate(e),lt({pendingNavTarget:void 0})},qa=[{intent:f.ExitCommandLine,mode:p.HELP,action:()=>(Ga(),c("Exiting help",null))},{intent:f.Exit,mode:p.HELP,action:()=>(Ga(),c("Closed help",null))},{intent:f.NavPreviousItem,mode:p.HELP,description:"[arrows/hjkl] navigate",action:()=>(T.navigateToPreviousItem(),c("Navigating to previous help item",null))},{intent:f.NavNextItem,mode:p.HELP,action:()=>(T.navigateToNextItem(),c("Navigating to next help item",null))},{intent:f.NavToPreviousContainer,mode:p.HELP,action:()=>(T.navigateToPreviousContainer(),c("Navigating to previous help container",null))},{intent:f.NavToNextContainer,mode:p.HELP,action:()=>(T.navigateToNextContainer(),c("Navigating to next help container",null))}];var rm=e=>{N({mode:p.COMMAND_LINE});let{pendingNavTarget:t}=ct();t&&T.navigate(t),lt({pendingNavTarget:void 0}),U(`${e} `)},Ya=()=>{U("");let{pendingNavTarget:e}=ct();e&&T.navigate(e),lt({pendingNavTarget:void 0}),N({mode:p.DEFAULT})},Xa=[{intent:f.InitCommandPalette,mode:p.DEFAULT,description:"[?] view command palette (explore descriptions for every command)",action:()=>{U("");let{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}=v();return lt({pendingNavTarget:{contextNode:e,selectedIndex:t,selectedNode:n,breadCrumb:r}}),N({mode:p.PALETTE}),c("Opening command palette",null)}},{intent:f.Confirm,mode:p.PALETTE,action:()=>{let{selectedNode:e}=v();if(!e||!et(e))return a("Command only applicable on text nodes");if(e.props.disabled)return a("Command is not available in this context");let t=e.title;return t?(rm(t),c("Selected command",t)):c("No command selected",null)}},{intent:f.ExitCommandLine,mode:p.PALETTE,action:()=>(Ya(),c("Exiting palette",null))},{intent:f.Exit,mode:p.PALETTE,action:()=>(Ya(),c("Closed command palette",null))},{intent:f.NavPreviousItem,mode:p.PALETTE,description:"[arrows/hjkl] navigate",action:()=>(T.navigateToPreviousItem(),c("Navigating to previous item",null))},{intent:f.NavNextItem,mode:p.PALETTE,action:()=>(T.navigateToNextItem(),c("Navigating to next item",null))},{intent:f.NavToPreviousContainer,mode:p.PALETTE,action:()=>(T.navigateToPreviousContainer(),c("Navigating to previous container",null))},{intent:f.NavToNextContainer,mode:p.PALETTE,action:()=>(T.navigateToNextContainer(),c("Navigating to next container",null))}];var Ja=[...qa,...Xa,{intent:f.AddItem,mode:p.DEFAULT,description:"[n] new...",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.NEW} `),c("Adding new item",null))},{intent:f.Delete,mode:p.DEFAULT,description:"[d] delete",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.DELETE} `),c("Deleting item",null))},{intent:f.InitCommandLine,mode:p.DEFAULT,description:"[:] focus command line",action:()=>(N({mode:p.COMMAND_LINE}),U(""),c("Entering command line mode",null))},{intent:f.Confirm,mode:p.DEFAULT,description:"[<Enter>] confirm/enter",action:()=>{let{selectedNode:e,contextNode:t}=v();if(!B(e?.id??"")?.length){if(e?.title===Q.DESCRIPTION)return N({mode:p.COMMAND_LINE}),U(`${x.EDIT} description `),c("Propose command",!0);if(e?.title===Q.ASSIGNEES)return N({mode:p.COMMAND_LINE}),U(`${x.ASSIGN} `),c("Propose command",!0);if(e?.title===Q.TAGS)return N({mode:p.COMMAND_LINE}),U(`${x.TAG} `),c("Propose command",!0);if(t.title===Q.DESCRIPTION&&e?.context==="TEXT")return N({mode:p.COMMAND_LINE}),U(`${x.EDIT} description `),c("Propose command",!0)}return T.enterChildNode(),c("Entering context",null)}},{intent:f.EditTitle,mode:p.DEFAULT,description:"[r] rename title",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.EDIT} title ${v().selectedNode?.title}`),c("Exiting context",null))},{intent:f.EditDescription,mode:p.DEFAULT,description:"[e] edit description",action:()=>(N({mode:p.COMMAND_LINE}),U(`${x.EDIT} description `),c("Exiting context",null))},{intent:f.Exit,mode:p.DEFAULT,description:"[q] exit context",action:()=>(T.enterParentNode(),c("Exiting context",null))},{intent:f.NavPreviousItem,mode:p.DEFAULT,description:"[arrows/hjkl] navigate",action:()=>(T.navigateToPreviousItem(),c("Navigating to previous item",null))},{intent:f.NavNextItem,mode:p.DEFAULT,action:()=>(T.navigateToNextItem(),c("Navigating to next item",null))},{intent:f.NavToPreviousContainer,mode:p.DEFAULT,action:()=>(T.navigateToPreviousContainer(),c("Navigating to previous container",null))},{intent:f.NavToNextContainer,mode:p.DEFAULT,action:()=>(T.navigateToNextContainer(),c("Navigating to next container",null))}];var om=500,im=e=>e.replace(/[\r\n]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,""),Qa=e=>{let t=im(e);t&&or(n=>(n+t).slice(0,om))};var sm=[p.COMMAND_LINE,p.PALETTE],am=e=>[{intent:f.MoveCursorLeft,mode:e,action:()=>(So(-1),c("Moving cursor left",null))},{intent:f.MoveCursorRight,mode:e,action:()=>(So(1),c("Moving cursor right",null))},{intent:f.MoveCursorLeftOfWord,mode:e,action:()=>(Io("left"),c("Moving cursor left of word",null))},{intent:f.MoveCursorRightOfWord,mode:e,action:()=>(Io("right"),c("Moving cursor right of word",null))},{intent:f.AutoCompleteCommand,mode:e,action:()=>(or((t,{remainder:n})=>n?t+n:t),c("Auto-completing command",null))},{intent:f.CaptureInput,mode:e,action:(t,{sequence:n})=>(Qa(n??""),c("Capturing input",null))},{intent:f.EraseInput,mode:e,action:()=>(Hs(),c("Erasing input",null))},{intent:f.EraseInputWord,mode:e,action:()=>(js(),c("Erasing input word",null))}],Za=[{intent:f.Confirm,mode:p.COMMAND_LINE,action:()=>(Be(),c("Executing command",null))},{intent:f.ViewHelp,mode:p.DEFAULT,action:()=>(N({mode:p.HELP}),c("Viewing help",null))},...sm.flatMap(am),{intent:f.ExitCommandLine,mode:p.COMMAND_LINE,action:()=>(N({mode:p.DEFAULT}),c("Exiting command line",null))},{intent:f.GetLastCommandFromHistory,mode:p.COMMAND_LINE,action:()=>(zs(),c("Getting last command from history",null))},{intent:f.GetNextCommandFromHistory,mode:p.COMMAND_LINE,action:()=>(Gs(),c("Getting next command from history",null))}];import nd from"chalk";var Er=nd.dim.hex(h.secondary2)(": for command line"),ed="q to exit",td=`${nd.hex(h.accent)("m")} to confirm`,Uo={[w.WORKSPACE]:[Er],[w.BOARD]:[Er],[w.BOARD+p.COMMAND_LINE]:[Er],[w.SWIMLANE]:[Er],[w.TICKET+p.HELP]:[ed],[w.SWIMLANE+p.HELP]:[ed],[w.TICKET]:[],[w.FIELD]:[],[w.SWIMLANE+p.MOVE]:[td],[w.TICKET+p.MOVE]:[td]};var fn=e=>e.trim().toLocaleLowerCase(),dm=e=>{let{tags:t}=v();return(e.props.tags??[]).map(n=>t[n]?.name).filter(n=>!!n)},cm=e=>{let{contributors:t}=v();return(e.props.assignees??[]).map(n=>t[n]?.name).filter(n=>!!n)},rd=(e,t)=>{let n=fn(t.value);if(!n)return!0;switch(t.target){case"title":return fn(e.title??"").includes(n);case"description":return fn(e.props.description??"").includes(n);case"tag":return dm(e).map(fn).some(o=>o.includes(n));case"assignee":return cm(e).map(fn).some(o=>o.includes(n));default:return!0}};function od(e,t,n){let r=t[e];if(!r)return a("buildBreadCrumb(): current node not found");let o=[],i=r;for(;i&&(o.push(i),!(i.id===n||!i.parentNodeId));)i=t[i.parentNodeId];let s=o[o.length-1];return!s||s.id!==n?a("buildBreadCrumb(): node is not connected to root"):(o.reverse(),c("Breadcrumb built",o))}var id=e=>{let t={};for(let n of e)n.intent&&(t[n.mode]||(t[n.mode]={}),t[n.mode][n.intent]=n);return t};var bt,_o,$o=new Set,sd=()=>{for(let e of $o)e()},um=e=>($o.add(e),()=>$o.delete(e));function ad(e){let{contextNodeId:t,mode:n,rootNodeId:r,nodes:o,filters:i}=e;if(!t)return a("derive(): contextNodeId is missing");if(!r)return a("derive(): rootNode is missing");if(!o[r])return a("derive(): unable to find root node");let l=o[t];if(!l)return a("Unable to derive state, contextNode not found");let u=od(t,o,r);if(d(u))return logger.error(u.message),u;let m=u.value,{context:g}=l,y=Uo[g+n]??Uo[g]??[],C=[...Ja,...za[g]??[],...Za],I=id(C),S=mm(o,i),A=S[t]?.[e.selectedIndex]??null;return c("Derived successfully",{...e,contextNode:l,breadCrumb:m,availableHints:y,availableActions:C,actionIndex:I,selectedNode:A,renderedChildrenIndex:S})}var v=()=>{if(!bt)throw new Error("State not initialized. Call initWorkspaceState() first.");return bt},ot=()=>bt?c("Retrieved state",bt):a("State not initialized. Call initWorkspaceState() first.");function nn(e){_o=e;let t=Ye(process.cwd()),n=!1;if(!d(t)){let i=Qe(t.value);if(d(i))return a(i.message);n=!0}let r={readOnly:!1,filters:[],tags:{},contributors:{},mode:p.DEFAULT,nodes:{[e.id]:e},rootNodeId:e.id,contextNodeId:e.id,renderedChildrenIndex:{},selectedIndex:-1,syncStatus:{status:"synced",msg:""},eventLog:[],unappliedEvents:[],timeMode:"live",hasProjectDefinition:n,hasInitializingEvents:!1},o=ad(r);return d(o)?o:(bt=o.value,sd(),c("State initialized",null))}function Ne(e){let t=v(),n=e(t),r=ad(n);return d(r)?a(r.message??"Unable to update state"):(bt=r.value,sd(),c("State updated",null))}var N=e=>Ne(t=>({...t,...e}));var K=()=>lm(um,v,v),mm=(e,t)=>{let n={};for(let r of Object.values(e))_(r)&&t.length>0&&!t.every(o=>rd(r,o))||!r.parentNodeId||r.isDeleted||((!r.parentNodeId||!n[r.parentNodeId])&&(n[r.parentNodeId]=[]),n[r.parentNodeId].push(r));for(let r of Object.keys(n))n[r].sort((o,i)=>{let s=e[o.id],l=e[i.id];return!s||!l?0:s.rank.localeCompare(l.rank)});return n},$=e=>v()?.renderedChildrenIndex[e]??[],gn=()=>_o?nn(_o):a("Cannot reset state: no initial workspace found"),Dt=()=>bt!==void 0;import{Box as Wo,Text as vn}from"ink";import Me,{useEffect as pm,useMemo as gm}from"react";import{ulid as fm}from"ulid";var dd=({text:e,match:t,color:n,highlightColor:r=h.secondary,dimColor:o=!1})=>{if(!t)return Me.createElement(vn,{color:n,dimColor:o},e);let i=e.toLowerCase(),s=t.toLowerCase(),l=i.indexOf(s);return l===-1?Me.createElement(vn,{color:n,dimColor:o},e):Me.createElement(vn,{color:n,dimColor:o},e.slice(0,l),Me.createElement(vn,{backgroundColor:r,bold:!0},e.slice(l,l+t.length)),e.slice(l+t.length))},cd=fm(),vm=e=>`${e}`,xm=e=>{let{pendingNavTarget:t}=ct();if(!t)return[];let{breadCrumb:n,contextNode:r,selectedNode:o}=t,i=new Set(ee(x.NONE,{breadCrumb:n,contextNode:r,readOnly:v().readOnly,selectedNode:o}));return[...new Set(Object.values(x))].filter(s=>s!=="move").filter(s=>s.length>0).filter(s=>s!==x.PALETTE).map(s=>{let l=ir(s),u=xr.find(m=>m.intent===l);return{command:s,description:u?.description??`[${s}] Run command`,isAvailable:i.has(s)}}).filter(s=>s.command.toLowerCase().startsWith(e)||e.length>=2&&s.description.toLowerCase().includes(e)).sort((s,l)=>s.isAvailable!==l.isAvailable?s.isAvailable?-1:1:s.command.localeCompare(l.command))},ym=e=>q.text({id:cd,parentNodeId:e,rank:"000000",name:"Command Palette",props:{},readonly:!0,isVirtual:!0}),hm=(e,t,n)=>q.text({id:vm(e.command),parentNodeId:n,rank:String(t).padStart(6,"0"),name:e.command,props:{value:e.description,disabled:!e.isAvailable},readonly:!0,isVirtual:!0}),Ho=[],Em=e=>{ld();let t=b.createNode(ym(v().rootNodeId));d(t)||!et(t.value)||(Ho=[t.value,...e.map((n,r)=>hm(n,r,cd)).map(b.createNode).filter(J).map(({value:n})=>n).filter(et)],T.navigate({contextNode:t.value,selectedIndex:0}))},ld=()=>{let e=Ho.map(t=>t.id);Ho=[];for(let t of e)b.deleteNode(t)};function ud({width:e,height:t}){let r=qs().value.trim().toLowerCase(),o=gm(()=>xm(r),[r]);pm(()=>(Em(o),()=>{ld()}),[o]);let i=v().selectedIndex;return Me.createElement(Wo,{flexDirection:"column",width:e,height:t-2},Me.createElement(st,{height:t-4,itemHeight:3,selectedIndex:i},o.map((s,l)=>{let u=l===i,m=s.isAvailable?h.accent:h.secondary2,g=s.isAvailable?"":"[unavailable] ";return Me.createElement(Wo,{key:s.command,flexDirection:"column",paddingX:1,borderLeft:!1,borderBottom:!1,borderRight:!1,borderColor:h.secondary,borderStyle:"single"},Me.createElement(vn,{color:m,dimColor:!s.isAvailable},u?"\u276F ":" ",Me.createElement(dd,{text:Li(s.command),match:r,color:m,dimColor:!s.isAvailable})),Me.createElement(Wo,{paddingLeft:2},Me.createElement(dd,{text:g+s.description,match:r.length>=2?r:"",color:u&&s.isAvailable?h.primary:h.secondary2,dimColor:!s.isAvailable})))})))}import{Box as km}from"ink";import Vo from"react";import yn from"chalk";import{Box as jo,Text as md}from"ink";import xn,{useEffect as Cm,useMemo as Nm,useState as bm}from"react";var pd=yn.gray,Sm=yn.inverse,Im=yn.inverse.gray,Rm={hint:"",hints:[],overlap:0,remainder:""},fd=({value:e,command:t})=>{if(!t)return null;let n=e.trimStart(),o=e.length-n.length;return e.slice(o,o+t.length)!==t?null:{start:o,end:o+t.length}},Am=({command:e,modifier:t})=>{if(!t)return null;if(e==="tag"||e==="assign"){let n=be(t);return{bg:r=>yn.bgHex(n).black(r),bgCursor:r=>yn.bgHex(n).inverse.black(r)}}return eo(t)},Tm=({value:e,command:t,modifier:n})=>{if(!t||!n)return null;let r=fd({value:e,command:t});if(!r)return null;let i=e.slice(r.end).match(/^\s*/)?.[0].length??0,s=r.end+i;return e.slice(s,s+n.length)!==n?null:{start:s,end:s+n.length}},gd=()=>({value:ie.value,cursorPosition:ie.cursorPosition,commandIsPending:ie.commandIsPending,autoCompletion:ie.commandMeta.autoCompletion??Rm,infoMessage:ie.commandMeta.infoMessage,validationStatus:ie.commandMeta.validity,command:ie.commandMeta.command,inputString:ie.commandMeta.inputString,modifier:ie.commandMeta.modifier}),wm=(e,t)=>e.value===t.value&&e.cursorPosition===t.cursorPosition&&e.commandIsPending===t.commandIsPending&&e.infoMessage===t.infoMessage&&e.autoCompletion.hint===t.autoCompletion.hint&&e.autoCompletion.overlap===t.autoCompletion.overlap&&e.autoCompletion.remainder===t.autoCompletion.remainder&&e.validationStatus===t.validationStatus&&e.command===t.command&&e.modifier===t.modifier&&e.inputString===t.inputString,vd=({width:e,mode:t})=>{let[n,r]=bm(gd());Cm(()=>{let C=()=>{let S=gd();r(A=>wm(A,S)?A:S)},I=bo(C);return C(),()=>{I()}},[]);let{value:o,cursorPosition:i,infoMessage:s,commandIsPending:l,autoCompletion:u,command:m,modifier:g}=n,y=Nm(()=>{let C=Math.max(0,Math.min(i,o.length)),I=fd({value:o,command:m}),S=Tm({value:o,command:m,modifier:g}),A=m?eo(m):null,R=Am({command:m,modifier:g}),M=(re,ue)=>{let Rt=I&&ue>=I.start&&ue<I.end,ft=S&&ue>=S.start&&ue<S.end;return Rt&&A?A.fg(re):ft&&R?R.bg(re):re},F=(re,ue)=>{let Rt=I&&ue>=I.start&&ue<I.end,ft=S&&ue>=S.start&&ue<S.end;return Rt&&A?A.fgCursor(re):ft&&R?R.bgCursor(re):Sm(re)},Ie=o.slice(0,C),le=o[C]??" ",Vt=C<o.length?o.slice(C+1):"",bn=Array.from(Ie).map((re,ue)=>M(re,ue)).join(""),It=F(le,C),Kt=Array.from(Vt).map((re,ue)=>M(re,C+1+ue)).join("");if(u.hint){let re=u.hint[u.overlap]??le;It=Im(re),Kt=pd(u.remainder.slice(1)+Vt)}return pd(t===p.PALETTE?"?":":")+bn+It+Kt},[o,i,u,m,g]);return xn.createElement(jo,{flexDirection:"column",justifyContent:"flex-start"},xn.createElement(jo,{flexDirection:"column",paddingX:1,borderColor:h.secondary,borderStyle:"round",width:e},xn.createElement(jo,null,xn.createElement(md,null,y),s&&xn.createElement(md,{wrap:"truncate",color:l?h.red:h.secondary2},` ${s} `))))};import{Box as Mm,Text as Pm}from"ink";import xd from"react";var Lm=(e,t)=>{let n=[],r=0;for(let o of e){let s=(n.length>0?" | ":"").length+o.length;if(r+s>t-4)break;n.push(o),r+=s}return n},yd=({width:e,availableHints:t})=>{let n=Lm(t,e).join(" | ");return xd.createElement(Mm,{width:e,borderStyle:"round",borderColor:h.secondary,paddingX:1},xd.createElement(Pm,{color:h.secondary2},n.length?n:"\xA0"))};var hn=({width:e,mode:t,availableHints:n})=>{let r=[],o=0;for(let i of n){let l=(r.length>0?" | ":"").length+i.length;if(o+l>e+2)break;r.push(i),o+=l}return Vo.createElement(km,null,t===p.COMMAND_LINE||t===p.PALETTE?Vo.createElement(vd,{width:e,mode:t}):Vo.createElement(yd,{width:e,mode:t,availableHints:n}))};import{Box as mt,Text as Ht}from"ink";import ce,{useEffect as Dm,useMemo as Fm}from"react";import{ulid as hd}from"ulid";var Nr=hd(),Bm=()=>[...new Set([...v().availableActions].map(e=>e.description).filter(e=>e!==void 0))].map(e=>{let[t,n]=e.split("]"),r=t?.replace("[",""),o=n?.trim();return[r,o]}).filter(e=>e[0]!==void 0&&e[1]!==void 0).sort(([e],[t])=>e.length===1&&t.length!==1?-1:e.length!==1&&t.length===1?1:e.localeCompare(t,void 0,{sensitivity:"base"})).map(([e,t])=>({keys:e,action:t})),Om=e=>q.text({id:Nr,parentNodeId:e,rank:"000000",name:"Help",props:{},isVirtual:!0,readonly:!0}),Um=(e,t,n)=>q.text({id:hd(),parentNodeId:n,rank:String(t).padStart(6,"0"),name:e.keys,props:{value:e.action},readonly:!0,isVirtual:!0}),Cr=[],Ed=()=>{let e=Cr.filter(n=>n.id!==Nr).map(n=>n.id),t=Cr.filter(n=>n.id===Nr).map(n=>n.id);Cr=[];for(let n of[...e,...t])b.deleteNode(n)},_m=e=>{Ed();let t=b.createNode(Om(v().rootNodeId));if(d(t)||!et(t.value))return logger.error("Could not attach help nodes");Cr=[t.value,...e.map((n,r)=>Um(n,r,Nr)).map(b.createNode).filter(J).map(({value:n})=>n).filter(et)],T.navigate({contextNode:t.value,selectedIndex:0})},Cd=({width:e,height:t})=>{let n=Fm(()=>Bm(),[]);Dm(()=>(_m(n),()=>{Ed()}),[n]);let r=v().selectedIndex;return ce.createElement(mt,{flexDirection:"column",marginTop:3,borderColor:h.secondary,borderStyle:"round",width:e,height:t-2},ce.createElement(mt,{paddingX:1,justifyContent:"center"},ce.createElement(Ht,{color:h.accent},"Help"),ce.createElement(Ht,{dimColor:!0}," \u2014 navigate with arrows/hjkl, press q to close")),ce.createElement(mt,{paddingX:1,marginTop:1},ce.createElement(mt,{width:20,justifyContent:"flex-end"},ce.createElement(Ht,{color:h.secondary},"Key(s)")),ce.createElement(mt,{flexGrow:1,width:40,paddingLeft:2},ce.createElement(Ht,{color:h.secondary},"Action"))),ce.createElement(st,{height:t-7,itemHeight:1,selectedIndex:r},n.map(({keys:o,action:i},s)=>{let l=s===r;return ce.createElement(mt,{paddingX:1,key:`${o}-${i}-${s}`,flexDirection:"row"},ce.createElement(mt,{width:20,justifyContent:"flex-end"},ce.createElement(Ht,{color:h.accent},o)),ce.createElement(mt,{flexGrow:1,width:40,paddingLeft:2},ce.createElement(Ht,{color:l?h.primary:h.secondary2},i)))})))};import $m from"chalk";import{Box as br,Text as Ge}from"ink";import xe from"react";var Nd=({width:e,height:t})=>xe.createElement(br,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:h.secondary,rowGap:1},xe.createElement(Ge,{color:h.accent,bold:!0},"Initialize project"),xe.createElement(Ge,null,`This folder is not an ${$m.hex(h.accent)("epiq")} project yet.`),xe.createElement(Ge,{color:h.primary},"To start tracking issues here, we need to initialize a new",xe.createElement(Ge,{color:h.primary,backgroundColor:h.secondary}," .epiq/project.json "),"file in this repository."),xe.createElement(br,{marginTop:1,flexDirection:"column"},xe.createElement(br,null,xe.createElement(Ge,{color:h.accent}," "),xe.createElement(Ge,{color:h.primary},"Type "),xe.createElement(Ge,{backgroundColor:h.secondary}," :init "))),xe.createElement(br,{marginTop:1},xe.createElement(Ge,{color:h.secondary2},"This will create, commit and push "),xe.createElement(Ge,{color:h.primary,backgroundColor:h.secondary}," .epiq/project.json ")));import{Box as Sr,Text as Oe}from"ink";import ne from"react";var Wm=({isDone:e,command:t,value:n})=>ne.createElement(Sr,null,ne.createElement(Oe,{color:h.accent,dimColor:e},e?" \u2714 ":" "),ne.createElement(Oe,{dimColor:e},"Type "),ne.createElement(Oe,{backgroundColor:h.secondary,dimColor:e}," "+t+" "),n!==void 0&&ne.createElement(ne.Fragment,null,ne.createElement(Oe,{dimColor:e}," "),ne.createElement(Oe,{color:h.secondary,dimColor:e},"<"+n+">"))),Hm=e=>{if(typeof e=="string")return e;if(typeof e=="boolean")return e?"on":"off"};function Ko({width:e,height:t}){let{isSetPreferredEditor:n,isSetUserName:r,userName:o,preferredEditor:i,autoSync:s,isSetAutoSync:l}=Ze(),u=[{key:"username",done:r,command:":config username",value:o,message:"First, choose your username."},{key:"editor",done:n,command:":config editor",value:i,message:"Nice. Now pick your editor."},{key:"autosync",done:l,command:":config autosync",value:s,message:"Almost there. Configure auto sync."}],m=u.findIndex(y=>!y.done),g=m===-1?void 0:u[m];return ne.createElement(Sr,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:h.secondary,rowGap:1},ne.createElement(Oe,{color:h.accent,bold:!0},"Welcome! \u{1F539}"),ne.createElement(Oe,null,"Let's get you started - it's a breeze."),ne.createElement(Oe,{color:h.secondary2},"Remember - you can always search available commands by typing:",ne.createElement(Oe,{color:h.accent}," ? ")),g&&ne.createElement(Oe,{color:h.secondary2},g.message),ne.createElement(Sr,{flexDirection:"column"},u.map((y,C)=>m===-1||C<=m?ne.createElement(Sr,{key:y.key,marginBottom:1},ne.createElement(Wm,{isDone:y.done,command:y.command,value:y.done?Hm(y.value):void 0})):null)))}import wr from"chalk";import{Box as Tr,Text as jt}from"ink";import se from"react";var bd="0.6.14";import{Box as Ir,Text as jm}from"ink";import St from"react";var Sd=({width:e})=>{let{viewMode:t}=O(),n=K(),{breadCrumb:r,contextNode:o,selectedIndex:i,renderedChildrenIndex:s}=n,l=s[o.id]?.[i],u=nt(l?.id??o.id,"TICKET"),m=J(u)?u.value:void 0,g=m?.props.tags??[],y=m?.props.assignees??[],C=m?.parentNodeId?!Xr(o.id,m.parentNodeId)&&t==="dense":!1,I=r.map((R,M)=>{let F=M===r.length-1,Ie=B(R.id),le=F?Ie?.[i]?.title:void 0;return`${M?" / ":""}${R.title??""}${le?` \u25B8 ${le}`:""}`}).join(""),S=g.reduce((R,M)=>R+(b.getTag(M)?.name.length??0)+4,0)+y.reduce((R,M)=>R+(b.getContributor(M)?.name.length??0)+4,0),A=e-S;return St.createElement(Ir,{overflow:"hidden",justifyContent:"flex-start",alignItems:"flex-start"},St.createElement(Ir,{overflow:"hidden",width:A},St.createElement(jm,{wrap:"truncate-end",color:h.secondary2},I)),C?g.map(R=>St.createElement(Ir,{key:R,paddingLeft:1},St.createElement(_t,{id:R}))):null,C?y.map(R=>St.createElement(Ir,{key:R,paddingLeft:1},St.createElement(Ut,{id:R}))):null)};import{Box as Vm,Text as Id}from"ink";import Rr from"react";var Km=({filters:e})=>Rr.createElement(Vm,{columnGap:1},Rr.createElement(Id,{color:"red"},"APPLIED FILTERS:"),e.map(({value:t,target:n,operator:r})=>Rr.createElement(Id,{backgroundColor:"black",color:"white"},` ${n}${r}"${t}" `))),Rd=Rr.memo(Km);import{Box as zm,Text as Ar}from"ink";import En from"react";function Ad(){let{eventLog:e,unappliedEvents:t}=K(),n=e.at(-1)?.id,r=$n(n??""),o=J(r)?qi(r.value):"INVALID DATE";return En.createElement(zm,{paddingLeft:1},En.createElement(Ar,{backgroundColor:h.accent}," Readonly "),En.createElement(Ar,{color:h.accent}," "+t.length+" edits ago at "+o+"."),En.createElement(Ar,{color:h.accent}," Resume with "),En.createElement(Ar,{backgroundColor:h.accent}," :peek now "))}import zo from"chalk";import{Box as Gm,Text as Td}from"ink";import Go,{useEffect as qm,useState as Ym}from"react";var Xm=["#4c567a","#9d7cd8","#7aa2f7","#7dcfff","#9d7cd8"],wd=e=>{let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}},Jm=({r:e,g:t,b:n})=>{let r=o=>Math.round(Math.max(0,Math.min(255,o))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`},Qm=(e,t,n)=>{let r=wd(e),o=wd(t);return Jm({r:r.r+(o.r-r.r)*n,g:r.g+(o.g-r.g)*n,b:r.b+(o.b-r.b)*n})},Zm=(e,t)=>{if(e.length===1)return e[0];let n=t*(e.length-1),r=Math.floor(n),o=n-r,i=e[r],s=e[Math.min(r+1,e.length-1)];return Qm(i,s,o)};function Md({syncStatus:e,autoSync:t}){let[n,r]=Ym(0);qm(()=>{if(e.status!=="syncing"){r(0);return}let l=setInterval(()=>{r(u=>u+1)},50);return()=>clearInterval(l)},[e.status]);let o={synced:" ",failed:"retry",syncing:"...",pending:"wait"},s={synced:h.secondary2,failed:h.yellow,pending:h.secondary2,syncing:Zm(Xm,(Math.sin(n*.12)+1)/2)??""}[e.status];return Go.createElement(Gm,null,Go.createElement(Td,null,zo.hex(h.secondary2).dim(t?"AutoSync: ":"Sync: ")),Go.createElement(Td,null,zo.hex(s)("\u25CF")+zo.hex(h.secondary2).dim(` ${o[e.status].padEnd(4)} `)))}function Cn({filters:e,hideBreadCrumb:t=!1}){let{timeMode:n,syncStatus:r,mode:o}=K(),{userName:i,preferredEditor:s,autoSync:l}=O(),u=64,m=process.stdout.columns-u-8;return se.createElement(Tr,{justifyContent:"space-between",flexDirection:"row","max-width":process.stdout.columns-40,overflow:"hidden"},t?se.createElement(jt,null," "):o===p.PALETTE?se.createElement(Tr,null,se.createElement(jt,{color:h.accent},"Command Palette"),se.createElement(jt,{dimColor:!0,color:h.secondary2}," ","- search, select and press enter")):se.createElement(Tr,{paddingLeft:1},e.length>0?se.createElement(Rd,{filters:e}):se.createElement(Sd,{width:m})),n==="live"?se.createElement(Tr,{columnGap:1,paddingRight:2,"max-width":u,overflow:"hidden",justifyContent:"flex-end"},se.createElement(Md,{autoSync:!!l,syncStatus:r}),se.createElement(jt,null,wr.hex(h.secondary2).dim("Mode: ")+wr.hex(h.secondary2).dim(o.padEnd(8," "))," "),se.createElement(Pd,{icon:"@",value:i}),se.createElement(Pd,{icon:"\u276F",value:s}),se.createElement(jt,{dimColor:!0,color:h.secondary2},bd+" ")):"",n==="peek"?se.createElement(Ad,null):"")}function Pd({icon:e,value:t}){return se.createElement(jt,null,wr.dim(e)+wr.hex(h.accent)(` ${t??"-"} `))}import{Box as ep,Text as tp}from"ink";import Nn from"react";import{Box as Mr,Text as qo}from"ink";import pt from"react";function Yo(){let e=K(),t=e.nodes[e.rootNodeId],o=process.stdout.rows-1-3,i=process.stdout.columns||120,s=t?.id?$(t?.id):[];return pt.createElement(Mr,{flexDirection:"column",height:o,padding:1,borderStyle:"round",borderColor:h.secondary,width:i},pt.createElement(Mr,{padding:1,paddingTop:0,paddingBottom:0},pt.createElement(qo,null,"Select a board:")),pt.createElement(Mr,{padding:1,flexDirection:"column"},s.map((l,u)=>{let m=e.contextNode.context==="WORKSPACE"&&e.selectedIndex===u,y=$(l.id).flatMap(({id:C})=>B(C)).length;return pt.createElement(Mr,{key:l.id??u},pt.createElement(qo,{color:m?h.accent:h.secondary2},pt.createElement(ge,{isSelected:m})),pt.createElement(qo,{color:m?h.accent:h.secondary2},l.title," (",y," issues)",l.readonly?" \u{1F512}":""))})))}var np=({contextNode:e,selectedIndex:t,breadCrumb:n,mode:r,viewMode:o,height:i,width:s})=>{let{renderedChildrenIndex:l}=K(),u=n.find(({context:C})=>C==="BOARD"),y=i-1-3;return Nn.createElement(ep,{flexDirection:"row"},e.context==="WORKSPACE"?Nn.createElement(Yo,null):u?Nn.createElement(mr,{height:y,width:s,swimlanes:(l[u.id]??[]).filter(C=>C!==void 0&&wt(C)),contextNode:e,selectedIndex:t,breadCrumb:n,viewMode:o,mode:r}):Nn.createElement(tp,null))},Ld=Nn.memo(np);import{useEffect as rp}from"react";var op=e=>{rp(()=>{if(!e)return;let t,n=!1,r=()=>{if(n)return;let{autoSyncIntervalMs:o,userName:i,preferredEditor:s}=O();s&&i&&o&&(t=setTimeout(()=>{if(n)return;let{readOnly:l,mode:u}=v();u==="default"&&!l&&Jn(),r()},o))};return r(),()=>{n=!0,t&&clearTimeout(t)}},[e])},kd=({autoSync:e})=>(op(e),null);function Xo({width:e,height:t}){let n=K(),{autoSync:r,viewMode:o}=Ci(),i=n.filters;if(n.mode===p.HELP)return z.createElement(gt,{flexDirection:"column"},z.createElement(Cd,{width:e,height:t}));if(n.mode===p.PALETTE)return z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{filters:i}),z.createElement(ud,{width:e,height:t-2}),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}));let{isSetupDone:s}=Ze(),l=!s,u=s&&!n.hasProjectDefinition;if(l)return z.createElement(gt,{flexDirection:"column"},z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{hideBreadCrumb:!0,filters:i}),z.createElement(Ko,{height:t,width:e})),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}));if(u)return z.createElement(gt,{flexDirection:"column"},z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{hideBreadCrumb:!0,filters:i}),z.createElement(Nd,{height:t,width:e})),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}));let m=Ce(n.breadCrumb??[],"BOARD");if(J(m)){let g=m.value.id,y=$(g).length,C=3,I=Math.floor(e/C),S=Math.floor(e/Math.max(y,1));e=Math.min(S,I)*Math.max(y,C)}return z.createElement(gt,{flexDirection:"column"},z.createElement(kd,{autoSync:r}),z.createElement(gt,{flexDirection:"column"},z.createElement(Cn,{filters:i}),z.createElement(Ld,{width:e,height:t,contextNode:n.contextNode,selectedIndex:n.selectedIndex,breadCrumb:n.breadCrumb,viewMode:o??"dense",mode:n.mode})),z.createElement(hn,{width:e,mode:n.mode,availableHints:n.availableHints}))}import ip from"readline";var Pr,Lr,Ue,sp=new Set([f.MoveCursorLeft,f.EraseInputWord,f.MoveCursorLeftOfWord,f.MoveCursorRight,f.MoveCursorRightOfWord,f.NavToPreviousContainer,f.NavToNextContainer,f.NavPreviousItem,f.NavNextItem,f.SetViewDense,f.SetViewWide,f.Confirm,f.Exit,f.InitCommandLine,f.InitCommandPalette,f.ExitCommandLine,f.CaptureInput,f.EraseInput,f.EraseInputWord,f.HideHelp,f.ViewHelp,f.SetViewDense,f.SetViewWide,f.GetLastCommandFromHistory,f.GetNextCommandFromHistory,f.AutoCompleteCommand]),Dd=async e=>{if(e.ctrl&&e.name==="c")return T.exit();let{actionIndex:t,mode:n,readOnly:r}=v(),o=Xs(e,n);if(!o||r&&!sp.has(o))return;let i=t[n]?.[o];if(i?.action)try{await i.action(i,e)}catch(s){logger.error(s)}},ap=()=>async function(t,n){n.name!=="escape"&&(Ue&&(clearTimeout(Ue),Ue=void 0),await Dd(n))},dp=()=>async function(t){if(t.length===1&&t[0]===27){Ue&&clearTimeout(Ue),Ue=setTimeout(()=>{Dd({name:"escape",ctrl:!1,meta:!1,shift:!1,sequence:"\x1B"}),Ue=void 0},25);return}Ue&&(clearTimeout(Ue),Ue=void 0)};function Fd(){Pr&&process.stdin.removeListener("keypress",Pr),Lr&&process.stdin.removeListener("data",Lr),Pr=ap(),Lr=dp(),ip.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.on("data",Lr),process.stdin.on("keypress",Pr)}ba();lp(`${kr.bold("Epiq CLI")}
58
58
 
59
59
  ${kr.dim("Boot in directory:")}
60
60
  ${kr.cyan("$ epiq")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epiq",
3
- "version": "0.6.12",
3
+ "version": "0.6.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "EPIQ - CLI based issue tracker",
package/readme.md CHANGED
@@ -7,11 +7,15 @@ Issue tracking is a core part of software development, but it often becomes a pa
7
7
  > You can manage all your projects directly via the command line in a visual kanban board and edit content in your favorite editor.
8
8
 
9
9
  With great attention to user ergonomics and developer experience, epiq makes project management painless and friction free.
10
+ ![Epiq cli kanban view](https://raw.githubusercontent.com/ljtn/epiq/main/source/assets/banner.gif)
11
+
12
+ ![Epiq cli gif view](https://raw.githubusercontent.com/ljtn/epiq/main/source/assets/banner.gif)
10
13
 
11
14
  ## What is epiq?
12
15
 
13
16
  Epiq is a vim-inspired issue tracker that brings project management into the terminal. It renders directly in ASCII and persists state as an immutable distributed event log, versioned and synchronized through Git.
14
17
 
18
+ ![Epiq cli gif view](https://raw.githubusercontent.com/ljtn/epiq/main/source/assets/banner.gif)
15
19
  ![Epiq cli kanban view](https://raw.githubusercontent.com/ljtn/epiq/main/source/assets/overview.png)
16
20
  ![Epiq cli log view](https://raw.githubusercontent.com/ljtn/epiq/main/source/assets/log.png)
17
21