local-operator-ui 0.31.28 → 0.31.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/out/main/index.js +931 -31
  2. package/out/renderer/assets/{_basePickBy-D16oopNi.js → _basePickBy-Y9GC34gi.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-BYKYfwtj.js → _baseUniq-B0peOdjF.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-CpwkLhdq.js → agent-details-page-DVzsvKvr.js} +1 -1
  5. package/out/renderer/assets/{agent-hub-page-BYeba0zC.js → agent-hub-page-Dp8llcze.js} +1 -1
  6. package/out/renderer/assets/agents-page-DlN3w0Rq.js +7 -0
  7. package/out/renderer/assets/{arc-BYg3WIzZ.js → arc-DQzRvMGZ.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-np6HwkQz.js → architectureDiagram-IEHRJDOE-BHLUr3Vi.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-CaR7YwVl.js → blockDiagram-JOT3LUYC-CVK0U-3j.js} +1 -1
  10. package/out/renderer/assets/{book-open--g1VlVMp.js → book-open-j4JS3yvI.js} +1 -1
  11. package/out/renderer/assets/browser-page-BI7a4ZtV.js +1 -0
  12. package/out/renderer/assets/{browser-webauthn-prompt-Bsk0eXNZ.js → browser-webauthn-prompt-nwdqBWnv.js} +1 -1
  13. package/out/renderer/assets/{c4Diagram-VJAJSXHY-DqBT3rl5.js → c4Diagram-VJAJSXHY-BqLTGVHe.js} +1 -1
  14. package/out/renderer/assets/channel-BP8e6HYH.js +1 -0
  15. package/out/renderer/assets/{chunk-4BMEZGHF-B7-MzFPi.js → chunk-4BMEZGHF-BSPZPecM.js} +1 -1
  16. package/out/renderer/assets/{chunk-A2AXSNBT-B9IqNrNg.js → chunk-A2AXSNBT-CEEG3uIi.js} +1 -1
  17. package/out/renderer/assets/{chunk-AEK57VVT-DFzBJNd9.js → chunk-AEK57VVT-CvyIUWUR.js} +1 -1
  18. package/out/renderer/assets/{chunk-D6G4REZN-DW-XzsAv.js → chunk-D6G4REZN-D4lVOdW7.js} +1 -1
  19. package/out/renderer/assets/{chunk-RZ5BOZE2-C7el6yre.js → chunk-RZ5BOZE2-znegx9P6.js} +1 -1
  20. package/out/renderer/assets/{chunk-XZIHB7SX-BGYrq1Wn.js → chunk-XZIHB7SX-DPz_D8Nf.js} +1 -1
  21. package/out/renderer/assets/classDiagram-GIVACNV2-DVXt0ycE.js +1 -0
  22. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DVXt0ycE.js +1 -0
  23. package/out/renderer/assets/clone-D0eJwRGh.js +1 -0
  24. package/out/renderer/assets/{console-mirror-ffbsozOd.js → console-mirror-GUGtzmyW.js} +1 -1
  25. package/out/renderer/assets/{consoleCapture-CiApa6fi.js → consoleCapture-D8nStIVt.js} +1 -1
  26. package/out/renderer/assets/{conversation-input-sync-DQUYkOfh.js → conversation-input-sync-CGaXAqah.js} +246 -239
  27. package/out/renderer/assets/{dagre-OKDRZEBW-BVScRDvj.js → dagre-OKDRZEBW-ByuMXl-x.js} +1 -1
  28. package/out/renderer/assets/{diagram-SSKATNLV-B0iQ6YY1.js → diagram-SSKATNLV-DrN1Clbm.js} +1 -1
  29. package/out/renderer/assets/{diagram-VNBRO52H-Co6YPtUT.js → diagram-VNBRO52H-BU95qC98.js} +1 -1
  30. package/out/renderer/assets/{erDiagram-Q7BY3M3F-C9XIuSQl.js → erDiagram-Q7BY3M3F-CLttNK5z.js} +1 -1
  31. package/out/renderer/assets/{error-boundary-DH4MhqhL.js → error-boundary-BR1z8pWF.js} +5 -5
  32. package/out/renderer/assets/{flowDiagram-4HSFHLVR-QTHrGPk1.js → flowDiagram-4HSFHLVR-BCsFW1Gf.js} +1 -1
  33. package/out/renderer/assets/{ganttDiagram-APWFNJXF-qC1VnBIz.js → ganttDiagram-APWFNJXF-Cdg1Q_-7.js} +1 -1
  34. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-D7UGP8uH.js → gitGraphDiagram-7IBYFJ6S-0tWQBOZl.js} +1 -1
  35. package/out/renderer/assets/{graph-BIUuz2bp.js → graph-BOvjqm1y.js} +1 -1
  36. package/out/renderer/assets/{index-Ckvy9Zge.js → index-Bbr0EFhm.js} +1 -1
  37. package/out/renderer/assets/index-Cy3MjKxd.css +1 -0
  38. package/out/renderer/assets/{index-vK67PDia.js → index-D09I1LXM.js} +196 -196
  39. package/out/renderer/assets/{index-DTc-sJ8S.js → index-DbuNRNvX.js} +1 -1
  40. package/out/renderer/assets/{infoDiagram-PH2N3AL5-DYtVGJC7.js → infoDiagram-PH2N3AL5-cyj8Lve1.js} +1 -1
  41. package/out/renderer/assets/{installer-BcSiJA6N.js → installer-DDGjYv9v.js} +1 -1
  42. package/out/renderer/assets/{journeyDiagram-U35MCT3I-vVg2sFTp.js → journeyDiagram-U35MCT3I-DWBKDniU.js} +1 -1
  43. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BE36wSk2.js → kanban-definition-NDS4AKOZ-Cl5Gtazo.js} +1 -1
  44. package/out/renderer/assets/{layout-bOQrw0b8.js → layout-CxuQX-mj.js} +1 -1
  45. package/out/renderer/assets/{legacy-agents-page-BSKz_UrV.js → legacy-agents-page-EmhBvGX8.js} +1 -1
  46. package/out/renderer/assets/{mermaid.core-DpvY6Bhk.js → mermaid.core-eIMT1oSc.js} +5 -5
  47. package/out/renderer/assets/{mesh-page-9Q8Sc9J_.js → mesh-page-B8pGIWvO.js} +1 -1
  48. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-B9PPN6sb.js → mindmap-definition-ALO5MXBD-zPRivaIU.js} +1 -1
  49. package/out/renderer/assets/{mini-ySULdryU.js → mini-D6nPFjTs.js} +1 -1
  50. package/out/renderer/assets/{org-surface-gate-Dl4zcl5q.js → org-surface-gate-BeX5voGq.js} +1 -1
  51. package/out/renderer/assets/{page-header-DazB-GQz.js → page-header-BLBgjVqc.js} +1 -1
  52. package/out/renderer/assets/{pieDiagram-IB7DONF6-DkioNhQY.js → pieDiagram-IB7DONF6-CUTT0oqK.js} +1 -1
  53. package/out/renderer/assets/projects-page-D60z6cvI.js +55 -0
  54. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-4m3m0N6F.js → quadrantDiagram-7GDLP6J5-B6ksoL9Y.js} +1 -1
  55. package/out/renderer/assets/{radar-MK3ICKWK-DS8YGAOb.js → radar-MK3ICKWK-BpDoqWc2.js} +1 -1
  56. package/out/renderer/assets/{radient-auth-buttons-DZeHRL7u.js → radient-auth-buttons-Ep1e0Z5I.js} +1 -1
  57. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DsBdUu3C.js → requirementDiagram-KVF5MWMF-DQwmYS7R.js} +1 -1
  58. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-CnaPYKR6.js → sankeyDiagram-QLVOVGJD-Dc8VJLoV.js} +1 -1
  59. package/out/renderer/assets/{schedules-page-B0dSGpXt.js → schedules-page-DyMkIr1h.js} +1 -1
  60. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-C3eja1QY.js → sequenceDiagram-X6HHIX6F-SsVDN37O.js} +1 -1
  61. package/out/renderer/assets/{settings-page-CrMsVX3d.js → settings-page-C_1ja3uN.js} +6 -6
  62. package/out/renderer/assets/{settings-section-BGG4XzV0.js → settings-section-BLUoPALO.js} +1 -1
  63. package/out/renderer/assets/{stateDiagram-DGXRK772-CjFKiyXn.js → stateDiagram-DGXRK772-vwQ-TB_f.js} +1 -1
  64. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D30uaRbQ.js +1 -0
  65. package/out/renderer/assets/{timeline-definition-BDJGKUSR-CAXy0nQD.js → timeline-definition-BDJGKUSR-CQ_pAZms.js} +1 -1
  66. package/out/renderer/assets/{ui-preferences-store-B6Fr0UX9.js → ui-preferences-store-CxJfZcpf.js} +1 -1
  67. package/out/renderer/assets/{use-download-agent-mutation-LsNre_-6.js → use-download-agent-mutation-DIujvdLj.js} +1 -1
  68. package/out/renderer/assets/{use-memberships-query-BgiSfYgr.js → use-memberships-query-BhO5nUlo.js} +1 -1
  69. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CfNm8SWG.js → xychartDiagram-VJFVF3MP-Cs3B-KEl.js} +1 -1
  70. package/out/renderer/console-capture.html +5 -5
  71. package/out/renderer/index.html +7 -7
  72. package/out/renderer/installer.html +4 -4
  73. package/out/renderer/mini.html +6 -6
  74. package/package.json +10 -3
  75. package/out/renderer/assets/agents-page-BQdR1fgV.js +0 -7
  76. package/out/renderer/assets/browser-page-BPwZPQY2.js +0 -1
  77. package/out/renderer/assets/channel-mWTr8anL.js +0 -1
  78. package/out/renderer/assets/classDiagram-GIVACNV2-DsNAZ0y6.js +0 -1
  79. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DsNAZ0y6.js +0 -1
  80. package/out/renderer/assets/clone-48M_nlg0.js +0 -1
  81. package/out/renderer/assets/index-C5Ighs_C.css +0 -1
  82. package/out/renderer/assets/projects-page-C37RiUJz.js +0 -35
  83. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BsbYpgkp.js +0 -1
  84. /package/out/renderer/assets/{index-D-TXozHA.js → index-CSNQxVPq.js} +0 -0
@@ -1,35 +0,0 @@
1
- import{r as p,j as t,c as $}from"./index-D-TXozHA.js";import{bN as ns,bO as Re,bP as rs,bQ as kt,u as wt,bR as is,bS as os,bT as ls,bU as cs,bV as ds,bW as us,bX as et,bY as tt,bZ as ms,b_ as hs,aF as St,aM as re,X as Q,aG as ze,aX as fs,aP as De,av as Ce,aT as Ee,b$ as ps,c0 as xs,c1 as gs,c2 as js,c3 as xe,aU as Tt,c4 as bs,c5 as vs,ag as be,b6 as ys,b5 as Ns,b2 as st,c6 as ks,c7 as ws,c8 as Ss,c9 as Ts,ca as _s,cb as Ds,a as _t,cc as Dt,d as je,S as Cs,cd as Es,aO as Os,aw as V,aN as se,af as Ps,ah as Ms,an as As,aQ as $s,aY as Rs}from"./conversation-input-sync-DQUYkOfh.js";import{P as at}from"./page-header-DazB-GQz.js";import{c as We,s as ve,f as Ct,t as ye,u as Ne,v as ke,w as me,B as I,D as Ls,k as Is,l as Fs,o as Ae,R as Us,U as Bs,V as Ys,W as qs,Y as zs,n as Ws,p as ie,P as Ks,Z as Hs,N as Qs,I as W,S as de,L as q,T as Gs,y as Et,O as Xs,X as Vs,C as Js,A as Le,M as Zs,z as ea,F as ta,G as sa,e as ce}from"./error-boundary-DH4MhqhL.js";import{aA as aa,aB as Ot,aC as na,ag as ra,a7 as we,aD as ia,A as nt,aE as rt,aF as oa}from"./index-vK67PDia.js";import"./ui-preferences-store-B6Fr0UX9.js";import"./console-mirror-ffbsozOd.js";function it(e,s){return e.filter(a=>!s.includes(a))}function la(e,s,a){const r=e.slice(0);return r[s]=a,r}var ca=class extends ns{#a;#e;#n;#r;#t;#s;#i;#o;#l=[];constructor(e,s,a){super(),this.#a=e,this.#r=a,this.#n=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#m(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#n=e,this.#r=s,Re.batch(()=>{const a=this.#t,r=this.#u(this.#n);this.#l=r,r.forEach(n=>n.observer.setOptions(n.defaultedQueryOptions));const o=r.map(n=>n.observer),i=o.map(n=>n.getCurrentResult()),d=o.some((n,h)=>n!==a[h]);a.length===o.length&&!d||(this.#t=o,this.#e=i,this.hasListeners()&&(it(a,o).forEach(n=>{n.destroy()}),it(o,a).forEach(n=>{n.subscribe(h=>{this.#m(n,h)})}),this.#h()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const a=this.#u(e),r=a.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions));return[r,o=>this.#d(o??r,s),()=>this.#c(r,a)]}#c(e,s){return s.map((a,r)=>{const o=e[r];return a.defaultedQueryOptions.notifyOnChangeProps?o:a.observer.trackResult(o,i=>{s.forEach(d=>{d.observer.trackProp(i)})})})}#d(e,s){return s?((!this.#s||this.#e!==this.#o||s!==this.#i)&&(this.#i=s,this.#o=this.#e,this.#s=rs(this.#s,s(e))),this.#s):e}#u(e){const s=new Map(this.#t.map(r=>[r.options.queryHash,r])),a=[];return e.forEach(r=>{const o=this.#a.defaultQueryOptions(r),i=s.get(o.queryHash);i?a.push({defaultedQueryOptions:o,observer:i}):a.push({defaultedQueryOptions:o,observer:new kt(this.#a,o)})}),a}#m(e,s){const a=this.#t.indexOf(e);a!==-1&&(this.#e=la(this.#e,a,s),this.#h())}#h(){if(this.hasListeners()){const e=this.#s,s=this.#c(this.#e,this.#l),a=this.#d(s,this.#r?.combine);e!==a&&Re.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}};function da({queries:e,...s},a){const r=wt(a),o=is(),i=os(),d=p.useMemo(()=>e.map(y=>{const N=r.defaultQueryOptions(y);return N._optimisticResults=o?"isRestoring":"optimistic",N}),[e,r,o]);d.forEach(y=>{ls(y),cs(y,i)}),ds(i);const[n]=p.useState(()=>new ca(r,d,s)),[h,m,c]=n.getOptimisticResult(d,s.combine),k=!o&&s.subscribed!==!1;p.useSyncExternalStore(p.useCallback(y=>k?n.subscribe(Re.batchCalls(y)):us,[n,k]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),p.useEffect(()=>{n.setQueries(d,s)},[d,s,n]);const l=h.some((y,N)=>et(d[N],y))?h.flatMap((y,N)=>{const g=d[N];if(g){const j=new kt(r,g);if(et(g,y))return tt(g,j,i);ms(y,o)&&tt(g,j,i)}return[]}):[];if(l.length>0)throw Promise.all(l);const T=h.find((y,N)=>{const g=d[N];return g&&hs({result:y,errorResetBoundary:i,throwOnError:g.throwOnError,query:r.getQueryCache().get(g.queryHash),suspense:g.suspense})});if(T?.error)throw T.error;return m(c())}/**
2
- * @license lucide-react v0.507.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ua=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],ma=We("link-2",ua);/**
7
- * @license lucide-react v0.507.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ha=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],fa=We("send-horizontal",ha);/**
12
- * @license lucide-react v0.507.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const pa=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],xa=We("unlink",pa),Oe={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function ga(e){return St({queryKey:Oe.list,enabled:e,queryFn:()=>Q({op:"projects.list"}).then(s=>s.projects),retry:ze,staleTime:1e4})}function ja(e,s){return da({queries:e.map(a=>({queryKey:Oe.detail(a),enabled:s&&!!a,queryFn:()=>Q({op:"projects.get",key:a}),retry:ze,staleTime:1e4}))})}function Pt(e,s){return St({queryKey:Oe.detail(e??""),enabled:s&&!!e,queryFn:()=>Q({op:"projects.get",key:e??""}),retry:ze,staleTime:1e4})}function oe(){const e=wt();return()=>{e.invalidateQueries({queryKey:Oe.list})}}function ba(){const e=oe();return re({mutationFn:s=>Q({op:"projects.create",name:s.name,...s.description!==void 0?{description:s.description}:{},...s.status!==void 0?{status:s.status}:{},...s.tags!==void 0?{tags:s.tags}:{}}),onSuccess:()=>e()})}function Mt(){const e=oe();return re({mutationFn:s=>Q({op:"projects.update",key:s.key,fields:s.fields}),onSuccess:()=>e()})}function At(){const e=oe();return re({mutationFn:s=>Q({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function va(){const e=oe();return re({mutationFn:s=>Q({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ya(){const e=oe();return re({mutationFn:s=>Q({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function Na(){const e=oe();return re({mutationFn:s=>Q({op:"projects.milestone",key:s.key,name:s.name,...s.targetDate!==void 0?{targetDate:s.targetDate}:{},...s.completed!==void 0?{completed:s.completed}:{}}),onSuccess:()=>e()})}function ka(){const e=oe();return re({mutationFn:s=>Q({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const wa={planning:{label:"Planning",variant:"info"},active:{label:"Active",variant:"accent"},qa:{label:"QA",variant:"attention"},validation:{label:"Validation",variant:"warning"},done:{label:"Done",variant:"success"},paused:{label:"Paused",variant:"neutral"},archived:{label:"Archived",variant:"outline"}};function z(e){return wa[e]??{label:e||"Unknown",variant:"neutral"}}function Sa(e){return e==="done"}const Ta={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function _a(e){return Ta[e]??{label:String(e),variant:"neutral"}}const Se="Stale",Da=/^(\d{4})-(\d{2})-(\d{2})$/;function J(e,s,a=new Date){if(!e)return"";const r=Da.exec(e);if(!r)return e;const o=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));if(Number.isNaN(o.getTime()))return e;const i=o.toLocaleDateString(s,{month:"short",day:"numeric"});return o.getFullYear()===a.getFullYear()?i:`${i}, ${o.getFullYear()}`}function fe(e,s){if(e==null)return"";const a=Math.max(0,Math.floor(s/1e3-e));return a<60?"just now":a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function pe(e){return e==="just now"?"just now":`${e} ago`}function Ca(e){return e?`reported ${pe(e)}`:"no progress"}const $t=/^$|^\d{4}-\d{2}-\d{2}$/;function Rt(e){return e?e==="operator"?"the operator":`session ${e}`:""}function Ea(e,s){if(!e.progress)return"not reported yet";const a=fe(e.progress_updated_at,s),r=Rt(e.progress_reported_by),o=[a?`reported ${pe(a)}`:"reported"];return r&&o.push(`by ${r}`),o.join(" ")}function Lt(e,s){if(e==null)return"";const a=String(e);return s==="points"?`${a} pt`:s==="days"?`${a}d`:a}function It(e,s){return s<=0?"":`${e}/${s}`}function Ke(e){return e<=0?"":`${e} live`}function Oa(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function Pa(e){return e===1?"1 project":`${e} projects`}function Ma(e){const s=Oa(e.sessions);if(!s)return"";const a=Ke(e.live_sessions);return a?`${s} · ${a}`:s}function Aa(e){if(!e.exists)return{label:"Missing",variant:"outline"};if(e.archived)return{label:"Archived",variant:"neutral"};switch(e.runtime?.state){case"live":return{label:"Live",variant:"success"};case"wedged":return{label:"Wedged",variant:"warning"};case"stale":return{label:"Stale",variant:"warning"};case"stopped":return{label:"Stopped",variant:"neutral"};default:return{label:String(e.runtime?.state??"Unknown"),variant:"neutral"}}}function $a(e){return e?e.running>0?e.running===1?"1 subagent running":`${e.running} subagents running`:e.settled===1?"1 subagent":`${e.settled} subagents`:""}function Ra(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function Ft(e,s){const a=[],r=J(e.completed_at??e.target_date,s);r&&a.push({key:e.completed_at?"completed":"target",text:e.completed_at?`completed ${r}`:`due ${r}`});const o=Lt(e.estimate,e.estimate_unit);o&&a.push({key:"estimate",text:o});const i=It(e.milestones_completed,e.milestones_total);i&&a.push({key:"milestones",text:`milestones ${i}`});const d=Ke(e.live_sessions);return d&&a.push({key:"live",text:d}),a}const he=864e5,La=/^(\d{4})-(\d{2})-(\d{2})$/;function ne(e){if(!e)return null;const s=La.exec(e);if(!s)return null;const a=Number(s[1]),r=Number(s[2]),o=Number(s[3]),i=Date.UTC(a,r-1,o),d=new Date(i);return d.getUTCFullYear()!==a||d.getUTCMonth()!==r-1||d.getUTCDate()!==o?null:i}const Ie=["planning","active","qa","validation","done"],Fe=["paused","archived"],Pe=[{value:"24h",label:"Last 24 hours",phrase:"the last 24 hours",seconds:86400},{value:"7d",label:"Last 7 days",phrase:"the last 7 days",seconds:604800},{value:"30d",label:"Last 30 days",phrase:"the last 30 days",seconds:2592e3},{value:"90d",label:"Last 90 days",phrase:"the last 90 days",seconds:7776e3},{value:"all",label:"All time",phrase:null,seconds:null}],Ut="7d",Ia=Pe.find(e=>e.value===Ut);function Bt(e){return Pe.find(s=>s.value===e)??Ia}function Fa(e){return Pe.some(s=>s.value===e)}function Ua(e,s,a){const r=Bt(s);return r.seconds===null?e:e.filter(o=>a/1e3-o.updated_at<=r.seconds)}function Ba(e){const s=Bt(e);return s.seconds===null?null:`Nothing changed in ${s.phrase}.`}const Yt="projects-board-window";function Ya(){try{const e=localStorage.getItem(Yt);if(e!==null&&Fa(e))return e}catch{}return Ut}function ot(e){try{localStorage.setItem(Yt,e)}catch{}}const qt="projects-board-column-order";let Ue=null;function qa(){if(Ue)return[...Ue];try{const e=localStorage.getItem(qt);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const a=[];for(const r of s){if(typeof r!="string"||r.length===0)return[];a.includes(r)||a.push(r)}return a}catch{return[]}}function za(e){Ue=[...e];try{localStorage.setItem(qt,JSON.stringify(e))}catch{}}function Wa(e,s,a){const r=e.filter(i=>i!==s),o=Math.max(0,Math.min(a,r.length));return r.splice(o,0,s),r}function Ka(e,s=[]){const a=new Map;for(const n of e){const h=a.get(n.status)??[];h.push(n),a.set(n.status,h)}const r=Ie.map(n=>({status:n,projects:a.get(n)??[]}));for(const n of Fe){const h=a.get(n)??[];h.length>0&&r.push({status:n,projects:h})}for(const[n,h]of a)!Fe.includes(n)&&!Ie.includes(n)&&r.push({status:n,projects:h});if(s.length===0)return r;const o=new Map(s.map((n,h)=>[n,h])),i=r.filter(n=>o.has(n.status));i.sort((n,h)=>(o.get(n.status)??0)-(o.get(h.status)??0));const d=r.filter(n=>!o.has(n.status));return[...i,...d]}function Ha(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const a=ne(e.target_date);return a===null?!1:a<s}function le(e){return e.title||e.name}function Qa(e,s){const a=[];for(const r of[e,s]){const o=r?.trim();o&&!a.includes(o)&&a.push(o)}return a.join(" · ")}const He="No team";function Qe(e){const s=e.team?.trim();if(s)return s;const a=e.owner?.trim();return a||null}function Ge(e,s){const a=new Map,r=[];for(const i of e){const d=s(i);if(d===null){r.push(i);continue}const n=a.get(d);n?n.push(i):a.set(d,[i])}const o=[...a.entries()].sort(([i],[d])=>i.localeCompare(d,void 0,{sensitivity:"base"})).map(([i,d])=>({team:i,items:d}));return r.length>0&&o.push({team:null,items:r}),o}function Xe(e){return e.title||e.session_id}function Ga(e){return[...e].reverse()}function Xa(e){return e<=0?"":e===1?"1 update":`${e} updates`}const lt=e=>String(e).padStart(2,"0");function Be(e){return`${e.getFullYear()}-${lt(e.getMonth()+1)}-${lt(e.getDate())}`}function Va(e){const s=Date.parse(e);return Number.isNaN(s)?"":Be(new Date(s))}function Ja(e,s,a=new Date){if(!e)return"";if(e===Be(a))return"Today";const r=new Date(a.getFullYear(),a.getMonth(),a.getDate()-1);return e===Be(r)?"Yesterday":J(e,s,a)}function Za(e,s){const a=Date.parse(e);return Number.isNaN(a)?"":new Date(a).toLocaleTimeString(s,{hour:"numeric",minute:"2-digit"})}function en(e,s){const a=Date.parse(e);return Number.isNaN(a)?"":pe(fe(a/1e3,s))}function tn(e,s,a=Date.now()){const r=[],o=Rt(e.by);o&&r.push({key:"author",text:o});const i=Za(e.at,s);i&&r.push({key:"time",text:i});const d=en(e.at,a);return d&&r.push({key:"age",text:d}),r}function sn(e,s,a=new Date){const r=[];for(const o of Ga(e)){const i=Va(o.at),d=r[r.length-1];if(d&&d.key===i){d.entries.push(o);continue}r.push({key:i,label:Ja(i,s,a),entries:[o]})}return r}function an(e){return!Number.isFinite(e)||e<0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function nn(e,s){return s<=0?"":`${e} of ${s} complete`}function rn(e){let s=0,a=0,r=!1;for(const o of e)o.todos&&(r=!0,s+=o.todos.open,a+=o.todos.total);return r?{open:s,total:a}:null}function ct(e){return`${e.open} open of ${e.total}`}function on(e){const s=e.filter(r=>r.exists);return(s.find(r=>r.runtime?.state==="live")??s[0])?.session_id??null}function ln(e){const s=le(e),a=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${a}`,"Review the project details and continue or complete the work."].join(`
17
- `)}function cn(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const dt="complete them, or pass force_done=true to close with them open",dn="complete or remove the incomplete milestones, then mark it done";function zt(e){return e.includes(dt)?e.replace(dt,dn):e}const un="Shows projects last updated within this window; older ones are hidden.",mn=({value:e,onChange:s})=>t.jsxs(ve,{value:e,onValueChange:a=>s(a),children:[t.jsx(Ct,{content:e==="all"?null:un,side:"bottom",disableHoverableContent:!0,children:t.jsx(ye,{"aria-label":"Projects updated within",className:$("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(Ne,{})})}),t.jsx(ke,{children:Pe.map(a=>t.jsx(me,{value:a.value,children:a.label},a.value))})]}),te=["day","week","month","quarter"],Ve={day:24,week:9,month:3,quarter:1};function Wt(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function ae(e,s){return Math.round((s-e)/he)}function ut(e,s){return ae(e,s)+1}function hn(e,s){for(const a of te)if(e*Ve[a]<=s)return a;return te[te.length-1]}function fn(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(a=>!!a.target_date)}function pn(e,s){const a=[s];for(const r of e){for(const o of[r.project.start_date,r.project.target_date,r.project.completed_at]){const i=ne(o);i!==null&&a.push(i)}for(const o of r.milestones){const i=ne(o.target_date);i!==null&&a.push(i)}}return a.length===1?null:{startMs:Math.min(...a),endMs:Math.max(...a)}}function xn(e){const s=[],a=[];for(const r of e)(fn(r)?s:a).push(r);return{dated:s,undated:a}}function gn(e){const{project:s}=e,a=ne(s.start_date),r=ne(s.target_date),o=ne(s.completed_at),i=s.status==="done"&&o!==null?o:r,d=a??i,n=i??a;return d===null||n===null?null:{fromMs:Math.min(d,n),toMs:Math.max(d,n)}}function jn(e){const s=[];for(const a of e.milestones){const r=ne(a.target_date);r!==null&&s.push({name:a.name,dayMs:r,status:a.status})}return s}const ge=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function H(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function bn(e){const{year:s,month:a}=H(e);return Date.UTC(s,a-1,1)}function vn(e){const{year:s,month:a}=H(e);return a===12?Date.UTC(s+1,0,1):Date.UTC(s,a,1)}function yn(e){const{year:s,month:a}=H(e);return Date.UTC(s,Math.floor((a-1)/3)*3,1)}function Nn(e){const{year:s,month:a}=H(e),r=Math.floor((a-1)/3);return r===3?Date.UTC(s+1,0,1):Date.UTC(s,r*3+3,1)}function kn(e){const{weekday:s}=H(e);return e-(s+6)%7*he}const wn=26;function Sn(e,s,a){const r=[],o=(c,k,x)=>{c<e||c>s||r.push({dayMs:c,label:k,major:x})};if(a==="day"){let c=!1;for(let k=e;k<=s;k+=he){const{day:x,month:l}=H(k);x===1?(o(k,ge[l-1],!0),c=!0):c?(o(k,"",!1),c=!1):o(k,String(x),!1)}return r}if(a==="week"){for(let c=kn(e);c<=s;c+=7*he){if(c<e)continue;const{day:k,month:x}=H(c);H(c-7*he).month!==x?o(c,`${ge[x-1]} ${k}`,!0):o(c,String(k),!1)}return r}const i=a==="month"?bn:yn,d=a==="month"?vn:Nn,n=c=>{const{year:k,month:x}=H(c);if(a==="month")return x===1&&k!==H(e).year?`${ge[0]} '${String(k%100).padStart(2,"0")}`:ge[x-1];const l=Math.floor((x-1)/3)+1;return l===1&&k!==H(e).year?`Q1 '${String(k%100).padStart(2,"0")}`:`Q${l}`};o(e,n(i(e)),!0);const h=Math.ceil(wn/Ve[a]);let m=e;for(let c=d(i(e));c<=s;c=d(c))ae(m,c)<h||(o(c,n(c),!0),m=c);return r}const mt={active:"In flight",paused:"On hold",done:"Finished"};function Tn(){const[e,s]=p.useState(null);return p.useEffect(()=>{if(!e)return;const a=document.querySelector(`[data-project-menu="${e}"]`);a&&(a.focus(),s(null))}),p.useCallback(a=>s(a),[])}const _n=4,$e="Drag the header, or press the arrow keys, to move this column.",ht="board-column-move-hint",Dn=({projects:e,nowMs:s,onOpen:a,onEdit:r,onDelete:o,onMove:i,movingKeys:d=[],teamLabelFor:n=h=>h})=>{const[h,m]=p.useState(qa),c=Ka(e,h),k=Ge(e,Qe),[x,l]=p.useState(null),[T,y]=p.useState(""),N=p.useRef(null),g=p.useRef(null),j=p.useRef(null),f=p.useRef(null),D=p.useRef(null),U=new Set(d),_=(b,v)=>{const S=Wa(c.map(P=>P.status),b,v);m(S),za(S),y(`Moved ${z(b).label} column to position ${S.indexOf(b)+1} of ${S.length}.`)},R=(b,v)=>{const S=N.current;if(!S)return 0;let P=0;const F=S.querySelectorAll("[data-board-column]");for(const B of F){if(B.dataset.boardColumn===v)continue;const Z=B.getBoundingClientRect();b>(Z.left+Z.right)/2&&(P+=1)}return P},Y=(b,v)=>{const S=c.filter(B=>B.status!==b),P=S[v-1]?.status,F=S[v]?.status;return P&&F?`between ${z(P).label} and ${z(F).label}`:F?`before ${z(F).label}`:P?`after ${z(P).label}`:"in place"},G=(b,v)=>{const S=R(b,v.status);S!==v.over&&(v.over=S,l({status:v.status,over:S}),y(`Moving ${z(v.status).label} column; it will drop ${Y(v.status,S)}.`))},C=()=>{f.current!==null&&(cancelAnimationFrame(f.current),f.current=null)},u=32,M=12,E=()=>{f.current=null;const b=D.current,v=N.current,S=j.current;if(!b?.armed||!v||S===null)return;const P=v.getBoundingClientRect(),F=v.scrollWidth-v.clientWidth;let B=0;if(S-P.left<u&&v.scrollLeft>0?B=-1:P.right-S<u&&v.scrollLeft<F&&(B=1),B!==0){const Z=v.scrollLeft;v.scrollLeft=Z+B*M,v.scrollLeft!==Z&&G(S,b)}else G(S,b);X(b.status,b.over),f.current=requestAnimationFrame(E)};p.useEffect(()=>()=>{f.current!==null&&cancelAnimationFrame(f.current)},[]);const O=(b,v)=>{if(b.button===0){try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}D.current={pointerId:b.pointerId,status:v,startX:b.clientX,startY:b.clientY,armed:!1,over:c.findIndex(S=>S.status===v)},j.current=b.clientX}},A=b=>{const v=D.current;if(!(!v||b.pointerId!==v.pointerId)){if(j.current=b.clientX,!v.armed){if(Math.hypot(b.clientX-v.startX,b.clientY-v.startY)<_n)return;v.armed=!0,l({status:v.status,over:v.over}),y(`Moving ${z(v.status).label} column.`),f.current===null&&(f.current=requestAnimationFrame(E))}G(b.clientX,v)}},L=b=>{const v=D.current;if(D.current=null,C(),l(null),!v?.armed)return;if(!b){y("Move cancelled.");return}const S=c.findIndex(P=>P.status===v.status);if(v.over===S){y("");return}_(v.status,v.over)},w=b=>{const v=D.current;!v||b.pointerId!==v.pointerId||L(!0)},K=()=>{L(!1)};p.useEffect(()=>{if(!x)return;const b=v=>{v.key==="Escape"&&L(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[x!==null]);const X=p.useCallback((b,v)=>{const S=N.current,P=g.current;if(!S||!P)return;const F=S.getBoundingClientRect(),B=[];for(const Ze of S.querySelectorAll("[data-board-column]"))Ze.dataset.boardColumn!==b&&B.push(Ze.getBoundingClientRect());const Z=6,Zt=v>=B.length?(B[B.length-1]?.right??F.left)+Z:(B[v]?.left??F.right)-Z,Me=S.scrollLeft,es=2,ts=Zt-F.left+Me,Je=Me+1,ss=Me+F.width-es-1,as=Math.round(Math.min(Math.max(ts,Je),Math.max(Je,ss)));P.style.left=`${as}px`},[]);p.useLayoutEffect(()=>{x&&X(x.status,x.over)},[x,X]);const ue=(b,v)=>{if(b.key==="Enter"||b.key===" "){b.preventDefault(),y($e);return}if(b.key!=="ArrowLeft"&&b.key!=="ArrowRight")return;b.preventDefault();const S=c.map(B=>B.status),P=S.indexOf(v),F=b.key==="ArrowLeft"?P-1:P+1;if(F<0||F>=S.length){y(`${z(v).label} column is already ${F<0?"the first column":"the last column"}.`);return}_(v,F)};return t.jsxs("div",{className:"[container-type:size] flex min-h-0 flex-1 flex-col","data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:T}),t.jsx("span",{id:ht,className:"sr-only",children:$e}),t.jsxs("div",{ref:N,"data-board-strip":"",className:$("relative flex min-h-0 flex-1 items-start overflow-auto px-9 pb-9",x&&"cursor-grabbing select-none"),children:[x&&t.jsx("div",{ref:g,"aria-hidden":"true","data-board-drop-indicator":"",className:"pointer-events-none absolute top-3 bottom-3 w-0.5 rounded-full bg-accent"}),t.jsxs("div",{className:"flex w-max flex-col",children:[t.jsx("div",{className:"sticky top-0 z-30 flex gap-3",children:c.map(b=>{const v=z(b.status);return t.jsxs("header",{"data-board-column":b.status,"data-board-column-handle":b.status,onPointerDown:S=>O(S,b.status),onPointerMove:A,onPointerUp:w,onPointerCancel:K,className:$("flex h-11 w-64 shrink-0 cursor-grab items-center justify-between gap-2 rounded-t-md bg-sunken px-3 active:cursor-grabbing",x?.status===b.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(I,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":b.status,"aria-label":`Move ${v.label} column`,"aria-describedby":ht,title:$e,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:S=>ue(S,b.status),children:t.jsx(aa,{"aria-hidden":"true"})}),t.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[t.jsx("span",{className:"truncate text-body-sm font-medium text-ink",children:v.label}),mt[b.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:mt[b.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:b.projects.length})]},b.status)})}),k.map(b=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":b.team??"",className:"sticky top-11 z-20 flex h-8 items-center bg-canvas px-3 text-meta",children:t.jsxs("span",{className:"sticky left-3 flex min-w-0 max-w-[calc(100cqw-2.25rem)] items-center gap-2",children:[t.jsx("span",{className:"truncate text-ink",children:b.team==null?He:n(b.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:b.items.length})]})}),t.jsx("div",{className:"flex gap-3 rounded-md bg-sunken py-2",children:c.map(v=>{const S=b.items.filter(P=>P.status===v.status);return t.jsx("div",{"data-board-cell":v.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:S.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:S.map(P=>t.jsx("li",{children:t.jsx(Cn,{project:P,nowMs:s,busy:U.has(P.id),onOpen:()=>a(P),onEdit:()=>r(P),onDelete:()=>o(P),onMove:F=>i(P,F)})},P.id))})},v.status)})})]},b.team??""))]})]})]})},Cn=({project:e,nowMs:s,busy:a,onOpen:r,onEdit:o,onDelete:i,onMove:d})=>{const n=Ft(e,typeof navigator>"u"?void 0:navigator.language),h=le(e),m=p.useRef(null),[c,k]=p.useState(!1);p.useEffect(()=>{const N=m.current;if(!N)return;const g=()=>{N.isConnected&&k(N.scrollWidth-N.clientWidth>.5)},j=requestAnimationFrame(g),f=new ResizeObserver(g);return f.observe(N),document.fonts?.ready.then(g).catch(()=>{}),()=>{cancelAnimationFrame(j),f.disconnect()}},[h,c]);const x=Ha(e,Wt(s)),l=fe(e.progress_updated_at,s),T=()=>{const N=window.getSelection();N&&!N.isCollapsed||r()},y=N=>{N.key!=="Enter"&&N.key!==" "||N.target===N.currentTarget&&(N.preventDefault(),r())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":`Open ${h}`,onClick:T,onKeyDown:y,className:$("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",x&&"border border-warning-border"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx(Ct,{content:c?h:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:m,"data-project-title":e.name,tabIndex:c?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:h})}),e.title&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.name}),e.description&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.description})]}),t.jsxs(Ls,{children:[t.jsx(Is,{"data-project-menu":e.id,"aria-label":`Actions for ${h}`,disabled:a,onClick:N=>N.stopPropagation(),className:$("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:t.jsx(fs,{className:"size-4"})}),t.jsxs(Fs,{align:"end",onClick:N=>N.stopPropagation(),children:[t.jsx(Ae,{onSelect:r,children:"Open"}),t.jsxs(Us,{children:[t.jsx(Bs,{children:"Set status"}),t.jsx(Ys,{children:t.jsx(qs,{value:e.status,onValueChange:d,children:[...Ie,...Fe].map(N=>t.jsx(zs,{value:N,children:z(N).label},N))})})]}),t.jsx(Ws,{}),t.jsx(Ae,{onSelect:o,children:"Edit"}),t.jsx(Ae,{onSelect:i,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[n.filter(N=>N.key!=="live").map(N=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:N.text},N.key)),x&&t.jsx(ie,{variant:"warning",children:"Overdue"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-meta text-ink-muted",children:Ca(l)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!l)&&t.jsx("span",{"aria-label":Se,title:Se,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(En,{project:e})]})]})]})},En=({project:e})=>{const[s,a]=p.useState(!1),r=De(),o=Pt(e.id,s),i=o.data?.links??[],d=Ma(e),n=le(e);return t.jsxs(Ks,{open:s,onOpenChange:a,children:[t.jsx(Hs,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${n}`,onClick:h=>h.stopPropagation(),className:$("rounded-sm px-1 text-meta whitespace-nowrap",e.live_sessions>0?"text-success hover:bg-sunken":"text-ink-muted hover:bg-sunken"),children:d}),t.jsx(Qs,{align:"end",className:"w-64 p-2 outline-none",onClick:h=>h.stopPropagation(),children:o.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"Loading linked sessions…"}):o.isError?t.jsxs("div",{className:"flex flex-col items-start gap-1.5 px-1 py-2",children:[t.jsx("p",{className:"text-meta text-ink-muted",children:o.error instanceof Error&&o.error.message?o.error.message:"The linked sessions could not be read."}),t.jsx(I,{variant:"secondary",size:"sm",onClick:()=>void o.refetch(),children:"Try again"})]}):i.length===0?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"No sessions linked yet."}):t.jsx("ul",{className:"flex flex-col",children:i.map(h=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!h.exists,onClick:()=>{h.exists&&(a(!1),Ot(r,h.session_id))},className:$("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",h.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:h.title||h.session_id})})},h.session_id))})})]})},Kt=({open:e,projectName:s,onClose:a,onConfirm:r})=>{const[o,i]=p.useState(""),[d,n]=p.useState(null),[h,m]=p.useState(!1),c=p.useId();p.useEffect(()=>{e&&(i(""),n(null),m(!1))},[e]);const k=o.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,x=async()=>{m(!0),n(null);try{await r(o.trim()),a()}catch(l){n(l instanceof Error&&l.message?l.message:"The project was not deleted.")}finally{m(!1)}};return t.jsx(Ce,{open:e,onClose:a,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Ee,{onClick:a,disabled:h,children:"Cancel"}),t.jsxs(ps,{onClick:()=>void x(),disabled:!k||h,children:[h&&t.jsx(de,{size:"xs"}),"Delete project"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink",children:"This deletes the project and its milestones. The sessions linked to it are not touched."}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Type"," ",t.jsx("span",{className:"font-mono text-mono-sm text-ink",children:s})," ","to confirm."]}),t.jsx(W,{id:`${c}-confirm`,value:o,onChange:l=>i(l.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":o.length>0&&!k,autoFocus:!0}),d&&t.jsx("p",{className:"text-body-sm text-danger",children:d})]})})},On=/^(https?:|mailto:)/i,Pn={a:({href:e,children:s})=>typeof e=="string"&&On.test(e)?t.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:s}):t.jsx("span",{className:"font-mono text-mono-sm",children:s}),table:gs},Te=p.memo(({children:e,className:s})=>t.jsx("div",{className:$("lo-markdown",s),children:t.jsx(xs,{remarkPlugins:[js],components:Pn,children:e})})),ft=`## Summary
18
-
19
- ## Goals
20
-
21
- ## Notes`,Mn=new RegExp("\\p{Mn}","gu"),An=/[^a-z0-9._-]+/g,$n=/[._-]{2,}/g,Rn=/^[^a-z0-9]+/,pt=/[^a-z0-9]+$/;function Ln(e){return e.normalize("NFKD").replace(Mn,"").toLowerCase().replace(An,"-").replace($n,"-").replace(Rn,"").replace(pt,"").slice(0,64).replace(pt,"")}const In=/&#x([0-9a-f]+);/gi,Fn=/&#(\d+);/g,Un=/&nbsp;/g,Bn=/&lt;/g,Yn=/&gt;/g,qn=/&quot;/g,zn=/&#39;|&apos;/g,Wn=/&amp;/g,xt=e=>e.replace(In,(s,a)=>String.fromCodePoint(Number.parseInt(a,16))).replace(Fn,(s,a)=>String.fromCodePoint(Number.parseInt(a,10))).replace(Un," ").replace(Bn,"<").replace(Yn,">").replace(qn,'"').replace(zn,"'").replace(Wn,"&"),Kn=/<[^>]*>|[^<]+/g,Hn=/^<\//,Qn=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,Gn=/\s+/g,gt=/class="[^"]*language-([\w+-]+)/,Xn=/href="([^"]*)"/,Vn=/src="([^"]*)"/,Jn=/alt="([^"]*)"/,Zn=/[ \t]+\n/g,er=/\n{3,}/g;function tr(e){const s=[],a=(...m)=>{for(let c=s.length-1;c>=0;c--)if(m.includes(s[c].tag)){const[k]=s.splice(c,1);return k}},r=[],o=()=>s.some(m=>m.tag==="pre"),i=()=>s.filter(m=>m.tag==="blockquote").length;let d=!0;const n=m=>{m&&(i()>0&&d&&!o()&&r.push("> ".repeat(i())),r.push(m),d=m.endsWith(`
22
- `))},h=e.match(Kn)??[];for(let m=0;m<h.length;m++){const c=h[m];if(!c.startsWith("<")){n(o()?xt(c):xt(c).replace(Gn," "));continue}const k=Hn.test(c),x=(c.match(Qn)?.[1]??"").toLowerCase();if(k){switch(x){case"p":case"div":n(`
23
-
24
- `);break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":a(x),n(`
25
-
26
- `);break;case"li":{a("li"),n(`
27
- `);const l=[...s].reverse().find(T=>T.tag==="ul"||T.tag==="ol");l?.ordered&&(l.index=(l.index??1)+1);break}case"ul":case"ol":a(x),n(`
28
- `);break;case"strong":case"b":a("strong","b")&&n("**");break;case"em":case"i":a("em","i")&&n("*");break;case"del":case"s":a("del","s")&&n("~~");break;case"code":{a("code")?.inline&&n("`");break}case"pre":a("pre")&&n("\n```\n\n");break;case"a":{const l=a("a");l?.href&&n(`](${l.href})`);break}case"blockquote":a("blockquote")&&n(`
29
- `);break}continue}switch(x){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const l=Number(x[1]);s.push({tag:x}),n(`${"#".repeat(l)} `);break}case"ul":case"ol":s.push({tag:x,ordered:x==="ol",index:1});break;case"li":{const l=[...s].reverse().find(T=>T.tag==="ul"||T.tag==="ol");s.push({tag:"li"}),l?.ordered?n(`${l.index??1}. `):n("- ");break}case"strong":case"b":s.push({tag:x}),n("**");break;case"em":case"i":s.push({tag:x}),n("*");break;case"del":case"s":s.push({tag:x}),n("~~");break;case"code":{const l=s[s.length-1]?.tag!=="pre";s.push({tag:"code",inline:l}),l&&n("`");break}case"pre":{const l=c.match(gt)?.[1]??h[m+1]?.match(gt)?.[1]??"";s.push({tag:"pre"}),n(`
30
- \`\`\`${l}
31
- `);break}case"a":{const l=c.match(Xn)?.[1]??"";s.push({tag:"a",href:l}),l&&n("[");break}case"img":{const l=c.match(Vn)?.[1]??"",T=c.match(Jn)?.[1]??"";l&&n(`![${T}](${l})`);break}case"br":n(`
32
- `);break;case"blockquote":s.push({tag:"blockquote"});break}}return r.join("").replace(Zn,`
33
- `).replace(er,`
34
-
35
- `).trim()}const sr=[{value:"planning",label:"Planning"},{value:"active",label:"Active"},{value:"qa",label:"QA"},{value:"validation",label:"Validation"},{value:"done",label:"Done"},{value:"paused",label:"Paused"},{value:"archived",label:"Archived"}],Ye={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},jt=$t;function bt(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}function ar(e){return e?{name:e.name,title:e.title??"",owner:e.owner??"",team:e.team??"",description:e.description,status:e.status,tags:e.tags.join(", "),startDate:e.start_date??"",targetDate:e.target_date??"",estimate:e.estimate===null||e.estimate===void 0?"":String(e.estimate),estimateUnit:e.estimate_unit||"points"}:Ye}const qe=({open:e,mode:s,initial:a,onClose:r,onSubmit:o})=>{const[i,d]=p.useState(Ye),[n,h]=p.useState({}),[m,c]=p.useState(null),k=p.useRef(null),[x,l]=p.useState(!1),[T,y]=p.useState(s==="edit"),[N,g]=p.useState(!1),j=p.useId(),f=p.useRef(null);p.useEffect(()=>{e&&(d(s==="create"?{...Ye,description:ft}:ar(a)),h({}),c(null),l(!1),y(s==="edit"),g(!1))},[e]),p.useEffect(()=>{m&&k.current?.scrollIntoView({block:"nearest"})},[m]);const D=(u,M)=>{d(E=>({...E,[u]:M}))},U=s==="create"&&!T?Ln(i.title):i.name,_=u=>{const M=u.clipboardData?.getData("text/html");if(!M)return;const E=tr(M);if(!E)return;u.preventDefault();const O=u.currentTarget,A=O.selectionStart??O.value.length,L=O.selectionEnd??A,w=O.value.slice(0,A)+E+O.value.slice(L);D("description",w),requestAnimationFrame(()=>{const K=f.current;if(!K)return;const X=A+E.length;K.setSelectionRange(X,X)})},R=(u,M)=>{const E={},O=bs(M);O&&(E.name=O),u.description.length>xe&&(E.description=`Keep the description within ${xe} characters.`);const A=bt(u.tags);if(A.length>8)E.tags="At most 8 tags.";else for(const L of A){const w=vs(L);if(w){E.tags=w;break}}if(jt.test(u.startDate)||(E.startDate="Dates are YYYY-MM-DD, or empty."),jt.test(u.targetDate)||(E.targetDate="Dates are YYYY-MM-DD, or empty."),!E.startDate&&!E.targetDate&&u.startDate&&u.targetDate&&u.targetDate<u.startDate&&(E.targetDate="The target date is before the start date."),u.estimate){const L=Number(u.estimate);(!Number.isFinite(L)||!(L>0)||L>1e3)&&(E.estimate="Estimates are greater than 0 and at most 1000.")}for(const L of["title","owner","team"])u[L].trim().length>80&&(E[L]=`${L==="title"?"Titles":L==="owner"?"Owners":"Teams"} are at most 80 characters.`);return E},Y=async()=>{const u=U.trim(),M=R(i,u);if(h(M),Object.keys(M).length>0)return;l(!0),c(null);const E=bt(i.tags);try{if(s==="create"){const O={};i.title.trim()&&(O.title=i.title.trim()),i.owner.trim()&&(O.owner=i.owner.trim()),i.team.trim()&&(O.team=i.team.trim()),i.startDate&&(O.start_date=i.startDate),i.targetDate&&(O.target_date=i.targetDate),i.estimate&&(O.estimate=Number(i.estimate),O.estimate_unit=i.estimateUnit),await o({mode:"create",fields:{name:u,...i.description.trim()&&i.description.trim()!==ft?{description:i.description.trim()}:{},status:i.status,...E.length>0?{tags:E}:{}},...Object.keys(O).length>0?{followUp:O}:{}})}else await o({mode:"edit",key:a?.key??"",fields:{name:u,description:i.description.trim(),title:i.title.trim(),owner:i.owner.trim(),team:i.team.trim(),status:i.status,tags:E,start_date:i.startDate,target_date:i.targetDate,...i.estimate?{estimate:Number(i.estimate)}:{},estimate_unit:i.estimateUnit}});r()}catch(O){const A=O instanceof Error&&O.message?O.message:"";c(zt(A)||"The project was not saved.")}finally{l(!1)}},G=s==="create"?"New project":"Edit project",C=i.description.length>xe;return t.jsx(Ce,{open:e,onClose:r,title:G,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:x,onEscapeKeyDown:u=>{x&&u.preventDefault()},onInteractOutside:u=>{x&&u.preventDefault()}},dataTourTag:s==="create"?"project-create-dialog":"project-edit-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Ee,{onClick:r,disabled:x,children:"Cancel"}),t.jsxs(Tt,{"data-project-submit":"",onClick:()=>void Y(),disabled:x,children:[x&&t.jsx(de,{size:"xs"}),s==="create"?"Create project":"Save changes"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:u=>{u.preventDefault(),Y()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${j}-title`,children:"Title"}),t.jsx(W,{id:`${j}-title`,"data-project-title":"",value:i.title,onChange:u=>D("title",u.target.value),placeholder:"Payments migration",autoFocus:!0,className:"h-10 text-heading","aria-invalid":!!n.title}),n.title&&t.jsx("p",{className:"text-meta text-danger",children:n.title}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{htmlFor:`${j}-key`,className:"shrink-0 text-meta text-ink-muted",children:"Key"}),t.jsx(W,{id:`${j}-key`,"data-project-key":"",value:U,onChange:u=>{y(!0),D("name",u.target.value)},placeholder:"payments-migration","aria-invalid":!!n.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:s==="create"&&!T?"Derived from the title until you edit it.":"Letters, digits, dot, underscore or dash; no spaces."})]}),n.name&&t.jsx("p",{className:"text-meta text-danger",children:n.name})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(q,{htmlFor:`${j}-description`,children:"Description"}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Description mode"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(u=>t.jsx("button",{type:"button","data-project-description-mode":u,"aria-pressed":N===(u==="preview"),onClick:()=>g(u==="preview"),className:$("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",N===(u==="preview")&&"bg-surface text-ink"),children:u==="write"?"Write":"Preview"},u))})]})]}),N?t.jsx("div",{"data-project-description-preview":"",className:"h-44 overflow-y-auto rounded-md border border-hairline bg-sunken px-3 py-2",children:i.description.trim()?t.jsx(Te,{className:"text-body-sm",children:i.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Gs,{ref:f,id:`${j}-description`,"data-project-description":"",value:i.description,onChange:u=>D("description",u.target.value),onPaste:_,rows:8,placeholder:"Markdown — headings, lists, code.","aria-invalid":C||!!n.description,className:"h-44 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.description?t.jsx("p",{className:"text-meta text-danger",children:n.description}):t.jsx("span",{}),t.jsxs("p",{className:$("text-meta tabular-nums",C?"text-danger":"text-ink-muted"),children:[i.description.length,"/",xe]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{children:"Status"}),t.jsxs(ve,{value:i.status,onValueChange:u=>D("status",u),children:[t.jsx(ye,{"aria-label":"Status",children:t.jsx(Ne,{})}),t.jsx(ke,{children:sr.map(u=>t.jsx(me,{value:u.value,children:u.label},u.value))})]}),i.status==="done"&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Moving a project to Done stamps today as its completion date."})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${j}-owner`,children:"Owner"}),t.jsx(W,{id:`${j}-owner`,"data-project-owner":"",value:i.owner,onChange:u=>D("owner",u.target.value),placeholder:"atlas","aria-invalid":!!n.owner}),n.owner&&t.jsx("p",{className:"text-meta text-danger",children:n.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${j}-team`,children:"Team"}),t.jsx(W,{id:`${j}-team`,value:i.team,onChange:u=>D("team",u.target.value),placeholder:"platform","aria-invalid":!!n.team}),n.team&&t.jsx("p",{className:"text-meta text-danger",children:n.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${j}-target`,children:"Target date"}),t.jsx(W,{id:`${j}-target`,"data-project-target":"",value:i.targetDate,onChange:u=>D("targetDate",u.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!n.targetDate}),n.targetDate&&t.jsx("p",{className:"text-meta text-danger",children:n.targetDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${j}-start`,children:"Start date"}),t.jsx(W,{id:`${j}-start`,value:i.startDate,onChange:u=>D("startDate",u.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!n.startDate}),n.startDate&&t.jsx("p",{className:"text-meta text-danger",children:n.startDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${j}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(W,{id:`${j}-estimate`,value:i.estimate,onChange:u=>D("estimate",u.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!n.estimate,className:"max-w-28"}),t.jsxs(ve,{value:i.estimateUnit,onValueChange:u=>D("estimateUnit",u),children:[t.jsx(ye,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(Ne,{})}),t.jsxs(ke,{children:[t.jsx(me,{value:"points",children:"Points"}),t.jsx(me,{value:"days",children:"Days"})]})]})]}),n.estimate&&t.jsx("p",{className:"text-meta text-danger",children:n.estimate}),s==="edit"&&i.estimate.trim()===""&&a?.estimate!==null&&a?.estimate!==void 0&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Clearing an estimate is not supported yet — saving keeps its current value."})]}),t.jsxs("div",{className:"col-span-2 flex flex-col gap-1.5",children:[t.jsx(q,{htmlFor:`${j}-tags`,children:"Tags"}),t.jsx(W,{id:`${j}-tags`,value:i.tags,onChange:u=>D("tags",u.target.value),placeholder:"q4, payments","aria-invalid":!!n.tags}),n.tags?t.jsx("p",{className:"text-meta text-danger",children:n.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]})]}),m&&t.jsx("p",{ref:k,className:"text-body-sm text-danger",children:m})]})})},nr=({links:e,target:s,onTargetChange:a,onSend:r,focusTick:o})=>{const[i,d]=p.useState(""),[n,h]=p.useState(!1),m=p.useRef(null);p.useEffect(()=>{o>0&&m.current?.focus()},[o]);const c=e.filter(y=>y.exists),x=(c.find(y=>y.session_id===s)??null)?.runtime?.busy===!0,l=!!s&&i.trim().length>0&&!n,T=async()=>{if(!(!l||!s)){h(!0);try{await r(s,i.trim(),x?"steer":"prompt")&&d("")}finally{h(!1),m.current?.focus()}}};return t.jsxs("div",{className:"flex flex-col gap-2 rounded-md bg-elevated p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-ink-muted",children:"Send to"}),t.jsxs(ve,{value:s??void 0,onValueChange:y=>a(y),children:[t.jsx(ye,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(Ne,{placeholder:"No session selected"})}),t.jsx(ke,{children:c.map(y=>t.jsx(me,{value:y.session_id,children:Xe(y)},y.session_id))})]}),x&&t.jsx("span",{className:"text-meta text-ink-muted",children:"The session is working — this message steers the running turn."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(W,{ref:m,"aria-label":"Message the selected session",placeholder:"Message the session",value:i,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),T())}}),t.jsxs(I,{variant:"secondary",disabled:!l,onClick:()=>void T(),"data-tour-tag":"project-quick-send",children:[n?t.jsx(de,{size:"xs"}):t.jsx(fa,{}),"Send"]})]})]})},rr=({links:e,busy:s,onUnlink:a,onLink:r,onQuickSend:o,onStartSession:i})=>{const d=De(),n=be(g=>g.sessions),[h,m]=p.useState(!1),[c,k]=p.useState(null),[x,l]=p.useState(0),T=c&&e.some(g=>g.session_id===c&&g.exists)?c:on(e),y=p.useMemo(()=>{const g=new Set(e.map(j=>j.session_id));return n.filter(j=>!g.has(j.session_id)).map(j=>({id:j.session_id,name:j.title||j.session_id,description:j.cwd??void 0}))},[n,e]),N=g=>{be.getState().openSession(g).then(j=>{j&&d(`/chat/${g}`)})};return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Linked sessions"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(I,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(na,{}),"New session"]}),t.jsxs(I,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx(ma,{}),"Link session"]})]})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No sessions linked yet. Link the conversations that are working on this project so its progress stays with them."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(g=>{const j=Aa(g),f=$a(g.subagents),D=Ra(g.todos),U=g.title||g.session_id,_=g.exists;return t.jsxs("li",{className:$("flex items-center gap-2 rounded-sm px-2 py-2",_&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!_,onClick:()=>{_&&N(g.session_id)},className:$("flex min-w-0 flex-1 items-center gap-2 text-left",_?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:$("min-w-0 truncate text-body-sm",g.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:U})}),g.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),f&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:f}),D&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:D}),t.jsx(ie,{variant:j.variant,children:j.label}),_&&t.jsx(I,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${U}`,title:`Message ${U}`,onClick:()=>{k(g.session_id),l(R=>R+1)},children:t.jsx(ra,{})}),t.jsx(I,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${U}`,onClick:()=>a(g.session_id),children:t.jsx(xa,{})})]},g.session_id)})}),e.length>0&&t.jsx(nr,{links:e,target:T,onTargetChange:k,onSend:o,focusTick:x}),t.jsx(Ce,{open:h,onClose:()=>m(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Ee,{onClick:()=>m(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(q,{children:"Session"}),t.jsx(Et,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:y,selected:null,onSelect:g=>{m(!1),r(g.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},ir=({milestones:e,summary:s,busy:a,onToggle:r,onRemove:o,onAdd:i})=>{const[d,n]=p.useState(""),[h,m]=p.useState(""),c=!$t.test(h.trim()),k=d.trim().length>0&&!c&&!a,x=()=>{k&&(i(d.trim(),h.trim()),n(""),m(""))};return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Milestones"}),s&&e.length>0&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:s})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No milestones yet. Add one below to mark the dates this project is planned around."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(l=>{const T=_a(l.status),y=l.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Xs,{checked:y,disabled:a,onCheckedChange:N=>r(l.name,N===!0),"aria-label":y?`Mark ${l.name} not complete`:`Mark ${l.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:l.name}),l.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:J(l.target_date,typeof navigator>"u"?void 0:navigator.language)}),t.jsx(ie,{variant:T.variant,children:T.label}),t.jsx(I,{variant:"ghost",size:"icon-sm",disabled:a,"aria-label":`Remove ${l.name}`,onClick:()=>o(l.name),children:t.jsx(Vs,{})})]},l.name)})}),t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[t.jsx(q,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(W,{id:"project-milestone-name",value:d,onChange:l=>n(l.target.value),placeholder:"beta cut",onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),x())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(q,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(W,{id:"project-milestone-date",value:h,onChange:l=>m(l.target.value),placeholder:"YYYY-MM-DD","aria-invalid":c}),c&&t.jsx("p",{className:"text-meta text-danger",children:"Dates are YYYY-MM-DD, or empty."})]}),t.jsxs(I,{variant:"secondary",disabled:!k,onClick:x,"data-tour-tag":"project-milestone-add",children:[t.jsx(we,{}),"Add"]})]})]})},or=({project:e,nowMs:s})=>{const a=typeof navigator>"u"?void 0:navigator.language,r=new Date(s),o=[],i=J(e.start_date,a,r);i&&o.push({label:"Start",value:i});const d=J(e.target_date,a,r);d&&o.push({label:"Target",value:d});const n=J(e.completed_at,a,r);n&&o.push({label:"Completed",value:n});const h=Lt(e.estimate,e.estimate_unit);if(h&&o.push({label:"Estimate",value:h}),e.tags.length>0&&o.push({label:"Tags",value:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(m=>t.jsx(ie,{variant:"outline",children:m},m))})}),e.updated_at>0){const m=pe(fe(e.updated_at,s)),c=new Date(e.updated_at*1e3).toLocaleString(a);o.push({label:"Updated",value:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:c,children:m})})}return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Properties"}),o.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No dates, estimate or tags yet."}):t.jsx("dl",{className:"flex flex-col gap-2",children:o.map(m=>t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"w-24 shrink-0 text-body-sm text-ink-muted",children:m.label}),t.jsx("dd",{className:"min-w-0 text-body-sm text-ink",children:m.value})]},m.label))})]})},Ht="plain",Qt=e=>`team:${e}`,Gt=e=>`agent:${e}`;function lr(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function cr(e){return e.kind==="team"?Qt(e.name):e.kind==="agent"?Gt(e.name):Ht}const vt={kind:"plain"},dr=({open:e,onClose:s,onStart:a,teamsEnabled:r,profilesEnabled:o})=>{const[i,d]=p.useState(vt),[n,h]=p.useState(null),[m,c]=p.useState(!1),k=ys(e&&r),x=Ns(e&&o);p.useEffect(()=>{e&&(d(vt),h(null),c(!1))},[e]);const l=p.useMemo(()=>{const j=[{id:Ht,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const f of k.data??[])j.push({id:Qt(f.name),name:st(f),keywords:f.name===st(f)?void 0:[f.name],description:`Team · manager: ${f.manager}`,group:"Teams"});for(const f of(x.data??[]).filter(D=>D.source!=="builtin"))j.push({id:Gt(f.name),name:f.name,description:f.description||f.kind,group:"Agents"});return j},[k.data,x.data]),T=l.find(j=>j.id===cr(i))??l[0],y=!r||!o,N=k.isLoading||x.isLoading,g=async()=>{c(!0),h(null);try{await a(i),s()}catch(j){h(j instanceof Error&&j.message?j.message:"The session could not be started.")}finally{c(!1)}};return t.jsx(Ce,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Ee,{onClick:s,disabled:m,children:"Cancel"}),t.jsxs(Tt,{onClick:()=>void g(),disabled:m,children:[m&&t.jsx(de,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Et,{label:"Work with",placeholder:"Search teams and agents",options:l,selected:T,onSelect:j=>d(lr(j.id)),busy:N,busyLabel:"Loading teams and agents"}),t.jsx("p",{className:"text-meta text-ink-muted",children:"The session starts now, links itself to this project, and opens with a prompt you can edit before sending."}),y&&t.jsx("p",{className:"text-meta text-ink-muted",children:"This server does not offer the team or agent catalogues yet, so only a plain session can be started."}),n&&t.jsx("p",{className:"text-body-sm text-danger",children:n})]})})},Xt=({status:e})=>{const s=z(e);return t.jsxs(ie,{variant:s.variant,children:[Sa(e)&&t.jsx(Js,{"aria-hidden":!0}),s.label]})},ur=({links:e})=>{const s=rn(e),a=e.filter(r=>r.todos!==null);return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"To-dos"}),s&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:ct(s)})]}),a.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No to-do snapshots from the linked sessions yet. A session publishes its list as it works, and it appears here once it has."}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:a.map(r=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:r.title?"min-w-0 flex-1 truncate text-body-sm text-ink":"min-w-0 flex-1 truncate font-mono text-mono-sm text-ink-muted",children:Xe(r)}),r.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:ct(r.todos)})]},r.session_id))})]})},mr=/[/\\]/;function Vt(e){if(e.name)return e.name;const s=e.path.split(mr);return s[s.length-1]||"Attachment"}const hr=({attachment:e})=>{const s=Vt(e),a=an(e.bytes);return t.jsxs("div",{className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-surface px-3 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2.5 text-left",onClick:()=>{window.api?.openFile(e.path)},title:`Open ${s}`,children:[t.jsx(_s,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),a&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:a}),t.jsx(Ds,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},fr=({attachment:e})=>{const s=Vt(e),a=ia(e.path,{mimeType:ks(e.name||e.path),sizeBytes:e.bytes});return a.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(ws,{file:e.path,src:a.url,label:s,conversationId:""})}):a.status==="loading"?t.jsx(Ss,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(Ts,{name:s})},pr=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(fr,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(hr,{attachment:s},`${s.path}:${s.added_at}`))}),xr=({update:e,nowMs:s})=>{const a=typeof navigator>"u"?void 0:navigator.language,r=tn(e,a,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[r.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:r.map((o,i)=>t.jsxs(p.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:o.text})]},o.key))}),e.text&&t.jsx(Te,{children:e.text}),e.attachments.length>0&&t.jsx(pr,{attachments:e.attachments})]})},gr=({updates:e,nowMs:s})=>{const a=typeof navigator>"u"?void 0:navigator.language,r=Xa(e.length),o=sn(e,a,new Date(s));return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Updates"}),r&&t.jsx("span",{className:"text-meta text-ink-muted",children:r})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No updates yet. Progress reported by you or by the sessions working on this project is appended here."}):t.jsx("div",{className:"flex flex-col gap-4",children:o.map(i=>t.jsxs("div",{className:"flex flex-col gap-2",children:[i.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:i.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:i.entries.map((d,n)=>t.jsx(xr,{update:d,nowMs:s},`${d.at}:${d.by}:${n}`))})]},i.key||"ungrouped"))})]})},jr="project_not_found",br=({projectKey:e,nowMs:s})=>{const a=De(),r=_t(),o=Dt(je(r.data,"team_catalogue")),i=Pt(e,!0),d=Mt(),n=At(),h=Na(),m=ka(),c=va(),k=ya(),[x,l]=p.useState(!1),[T,y]=p.useState(!1),[N,g]=p.useState(!1),j=d.isPending||n.isPending||h.isPending||m.isPending||c.isPending||k.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(de,{label:"Loading project"})});if(i.isError||!i.data){const C=i.error instanceof Cs&&(i.error.code===jr||i.error.status===404);return t.jsxs("div",{className:"mx-auto flex w-full max-w-200 flex-col items-start gap-4",children:[t.jsx(Le,{variant:"danger",className:"w-full",children:C?"This project could not be found. It may have been deleted.":i.error instanceof Error&&i.error.message?i.error.message:"The project could not be read."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(I,{variant:"secondary",onClick:()=>void i.refetch(),children:"Try again"}),t.jsxs(I,{variant:"secondary",onClick:()=>void a("/projects"),children:[t.jsx(nt,{}),"All projects"]})]})]})}const{project:f,links:D}=i.data,U=le(f),_=Qa(f.owner,f.team?o(f.team):f.team),R=nn(f.milestones.filter(C=>C.completed_at!==null).length,f.milestones.length),Y=async(C,u,M)=>{const E=be.getState(),O=Ps(null,C,E.drafts);if(!O)return!1;try{if(await Ms(O,{text:u,attachments:[],images:[],mode:M,cwd:E.cwd},C)===null)return V("That session already has a message going out. Try again in a moment."),!1;const L=D.find(w=>w.session_id===C);return se(`Sent to ${L?Xe(L):C}`),!0}catch(A){return V(A instanceof Error&&A.message?A.message:"The message was not sent."),!1}},G=async C=>{const u=be.getState(),M=C.kind==="plain"?void 0:{kind:C.kind,name:C.name},E=await u.createSession(u.cwd||"~",M);if(!E)throw new Error(u.error??"The session could not be started.");As.getState().setCurrentInput(E,ln(f));let O=null;try{await c.mutateAsync({key:f.id,sessionId:E})}catch(A){O=A instanceof Error&&A.message?A.message:"the link was refused"}if(O)V(`Session started, but linking it failed: ${O}`);else{const A=M?` with ${cn(M)}`:"";se(`Session started${A} and linked to ${U}.`)}await Ot(a,E)};return t.jsxs("div",{className:"mx-auto flex w-full max-w-200 flex-col gap-8",children:[t.jsxs("header",{className:"flex flex-col gap-4",children:[t.jsxs("button",{type:"button",onClick:()=>void a("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(nt,{className:"size-4"}),"All projects"]}),t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h1",{"data-project-title":f.name,className:"min-w-0 break-words text-display text-ink",children:U}),t.jsx(Xt,{status:f.status}),f.progress_stale&&t.jsx(ie,{variant:"warning",children:Se})]}),f.title&&t.jsx("p",{className:"font-mono text-mono-sm text-ink-muted",children:f.name}),_&&t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Managed by ",_]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(I,{variant:"secondary",onClick:()=>l(!0),"data-tour-tag":"project-edit",children:[t.jsx(Es,{}),"Edit"]}),t.jsxs(I,{variant:"secondary",onClick:()=>y(!0),"data-tour-tag":"project-delete",children:[t.jsx(Os,{}),"Delete"]})]})]})]}),f.description.trim()&&t.jsx(Te,{className:"text-body",children:f.description}),t.jsx(or,{project:f,nowMs:s}),f.updates.length===0&&f.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:"Progress"}),t.jsx(Te,{className:"text-body",children:f.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:Ea(f,s)})]}),t.jsx(ir,{milestones:f.milestones,summary:R,busy:j,onToggle:(C,u)=>{h.mutateAsync({key:f.id,name:C,completed:u}).catch(M=>{V(M instanceof Error&&M.message?M.message:"The milestone was not updated.")})},onRemove:C=>{m.mutateAsync({key:f.id,name:C}).catch(u=>{V(u instanceof Error&&u.message?u.message:"The milestone was not removed.")})},onAdd:(C,u)=>{h.mutateAsync({key:f.id,name:C,targetDate:u}).catch(M=>{V(M instanceof Error&&M.message?M.message:"The milestone was not added.")})}}),t.jsx(rr,{projectKey:f.id,links:D,busy:j,onStartSession:()=>g(!0),onQuickSend:Y,onLink:C=>{c.mutateAsync({key:f.id,sessionId:C}).catch(u=>{V(u instanceof Error&&u.message?u.message:"The session was not linked.")})},onUnlink:C=>{k.mutateAsync({key:f.id,sessionId:C}).catch(u=>{V(u instanceof Error&&u.message?u.message:"The session was not unlinked.")})}}),t.jsx(ur,{links:D}),t.jsx(gr,{updates:f.updates,nowMs:s}),t.jsx(qe,{open:x,mode:"edit",initial:{key:f.id,name:f.name,title:f.title,owner:f.owner,team:f.team,description:f.description,status:f.status,tags:f.tags,start_date:f.start_date,target_date:f.target_date,estimate:f.estimate,estimate_unit:f.estimate_unit},onClose:()=>l(!1),onSubmit:async C=>{C.mode==="edit"&&(await d.mutateAsync({key:C.key,fields:C.fields}),se("Project saved"))}}),t.jsx(Kt,{open:T,projectName:f.name,onClose:()=>y(!1),onConfirm:async C=>{await n.mutateAsync({key:f.id,confirmedName:C}),se("Project deleted"),a("/projects")}}),t.jsx(dr,{open:N,onClose:()=>g(!1),onStart:G,teamsEnabled:je(r.data,"team_catalogue"),profilesEnabled:je(r.data,"profile_catalogue")})]})},vr=({team:e,count:s,headingId:a,className:r,...o})=>t.jsxs("div",{...o,className:$("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",r),children:[t.jsx("h3",{id:a,className:"truncate text-ink",children:e??He}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":Pa(s),children:s})]}),ee=[{key:"name",label:"Project",className:"min-w-0 flex-1"},{key:"status",label:"Status",className:"w-20 shrink-0"},{key:"target",label:"Target",className:"hidden w-32 shrink-0 @[40rem]:block"},{key:"estimate",label:"Estimate",className:"hidden w-16 shrink-0 @[40rem]:block"},{key:"milestones",label:"Milestones",className:"hidden w-20 shrink-0 @[34rem]:block"},{key:"live",label:"Live",className:"hidden w-14 shrink-0 @[34rem]:block"},{key:"progress",label:"Progress",className:"w-40 shrink-0"}];function yr(e,s){const a=fe(e.progress_updated_at,s);return a?pe(a):"not reported"}const Nr=({projects:e,nowMs:s,onOpen:a,teamLabelFor:r=o=>o})=>{const o=Ge(e,Qe),i=p.useId(),d=n=>`${i}-team-${n}`;return t.jsxs("div",{className:"@container flex min-h-0 flex-1 flex-col","data-testid":"project-list",children:[t.jsx("div",{className:"flex shrink-0 items-center gap-3 px-9 py-2 text-meta text-ink-muted","aria-hidden":"true",children:ee.map(n=>t.jsx("span",{className:n.className,children:n.label},n.key))}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:o.map((n,h)=>t.jsxs("li",{children:[t.jsx(vr,{team:n.team==null?null:r(n.team),count:n.items.length,headingId:d(h),className:"sticky top-0 z-10","data-project-team":n.team??""}),t.jsx("ul",{"aria-labelledby":d(h),className:"divide-y divide-hairline",children:n.items.map(m=>{const c=new Map(Ft(m,typeof navigator>"u"?void 0:navigator.language).map(l=>[l.key,l.text])),k=It(m.milestones_completed,m.milestones_total),x=Ke(m.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>a(m),"data-project-name":m.name,className:$("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-elevated"),children:[t.jsx("span",{className:$(ee[0].className,"truncate text-body-sm text-ink"),children:le(m)}),t.jsx("span",{className:ee[1].className,children:t.jsx(Xt,{status:m.status})}),t.jsx("span",{className:$(ee[2].className,"truncate text-meta text-ink-muted"),children:c.get("target")??c.get("completed")??""}),t.jsx("span",{className:$(ee[3].className,"truncate text-meta text-ink-muted"),children:c.get("estimate")??""}),t.jsx("span",{className:$(ee[4].className,"truncate text-meta text-ink-muted"),children:k}),t.jsx("span",{className:$(ee[5].className,"truncate text-meta text-ink-muted"),children:x}),t.jsxs("span",{className:$(ee[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:yr(m,s)}),m.progress_stale&&t.jsx(ie,{variant:"warning",children:Se})]})]})},m.id)})})]},n.team??""))})]})},_e=224,yt=36,kr={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},wr=({items:e,nowMs:s,onOpen:a,pendingDetails:r,failedDetails:o,onRetryDetails:i,teamLabelFor:d=n=>n})=>{const[n,h]=p.useState(null),[m,c]=p.useState(0),k=p.useRef(null),x=Wt(s),l=p.useMemo(()=>pn(e,x),[e,x]),T=p.useMemo(()=>xn(e),[e]),y=p.useMemo(()=>Ge(T.dated,_=>Qe(_.project)),[T]);p.useLayoutEffect(()=>{const _=k.current;if(!_)return;const R=()=>c(_.clientWidth);if(R(),typeof ResizeObserver>"u")return;const Y=new ResizeObserver(R);return Y.observe(_),()=>Y.disconnect()},[]);const N=Math.max(m-_e-24,160),g=l?hn(ut(l.startMs,l.endMs),N):"month",j=n??g,f=_=>{const R=te.indexOf(j),Y=te[R-_];Y&&h(Y)},D=Ve[j],U=l?ut(l.startMs,l.endMs)*D:0;return t.jsxs("div",{ref:k,className:"flex min-h-0 flex-1 flex-col","data-testid":"project-timeline",children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-9 py-2",children:[t.jsx("span",{className:"truncate text-meta text-ink-muted","data-timeline-note":!0,children:o>0?`Milestones could not be read for ${o} project${o===1?"":"s"}.`:r>0?`Loading milestones for ${r} project${r===1?"":"s"}…`:`${T.dated.length} dated · ${T.undated.length} without dates`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[o>0&&t.jsx(I,{variant:"secondary",size:"sm",onClick:i,children:"Try again"}),t.jsx(I,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!l||j===te[0],onClick:()=>f(1),children:t.jsx(we,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:kr[j]}),t.jsx(I,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!l||j===te[te.length-1],onClick:()=>f(-1),children:t.jsx(Zs,{})})]})]}),l&&T.dated.length>0?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 pb-6",children:t.jsxs("div",{className:"min-w-max",children:[t.jsx(Sr,{startMs:l.startMs,endMs:l.endMs,tier:j,pxPerDay:D,trackPx:U}),y.map(_=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":_.team??"",children:t.jsxs("span",{className:"sticky left-0 z-20 flex shrink-0 items-center gap-2 bg-canvas px-3 py-1 text-meta",style:{width:_e},children:[t.jsx("span",{className:"truncate text-ink",children:_.team==null?He:d(_.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:_.items.length})]})}),_.items.map(R=>t.jsx(Tr,{item:R,spanStart:l.startMs,pxPerDay:D,trackPx:U,today:x,onOpen:()=>a(R)},R.project.id))]},_.team??""))]})}):t.jsx("p",{className:"px-9 py-6 text-body-sm text-ink-muted",children:"No dates on any project yet. Set a start date, a target date or a milestone date and it will appear on the timeline."}),T.undated.length>0&&t.jsxs("div",{className:"shrink-0 px-9 py-2 text-meta text-ink-muted",children:["No dates (",T.undated.length,"):"," ",T.undated.map((_,R)=>t.jsxs("span",{children:[R>0&&", ",t.jsx("button",{type:"button",className:"text-ink hover:underline",onClick:()=>a(_),children:le(_.project)})]},_.project.id))]})]})},Sr=({startMs:e,endMs:s,tier:a,pxPerDay:r,trackPx:o})=>{const i=Sn(e,s,a);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:_e}}),t.jsx("span",{className:"relative block h-6",style:{width:o},children:i.map(d=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:ae(e,d.dayMs)*r},children:[t.jsx("span",{className:$("absolute top-0 h-full w-px",d.major?"bg-hairline":"bg-hairline/60"),"aria-hidden":"true"}),t.jsx("span",{className:"absolute top-1/2 left-1 -translate-y-1/2 whitespace-nowrap text-meta text-ink-muted",children:d.label})]},d.dayMs))})]})},Tr=({item:e,spanStart:s,pxPerDay:a,trackPx:r,today:o,onOpen:i})=>{const{project:d}=e,n=gn(e),h=jn(e),m=c=>new Date(c).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:i,"data-project-name":d.name,className:"flex w-full items-stretch text-left transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[t.jsx("span",{className:"sticky left-0 z-10 flex shrink-0 items-center gap-2 border-r border-hairline bg-canvas px-3",style:{width:_e,height:yt},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:le(d)})}),t.jsxs("span",{className:"relative block",style:{width:r,height:yt},children:[n&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:ae(s,n.fromMs)*a,width:(ae(n.fromMs,n.toMs)+1)*a},title:`${J(m(n.fromMs))} → ${J(m(n.toMs))}`}),h.map(c=>t.jsx("span",{"data-milestone":c.status,className:$("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",c.status==="completed"&&"bg-success",c.status==="overdue"&&"bg-warning",c.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:ae(s,c.dayMs)*a},title:`${c.name} · ${c.status} · ${J(m(c.dayMs))}`},`${c.name}-${c.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:ae(s,o)*a},"aria-hidden":"true"})]})]})},Jt="projects-view",_r=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function Dr(){try{const e=localStorage.getItem(Jt);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"list"}function Cr(e){try{localStorage.setItem(Jt,e)}catch{}}const Er=({value:e,onChange:s})=>t.jsx(ea,{value:e,onValueChange:a=>s(a),children:t.jsx(ta,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:_r.map(a=>t.jsx(sa,{value:a.value,children:a.label},a.value))})}),Or=["r1","r2","r3","r4","r5","r6"],Nt={unpaired:"This app is not paired with the Local Operator server, so Projects are unavailable.","below-version":"The Local Operator server is older than this app expects, so Projects are unavailable. Update the server and try again.",unknown:"The server's capabilities could not be read, so Projects are unavailable."},Fr=({nowMs:e=Date.now()})=>{const{projectId:s}=$s(),a=De(),r=_t(),o=Rs(r.data,"projects",1),i=o==="enabled",d=Dt(je(r.data,"team_catalogue")),n=ga(i),h=ba(),m=Mt(),c=At(),[k,x]=p.useState(!1),[l,T]=p.useState(()=>Dr()),[y,N]=p.useState(()=>Ya()),[g,j]=p.useState(null),[f,D]=p.useState(null),U=Tn(),_=n.data??[],R=p.useMemo(()=>Ua(_,y,e),[_,y,e]),Y=Ba(y),[G,C]=p.useState(!1);p.useEffect(()=>{if(!G)return;const w=document.querySelector('[data-tour-tag="projects-board-window"]');w&&(w.focus(),C(!1))});const u=ja(l==="timeline"?_.map(w=>w.id):[],i),M=_.map((w,K)=>({project:w,milestones:u[K]?.data?.project.milestones??[]})),E=l==="timeline"?u.filter(w=>w.isLoading).length:0,O=l==="timeline"?u.filter(w=>w.isError).length:0,A=()=>{for(const w of u)w.isError&&w.refetch()},L=(w,K)=>{m.mutate({key:w.id,fields:{status:K}},{onSuccess:()=>{se(`Moved to ${z(K).label}`),n.refetch().then(()=>U(w.id))}})};return i?s?t.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto overflow-x-hidden p-6 [scrollbar-gutter:stable_both-edges]",children:t.jsx(br,{projectKey:s,nowMs:e})}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex shrink-0 flex-col gap-8 px-6 pt-6",children:[t.jsx(at,{title:"Projects",icon:rt,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(I,{variant:"secondary",size:"icon","aria-label":"Refresh projects",title:"Refresh projects",disabled:n.isFetching,onClick:()=>void n.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(oa,{})}),t.jsxs(I,{variant:"secondary",onClick:()=>x(!0),"data-tour-tag":"create-project-button",children:[t.jsx(we,{}),"New project"]})]})}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3",children:[t.jsx(Er,{value:l,onChange:w=>{T(w),Cr(w)}}),l==="board"&&!(n.isSuccess&&n.data.length===0)&&t.jsx(mn,{value:y,onChange:w=>{N(w),ot(w)}})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[n.isLoading&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("output",{className:"px-9 py-2 text-meta text-ink-dim",children:"Loading projects…"}),Or.map(w=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(ce,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(ce,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ce,{className:"h-4 w-40 shrink-0 bg-elevated"})]},w))]}),n.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Le,{variant:"danger",children:n.error instanceof Error&&n.error.message?n.error.message:"The projects could not be read."}),t.jsx(I,{variant:"secondary",size:"sm",onClick:()=>void n.refetch(),children:"Try again"})]}),n.isSuccess&&n.data.length===0&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4",children:[t.jsx("p",{className:"text-heading text-ink",children:"No projects yet."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Create one here, or ask an agent to create one and link this session."}),t.jsxs(I,{variant:"primary",onClick:()=>x(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(we,{}),"New project"]})]}),n.isSuccess&&n.data.length>0&&l==="list"&&t.jsx(Nr,{projects:n.data,nowMs:e,onOpen:w=>void a(`/projects/${w.id}`),teamLabelFor:d}),n.isSuccess&&n.data.length>0&&l==="board"&&R.length>0&&t.jsx(Dn,{projects:R,nowMs:e,onOpen:w=>void a(`/projects/${w.id}`),onEdit:j,onDelete:D,onMove:L,teamLabelFor:d,movingKeys:m.isPending&&m.variables?[m.variables.key]:[]}),n.isSuccess&&n.data.length>0&&l==="board"&&R.length===0&&Y!==null&&t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4",children:[t.jsx("p",{className:"text-heading text-ink",children:Y}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:"Older projects are hidden by the window."}),t.jsx(I,{variant:"secondary",onClick:()=>{N("all"),ot("all"),C(!0)},children:"Show all time"})]}),n.isSuccess&&n.data.length>0&&l==="timeline"&&t.jsx(wr,{items:M,nowMs:e,onOpen:w=>void a(`/projects/${w.project.id}`),pendingDetails:E,failedDetails:O,onRetryDetails:A,teamLabelFor:d})]}),t.jsx(qe,{open:g!==null,mode:"edit",initial:g?{key:g.id,name:g.name,title:g.title,owner:g.owner,team:g.team,description:g.description,status:g.status,tags:g.tags,start_date:g.start_date,target_date:g.target_date,estimate:g.estimate,estimate_unit:g.estimate_unit}:null,onClose:()=>j(null),onSubmit:async w=>{w.mode==="edit"&&(await m.mutateAsync({key:w.key,fields:w.fields}),se("Project saved"),j(null))}}),t.jsx(Kt,{open:f!==null,projectName:f?.name??"",onClose:()=>D(null),onConfirm:async w=>{f&&(await c.mutateAsync({key:f.id,confirmedName:w}),se("Project deleted"),D(null))}}),t.jsx(qe,{open:k,mode:"create",onClose:()=>x(!1),onSubmit:async w=>{if(w.mode!=="create")return;const K=await h.mutateAsync(w.fields),X=w.followUp?.title??w.fields.name;if(w.followUp)try{await m.mutateAsync({key:K.id,fields:w.followUp})}catch(ue){const b=ue instanceof Error&&ue.message?ue.message:"";V(`Project ${X} was created, but the extra fields were not saved: ${zt(b)||"the server refused them."} Open the project and use Edit to set them.`);return}se(`Project ${X} created`)}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(at,{title:"Projects",icon:rt}),r.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(de,{label:"Checking the server's Projects support"})}):t.jsx(Le,{variant:"warning",children:Nt[o]??Nt.unknown})]})};export{Fr as ProjectsPage};
@@ -1 +0,0 @@
1
- import{s as r,b as e,a,S as s}from"./chunk-AEK57VVT-DFzBJNd9.js";import{_ as i}from"./mermaid.core-DpvY6Bhk.js";import"./chunk-RZ5BOZE2-C7el6yre.js";import"./conversation-input-sync-DQUYkOfh.js";import"./ui-preferences-store-B6Fr0UX9.js";import"./index-D-TXozHA.js";import"./error-boundary-DH4MhqhL.js";var n={parser:a,get db(){return new s(2)},renderer:e,styles:r,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{n as diagram};