local-operator-ui 0.34.48 → 0.34.49

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 (120) hide show
  1. package/out/main/index.js +2259 -47
  2. package/out/preload/index.js +1 -0
  3. package/out/renderer/assets/{_basePickBy-4PhBKMwz.js → _basePickBy-Coq1U1Is.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-DpFJNrpb.js → _baseUniq-CN5nbj15.js} +1 -1
  5. package/out/renderer/assets/agent-details-page-BOHG1UL8.js +6 -0
  6. package/out/renderer/assets/agent-hub-page-lDe6m3U_.js +11 -0
  7. package/out/renderer/assets/agents-page-CS2ctxLL.js +7 -0
  8. package/out/renderer/assets/{arc-DkuXQZT0.js → arc-CyEksofH.js} +1 -1
  9. package/out/renderer/assets/architectureDiagram-IEHRJDOE-o2ZHU4e3.js +36 -0
  10. package/out/renderer/assets/{blockDiagram-JOT3LUYC-2iLLg_nw.js → blockDiagram-JOT3LUYC-B0Yyp4_C.js} +1 -1
  11. package/out/renderer/assets/{book-open-CTi9TDfn.js → book-open-CEakesEi.js} +1 -1
  12. package/out/renderer/assets/browser-page-CjbkyuiR.js +1 -0
  13. package/out/renderer/assets/browser-webauthn-prompt-Dq82YVua.js +1 -0
  14. package/out/renderer/assets/{c4Diagram-VJAJSXHY-SvCGL91g.js → c4Diagram-VJAJSXHY-DLUNsMlf.js} +1 -1
  15. package/out/renderer/assets/channel-BrqzOdfK.js +1 -0
  16. package/out/renderer/assets/{chunk-4BMEZGHF-CzVlqRCP.js → chunk-4BMEZGHF-TEJuQZ1Y.js} +1 -1
  17. package/out/renderer/assets/{chunk-A2AXSNBT-DqhEqW0h.js → chunk-A2AXSNBT-B_dFl8CN.js} +1 -1
  18. package/out/renderer/assets/{chunk-AEK57VVT-BEa7M8E9.js → chunk-AEK57VVT-BZoQ5TO6.js} +1 -1
  19. package/out/renderer/assets/{chunk-D6G4REZN-4tI3iHrd.js → chunk-D6G4REZN-D1bYNZJL.js} +1 -1
  20. package/out/renderer/assets/{chunk-RZ5BOZE2-BSTylGcM.js → chunk-RZ5BOZE2-DbkFvpUt.js} +1 -1
  21. package/out/renderer/assets/{chunk-XZIHB7SX-BWyzWCnC.js → chunk-XZIHB7SX-C0c85hT-.js} +1 -1
  22. package/out/renderer/assets/classDiagram-GIVACNV2-C4Q7B2pX.js +1 -0
  23. package/out/renderer/assets/classDiagram-v2-COTLJTTW-C4Q7B2pX.js +1 -0
  24. package/out/renderer/assets/clone-T21nSsyt.js +1 -0
  25. package/out/renderer/assets/{console-mirror-CxkpeCdB.js → console-mirror-DDhXu5hQ.js} +2 -2
  26. package/out/renderer/assets/consoleCapture-DomsRGWw.js +1 -0
  27. package/out/renderer/assets/{conversation-input-sync-DFpqmO4l.js → conversation-input-sync-B3FVv0Mq.js} +257 -257
  28. package/out/renderer/assets/dagre-OKDRZEBW-CAb1XIuS.js +4 -0
  29. package/out/renderer/assets/diagram-SSKATNLV-CAh7vH7L.js +43 -0
  30. package/out/renderer/assets/diagram-VNBRO52H-CU4FF4Qr.js +24 -0
  31. package/out/renderer/assets/en-US-CHJkXXr4.js +1 -0
  32. package/out/renderer/assets/{erDiagram-Q7BY3M3F-D1W_lttQ.js → erDiagram-Q7BY3M3F-CbnNz_kj.js} +1 -1
  33. package/out/renderer/assets/error-boundary-etstfCzN.js +126 -0
  34. package/out/renderer/assets/{flowDiagram-4HSFHLVR-3Jb09NsW.js → flowDiagram-4HSFHLVR-BB6aJVKV.js} +1 -1
  35. package/out/renderer/assets/{format-CZUObkkr.js → format-esAOn2VS.js} +1 -1
  36. package/out/renderer/assets/{ganttDiagram-APWFNJXF-BuFcOiO1.js → ganttDiagram-APWFNJXF-CtOJM4d7.js} +1 -1
  37. package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-DvrevAjH.js +65 -0
  38. package/out/renderer/assets/{graph-D8Y4lmRI.js → graph-DOR9Sgwh.js} +1 -1
  39. package/out/renderer/assets/index-5vl5RXGq.js +1 -0
  40. package/out/renderer/assets/index-9_-S4Njy.js +809 -0
  41. package/out/renderer/assets/index-CZ5usiad.js +7 -0
  42. package/out/renderer/assets/index-CftawgM9.js +57 -0
  43. package/out/renderer/assets/index-VwZaZzVv.css +1 -0
  44. package/out/renderer/assets/infoDiagram-PH2N3AL5-CTd32x3B.js +2 -0
  45. package/out/renderer/assets/installer-CjbOLDvI.js +1 -0
  46. package/out/renderer/assets/{journeyDiagram-U35MCT3I-BWLCHSce.js → journeyDiagram-U35MCT3I-2BsbTilL.js} +1 -1
  47. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-D7-FbJp3.js → kanban-definition-NDS4AKOZ-DoYAcNl0.js} +1 -1
  48. package/out/renderer/assets/{layout-DogvO2Ky.js → layout-DSk91znb.js} +1 -1
  49. package/out/renderer/assets/legacy-agents-page-BGSPncrN.js +33 -0
  50. package/out/renderer/assets/{mermaid.core-CdeoM9AZ.js → mermaid.core-BqK7XNWH.js} +5 -5
  51. package/out/renderer/assets/mesh-page-BxEA5Aan.js +1 -0
  52. package/out/renderer/assets/mindmap-definition-ALO5MXBD-HV-ovM7g.js +95 -0
  53. package/out/renderer/assets/mini-Bco2ITLo.js +1 -0
  54. package/out/renderer/assets/{notebook-pen-D7t7mRlh.js → notebook-pen-DsGb6zKu.js} +1 -1
  55. package/out/renderer/assets/org-access-B_xqEqnd.js +1 -0
  56. package/out/renderer/assets/{org-surface-gate-n0a6WDBY.js → org-surface-gate-D4SilXIt.js} +1 -1
  57. package/out/renderer/assets/{page-header-CJAvj3rs.js → page-header-DZ04Whs5.js} +1 -1
  58. package/out/renderer/assets/{parseISO-CZfAC2_J.js → parseISO-BHJWTxrA.js} +1 -1
  59. package/out/renderer/assets/{pieDiagram-IB7DONF6-B22hqaTH.js → pieDiagram-IB7DONF6-BArx4Jik.js} +1 -1
  60. package/out/renderer/assets/{projects-page-Dg-fywlg.js → projects-page-DABVK4s_.js} +14 -14
  61. package/out/renderer/assets/publication-validation-BmkCCv-H.js +1 -0
  62. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DJXJe1Jf.js → quadrantDiagram-7GDLP6J5-Dmmo_urD.js} +1 -1
  63. package/out/renderer/assets/{radar-MK3ICKWK-COD-ZwKJ.js → radar-MK3ICKWK-D8Sc1Ajv.js} +1 -1
  64. package/out/renderer/assets/radient-auth-buttons-BmQt2D1Y.js +1 -0
  65. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-Cg7p0tZp.js → requirementDiagram-KVF5MWMF-BU04-wPA.js} +1 -1
  66. package/out/renderer/assets/sankeyDiagram-QLVOVGJD-CIQO7kso.js +10 -0
  67. package/out/renderer/assets/schedules-page-DllGJFS2.js +115 -0
  68. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-B2P7CUDU.js → sequenceDiagram-X6HHIX6F-BN2soxj_.js} +1 -1
  69. package/out/renderer/assets/settings-page-DKzDa5P5.js +292 -0
  70. package/out/renderer/assets/stateDiagram-DGXRK772-bGNaZvy4.js +1 -0
  71. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CNVQhmQM.js +1 -0
  72. package/out/renderer/assets/{timeline-definition-BDJGKUSR-CbnWjiR-.js → timeline-definition-BDJGKUSR-DmM_eb2d.js} +1 -1
  73. package/out/renderer/assets/ui-preferences-store-Byw1dJtt.js +1 -0
  74. package/out/renderer/assets/use-download-agent-mutation-CXv_tRQE.js +61 -0
  75. package/out/renderer/assets/{use-memberships-query-DR_Lujnw.js → use-memberships-query-C4IVeIBl.js} +1 -1
  76. package/out/renderer/assets/{use-session-snapshot-DKL97J-r.js → use-session-snapshot-CrOrWGgL.js} +1 -1
  77. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-Cq_N4nhd.js → xychartDiagram-VJFVF3MP-CbbQZrKE.js} +1 -1
  78. package/out/renderer/console-capture.html +5 -5
  79. package/out/renderer/index.html +7 -7
  80. package/out/renderer/installer.html +4 -4
  81. package/out/renderer/mini.html +7 -7
  82. package/package.json +3 -5
  83. package/out/renderer/assets/agent-details-page-Ci1JjvpV.js +0 -6
  84. package/out/renderer/assets/agent-hub-page-NtBm1phk.js +0 -11
  85. package/out/renderer/assets/agents-page-YFjN8oZC.js +0 -7
  86. package/out/renderer/assets/architectureDiagram-IEHRJDOE-DWa4IuFf.js +0 -36
  87. package/out/renderer/assets/browser-page-DEUUMy_g.js +0 -1
  88. package/out/renderer/assets/browser-webauthn-prompt-AacQARJZ.js +0 -1
  89. package/out/renderer/assets/channel-CRKSwn0G.js +0 -1
  90. package/out/renderer/assets/classDiagram-GIVACNV2-BxJWvaym.js +0 -1
  91. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BxJWvaym.js +0 -1
  92. package/out/renderer/assets/clone-BCVTFSZA.js +0 -1
  93. package/out/renderer/assets/consoleCapture-C9FjfQJX.js +0 -1
  94. package/out/renderer/assets/dagre-OKDRZEBW-Bro14G70.js +0 -4
  95. package/out/renderer/assets/diagram-SSKATNLV-DxML5WmE.js +0 -43
  96. package/out/renderer/assets/diagram-VNBRO52H-C1VKCLuH.js +0 -24
  97. package/out/renderer/assets/en-US-BcB1DWxG.js +0 -1
  98. package/out/renderer/assets/error-boundary-C6UV5tx-.js +0 -126
  99. package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-BbZdk2nO.js +0 -65
  100. package/out/renderer/assets/index-B8qxAfMF.js +0 -55
  101. package/out/renderer/assets/index-D3f_KfVo.css +0 -1
  102. package/out/renderer/assets/index-D7GWaNpY.js +0 -809
  103. package/out/renderer/assets/index-Dhq36hI2.js +0 -7
  104. package/out/renderer/assets/index-Hr50KutK.js +0 -1
  105. package/out/renderer/assets/infoDiagram-PH2N3AL5-BVHpnvtw.js +0 -2
  106. package/out/renderer/assets/installer-B8s-TXTU.js +0 -1
  107. package/out/renderer/assets/legacy-agents-page-Dlp--Xt6.js +0 -33
  108. package/out/renderer/assets/mesh-page-BzfNUAkq.js +0 -1
  109. package/out/renderer/assets/messages-CZNg7vOE.js +0 -3
  110. package/out/renderer/assets/mindmap-definition-ALO5MXBD-CfocVEGs.js +0 -95
  111. package/out/renderer/assets/mini-D-rHRr3X.js +0 -1
  112. package/out/renderer/assets/org-access-BIipdCDk.js +0 -1
  113. package/out/renderer/assets/publication-validation-mYDoNagz.js +0 -1
  114. package/out/renderer/assets/radient-auth-buttons-BJmqjZos.js +0 -1
  115. package/out/renderer/assets/sankeyDiagram-QLVOVGJD-Qir1GlwB.js +0 -10
  116. package/out/renderer/assets/schedules-page-CtMNJr6J.js +0 -115
  117. package/out/renderer/assets/settings-page-CFbI2wWy.js +0 -292
  118. package/out/renderer/assets/stateDiagram-DGXRK772-CGQsk3sX.js +0 -1
  119. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CpHmsYwj.js +0 -1
  120. package/out/renderer/assets/use-download-agent-mutation-C7H5xbvf.js +0 -61
@@ -1,45 +1,45 @@
1
- import{r as d,j as t,c as $}from"./index-B8qxAfMF.js";import{bQ as Ea,bR as Yt,bS as Ra,bT as yn,u as vn,bU as Da,bV as Aa,bW as Oa,bX as $a,bY as Pa,bZ as Ma,b_ as Ds,b$ as As,c0 as Ia,c1 as La,C as ls,aH as $e,d as ce,c2 as Fa,D as cs,c3 as qa,c4 as Ua,_ as Et,c5 as Os,c6 as $s,c7 as Ps,bD as Ba,aI as fe,c8 as za,Z as Pe,a as Ve,c as he,aT as kn,aK as Rt,aF as lt,aO as Be,c9 as Ya,ca as Ha,cb as Wa,cc as Ka,cd as Ga,aQ as wn,aP as yt,bi as Va,aA as Qa,aq as vt,bv as Ja,bu as Xa,bs as Ms,ce as Za,cf as Nn,cg as er,ch as tr,aG as ie,ci as sr,cj as nr,ck as ar,cl as rr,cm as ir,cn as Sn,aJ as or,ap as lr,ak as cr,al as dr,an as ur,ao as mr,ar as fr,ax as hr,co as pr,cp as Tn,bz as xr,cq as gr,az as br,aL as jr,aU as yr}from"./conversation-input-sync-DFpqmO4l.js";import{P as Is}from"./page-header-CJAvj3rs.js";import{c as ct,z as ze,l as Dt,F as Ye,G as He,H as We,J as _e,B as U,q as ds,r as us,S as we,s as ms,v as ke,a4 as vr,a5 as kr,a6 as wr,a7 as Nr,a8 as Sr,u as Tr,y as xe,a0 as fs,a9 as hs,a2 as ps,I as ne,X as At,g as xs,T as _n,L as oe,M as Cn,C as En,A as Ht,N as _r,W as Cr,Y as Er,Z as Rr,k as Fe}from"./error-boundary-C6UV5tx-.js";import{aZ as Rn,b3 as Dr,b4 as Dn,b5 as Ar,b6 as Or,aJ as $r,az as at,A as Ls,b7 as Fs,b8 as Pr}from"./index-D7GWaNpY.js";import{h as Mr,j as Ir,k as Ke,l as Lr,m as Wt}from"./messages-CZNg7vOE.js";import{u as Fr}from"./use-session-snapshot-DKL97J-r.js";import"./console-mirror-CxkpeCdB.js";function qs(e,s){return e.filter(n=>!s.includes(n))}function qr(e,s,n){const a=e.slice(0);return a[s]=n,a}var Ur=class extends Ea{#n;#e;#a;#r;#t;#s;#i;#o;#l=[];constructor(e,s,n){super(),this.#n=e,this.#r=n,this.#a=[],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.#a=e,this.#r=s,Yt.batch(()=>{const n=this.#t,a=this.#u(this.#a);this.#l=a,a.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const r=a.map(o=>o.observer),i=r.map(o=>o.getCurrentResult()),l=r.some((o,c)=>o!==n[c]);n.length===r.length&&!l||(this.#t=r,this.#e=i,this.hasListeners()&&(qs(n,r).forEach(o=>{o.destroy()}),qs(r,n).forEach(o=>{o.subscribe(c=>{this.#m(o,c)})}),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const n=this.#u(e),a=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions));return[a,r=>this.#d(r??a,s),()=>this.#c(a,n)]}#c(e,s){return s.map((n,a)=>{const r=e[a];return n.defaultedQueryOptions.notifyOnChangeProps?r:n.observer.trackResult(r,i=>{s.forEach(l=>{l.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=Ra(this.#s,s(e))),this.#s):e}#u(e){const s=new Map(this.#t.map(a=>[a.options.queryHash,a])),n=[];return e.forEach(a=>{const r=this.#n.defaultQueryOptions(a),i=s.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new yn(this.#n,r)})}),n}#m(e,s){const n=this.#t.indexOf(e);n!==-1&&(this.#e=qr(this.#e,n,s),this.#f())}#f(){if(this.hasListeners()){const e=this.#s,s=this.#c(this.#e,this.#l),n=this.#d(s,this.#r?.combine);e!==n&&Yt.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function Br({queries:e,...s},n){const a=vn(n),r=Da(),i=Aa(),l=d.useMemo(()=>e.map(v=>{const g=a.defaultQueryOptions(v);return g._optimisticResults=r?"isRestoring":"optimistic",g}),[e,a,r]);l.forEach(v=>{Oa(v),$a(v,i)}),Pa(i);const[o]=d.useState(()=>new Ur(a,l,s)),[c,m,u]=o.getOptimisticResult(l,s.combine),h=!r&&s.subscribed!==!1;d.useSyncExternalStore(d.useCallback(v=>h?o.subscribe(Yt.batchCalls(v)):Ma,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),d.useEffect(()=>{o.setQueries(l,s)},[l,s,o]);const f=c.some((v,g)=>Ds(l[g],v))?c.flatMap((v,g)=>{const x=l[g];if(x){const y=new yn(a,x);if(Ds(x,v))return As(x,y,i);Ia(v,r)&&As(x,y,i)}return[]}):[];if(f.length>0)throw Promise.all(f);const j=c.find((v,g)=>{const x=l[g];return x&&La({result:v,errorResetBoundary:i,throwOnError:x.throwOnError,query:a.getQueryCache().get(x.queryHash),suspense:x.suspense})});if(j?.error)throw j.error;return m(u())}/**
1
+ import{r as d,j as t,c as $,t as bt}from"./index-CftawgM9.js";import{bP as Ra,bQ as Ht,bR as Da,bS as vn,u as kn,bT as Aa,bU as Oa,bV as $a,bW as Pa,bX as Ma,bY as Ia,bZ as As,b_ as Os,b$ as La,c0 as Fa,C as cs,aG as Pe,d as ce,c1 as qa,D as ds,c2 as Ua,c3 as Ba,Z as Rt,c4 as $s,c5 as Ps,c6 as Ms,bC as za,aH as fe,c7 as Ya,a as Ve,c as he,aS as wn,aJ as Dt,aE as lt,aN as Be,c8 as Ha,c9 as Wa,ca as Ka,cb as Ga,cc as Va,aP as Nn,aO as vt,bh as Qa,az as Ja,ap as kt,bu as Xa,bt as Za,br as Is,cd as er,ce as Sn,cf as tr,cg as sr,aF as ie,ch as nr,ci as ar,cj as rr,ck as ir,cl as or,cm as Tn,aI as lr,ao as cr,aj as dr,ak as ur,am as mr,an as fr,aq as hr,aw as pr,cn as xr,co as _n,by as gr,cp as br,ay as jr,aK as yr,aT as vr}from"./conversation-input-sync-B3FVv0Mq.js";import{P as Ls}from"./page-header-DZ04Whs5.js";import{c as ct,F as ze,l as At,G as Ye,H as He,J as We,K as _e,B as U,u as Ee,q as us,r as ms,S as we,s as fs,w as ke,a5 as kr,a6 as wr,a7 as Nr,a8 as Sr,a9 as Tr,v as _r,z as xe,a1 as hs,aa as ps,a3 as xs,I as ne,X as Ot,g as gs,T as Cn,L as oe,N as En,C as Rn,A as Wt,O as Cr,Y as Er,Z as Rr,_ as Dr,k as Fe}from"./error-boundary-etstfCzN.js";import{aZ as Dn,b3 as Ar,b4 as An,b5 as Or,b6 as $r,aJ as Pr,az as at,A as Fs,b7 as qs,b8 as Mr}from"./index-9_-S4Njy.js";import{h as Ir,j as Lr,k as Ke,l as Fr,m as Kt}from"./ui-preferences-store-Byw1dJtt.js";import{u as qr}from"./use-session-snapshot-CrOrWGgL.js";import"./console-mirror-DDhXu5hQ.js";function Us(e,s){return e.filter(n=>!s.includes(n))}function Ur(e,s,n){const a=e.slice(0);return a[s]=n,a}var Br=class extends Ra{#n;#e;#a;#r;#t;#s;#i;#o;#l=[];constructor(e,s,n){super(),this.#n=e,this.#r=n,this.#a=[],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.#a=e,this.#r=s,Ht.batch(()=>{const n=this.#t,a=this.#u(this.#a);this.#l=a,a.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const r=a.map(o=>o.observer),i=r.map(o=>o.getCurrentResult()),l=r.some((o,c)=>o!==n[c]);n.length===r.length&&!l||(this.#t=r,this.#e=i,this.hasListeners()&&(Us(n,r).forEach(o=>{o.destroy()}),Us(r,n).forEach(o=>{o.subscribe(c=>{this.#m(o,c)})}),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const n=this.#u(e),a=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions));return[a,r=>this.#d(r??a,s),()=>this.#c(a,n)]}#c(e,s){return s.map((n,a)=>{const r=e[a];return n.defaultedQueryOptions.notifyOnChangeProps?r:n.observer.trackResult(r,i=>{s.forEach(l=>{l.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=Da(this.#s,s(e))),this.#s):e}#u(e){const s=new Map(this.#t.map(a=>[a.options.queryHash,a])),n=[];return e.forEach(a=>{const r=this.#n.defaultQueryOptions(a),i=s.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new vn(this.#n,r)})}),n}#m(e,s){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Ur(this.#e,n,s),this.#f())}#f(){if(this.hasListeners()){const e=this.#s,s=this.#c(this.#e,this.#l),n=this.#d(s,this.#r?.combine);e!==n&&Ht.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function zr({queries:e,...s},n){const a=kn(n),r=Aa(),i=Oa(),l=d.useMemo(()=>e.map(v=>{const g=a.defaultQueryOptions(v);return g._optimisticResults=r?"isRestoring":"optimistic",g}),[e,a,r]);l.forEach(v=>{$a(v),Pa(v,i)}),Ma(i);const[o]=d.useState(()=>new Br(a,l,s)),[c,m,u]=o.getOptimisticResult(l,s.combine),h=!r&&s.subscribed!==!1;d.useSyncExternalStore(d.useCallback(v=>h?o.subscribe(Ht.batchCalls(v)):Ia,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),d.useEffect(()=>{o.setQueries(l,s)},[l,s,o]);const f=c.some((v,g)=>As(l[g],v))?c.flatMap((v,g)=>{const x=l[g];if(x){const y=new vn(a,x);if(As(x,v))return Os(x,y,i);La(v,r)&&Os(x,y,i)}return[]}):[];if(f.length>0)throw Promise.all(f);const j=c.find((v,g)=>{const x=l[g];return x&&Fa({result:v,errorResetBoundary:i,throwOnError:x.throwOnError,query:a.getQueryCache().get(x.queryHash),suspense:x.suspense})});if(j?.error)throw j.error;return m(u())}/**
2
2
  * @license lucide-react v0.507.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const zr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],An=ct("arrow-up",zr);/**
6
+ */const Yr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],On=ct("arrow-up",Yr);/**
7
7
  * @license lucide-react v0.507.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Yr=[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Hr=ct("calendar-off",Yr);/**
11
+ */const Hr=[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Wr=ct("calendar-off",Hr);/**
12
12
  * @license lucide-react v0.507.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const Wr=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Kr=ct("list-filter",Wr);/**
16
+ */const Kr=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Gr=ct("list-filter",Kr);/**
17
17
  * @license lucide-react v0.507.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Gr=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]],Vr=ct("message-square-more",Gr);/**
21
+ */const Vr=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]],Qr=ct("message-square-more",Vr);/**
22
22
  * @license lucide-react v0.507.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const Qr=[["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"}]],Jr=ct("unlink",Qr),Ot={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Xr(e){return ls({queryKey:Ot.list,enabled:e,queryFn:()=>ce({op:"projects.list"}).then(s=>s.projects),retry:cs,staleTime:1e4})}function Zr(e,s){return Br({queries:e.map(n=>({queryKey:Ot.detail(n),enabled:s&&!!n,queryFn:()=>ce({op:"projects.get",key:n}),retry:cs,staleTime:1e4}))})}function On(e,s){return ls({queryKey:Ot.detail(e??""),enabled:s&&!!e,queryFn:()=>ce({op:"projects.get",key:e??""}),retry:cs,staleTime:1e4})}function Me(){const e=vn();return()=>{e.invalidateQueries({queryKey:Ot.list})}}function ei(){const e=Me();return $e({mutationFn:s=>ce({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 $n(){const e=Me();return $e({mutationFn:s=>ce({op:"projects.update",key:s.key,fields:s.fields,...s.forceDone===!0?{force_done:!0}:{}}),retry:Fa,onSuccess:()=>e()})}function Pn(){const e=Me();return $e({mutationFn:s=>ce({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function ti(){const e=Me();return $e({mutationFn:s=>ce({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function si(){const e=Me();return $e({mutationFn:s=>ce({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ni(){const e=Me();return $e({mutationFn:s=>ce({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 ai(){const e=Me();return $e({mutationFn:s=>ce({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const Mn={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"}},qe=Object.keys(Mn);function Z(e){return Mn[e]??{label:e||"Unknown",variant:"neutral"}}const In=["planning","active","qa","validation","done","paused","archived"].map(e=>({value:e,label:Z(e).label}));function ri(e){return e==="done"}const ii={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function oi(e){return ii[e]??{label:String(e),variant:"neutral"}}const kt="Stale",li=/^(\d{4})-(\d{2})-(\d{2})$/;function Ce(e,s,n=new Date){if(!e)return"";const a=li.exec(e);if(!a)return e;const r=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(r.getTime()))return e;const i=qa(r,{month:"short",day:"numeric"},s);return r.getFullYear()===n.getFullYear()?i:`${i}, ${r.getFullYear()}`}function dt(e,s){if(e==null)return"";const n=Math.max(0,Math.floor(s/1e3-e));return n<60?"just now":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function ut(e){return e==="just now"?"just now":`${e} ago`}function ci(e){return e?`reported ${ut(e)}`:"no progress"}const Ln=/^$|^\d{4}-\d{2}-\d{2}$/;function Fn(e){return e?e==="operator"?"the operator":`session ${e}`:""}function di(e,s){if(!e.progress)return"not reported yet";const n=dt(e.progress_updated_at,s),a=Fn(e.progress_reported_by),r=[n?`reported ${ut(n)}`:"reported"];return a&&r.push(`by ${a}`),r.join(" ")}function qn(e,s){if(e==null)return"";const n=String(e);return s==="points"?`${n} pt`:s==="days"?`${n}d`:n}function Un(e,s){return s<=0?"":`${e}/${s}`}function gs(e){return e<=0?"":`${e} live`}function ui(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function mi(e){return e===1?"1 project":`${e} projects`}function fi(e){const s=ui(e.sessions);if(!s)return"";const n=gs(e.live_sessions);return n?`${s} · ${n}`:s}function hi(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 pi(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 xi(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function Bn(e,s){const n=[],a=Ce(e.completed_at??e.target_date,s);a&&n.push({key:e.completed_at?"completed":"target",text:e.completed_at?`completed ${a}`:`due ${a}`});const r=qn(e.estimate,e.estimate_unit);r&&n.push({key:"estimate",text:r});const i=Un(e.milestones_completed,e.milestones_total);i&&n.push({key:"milestones",text:`milestones ${i}`});const l=gs(e.live_sessions);return l&&n.push({key:"live",text:l}),n}const Ue=864e5,gi=/^(\d{4})-(\d{2})-(\d{2})$/;function pe(e){if(!e)return null;const s=gi.exec(e);if(!s)return null;const n=Number(s[1]),a=Number(s[2]),r=Number(s[3]),i=Date.UTC(n,a-1,r),l=new Date(i);return l.getUTCFullYear()!==n||l.getUTCMonth()!==a-1||l.getUTCDate()!==r?null:i}const Kt=["planning","active","qa","validation","done"],Gt=["paused","archived"],$t=[{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}],zn="7d",bi=$t.find(e=>e.value===zn);function Yn(e){return $t.find(s=>s.value===e)??bi}function ji(e){return $t.some(s=>s.value===e)}function Us(e,s,n){const a=Yn(s);return a.seconds===null?e:e.filter(r=>n/1e3-r.updated_at<=a.seconds)}function yi(e){const s=Yn(e);return s.seconds===null?null:`Nothing changed in ${s.phrase}.`}const Hn="projects-board-window";function vi(){try{const e=localStorage.getItem(Hn);if(e!==null&&ji(e))return e}catch{}return zn}function Bs(e){try{localStorage.setItem(Hn,e)}catch{}}const Wn="projects-board-column-order";let Vt=null;function ki(){if(Vt)return[...Vt];try{const e=localStorage.getItem(Wn);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const n=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];n.includes(a)||n.push(a)}return n}catch{return[]}}function wi(e){Vt=[...e];try{localStorage.setItem(Wn,JSON.stringify(e))}catch{}}function Ni(e,s,n){const a=e.filter(i=>i!==s),r=Math.max(0,Math.min(n,a.length));return a.splice(r,0,s),a}function Si(e,s=[]){const n=new Map;for(const o of e){const c=n.get(o.status)??[];c.push(o),n.set(o.status,c)}const a=Kt.map(o=>({status:o,projects:n.get(o)??[]}));for(const o of Gt){const c=n.get(o)??[];c.length>0&&a.push({status:o,projects:c})}for(const[o,c]of n)!Gt.includes(o)&&!Kt.includes(o)&&a.push({status:o,projects:c});if(s.length===0)return a;const r=new Map(s.map((o,c)=>[o,c])),i=a.filter(o=>r.has(o.status));i.sort((o,c)=>(r.get(o.status)??0)-(r.get(c.status)??0));const l=a.filter(o=>!r.has(o.status));return[...i,...l]}function Kn(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const n=pe(e.target_date);return n===null?!1:n<s}function G(e){return e.title||e.name}const bs="No team";function mt(e){const s=e.team?.trim();if(s)return s;const n=e.owner?.trim();return n||null}function js(e,s){const n=new Map,a=[];for(const i of e){const l=s(i);if(l===null){a.push(i);continue}const o=n.get(l);o?o.push(i):n.set(l,[i])}const r=[...n.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return a.length>0&&r.push({team:null,items:a}),r}function Pt(e){return e.title||e.session_id}function Ti(e){return[...e].reverse()}function _i(e){return e<=0?"":e===1?"1 update":`${e} updates`}const zs=e=>String(e).padStart(2,"0");function Qt(e){return`${e.getFullYear()}-${zs(e.getMonth()+1)}-${zs(e.getDate())}`}function Ci(e){const s=Date.parse(e);return Number.isNaN(s)?"":Qt(new Date(s))}function Ei(e,s,n=new Date){if(!e)return"";if(e===Qt(n))return"Today";const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);return e===Qt(a)?"Yesterday":Ce(e,s,n)}function Ri(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":Ua(new Date(n),{hour:"numeric",minute:"2-digit"},s)}function Di(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":ut(dt(n/1e3,s))}function Ai(e,s,n=Date.now()){const a=[],r=Fn(e.by);r&&a.push({key:"author",text:r});const i=Ri(e.at,s);i&&a.push({key:"time",text:i});const l=Di(e.at,n);return l&&a.push({key:"age",text:l}),a}function Oi(e,s,n=new Date){const a=[];for(const r of Ti(e)){const i=Ci(r.at),l=a[a.length-1];if(l&&l.key===i){l.entries.push(r);continue}a.push({key:i,label:Ei(i,s,n),entries:[r]})}return a}function $i(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 Pi(e,s){return s<=0?"":`${e} of ${s} complete`}function Mi(e){let s=0,n=0,a=!1;for(const r of e)r.todos&&(a=!0,s+=r.todos.open,n+=r.todos.total);return a?{open:s,total:n}:null}function Ys(e){return`${e.open} open of ${e.total}`}function Ii(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Li(e){const s=G(e),n=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${n}`,"Review the project details and continue or complete the work."].join(`
27
- `)}function Fi(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const qi=/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"/g;function Gn(e){const s=[];for(const n of e.matchAll(qi))s.push((n[1]??n[2]??"").replace(/\\(.)/g,"$1"));return s}const jt=3;function ys(e){if(e.length<=jt+1)return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;const s=e.length-jt;return`${e.slice(0,jt).join(", ")} and ${s} more`}function vs(e){return`${e} milestone${e===1?" is":"s are"}`}const Hs="complete them, or pass force_done=true to close with them open",Ui="complete or remove the incomplete milestones, then mark it done",Vn=/^cannot set status 'done': (\d+) milestones? still incomplete \((.+)\) — /;function ft(e){const s=e.match(Vn);if(s){const n=Number(s[1]),a=Gn(s[2]),r=a.length>0?ys(a):s[2];return`This can't be marked done yet: ${vs(n)} still incomplete (${r}). Complete or remove the incomplete milestones, then mark it done.`}return e.includes(Hs)?e.replace(Hs,Ui):e}const Bi="project_done_incomplete";function zi(e){const s=e.message.match(Vn),n=e.code===Bi;if(!n&&!s)return null;const a=typeof e.detail=="object"&&e.detail!==null&&Array.isArray(e.detail.incomplete)?e.detail.incomplete.filter(l=>typeof l=="string"):null,r=a&&a.length>0?a:s?Gn(s[2]):[];return{count:r.length>0?r.length:s?Number(s[1]):0,names:r,coded:n,message:e.message}}function Yi(e){if(e.count>0){const s=ys(e.names);return`${vs(e.count)} still open${s?` (${s})`:""}.`}return ft(e.message)||"Some milestones are still open."}function Hi(e){return e.count>0&&e.names.length>0?`This can't be marked done yet: ${vs(e.count)} still incomplete (${ys(e.names)}). Complete or remove the incomplete milestones, then mark it done.`:ft(e.message)||"Milestones are still open on this project. Complete or remove them, then mark it done."}function Qn(e,s,n){if(!e||e.forced_done!==!0)return`Moved to ${n}`;const a=typeof e.milestones_total=="number"&&typeof e.milestones_completed=="number"?e.milestones_total-e.milestones_completed:s,r=a>0?a:s;return`Moved to ${n} with ${r} milestone${r===1?"":"s"} still open`}const Wi="The project was not moved. Try again, or open it to change its status.";function Jn(e){return e.trim().slice(0,Mr)}const Ki={client:"Searches names, descriptions, tags, owners and teams. Update text is not searched. Clearing the search and filters restores the list.",backend:"Searches names, descriptions, tags, owners, teams and update text. Clearing the search and filters restores the list."},Gi=2,Vi=4,Qi=3,Ji=2,Xi=1,Zi=3,De={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},eo=/[^\p{L}\p{N}]+/u,to=/\s+/;function Ws(e,s){const n=s.trim().toLowerCase();if(!n)return 0;if(n===e)return Vi;if(n.startsWith(e))return Qi;const a=n.split(eo).filter(Boolean),r=e.split(to).filter(Boolean);if(r.length>0&&r.every(l=>a.some(o=>o.startsWith(l))))return Ji;const i=r.join("");return i.length>=Zi&&so(i,n)?Xi:0}function so(e,s){let n=0;for(const a of e){if(n=s.indexOf(a,n),n<0)return!1;n+=1}return!0}function no(e,s){const n=s.trim().toLowerCase();if(!n)return 0;const a=[[e.title,De.title],[e.name,De.name],[e.description,De.description],[e.owner,De.attribution],[e.team,De.attribution],[e.status,De.status]];let r=0;for(const[i,l]of a){if(!i)continue;const o=Ws(n,i)*l;o>r&&(r=o)}for(const i of e.tags){const l=Ws(n,i)*De.tags;l>r&&(r=l)}return r}function ao(e,s){const n=s.trim();if(!n)return e;const a=[];for(const r of e){const i=no(r,n);i>0&&a.push({project:r,score:i})}return a.sort((r,i)=>{if(r.score!==i.score)return i.score-r.score;if(r.project.updated_at!==i.project.updated_at)return i.project.updated_at-r.project.updated_at;const l=G(r.project).localeCompare(G(i.project),void 0,{sensitivity:"base"});if(l!==0)return l;const o=r.project.name.localeCompare(i.project.name,void 0,{sensitivity:"base"});return o!==0?o:r.project.id<i.project.id?-1:r.project.id>i.project.id?1:0}),a.map(r=>r.project)}function ro(e,s){if(s.length===0)return[];const n=new Map(e.map(r=>[r.id,r])),a=[];for(const r of s){const i=n.get(r.id);i!==void 0&&a.push(i)}return a}const io=180;function oo(e,s){const n=Jn(e),a=Rn(n,io),r=ls({queryKey:["desktop","projects","search",a],enabled:s&&a.length>0,queryFn:()=>ce({op:"projects.search",q:a,limit:Ir}),retry:!1,staleTime:3e4}),i=a===n,l=i&&r.data&&r.data.query===n?r.data:null,o=i&&n.length>0&&!l&&r.isError;return{answer:l,pending:s&&n.length>0&&!l&&!o}}const Qe=["status","team","owner","tags","progress","target","estimate","milestones","live"],Ks={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},nt={status:"Status",team:"Team",owner:"Owner",tags:"Tags",progress:"Progress",target:"Target date",estimate:"Estimate",milestones:"Milestones",live:"Live sessions"},lo=new Set(["status","progress","target","estimate","milestones","live"]),co={progress:["stale","up-to-date","not-reported"],target:["none","overdue","within-7","within-30"],estimate:["none","points","days"],milestones:["none","incomplete","complete"],live:["has-live","no-live"]},uo={stale:"Stale","up-to-date":"Up to date","not-reported":"Not reported",none:"No target date",overdue:"Overdue","within-7":"Due within 7 days","within-30":"Due within 30 days",points:"Points",days:"Days",incomplete:"Incomplete",complete:"Complete","has-live":"Has live sessions","no-live":"No live sessions"};function Xn(e,s){switch(e){case"status":return Z(s).label;case"team":return s===null?"No team":s;case"owner":return s===null?"No owner":s;case"tags":return s??"";case"estimate":if(s==="none")return"No estimate";break;case"milestones":if(s==="none")return"None set";break;case"target":if(s==="none")return"No target date";break}return uo[s]??s??""}function mo(e,s){return e[s].length>0}function rt(e){return Qe.every(s=>!mo(e,s))}function fo(e){return Qe.reduce((s,n)=>s+e[n].length,0)}function Zn(e,s,n){const a=e[s],r=a.includes(n)?a.filter(i=>i!==n):[...a,n];return{...e,[s]:r}}function ea(e,s,n,a){switch(e){case"status":return s.status===n;case"team":return mt(s)===n;case"owner":return(s.owner?.trim()||null)===n;case"tags":return s.tags.includes(n??"");case"progress":return n==="stale"?s.progress_stale===!0:n==="up-to-date"?s.progress_stale===!1:s.progress_updated_at===null;case"target":{if(n==="none")return pe(s.target_date)===null;if(n==="overdue")return Kn(s,a);const r=pe(s.target_date);if(r===null)return!1;const i=(r-a)/Ue;return n==="within-7"?i>=0&&i<=7:i>=0&&i<=30}case"estimate":return n==="none"?s.estimate===null:s.estimate===null?!1:n==="points"?s.estimate_unit==="points":s.estimate_unit==="days";case"milestones":return n==="none"?s.milestones_total===0:s.milestones_total===0?!1:n==="complete"?s.milestones_completed>=s.milestones_total:s.milestones_completed<s.milestones_total;case"live":return n==="has-live"?s.live_sessions>0:s.live_sessions===0}}function ta(e,s,n,a){const r=e[s];return r.length===0?!0:r.some(i=>ea(s,n,i,a))}function ho(e,s,n){return rt(s)?e:e.filter(a=>Qe.every(r=>ta(s,r,a,n)))}function po(e,s,n,a){return s.filter(r=>Qe.every(i=>i===e||ta(n,i,r,a)))}function xo(e,s,n){const a=n[e];switch(e){case"status":{const i=[...new Set(s.map(o=>o.status))].filter(o=>!qe.includes(o)).sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"})),l=a.filter(o=>typeof o=="string"&&!qe.includes(o)&&!i.includes(o));return[...qe,...i,...l]}case"team":{const r=new Set;let i=!1;for(const o of s){const c=mt(o);c===null?i=!0:r.add(c)}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"owner":{const r=new Set;let i=!1;for(const o of s){const c=o.owner?.trim();c?r.add(c):i=!0}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"tags":{const r=new Set;for(const i of s)for(const l of i.tags)r.add(l);for(const i of a)r.add(i??"");return[...r].sort((i,l)=>i.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return co[e]}}function sa(e,s,n,a){const r=po(e,s,n,a),i=lo.has(e),l=[];for(const o of xo(e,r,n)){const c=n[e].includes(o),m=r.reduce((u,h)=>u+(ea(e,h,o,a)?1:0),0);!i&&m===0&&!c||l.push({value:o,label:Xn(e,o),count:m,selected:c})}return{facet:e,label:nt[e],options:l}}function go(e,s,n){return Qe.map(a=>sa(a,e,s,n))}const Jt="projects-sort",bo="Default (as listed)";function jo(e){return yo.includes(e)}const yo=["name","status","target","estimate","milestones","live","progress"];function vo(){try{const e=localStorage.getItem(Jt);if(e===null)return null;const[s,n,...a]=e.split(":");if(a.length>0)return null;if(s&&jo(s)&&(n==="asc"||n==="desc"))return{key:s,direction:n}}catch{}return null}function ko(e){try{e===null?localStorage.removeItem(Jt):localStorage.setItem(Jt,`${e.key}:${e.direction}`)}catch{}}function Ge(e){switch(e){case"name":return"Project";case"status":return"Status";case"target":return"Target";case"estimate":return"Estimate";case"milestones":return"Milestones";case"live":return"Live";case"progress":return"Progress"}}function Ft(e){return e==="target"||e==="progress"?"desc":"asc"}function ks(e,s){const n=s==="desc";switch(e){case"name":return n?"Z to A":"A to Z";case"status":return n?"Archived first":"Planning first";case"target":return n?"latest first":"soonest first";case"estimate":return n?"days first":"points first";case"milestones":return n?"most complete first":"least complete first";case"live":return n?"most first":"fewest first";case"progress":return n?"most recent first":"most stale first"}}function wo(e){return e===null?"Sort cleared.":`Sorted by ${Ge(e.key)}, ${ks(e.key,e.direction)}.`}function No(e){const s=[e.search?"search":null,e.filters?"filters":null,e.sort?"sort":null].filter(a=>a!==null);if(s.length===0)return"";const n=s.length===1?`${s[0]} cleared.`:`${s.slice(0,-1).join(", ")} and ${s[s.length-1]} cleared.`;return n.charAt(0).toUpperCase()+n.slice(1)}function Gs(e,s){switch(e){case"name":return 0;case"status":return qe.includes(s.status)?0:1;case"target":return Xt(s)===null?1:0;case"estimate":return s.estimate===null?1:0;case"milestones":return s.milestones_total===0?1:0;case"live":return 0;case"progress":return s.progress_updated_at===null?1:0}}function Xt(e){return pe(e.completed_at??e.target_date)}function Vs(e){return e==="points"?0:e==="days"?1:2}function So(e,s,n){switch(e){case"name":return G(s).localeCompare(G(n),void 0,{sensitivity:"base"});case"status":return qe.indexOf(s.status)-qe.indexOf(n.status);case"target":{const a=Xt(s)??0,r=Xt(n)??0;return a-r}case"estimate":{const a=Vs(s.estimate_unit)-Vs(n.estimate_unit);return a!==0?a:(s.estimate??0)-(n.estimate??0)}case"milestones":return s.milestones_completed*n.milestones_total-n.milestones_completed*s.milestones_total;case"live":return s.live_sessions-n.live_sessions;case"progress":return(s.progress_updated_at??0)-(n.progress_updated_at??0)}}function Qs(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const n=G(e).localeCompare(G(s),void 0,{sensitivity:"base"});if(n!==0)return n;const a=e.name.localeCompare(s.name,void 0,{sensitivity:"base"});return a!==0?a:e.id<s.id?-1:e.id>s.id?1:0}function To(e,s,n){const a=Gs(n.key,e),r=Gs(n.key,s);if(a!==r)return a-r;if(a===1)return Qs(e,s);const i=So(n.key,e,s);return i!==0?n.direction==="desc"?-i:i:Qs(e,s)}function _o(e,s){return[...e].sort((n,a)=>To(n,a,s))}const Te=["day","week","month","quarter"],ws={day:24,week:9,month:3,quarter:1};function Ns(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function Ae(e,s){return Math.round((s-e)/Ue)}function Js(e,s){return Ae(e,s)+1}function Co(e,s){for(const n of Te)if(e*ws[n]<=s)return n;return Te[Te.length-1]}function Eo(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(n=>!!n.target_date)}function Ro(e,s){const n=[s];for(const a of e){for(const r of[a.project.start_date,a.project.target_date,a.project.completed_at]){const i=pe(r);i!==null&&n.push(i)}for(const r of a.milestones){const i=pe(r.target_date);i!==null&&n.push(i)}}return n.length===1?null:{startMs:Math.min(...n),endMs:Math.max(...n)}}function Do(e){const s=[],n=[];for(const a of e)(Eo(a)?s:n).push(a);return{dated:s,undated:n}}function Ao(e){return`${e} project${e===1?"":"s"} without dates`}function Oo(e){const{project:s}=e,n=pe(s.start_date),a=pe(s.target_date),r=pe(s.completed_at),i=s.status==="done"&&r!==null?r:a,l=n??i,o=i??n;return l===null||o===null?null:{fromMs:Math.min(l,o),toMs:Math.max(l,o)}}function $o(e){const s=[];for(const n of e.milestones){const a=pe(n.target_date);a!==null&&s.push({name:n.name,dayMs:a,status:n.status})}return s}const bt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function Po(e){const{year:s,month:n}=de(e);return Date.UTC(s,n-1,1)}function Mo(e){const{year:s,month:n}=de(e);return n===12?Date.UTC(s+1,0,1):Date.UTC(s,n,1)}function Io(e){const{year:s,month:n}=de(e);return Date.UTC(s,Math.floor((n-1)/3)*3,1)}function Lo(e){const{year:s,month:n}=de(e),a=Math.floor((n-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function Fo(e){const{weekday:s}=de(e);return e-(s+6)%7*Ue}const qo=26;function Uo(e,s,n){const a=[],r=(u,h,b)=>{u<e||u>s||a.push({dayMs:u,label:h,major:b})};if(n==="day"){let u=!1;for(let h=e;h<=s;h+=Ue){const{day:b,month:f}=de(h);b===1?(r(h,bt[f-1],!0),u=!0):u?(r(h,"",!1),u=!1):r(h,String(b),!1)}return a}if(n==="week"){for(let u=Fo(e);u<=s;u+=7*Ue){if(u<e)continue;const{day:h,month:b}=de(u);de(u-7*Ue).month!==b?r(u,`${bt[b-1]} ${h}`,!0):r(u,String(h),!1)}return a}const i=n==="month"?Po:Io,l=n==="month"?Mo:Lo,o=u=>{const{year:h,month:b}=de(u);if(n==="month")return b===1&&h!==de(e).year?`${bt[0]} '${String(h%100).padStart(2,"0")}`:bt[b-1];const f=Math.floor((b-1)/3)+1;return f===1&&h!==de(e).year?`Q1 '${String(h%100).padStart(2,"0")}`:`Q${f}`};r(e,o(i(e)),!0);const c=Math.ceil(qo/ws[n]);let m=e;for(let u=l(i(e));u<=s;u=l(u))Ae(m,u)<c||(r(u,o(u),!0),m=u);return a}function it(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}const wt=80,Nt=80,Xs=64,Zs=8;function Zt(e){return e.trim().length>wt?`Titles are at most ${wt} characters.`:null}function na(e){return e.length>Ke?`Keep the description within ${Ke} characters.`:null}function St(e,s){return e.trim().length>Nt?`${s==="owner"?"Owners":"Teams"} are at most ${Nt} characters.`:null}function es(e){return Ln.test(e)?null:"Dates are YYYY-MM-DD, or empty."}function ts(e,s){return e&&s&&s<e?"The target date is before the start date.":null}function aa(e){const s=e.trim();if(s==="")return null;const n=Number(s);return!Number.isFinite(n)||!(n>0)||n>1e3?"Estimates are greater than 0 and at most 1000.":null}function ss(e){const s=it(e);if(s.length>Zs)return{tags:s,error:`Up to ${Zs} tags.`};for(const n of s){const a=Lr(n);if(a)return{tags:s,error:a}}return{tags:s,error:null}}const Bo="project_name_exists";function en(e){return e.code===Bo?"A project with this key already exists.":ft(e.message)||"The project was not saved."}function zo(e,s){if(e.unit!==s.unit)return!1;const n=e.number.trim(),a=s.number.trim();return a===""?!0:n===""?!1:Number(n)===Number(a)}function Yo(e,s){const n=it(s);return n.length!==e.length?!1:n.every((a,r)=>a===e[r])}function Ho(e,s){const n={},a=s.number.trim();if(a!==""){const r=Number(a);(e.estimate===null||e.estimate!==r)&&(n.estimate=r)}return s.unit!==e.unit&&(n.estimate_unit=s.unit),Object.keys(n).length>0?n:null}function Je(e){return e instanceof Et?en({code:e.code,message:e.message}):en({message:e instanceof Error?e.message:""})}function ra(e){return e instanceof Et&&(e.code==="project_not_found"||e.status===404)}function ia(e){return!(e instanceof Error)||!e.message?Wi:ra(e)?"This project could not be found. It may have been deleted.":Je(e)}function oa(e){if(!(e instanceof Error))return null;const s=e instanceof Et?e:null;return zi({code:s?.code??null,message:e.message,detail:s?.detail})}async function Wo(e){try{return await e.move(),{kind:"accepted"}}catch(s){const n=oa(s);return n?.coded&&e.forceDoneOffered&&e.claimQuestion()?{kind:"question",refusal:n}:{kind:"spoken",copy:n?Hi(n):ia(s),refusal:n}}}const Ko="Shows projects last updated within this window; older ones are hidden.",Go=({value:e,onChange:s})=>t.jsxs(ze,{value:e,onValueChange:n=>s(n),children:[t.jsx(Dt,{content:e==="all"?null:Ko,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(He,{})})}),t.jsx(We,{children:$t.map(n=>t.jsx(_e,{value:n.value,children:n.label},n.value))})]}),ns=6e4,as=6e3,tn="Requesting updates…",Vo=400,Qo="Ask the sessions linked to this project to post a progress update",Jo="linked but not yet in use — it becomes a recipient after the first message",sn=e=>`project-request-update-${e}`,Xo=e=>`project-request-cooldown-${e}`,Zo=e=>`project-request-update-cooldown-${e}`,qt=e=>e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e[0]}, ${e[1]} and ${e.length-2} more`,nn=(e,s)=>e.sessions.filter(n=>n.outcome===s).map(n=>Pt({session_id:n.session_id,title:n.title})),el=e=>e.outcome==="failed"&&e.detail===Jo;function Tt(e,s){const n=Math.max(1,Math.ceil(s/1e3));return`Update already requested ${Math.max(0,Math.ceil(ns/1e3)-n)} s ago on ${e}. Try again in ${n} s.`}function tl(e){const s=G({title:e.project.title,name:e.project.key}),{delivered:n,unconfirmed:a,failed:r,total:i}=e.counts;if(e.state==="empty")return{variant:"info",title:`No linked sessions to ask. Link a session to ${s} first.`,duration:as};if(e.state==="cooldown")return{variant:"info",title:Tt(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:as};if(e.state!=="sent")return null;const l=nn(e,"failed"),o=nn(e,"unconfirmed");if(n>=1&&r===0&&a===0)return{variant:"success",title:n===1?`Requested an update from 1 session on ${s}.`:`Requested updates from ${n} sessions on ${s}.`};if(n>=1){let c=`Requested updates from ${n} of ${i} sessions on ${s}.`;return r>0&&(c+=` ${qt(l)} could not be reached.`),a>0&&(c+=` Delivery to ${qt(o)} could not be confirmed.`),{variant:"warning",title:c,duration:Number.POSITIVE_INFINITY}}if(r===0)return{variant:"warning",title:`Could not confirm delivery on ${s} — the requests may still reach its sessions.`,duration:Number.POSITIVE_INFINITY};if(a===0){const c=e.sessions.every(el);let m;return c?m=i===1?"The linked session has not started yet — it becomes a recipient after its first message.":`The ${i} linked sessions have not started yet — they become recipients after their first message.`:m=`Could not reach any of the ${i} linked sessions on ${s}.`,{variant:"error",title:m,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:`Could not reach ${r} of the ${i} linked sessions on ${s}. Delivery to ${qt(o)} could not be confirmed.`,duration:Number.POSITIVE_INFINITY}}const st=new Map,Ss=new Set,Ut=new Map,rs=new Set;let la=0;const _t=()=>{la+=1;for(const e of rs)e()},sl=e=>(rs.add(e),()=>{rs.delete(e)}),an=()=>la,ca=e=>Ss.has(e),da=e=>st.get(e);function nl(e){Ss.add(e),_t()}function al(e){Ss.delete(e),_t()}function rn(e,s,n){const a=Date.now();if(n<=a)return;const r=st.get(e);if(r&&r.untilMs>=n)return;st.set(e,{startedMs:s,untilMs:n});const i=Ut.get(e);i&&clearTimeout(i);const l=setTimeout(()=>{Ut.delete(e);const o=st.get(e);o&&o.untilMs<=Date.now()&&(st.delete(e),_t())},n-a);l.unref?.(),Ut.set(e,l),_t()}const rl=e=>/[.!?…]$/.test(e)?e:`${e}.`;function il(e,s){const n=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;rn(e,n-(ns-a),n+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&rn(e,n,n+ns)}async function ol(e){const s=e.id;if(ca(s)){Os(tn,{id:sn(s)});return}const n=Date.now(),a=da(s);if(a&&a.untilMs>n){$s(Tt(G(e),a.untilMs-n),{id:Xo(s),duration:as});return}nl(s);const r=sn(s);let i=!1;const l=setTimeout(()=>{i=!0,Os(tn,{id:r})},Vo);try{const o=await ce({op:"projects.request_update",key:s});il(s,o);const c=tl(o);if(c){const m={id:r,...c.duration!==void 0?{duration:c.duration}:{}};switch(c.variant){case"success":fe(c.title,m);break;case"warning":Ba(c.title,m);break;case"error":Ps(c.title,m);break;default:$s(c.title,m)}}else i&&za(r)}catch(o){const c=o instanceof Error&&o.message.trim()!==""?o.message.trim():null;Ps(c?`Could not request updates: ${rl(c)}`:"The request could not be confirmed.",{id:r,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),al(s)}}function ua(){return d.useCallback(e=>{ol(e)},[])}function ll(e){d.useSyncExternalStore(sl,an,an);const s=ca(e),n=da(e),a=n!==void 0?n.untilMs-Date.now():0,r=a>0;return{sending:s,cooling:r,cooldownRemainingMs:r?a:null}}const on={active:"In flight",paused:"On hold",done:"Finished"};function cl(){const[e,s]=d.useState(null);return d.useEffect(()=>{if(!e)return;const n=document.querySelector(`[data-project-menu="${e}"]`);n&&(n.focus(),s(null))}),d.useCallback(n=>s(n),[])}const dl=4,Bt="Drag the header, or press the arrow keys, to move this column.",ln="board-column-move-hint",ul=({projects:e,nowMs:s,onOpen:n,onEdit:a,onDelete:r,onMove:i,movingKeys:l=[],teamLabelFor:o=c=>c})=>{const[c,m]=d.useState(ki),u=Si(e,c),h=js(e,mt),[b,f]=d.useState(null),[j,v]=d.useState(""),g=d.useRef(null),x=d.useRef(null),y=d.useRef(null),C=d.useRef(null),w=d.useRef(null),L=new Set(l),T=(k,N)=>{const R=Ni(u.map(M=>M.status),k,N);m(R),wi(R),v(`Moved ${Z(k).label} column to position ${R.indexOf(k)+1} of ${R.length}.`)},_=(k,N)=>{const R=g.current;if(!R)return 0;let M=0;const F=R.querySelectorAll("[data-board-column]");for(const q of F){if(q.dataset.boardColumn===N)continue;const ae=q.getBoundingClientRect();k>(ae.left+ae.right)/2&&(M+=1)}return M},O=(k,N)=>{const R=u.filter(q=>q.status!==k),M=R[N-1]?.status,F=R[N]?.status;return M&&F?`between ${Z(M).label} and ${Z(F).label}`:F?`before ${Z(F).label}`:M?`after ${Z(M).label}`:"in place"},p=(k,N)=>{const R=_(k,N.status);R!==N.over&&(N.over=R,f({status:N.status,over:R}),v(`Moving ${Z(N.status).label} column; it will drop ${O(N.status,R)}.`))},A=()=>{C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},E=32,P=12,z=()=>{C.current=null;const k=w.current,N=g.current,R=y.current;if(!k?.armed||!N||R===null)return;const M=N.getBoundingClientRect(),F=N.scrollWidth-N.clientWidth;let q=0;if(R-M.left<E&&N.scrollLeft>0?q=-1:M.right-R<E&&N.scrollLeft<F&&(q=1),q!==0){const ae=N.scrollLeft;N.scrollLeft=ae+q*P,N.scrollLeft!==ae&&p(R,k)}else p(R,k);Q(k.status,k.over),C.current=requestAnimationFrame(z)};d.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]);const I=(k,N)=>{if(k.button===0){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}w.current={pointerId:k.pointerId,status:N,startX:k.clientX,startY:k.clientY,armed:!1,over:u.findIndex(R=>R.status===N)},y.current=k.clientX}},B=k=>{const N=w.current;if(!(!N||k.pointerId!==N.pointerId)){if(y.current=k.clientX,!N.armed){if(Math.hypot(k.clientX-N.startX,k.clientY-N.startY)<dl)return;N.armed=!0,f({status:N.status,over:N.over}),v(`Moving ${Z(N.status).label} column.`),C.current===null&&(C.current=requestAnimationFrame(z))}p(k.clientX,N)}},W=k=>{const N=w.current;if(w.current=null,A(),f(null),!N?.armed)return;if(!k){v("Move cancelled.");return}const R=u.findIndex(M=>M.status===N.status);if(N.over===R){v("");return}T(N.status,N.over)},V=k=>{const N=w.current;!N||k.pointerId!==N.pointerId||W(!0)},le=()=>{W(!1)};d.useEffect(()=>{if(!b)return;const k=N=>{N.key==="Escape"&&W(!1)};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[b!==null]);const Q=d.useCallback((k,N)=>{const R=g.current,M=x.current;if(!R||!M)return;const F=R.getBoundingClientRect(),q=[];for(const re of R.querySelectorAll("[data-board-column]"))re.dataset.boardColumn!==k&&q.push(re.getBoundingClientRect());const ae=6,Ee=N>=q.length?(q[q.length-1]?.right??F.left)+ae:(q[N]?.left??F.right)-ae,Y=R.scrollLeft,Ne=2,ge=Ee-F.left+Y,me=Y+1,X=Y+F.width-Ne-1,Re=Math.round(Math.min(Math.max(ge,me),Math.max(me,X)));M.style.left=`${Re}px`},[]);d.useLayoutEffect(()=>{b&&Q(b.status,b.over)},[b,Q]);const J=(k,N)=>{if(k.key==="Enter"||k.key===" "){k.preventDefault(),v(Bt);return}if(k.key!=="ArrowLeft"&&k.key!=="ArrowRight")return;k.preventDefault();const R=u.map(q=>q.status),M=R.indexOf(N),F=k.key==="ArrowLeft"?M-1:M+1;if(F<0||F>=R.length){v(`${Z(N).label} column is already ${F<0?"the first column":"the last column"}.`);return}T(N,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:j}),t.jsx("span",{id:ln,className:"sr-only",children:Bt}),t.jsxs("div",{ref:g,"data-board-strip":"",className:$("relative flex min-h-0 flex-1 items-start overflow-auto px-6 pb-9",b&&"cursor-grabbing select-none"),children:[b&&t.jsx("div",{ref:x,"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:u.map(k=>{const N=Z(k.status);return t.jsxs("header",{"data-board-column":k.status,"data-board-column-handle":k.status,onPointerDown:R=>I(R,k.status),onPointerMove:B,onPointerUp:V,onPointerCancel:le,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",b?.status===k.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(U,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":k.status,"aria-label":`Move ${N.label} column`,"aria-describedby":ln,title:Bt,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:R=>J(R,k.status),children:t.jsx(Dr,{"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:N.label}),on[k.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:on[k.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:k.projects.length})]},k.status)})}),h.map(k=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":k.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:k.team==null?bs:o(k.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:k.items.length})]})}),t.jsx("div",{className:"flex gap-3 rounded-md bg-sunken py-2",children:u.map(N=>{const R=k.items.filter(M=>M.status===N.status);return t.jsx("div",{"data-board-cell":N.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:R.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:R.map(M=>t.jsx("li",{children:t.jsx(ml,{project:M,nowMs:s,busy:L.has(M.id),onOpen:()=>n(M),onEdit:()=>a(M),onDelete:()=>r(M),onMove:F=>i(M,F)})},M.id))})},N.status)})})]},k.team??""))]})]})]})},ml=({project:e,nowMs:s,busy:n,onOpen:a,onEdit:r,onDelete:i,onMove:l})=>{const o=Pe(),c=Bn(e,o),m=Ve(),u=ua(),h=he(m.data,"projects_request_update"),b=G(e),f=d.useRef(null),[j,v]=d.useState(!1);d.useEffect(()=>{const w=f.current;if(!w)return;const L=()=>{w.isConnected&&v(w.scrollWidth-w.clientWidth>.5)},T=requestAnimationFrame(L),_=new ResizeObserver(L);return _.observe(w),document.fonts?.ready.then(L).catch(()=>{}),()=>{cancelAnimationFrame(T),_.disconnect()}},[b,j]);const g=Kn(e,Ns(s)),x=dt(e.progress_updated_at,s),y=()=>{const w=window.getSelection();w&&!w.isCollapsed||a()},C=w=>{w.key!=="Enter"&&w.key!==" "||w.target===w.currentTarget&&(w.preventDefault(),a())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":`Open ${b}`,onClick:y,onKeyDown:C,className:$("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",g&&"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(Dt,{content:j?b:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:f,"data-project-title":e.name,tabIndex:j?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:b})}),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(ds,{children:[t.jsx(us,{"data-project-menu":e.id,"aria-label":`Actions for ${b}`,disabled:n,onClick:w=>w.stopPropagation(),className:$("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:n?t.jsx(we,{size:"xs"}):t.jsx(kn,{className:"size-4"})}),t.jsxs(ms,{align:"end",onClick:w=>w.stopPropagation(),children:[t.jsx(ke,{onSelect:a,children:"Open"}),t.jsxs(vr,{children:[t.jsx(kr,{children:"Set status"}),t.jsx(wr,{children:t.jsx(Nr,{value:e.status,onValueChange:l,children:[...Kt,...Gt].map(w=>t.jsx(Sr,{value:w,children:Z(w).label},w))})})]}),h&&t.jsx(ke,{onSelect:()=>u(e),children:"Request update"}),t.jsx(Tr,{}),t.jsx(ke,{onSelect:r,children:"Edit"}),t.jsx(ke,{onSelect:i,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[c.filter(w=>w.key!=="live").map(w=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:w.text},w.key)),g&&t.jsx(xe,{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:ci(x)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!x)&&t.jsx("span",{"aria-label":kt,title:kt,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(fl,{project:e})]})]})]})},fl=({project:e})=>{const[s,n]=d.useState(!1),a=Rt(),r=On(e.id,s),i=r.data?.links??[],l=fi(e),o=G(e);return t.jsxs(fs,{open:s,onOpenChange:n,children:[t.jsx(hs,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${o}`,onClick:c=>c.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:l}),t.jsx(ps,{align:"end",className:"w-64 p-2 outline-none",onClick:c=>c.stopPropagation(),children:r.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"Loading linked sessions…"}):r.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:r.error instanceof Error&&r.error.message?r.error.message:"The linked sessions could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void r.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(c=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!c.exists,onClick:()=>{c.exists&&(n(!1),Dn(a,c.session_id))},className:$("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",c.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:c.title||c.session_id})})},c.session_id))})})]})},ma=({open:e,projectName:s,onClose:n,onConfirm:a})=>{const[r,i]=d.useState(""),[l,o]=d.useState(null),[c,m]=d.useState(!1),u=d.useId();d.useEffect(()=>{e&&(i(""),o(null),m(!1))},[e]);const h=r.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,b=async()=>{m(!0),o(null);try{await a(r.trim()),n()}catch(f){o(f instanceof Error&&f.message?f.message:"The project was not deleted.")}finally{m(!1)}};return t.jsx(lt,{open:e,onClose:n,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:n,disabled:c,children:"Cancel"}),t.jsxs(Ya,{onClick:()=>void b(),disabled:!h||c,children:[c&&t.jsx(we,{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(ne,{id:`${u}-confirm`,value:r,onChange:f=>i(f.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":r.length>0&&!h,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})};function hl(e){return e==="editing"||e==="saving"||e==="error"}function pl(e,s,n=Object.is){return!n(e,s)}function xl(e,s){if(e.key==="Escape")return e.defaultPrevented===!0?null:"revert";if(e.key!=="Enter"||!s.keyboardCommit)return null;const n=e.metaKey===!0||e.ctrlKey===!0;return s.multiline?n?"accept":null:s.onEditor?"accept":null}function gl(e,s){return e==="saving"||e==="error"?!0:e==="editing"&&s}function bl(e){const{phase:s,base:n,draft:a,fresh:r,equals:i}=e;return s==="saving"||s==="saved"||i(n,r)?"none":s==="idle"||i(n,a)||i(r,a)?"adopt":"conflict"}function cn(e,s,n=Object.is){return!n(e,s)}const Ts="group/inline-edit",zt="inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-xs text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",jl="relative before:absolute before:-inset-1.5 before:content-['']",yl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-left-1.5 before:right-0 before:content-['']",vl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-right-1.5 before:left-0 before:content-['']",is=({api:e,idle:s="affordance",className:n})=>{const{phase:a,labels:r}=e,i=a==="editing"||a==="saving"||a==="error",l=gl(a,e.dirty),o=e.acceptBlocked===!0;return t.jsx("span",{"data-inline-edit-slot":a,className:$("inline-flex shrink-0 items-center gap-0.5",n),children:l?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","data-inline-edit-control":"cancel","aria-label":a==="saving"?r.busy:r.cancel,title:a==="saving"?r.busy:r.cancel,"aria-disabled":a==="saving"||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||a!=="saving"&&e.cancel()},className:$(zt,yl,a==="saving"&&"cursor-default text-ink-disabled"),children:t.jsx(At,{className:"size-3","aria-hidden":"true"})}),a==="saving"?t.jsx("span",{"data-inline-edit-control":"busy",className:"inline-flex size-5 shrink-0 items-center justify-center",children:t.jsx(we,{size:"xs"})}):t.jsx("button",{type:"button","data-inline-edit-control":"accept","aria-label":a==="error"?r.retry??r.accept:r.accept,title:a==="error"?r.retry??r.accept:r.accept,"aria-disabled":o||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||o||e.accept()},className:$(zt,vl,o&&"cursor-default text-ink-disabled"),children:t.jsx(xs,{className:"size-3","aria-hidden":"true"})})]}):i?null:s==="affordance"?t.jsx("button",{ref:e.slotRef,type:"button","data-inline-edit-control":"begin","aria-label":r.begin,title:r.begin,onClick:c=>{c.detail>1||e.begin()},className:$(zt,jl,"opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","focus-visible:opacity-100"),children:t.jsx(Ha,{className:"size-3","aria-hidden":"true"})}):null})},kl="This changed while you were editing",wl="Keep mine",Nl="Use theirs",os=({api:e,className:s})=>{const{phase:n,error:a,conflict:r}=e;return n==="saved"?t.jsx("p",{"data-inline-edit-feedback":"saved",className:$("text-meta text-success",s),children:e.labels.saved}):!a&&!r?null:t.jsxs("div",{id:e.feedbackId,"data-inline-edit-feedback":a&&r?"error+conflict":a?"error":"conflict",role:"alert",className:$("flex flex-wrap items-center gap-x-3 gap-y-1",s),children:[a&&t.jsx("p",{className:"text-meta text-danger",children:a}),a&&r===null&&t.jsx("button",{type:"button","data-inline-edit-control":"retry",onClick:()=>e.accept(),className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:"Retry"}),r!==null&&t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-warning",children:kl}),t.jsx("button",{type:"button","data-inline-edit-control":"keep-mine",onClick:e.keepMine,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:wl}),t.jsx("button",{type:"button","data-inline-edit-control":"use-theirs",onClick:e.useTheirs,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:Nl})]})]})},fa=d.createContext(null),Sl=50,Tl=({children:e})=>{const[s,n]=d.useState(""),a=d.useMemo(()=>({current:r=>{n(""),window.setTimeout(()=>n(r),Sl)}}),[]);return t.jsxs(fa.Provider,{value:a,children:[e,t.jsx("span",{"data-inline-edit-announcement":"","aria-live":"polite",className:"sr-only",children:s})]})},_l=1200;function Cl(e){return e instanceof Error&&e.message?e.message:"The change was not saved."}function ht(e){const{value:s,multiline:n=!1,keyboardCommit:a=!0,selectAllOnBegin:r=!1,beginOnMount:i=!1,savedDwellMs:l=_l,labels:o}=e,c=d.useRef(e.equals??Object.is);c.current=e.equals??Object.is;const m=d.useRef(e.commit);m.current=e.commit;const u=d.useRef(e.validate);u.current=e.validate;const h=d.useRef(e.errorCopy);h.current=e.errorCopy;const b=d.useRef(e.onSettle);b.current=e.onSettle;const f=d.useRef(e.onBegin);f.current=e.onBegin;const j=d.useRef(o);j.current=o;const[v,g]=d.useState(i?"editing":"idle"),[x,y]=d.useState(s),[C,w]=d.useState(s),[L,T]=d.useState(null),[_,O]=d.useState(null),p=d.useRef(v),A=d.useRef(x),E=d.useRef(C),P=d.useRef(L),z=d.useRef(s);z.current=s;const I=d.useCallback(D=>{p.current=D,g(D)},[]),B=d.useCallback(D=>{A.current=D,y(D)},[]),W=d.useCallback(D=>{E.current=D,w(D)},[]),V=d.useCallback(D=>{P.current=D,T(D)},[]),le=d.useRef(null),Q=d.useRef(null),J=d.useRef(null),k=e.editorRef??J,N=d.useRef(k);N.current=k;const R=`${d.useId()}-inline-edit`,M=d.useContext(fa),F=d.useRef(null),q=F.current,Ee=q!==null&&(e.equals??Object.is)(s,q.previous)&&!(e.equals??Object.is)(s,q.saved)&&q!==null?q.saved:s,Y=d.useRef(Ee);Y.current=Ee,d.useEffect(()=>{const D=F.current;if(D===null)return;const te=c.current;(te(s,D.saved)||!te(s,D.previous))&&(F.current=null)},[s]);const Ne=d.useRef(i);d.useEffect(()=>{if(v!=="editing"||!Ne.current)return;Ne.current=!1;const D=N.current.current;D&&(D.focus(),r&&(D instanceof HTMLInputElement||D instanceof HTMLTextAreaElement)&&D.select())},[v,r]);const ge=d.useRef(!1);d.useEffect(()=>{ge.current&&(v!=="idle"&&v!=="saved"||(ge.current=!1,Q.current?.focus()))});const me=d.useRef(null),X=d.useCallback(()=>{me.current!==null&&(clearTimeout(me.current),me.current=null)},[]);d.useEffect(()=>()=>X(),[X]);const Re=d.useRef(v);d.useEffect(()=>{const D=Re.current;if(Re.current=v,D==="saving"&&v==="saved"){b.current?.("saved");return}(D==="editing"||D==="error")&&v==="idle"&&b.current?.("cancelled")},[v]),d.useEffect(()=>{const D=bl({phase:p.current,base:E.current,draft:A.current,fresh:Y.current,equals:c.current});D==="adopt"?(c.current(E.current,Y.current)||W(Y.current),c.current(Y.current,A.current)||B(Y.current)):D==="conflict"&&(P.current===null||!c.current(P.current,Y.current))&&V(Y.current)},[s,v,W,B,V]);const re=d.useCallback(D=>{V(null),O(null),B(E.current),I("idle"),D&&(ge.current=!0)},[V,B,I]),Xe=d.useCallback(()=>{p.current!=="saving"&&(p.current==="idle"||p.current==="saved"||(X(),re(!0)))},[X,re]),ee=d.useCallback((D,te=!0)=>{const tt=p.current;if(tt==="saving"||tt==="saved"||P.current!==null)return;const be=D!==void 0?D:A.current;if(!cn(E.current,be,c.current)){re(te&&tt!=="idle");return}const xt=u.current?.(be)??null;if(xt!==null){I("error"),O(xt);return}B(be),O(null),I("saving"),m.current(be).then(()=>{p.current==="saving"&&(F.current={saved:be,previous:E.current},W(be),B(be),te&&(ge.current=!0),I("saved"),X(),me.current=setTimeout(()=>{me.current=null,p.current==="saved"&&I("idle")},l),M?.current?.(j.current.saved))},Le=>{p.current==="saving"&&(I("error"),O(h.current?h.current(Le):Cl(Le)))})},[M,X,re,l,W,B,I]),Se=d.useCallback(()=>{p.current==="editing"||p.current==="saving"||(X(),Ne.current=!0,B(Y.current),W(Y.current),V(null),O(null),I("editing"),f.current?.())},[X,W,V,B,I]),Ie=d.useCallback(()=>{const D=P.current;D!==null&&(V(null),W(D),ee())},[ee,W,V]),It=d.useCallback(()=>{const D=P.current;D!==null&&(W(D),re(!0))},[re,W]),Ze=d.useCallback(D=>{const te=xl(D,{multiline:n,keyboardCommit:a,onEditor:D.target===N.current.current});if(te==="revert"){D.preventDefault(),Xe();return}te==="accept"&&(D.preventDefault(),ee())},[ee,Xe,a,n]),et=d.useCallback(D=>{if(p.current!=="editing")return;const te=D.relatedTarget;if(!(te!==null&&le.current?.contains(te))&&!(te instanceof Element&&te.closest("[data-radix-popper-content-wrapper]")!==null)&&P.current===null){if(!cn(E.current,A.current,c.current)){re(!1);return}ee(void 0,!1)}},[ee,re]),pt=v==="saved"?x:Ee;return{phase:v,dirty:pl(C,x,c.current),conflict:L,error:_,draft:x,setDraft:B,displayValue:pt,editing:hl(v),begin:Se,accept:ee,cancel:Xe,keepMine:Ie,useTheirs:It,handleKeyDown:Ze,handleBlur:et,fieldProps:{onKeyDown:Ze,onBlur:et,"aria-busy":v==="saving"?!0:void 0},editorAria:{"aria-invalid":_!==null?!0:void 0,"aria-describedby":_!==null||L!==null?R:void 0},fieldRef:le,editorRef:k,slotRef:Q,feedbackId:R,labels:o}}const El=/^(https?:|mailto:)/i,Rl={a:({href:e,children:s})=>typeof e=="string"&&El.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:Ka},ot=d.memo(({children:e,className:s})=>t.jsx("div",{className:$("lo-markdown",s),children:t.jsx(Wa,{remarkPlugins:[Ga],components:Rl,children:e})})),dn=`## Summary
26
+ */const Jr=[["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"}]],Xr=ct("unlink",Jr),$t={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Zr(e){return cs({queryKey:$t.list,enabled:e,queryFn:()=>ce({op:"projects.list"}).then(s=>s.projects),retry:ds,staleTime:1e4})}function ei(e,s){return zr({queries:e.map(n=>({queryKey:$t.detail(n),enabled:s&&!!n,queryFn:()=>ce({op:"projects.get",key:n}),retry:ds,staleTime:1e4}))})}function $n(e,s){return cs({queryKey:$t.detail(e??""),enabled:s&&!!e,queryFn:()=>ce({op:"projects.get",key:e??""}),retry:ds,staleTime:1e4})}function Me(){const e=kn();return()=>{e.invalidateQueries({queryKey:$t.list})}}function ti(){const e=Me();return Pe({mutationFn:s=>ce({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 Pn(){const e=Me();return Pe({mutationFn:s=>ce({op:"projects.update",key:s.key,fields:s.fields,...s.forceDone===!0?{force_done:!0}:{}}),retry:qa,onSuccess:()=>e()})}function Mn(){const e=Me();return Pe({mutationFn:s=>ce({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function si(){const e=Me();return Pe({mutationFn:s=>ce({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ni(){const e=Me();return Pe({mutationFn:s=>ce({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function ai(){const e=Me();return Pe({mutationFn:s=>ce({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 ri(){const e=Me();return Pe({mutationFn:s=>ce({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const In={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"}},qe=Object.keys(In);function Z(e){return In[e]??{label:e||"Unknown",variant:"neutral"}}const Ln=["planning","active","qa","validation","done","paused","archived"].map(e=>({value:e,label:Z(e).label}));function ii(e){return e==="done"}const oi={completed:{label:"Completed",variant:"success"},overdue:{label:"Overdue",variant:"warning"},upcoming:{label:"Upcoming",variant:"neutral"}};function li(e){return oi[e]??{label:String(e),variant:"neutral"}}const wt="Stale",ci=/^(\d{4})-(\d{2})-(\d{2})$/;function Ce(e,s,n=new Date){if(!e)return"";const a=ci.exec(e);if(!a)return e;const r=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(r.getTime()))return e;const i=Ua(r,{month:"short",day:"numeric"},s);return r.getFullYear()===n.getFullYear()?i:`${i}, ${r.getFullYear()}`}function dt(e,s){if(e==null)return"";const n=Math.max(0,Math.floor(s/1e3-e));return n<60?"just now":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function ut(e){return e==="just now"?"just now":`${e} ago`}function di(e){return e?`reported ${ut(e)}`:"no progress"}const Fn=/^$|^\d{4}-\d{2}-\d{2}$/;function qn(e){return e?e==="operator"?"the operator":`session ${e}`:""}function ui(e,s){if(!e.progress)return"not reported yet";const n=dt(e.progress_updated_at,s),a=qn(e.progress_reported_by),r=[n?`reported ${ut(n)}`:"reported"];return a&&r.push(`by ${a}`),r.join(" ")}function Un(e,s){if(e==null)return"";const n=String(e);return s==="points"?`${n} pt`:s==="days"?`${n}d`:n}function Bn(e,s){return s<=0?"":`${e}/${s}`}function bs(e){return e<=0?"":`${e} live`}function mi(e){return e<=0?"":e===1?"1 session":`${e} sessions`}function fi(e){return e===1?"1 project":`${e} projects`}function hi(e){const s=mi(e.sessions);if(!s)return"";const n=bs(e.live_sessions);return n?`${s} · ${n}`:s}function pi(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 xi(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 gi(e){return e?e.total===1?"1 todo":`${e.total} todos`:""}function zn(e,s){const n=[],a=Ce(e.completed_at??e.target_date,s);a&&n.push({key:e.completed_at?"completed":"target",text:e.completed_at?`completed ${a}`:`due ${a}`});const r=Un(e.estimate,e.estimate_unit);r&&n.push({key:"estimate",text:r});const i=Bn(e.milestones_completed,e.milestones_total);i&&n.push({key:"milestones",text:`milestones ${i}`});const l=bs(e.live_sessions);return l&&n.push({key:"live",text:l}),n}const Ue=864e5,bi=/^(\d{4})-(\d{2})-(\d{2})$/;function pe(e){if(!e)return null;const s=bi.exec(e);if(!s)return null;const n=Number(s[1]),a=Number(s[2]),r=Number(s[3]),i=Date.UTC(n,a-1,r),l=new Date(i);return l.getUTCFullYear()!==n||l.getUTCMonth()!==a-1||l.getUTCDate()!==r?null:i}const Gt=["planning","active","qa","validation","done"],Vt=["paused","archived"],Pt=[{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}],Yn="7d",ji=Pt.find(e=>e.value===Yn);function Hn(e){return Pt.find(s=>s.value===e)??ji}function yi(e){return Pt.some(s=>s.value===e)}function Bs(e,s,n){const a=Hn(s);return a.seconds===null?e:e.filter(r=>n/1e3-r.updated_at<=a.seconds)}function vi(e){const s=Hn(e);return s.seconds===null?null:`Nothing changed in ${s.phrase}.`}const Wn="projects-board-window";function ki(){try{const e=localStorage.getItem(Wn);if(e!==null&&yi(e))return e}catch{}return Yn}function zs(e){try{localStorage.setItem(Wn,e)}catch{}}const Kn="projects-board-column-order";let Qt=null;function wi(){if(Qt)return[...Qt];try{const e=localStorage.getItem(Kn);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const n=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];n.includes(a)||n.push(a)}return n}catch{return[]}}function Ni(e){Qt=[...e];try{localStorage.setItem(Kn,JSON.stringify(e))}catch{}}function Si(e,s,n){const a=e.filter(i=>i!==s),r=Math.max(0,Math.min(n,a.length));return a.splice(r,0,s),a}function Ti(e,s=[]){const n=new Map;for(const o of e){const c=n.get(o.status)??[];c.push(o),n.set(o.status,c)}const a=Gt.map(o=>({status:o,projects:n.get(o)??[]}));for(const o of Vt){const c=n.get(o)??[];c.length>0&&a.push({status:o,projects:c})}for(const[o,c]of n)!Vt.includes(o)&&!Gt.includes(o)&&a.push({status:o,projects:c});if(s.length===0)return a;const r=new Map(s.map((o,c)=>[o,c])),i=a.filter(o=>r.has(o.status));i.sort((o,c)=>(r.get(o.status)??0)-(r.get(c.status)??0));const l=a.filter(o=>!r.has(o.status));return[...i,...l]}function Gn(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const n=pe(e.target_date);return n===null?!1:n<s}function G(e){return e.title||e.name}const js="No team";function mt(e){const s=e.team?.trim();if(s)return s;const n=e.owner?.trim();return n||null}function ys(e,s){const n=new Map,a=[];for(const i of e){const l=s(i);if(l===null){a.push(i);continue}const o=n.get(l);o?o.push(i):n.set(l,[i])}const r=[...n.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return a.length>0&&r.push({team:null,items:a}),r}function Mt(e){return e.title||e.session_id}function _i(e){return[...e].reverse()}function Ci(e){return e<=0?"":e===1?"1 update":`${e} updates`}const Ys=e=>String(e).padStart(2,"0");function Jt(e){return`${e.getFullYear()}-${Ys(e.getMonth()+1)}-${Ys(e.getDate())}`}function Ei(e){const s=Date.parse(e);return Number.isNaN(s)?"":Jt(new Date(s))}function Ri(e,s,n=new Date){if(!e)return"";if(e===Jt(n))return"Today";const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);return e===Jt(a)?"Yesterday":Ce(e,s,n)}function Di(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":Ba(new Date(n),{hour:"numeric",minute:"2-digit"},s)}function Ai(e,s){const n=Date.parse(e);return Number.isNaN(n)?"":ut(dt(n/1e3,s))}function Oi(e,s,n=Date.now()){const a=[],r=qn(e.by);r&&a.push({key:"author",text:r});const i=Di(e.at,s);i&&a.push({key:"time",text:i});const l=Ai(e.at,n);return l&&a.push({key:"age",text:l}),a}function $i(e,s,n=new Date){const a=[];for(const r of _i(e)){const i=Ei(r.at),l=a[a.length-1];if(l&&l.key===i){l.entries.push(r);continue}a.push({key:i,label:Ri(i,s,n),entries:[r]})}return a}function Pi(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 Mi(e,s){return s<=0?"":`${e} of ${s} complete`}function Ii(e){let s=0,n=0,a=!1;for(const r of e)r.todos&&(a=!0,s+=r.todos.open,n+=r.todos.total);return a?{open:s,total:n}:null}function Hs(e){return`${e.open} open of ${e.total}`}function Li(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Fi(e){const s=G(e),n=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${n}`,"Review the project details and continue or complete the work."].join(`
27
+ `)}function qi(e){return e?e.kind==="team"?`team ${e.name}`:`agent ${e.name}`:""}const Ui=/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"/g;function Vn(e){const s=[];for(const n of e.matchAll(Ui))s.push((n[1]??n[2]??"").replace(/\\(.)/g,"$1"));return s}const yt=3;function vs(e){if(e.length<=yt+1)return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;const s=e.length-yt;return`${e.slice(0,yt).join(", ")} and ${s} more`}function ks(e){return`${e} milestone${e===1?" is":"s are"}`}const Ws="complete them, or pass force_done=true to close with them open",Bi="complete or remove the incomplete milestones, then mark it done",Qn=/^cannot set status 'done': (\d+) milestones? still incomplete \((.+)\) — /;function ft(e){const s=e.match(Qn);if(s){const n=Number(s[1]),a=Vn(s[2]),r=a.length>0?vs(a):s[2];return`This can't be marked done yet: ${ks(n)} still incomplete (${r}). Complete or remove the incomplete milestones, then mark it done.`}return e.includes(Ws)?e.replace(Ws,Bi):e}const zi="project_done_incomplete";function Yi(e){const s=e.message.match(Qn),n=e.code===zi;if(!n&&!s)return null;const a=typeof e.detail=="object"&&e.detail!==null&&Array.isArray(e.detail.incomplete)?e.detail.incomplete.filter(l=>typeof l=="string"):null,r=a&&a.length>0?a:s?Vn(s[2]):[];return{count:r.length>0?r.length:s?Number(s[1]):0,names:r,coded:n,message:e.message}}function Hi(e){if(e.count>0){const s=vs(e.names);return`${ks(e.count)} still open${s?` (${s})`:""}.`}return ft(e.message)||"Some milestones are still open."}function Wi(e){return e.count>0&&e.names.length>0?`This can't be marked done yet: ${ks(e.count)} still incomplete (${vs(e.names)}). Complete or remove the incomplete milestones, then mark it done.`:ft(e.message)||"Milestones are still open on this project. Complete or remove them, then mark it done."}function Jn(e,s,n){if(!e||e.forced_done!==!0)return`Moved to ${n}`;const a=typeof e.milestones_total=="number"&&typeof e.milestones_completed=="number"?e.milestones_total-e.milestones_completed:s,r=a>0?a:s;return`Moved to ${n} with ${r} milestone${r===1?"":"s"} still open`}const Ki="The project was not moved. Try again, or open it to change its status.";function Xn(e){return e.trim().slice(0,Ir)}const Gi={client:"Searches names, descriptions, tags, owners and teams. Update text is not searched. Clearing the search and filters restores the list.",backend:"Searches names, descriptions, tags, owners, teams and update text. Clearing the search and filters restores the list."},Vi=2,Qi=4,Ji=3,Xi=2,Zi=1,eo=3,Ae={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},to=/[^\p{L}\p{N}]+/u,so=/\s+/;function Ks(e,s){const n=s.trim().toLowerCase();if(!n)return 0;if(n===e)return Qi;if(n.startsWith(e))return Ji;const a=n.split(to).filter(Boolean),r=e.split(so).filter(Boolean);if(r.length>0&&r.every(l=>a.some(o=>o.startsWith(l))))return Xi;const i=r.join("");return i.length>=eo&&no(i,n)?Zi:0}function no(e,s){let n=0;for(const a of e){if(n=s.indexOf(a,n),n<0)return!1;n+=1}return!0}function ao(e,s){const n=s.trim().toLowerCase();if(!n)return 0;const a=[[e.title,Ae.title],[e.name,Ae.name],[e.description,Ae.description],[e.owner,Ae.attribution],[e.team,Ae.attribution],[e.status,Ae.status]];let r=0;for(const[i,l]of a){if(!i)continue;const o=Ks(n,i)*l;o>r&&(r=o)}for(const i of e.tags){const l=Ks(n,i)*Ae.tags;l>r&&(r=l)}return r}function ro(e,s){const n=s.trim();if(!n)return e;const a=[];for(const r of e){const i=ao(r,n);i>0&&a.push({project:r,score:i})}return a.sort((r,i)=>{if(r.score!==i.score)return i.score-r.score;if(r.project.updated_at!==i.project.updated_at)return i.project.updated_at-r.project.updated_at;const l=G(r.project).localeCompare(G(i.project),void 0,{sensitivity:"base"});if(l!==0)return l;const o=r.project.name.localeCompare(i.project.name,void 0,{sensitivity:"base"});return o!==0?o:r.project.id<i.project.id?-1:r.project.id>i.project.id?1:0}),a.map(r=>r.project)}function io(e,s){if(s.length===0)return[];const n=new Map(e.map(r=>[r.id,r])),a=[];for(const r of s){const i=n.get(r.id);i!==void 0&&a.push(i)}return a}const oo=180;function lo(e,s){const n=Xn(e),a=Dn(n,oo),r=cs({queryKey:["desktop","projects","search",a],enabled:s&&a.length>0,queryFn:()=>ce({op:"projects.search",q:a,limit:Lr}),retry:!1,staleTime:3e4}),i=a===n,l=i&&r.data&&r.data.query===n?r.data:null,o=i&&n.length>0&&!l&&r.isError;return{answer:l,pending:s&&n.length>0&&!l&&!o}}const Qe=["status","team","owner","tags","progress","target","estimate","milestones","live"],Gs={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},nt={status:"Status",team:"Team",owner:"Owner",tags:"Tags",progress:"Progress",target:"Target date",estimate:"Estimate",milestones:"Milestones",live:"Live sessions"},co=new Set(["status","progress","target","estimate","milestones","live"]),uo={progress:["stale","up-to-date","not-reported"],target:["none","overdue","within-7","within-30"],estimate:["none","points","days"],milestones:["none","incomplete","complete"],live:["has-live","no-live"]},mo={stale:"Stale","up-to-date":"Up to date","not-reported":"Not reported",none:"No target date",overdue:"Overdue","within-7":"Due within 7 days","within-30":"Due within 30 days",points:"Points",days:"Days",incomplete:"Incomplete",complete:"Complete","has-live":"Has live sessions","no-live":"No live sessions"};function Zn(e,s){switch(e){case"status":return Z(s).label;case"team":return s===null?"No team":s;case"owner":return s===null?"No owner":s;case"tags":return s??"";case"estimate":if(s==="none")return"No estimate";break;case"milestones":if(s==="none")return"None set";break;case"target":if(s==="none")return"No target date";break}return mo[s]??s??""}function fo(e,s){return e[s].length>0}function rt(e){return Qe.every(s=>!fo(e,s))}function ho(e){return Qe.reduce((s,n)=>s+e[n].length,0)}function ea(e,s,n){const a=e[s],r=a.includes(n)?a.filter(i=>i!==n):[...a,n];return{...e,[s]:r}}function ta(e,s,n,a){switch(e){case"status":return s.status===n;case"team":return mt(s)===n;case"owner":return(s.owner?.trim()||null)===n;case"tags":return s.tags.includes(n??"");case"progress":return n==="stale"?s.progress_stale===!0:n==="up-to-date"?s.progress_stale===!1:s.progress_updated_at===null;case"target":{if(n==="none")return pe(s.target_date)===null;if(n==="overdue")return Gn(s,a);const r=pe(s.target_date);if(r===null)return!1;const i=(r-a)/Ue;return n==="within-7"?i>=0&&i<=7:i>=0&&i<=30}case"estimate":return n==="none"?s.estimate===null:s.estimate===null?!1:n==="points"?s.estimate_unit==="points":s.estimate_unit==="days";case"milestones":return n==="none"?s.milestones_total===0:s.milestones_total===0?!1:n==="complete"?s.milestones_completed>=s.milestones_total:s.milestones_completed<s.milestones_total;case"live":return n==="has-live"?s.live_sessions>0:s.live_sessions===0}}function sa(e,s,n,a){const r=e[s];return r.length===0?!0:r.some(i=>ta(s,n,i,a))}function po(e,s,n){return rt(s)?e:e.filter(a=>Qe.every(r=>sa(s,r,a,n)))}function xo(e,s,n,a){return s.filter(r=>Qe.every(i=>i===e||sa(n,i,r,a)))}function go(e,s,n){const a=n[e];switch(e){case"status":{const i=[...new Set(s.map(o=>o.status))].filter(o=>!qe.includes(o)).sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"})),l=a.filter(o=>typeof o=="string"&&!qe.includes(o)&&!i.includes(o));return[...qe,...i,...l]}case"team":{const r=new Set;let i=!1;for(const o of s){const c=mt(o);c===null?i=!0:r.add(c)}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"owner":{const r=new Set;let i=!1;for(const o of s){const c=o.owner?.trim();c?r.add(c):i=!0}for(const o of a)o===null?i=!0:r.add(o);const l=[...r].sort((o,c)=>o.localeCompare(c,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"tags":{const r=new Set;for(const i of s)for(const l of i.tags)r.add(l);for(const i of a)r.add(i??"");return[...r].sort((i,l)=>i.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return uo[e]}}function na(e,s,n,a){const r=xo(e,s,n,a),i=co.has(e),l=[];for(const o of go(e,r,n)){const c=n[e].includes(o),m=r.reduce((u,h)=>u+(ta(e,h,o,a)?1:0),0);!i&&m===0&&!c||l.push({value:o,label:Zn(e,o),count:m,selected:c})}return{facet:e,label:nt[e],options:l}}function bo(e,s,n){return Qe.map(a=>na(a,e,s,n))}const Xt="projects-sort",jo="Default (as listed)";function yo(e){return vo.includes(e)}const vo=["name","status","target","estimate","milestones","live","progress"];function ko(){try{const e=localStorage.getItem(Xt);if(e===null)return null;const[s,n,...a]=e.split(":");if(a.length>0)return null;if(s&&yo(s)&&(n==="asc"||n==="desc"))return{key:s,direction:n}}catch{}return null}function wo(e){try{e===null?localStorage.removeItem(Xt):localStorage.setItem(Xt,`${e.key}:${e.direction}`)}catch{}}function Ge(e){switch(e){case"name":return"Project";case"status":return"Status";case"target":return"Target";case"estimate":return"Estimate";case"milestones":return"Milestones";case"live":return"Live";case"progress":return"Progress"}}function qt(e){return e==="target"||e==="progress"?"desc":"asc"}function ws(e,s){const n=s==="desc";switch(e){case"name":return n?"Z to A":"A to Z";case"status":return n?"Archived first":"Planning first";case"target":return n?"latest first":"soonest first";case"estimate":return n?"days first":"points first";case"milestones":return n?"most complete first":"least complete first";case"live":return n?"most first":"fewest first";case"progress":return n?"most recent first":"most stale first"}}function No(e){return e===null?"Sort cleared.":`Sorted by ${Ge(e.key)}, ${ws(e.key,e.direction)}.`}function So(e){const s=[e.search?"search":null,e.filters?"filters":null,e.sort?"sort":null].filter(a=>a!==null);if(s.length===0)return"";const n=s.length===1?`${s[0]} cleared.`:`${s.slice(0,-1).join(", ")} and ${s[s.length-1]} cleared.`;return n.charAt(0).toUpperCase()+n.slice(1)}function Vs(e,s){switch(e){case"name":return 0;case"status":return qe.includes(s.status)?0:1;case"target":return Zt(s)===null?1:0;case"estimate":return s.estimate===null?1:0;case"milestones":return s.milestones_total===0?1:0;case"live":return 0;case"progress":return s.progress_updated_at===null?1:0}}function Zt(e){return pe(e.completed_at??e.target_date)}function Qs(e){return e==="points"?0:e==="days"?1:2}function To(e,s,n){switch(e){case"name":return G(s).localeCompare(G(n),void 0,{sensitivity:"base"});case"status":return qe.indexOf(s.status)-qe.indexOf(n.status);case"target":{const a=Zt(s)??0,r=Zt(n)??0;return a-r}case"estimate":{const a=Qs(s.estimate_unit)-Qs(n.estimate_unit);return a!==0?a:(s.estimate??0)-(n.estimate??0)}case"milestones":return s.milestones_completed*n.milestones_total-n.milestones_completed*s.milestones_total;case"live":return s.live_sessions-n.live_sessions;case"progress":return(s.progress_updated_at??0)-(n.progress_updated_at??0)}}function Js(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const n=G(e).localeCompare(G(s),void 0,{sensitivity:"base"});if(n!==0)return n;const a=e.name.localeCompare(s.name,void 0,{sensitivity:"base"});return a!==0?a:e.id<s.id?-1:e.id>s.id?1:0}function _o(e,s,n){const a=Vs(n.key,e),r=Vs(n.key,s);if(a!==r)return a-r;if(a===1)return Js(e,s);const i=To(n.key,e,s);return i!==0?n.direction==="desc"?-i:i:Js(e,s)}function Co(e,s){return[...e].sort((n,a)=>_o(n,a,s))}const Te=["day","week","month","quarter"],Ns={day:24,week:9,month:3,quarter:1};function Ss(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function Oe(e,s){return Math.round((s-e)/Ue)}function Xs(e,s){return Oe(e,s)+1}function Eo(e,s){for(const n of Te)if(e*Ns[n]<=s)return n;return Te[Te.length-1]}function Ro(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(n=>!!n.target_date)}function Do(e,s){const n=[s];for(const a of e){for(const r of[a.project.start_date,a.project.target_date,a.project.completed_at]){const i=pe(r);i!==null&&n.push(i)}for(const r of a.milestones){const i=pe(r.target_date);i!==null&&n.push(i)}}return n.length===1?null:{startMs:Math.min(...n),endMs:Math.max(...n)}}function Ao(e){const s=[],n=[];for(const a of e)(Ro(a)?s:n).push(a);return{dated:s,undated:n}}function Oo(e){return`${e} project${e===1?"":"s"} without dates`}function $o(e){const{project:s}=e,n=pe(s.start_date),a=pe(s.target_date),r=pe(s.completed_at),i=s.status==="done"&&r!==null?r:a,l=n??i,o=i??n;return l===null||o===null?null:{fromMs:Math.min(l,o),toMs:Math.max(l,o)}}function Po(e){const s=[];for(const n of e.milestones){const a=pe(n.target_date);a!==null&&s.push({name:n.name,dayMs:a,status:n.status})}return s}const jt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function Mo(e){const{year:s,month:n}=de(e);return Date.UTC(s,n-1,1)}function Io(e){const{year:s,month:n}=de(e);return n===12?Date.UTC(s+1,0,1):Date.UTC(s,n,1)}function Lo(e){const{year:s,month:n}=de(e);return Date.UTC(s,Math.floor((n-1)/3)*3,1)}function Fo(e){const{year:s,month:n}=de(e),a=Math.floor((n-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function qo(e){const{weekday:s}=de(e);return e-(s+6)%7*Ue}const Uo=26;function Bo(e,s,n){const a=[],r=(u,h,b)=>{u<e||u>s||a.push({dayMs:u,label:h,major:b})};if(n==="day"){let u=!1;for(let h=e;h<=s;h+=Ue){const{day:b,month:f}=de(h);b===1?(r(h,jt[f-1],!0),u=!0):u?(r(h,"",!1),u=!1):r(h,String(b),!1)}return a}if(n==="week"){for(let u=qo(e);u<=s;u+=7*Ue){if(u<e)continue;const{day:h,month:b}=de(u);de(u-7*Ue).month!==b?r(u,`${jt[b-1]} ${h}`,!0):r(u,String(h),!1)}return a}const i=n==="month"?Mo:Lo,l=n==="month"?Io:Fo,o=u=>{const{year:h,month:b}=de(u);if(n==="month")return b===1&&h!==de(e).year?`${jt[0]} '${String(h%100).padStart(2,"0")}`:jt[b-1];const f=Math.floor((b-1)/3)+1;return f===1&&h!==de(e).year?`Q1 '${String(h%100).padStart(2,"0")}`:`Q${f}`};r(e,o(i(e)),!0);const c=Math.ceil(Uo/Ns[n]);let m=e;for(let u=l(i(e));u<=s;u=l(u))Oe(m,u)<c||(r(u,o(u),!0),m=u);return a}function it(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}const Nt=80,St=80,Zs=64,en=8;function es(e){return e.trim().length>Nt?`Titles are at most ${Nt} characters.`:null}function aa(e){return e.length>Ke?`Keep the description within ${Ke} characters.`:null}function Tt(e,s){return e.trim().length>St?`${s==="owner"?"Owners":"Teams"} are at most ${St} characters.`:null}function ts(e){return Fn.test(e)?null:"Dates are YYYY-MM-DD, or empty."}function ss(e,s){return e&&s&&s<e?"The target date is before the start date.":null}function ra(e){const s=e.trim();if(s==="")return null;const n=Number(s);return!Number.isFinite(n)||!(n>0)||n>1e3?"Estimates are greater than 0 and at most 1000.":null}function ns(e){const s=it(e);if(s.length>en)return{tags:s,error:`Up to ${en} tags.`};for(const n of s){const a=Fr(n);if(a)return{tags:s,error:a}}return{tags:s,error:null}}const zo="project_name_exists";function tn(e){return e.code===zo?"A project with this key already exists.":ft(e.message)||"The project was not saved."}function Yo(e,s){if(e.unit!==s.unit)return!1;const n=e.number.trim(),a=s.number.trim();return a===""?!0:n===""?!1:Number(n)===Number(a)}function Ho(e,s){const n=it(s);return n.length!==e.length?!1:n.every((a,r)=>a===e[r])}function Wo(e,s){const n={},a=s.number.trim();if(a!==""){const r=Number(a);(e.estimate===null||e.estimate!==r)&&(n.estimate=r)}return s.unit!==e.unit&&(n.estimate_unit=s.unit),Object.keys(n).length>0?n:null}function Je(e){return e instanceof Rt?tn({code:e.code,message:e.message}):tn({message:e instanceof Error?e.message:""})}function ia(e){return e instanceof Rt&&(e.code==="project_not_found"||e.status===404)}function oa(e){return!(e instanceof Error)||!e.message?Ki:ia(e)?"This project could not be found. It may have been deleted.":Je(e)}function la(e){if(!(e instanceof Error))return null;const s=e instanceof Rt?e:null;return Yi({code:s?.code??null,message:e.message,detail:s?.detail})}async function Ko(e){try{return await e.move(),{kind:"accepted"}}catch(s){const n=la(s);return n?.coded&&e.forceDoneOffered&&e.claimQuestion()?{kind:"question",refusal:n}:{kind:"spoken",copy:n?Wi(n):oa(s),refusal:n}}}const Go="Shows projects last updated within this window; older ones are hidden.",Vo=({value:e,onChange:s})=>t.jsxs(ze,{value:e,onValueChange:n=>s(n),children:[t.jsx(At,{content:e==="all"?null:Go,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(He,{})})}),t.jsx(We,{children:Pt.map(n=>t.jsx(_e,{value:n.value,children:n.label},n.value))})]}),as=6e4,rs=6e3,sn="Requesting updates…",Qo=400,Jo="Ask the sessions linked to this project to post a progress update",Xo="linked but not yet in use — it becomes a recipient after the first message",nn=e=>`project-request-update-${e}`,Zo=e=>`project-request-cooldown-${e}`,el=e=>`project-request-update-cooldown-${e}`,Ut=e=>e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e[0]}, ${e[1]} and ${e.length-2} more`,an=(e,s)=>e.sessions.filter(n=>n.outcome===s).map(n=>Mt({session_id:n.session_id,title:n.title})),tl=e=>e.outcome==="failed"&&e.detail===Xo;function _t(e,s){const n=Math.max(1,Math.ceil(s/1e3));return`Update already requested ${Math.max(0,Math.ceil(as/1e3)-n)} s ago on ${e}. Try again in ${n} s.`}function sl(e){const s=G({title:e.project.title,name:e.project.key}),{delivered:n,unconfirmed:a,failed:r,total:i}=e.counts;if(e.state==="empty")return{variant:"info",title:`No linked sessions to ask. Link a session to ${s} first.`,duration:rs};if(e.state==="cooldown")return{variant:"info",title:_t(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:rs};if(e.state!=="sent")return null;const l=an(e,"failed"),o=an(e,"unconfirmed");if(n>=1&&r===0&&a===0)return{variant:"success",title:n===1?`Requested an update from 1 session on ${s}.`:`Requested updates from ${n} sessions on ${s}.`};if(n>=1){let c=`Requested updates from ${n} of ${i} sessions on ${s}.`;return r>0&&(c+=` ${Ut(l)} could not be reached.`),a>0&&(c+=` Delivery to ${Ut(o)} could not be confirmed.`),{variant:"warning",title:c,duration:Number.POSITIVE_INFINITY}}if(r===0)return{variant:"warning",title:`Could not confirm delivery on ${s} — the requests may still reach its sessions.`,duration:Number.POSITIVE_INFINITY};if(a===0){const c=e.sessions.every(tl);let m;return c?m=i===1?"The linked session has not started yet — it becomes a recipient after its first message.":`The ${i} linked sessions have not started yet — they become recipients after their first message.`:m=`Could not reach any of the ${i} linked sessions on ${s}.`,{variant:"error",title:m,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:`Could not reach ${r} of the ${i} linked sessions on ${s}. Delivery to ${Ut(o)} could not be confirmed.`,duration:Number.POSITIVE_INFINITY}}const st=new Map,Ts=new Set,Bt=new Map,is=new Set;let ca=0;const Ct=()=>{ca+=1;for(const e of is)e()},nl=e=>(is.add(e),()=>{is.delete(e)}),rn=()=>ca,da=e=>Ts.has(e),ua=e=>st.get(e);function al(e){Ts.add(e),Ct()}function rl(e){Ts.delete(e),Ct()}function on(e,s,n){const a=Date.now();if(n<=a)return;const r=st.get(e);if(r&&r.untilMs>=n)return;st.set(e,{startedMs:s,untilMs:n});const i=Bt.get(e);i&&clearTimeout(i);const l=setTimeout(()=>{Bt.delete(e);const o=st.get(e);o&&o.untilMs<=Date.now()&&(st.delete(e),Ct())},n-a);l.unref?.(),Bt.set(e,l),Ct()}const il=e=>/[.!?…]$/.test(e)?e:`${e}.`;function ol(e,s){const n=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;on(e,n-(as-a),n+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&on(e,n,n+as)}async function ll(e){const s=e.id;if(da(s)){$s(sn,{id:nn(s)});return}const n=Date.now(),a=ua(s);if(a&&a.untilMs>n){Ps(_t(G(e),a.untilMs-n),{id:Zo(s),duration:rs});return}al(s);const r=nn(s);let i=!1;const l=setTimeout(()=>{i=!0,$s(sn,{id:r})},Qo);try{const o=await ce({op:"projects.request_update",key:s});ol(s,o);const c=sl(o);if(c){const m={id:r,...c.duration!==void 0?{duration:c.duration}:{}};switch(c.variant){case"success":fe(c.title,m);break;case"warning":za(c.title,m);break;case"error":Ms(c.title,m);break;default:Ps(c.title,m)}}else i&&Ya(r)}catch(o){const c=o instanceof Error&&o.message.trim()!==""?o.message.trim():null;Ms(c?`Could not request updates: ${il(c)}`:"The request could not be confirmed.",{id:r,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),rl(s)}}function ma(){return d.useCallback(e=>{ll(e)},[])}function cl(e){d.useSyncExternalStore(nl,rn,rn);const s=da(e),n=ua(e),a=n!==void 0?n.untilMs-Date.now():0,r=a>0;return{sending:s,cooling:r,cooldownRemainingMs:r?a:null}}const ln={active:"In flight",paused:"On hold",done:"Finished"};function dl(){const[e,s]=d.useState(null);return d.useEffect(()=>{if(!e)return;const n=document.querySelector(`[data-project-menu="${e}"]`);n&&(n.focus(),s(null))}),d.useCallback(n=>s(n),[])}const ul=4,zt="Drag the header, or press the arrow keys, to move this column.",cn="board-column-move-hint",ml=({projects:e,nowMs:s,onOpen:n,onEdit:a,onDelete:r,onMove:i,movingKeys:l=[],teamLabelFor:o=c=>c})=>{const[c,m]=d.useState(wi),u=Ti(e,c),h=ys(e,mt),[b,f]=d.useState(null),[j,v]=d.useState(""),g=d.useRef(null),x=d.useRef(null),y=d.useRef(null),C=d.useRef(null),w=d.useRef(null),L=new Set(l),T=(k,N)=>{const R=Si(u.map(M=>M.status),k,N);m(R),Ni(R),v(`Moved ${Z(k).label} column to position ${R.indexOf(k)+1} of ${R.length}.`)},_=(k,N)=>{const R=g.current;if(!R)return 0;let M=0;const F=R.querySelectorAll("[data-board-column]");for(const q of F){if(q.dataset.boardColumn===N)continue;const ae=q.getBoundingClientRect();k>(ae.left+ae.right)/2&&(M+=1)}return M},O=(k,N)=>{const R=u.filter(q=>q.status!==k),M=R[N-1]?.status,F=R[N]?.status;return M&&F?`between ${Z(M).label} and ${Z(F).label}`:F?`before ${Z(F).label}`:M?`after ${Z(M).label}`:"in place"},p=(k,N)=>{const R=_(k,N.status);R!==N.over&&(N.over=R,f({status:N.status,over:R}),v(`Moving ${Z(N.status).label} column; it will drop ${O(N.status,R)}.`))},A=()=>{C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)},E=32,P=12,z=()=>{C.current=null;const k=w.current,N=g.current,R=y.current;if(!k?.armed||!N||R===null)return;const M=N.getBoundingClientRect(),F=N.scrollWidth-N.clientWidth;let q=0;if(R-M.left<E&&N.scrollLeft>0?q=-1:M.right-R<E&&N.scrollLeft<F&&(q=1),q!==0){const ae=N.scrollLeft;N.scrollLeft=ae+q*P,N.scrollLeft!==ae&&p(R,k)}else p(R,k);Q(k.status,k.over),C.current=requestAnimationFrame(z)};d.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]);const I=(k,N)=>{if(k.button===0){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}w.current={pointerId:k.pointerId,status:N,startX:k.clientX,startY:k.clientY,armed:!1,over:u.findIndex(R=>R.status===N)},y.current=k.clientX}},B=k=>{const N=w.current;if(!(!N||k.pointerId!==N.pointerId)){if(y.current=k.clientX,!N.armed){if(Math.hypot(k.clientX-N.startX,k.clientY-N.startY)<ul)return;N.armed=!0,f({status:N.status,over:N.over}),v(`Moving ${Z(N.status).label} column.`),C.current===null&&(C.current=requestAnimationFrame(z))}p(k.clientX,N)}},W=k=>{const N=w.current;if(w.current=null,A(),f(null),!N?.armed)return;if(!k){v("Move cancelled.");return}const R=u.findIndex(M=>M.status===N.status);if(N.over===R){v("");return}T(N.status,N.over)},V=k=>{const N=w.current;!N||k.pointerId!==N.pointerId||W(!0)},le=()=>{W(!1)};d.useEffect(()=>{if(!b)return;const k=N=>{N.key==="Escape"&&W(!1)};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[b!==null]);const Q=d.useCallback((k,N)=>{const R=g.current,M=x.current;if(!R||!M)return;const F=R.getBoundingClientRect(),q=[];for(const re of R.querySelectorAll("[data-board-column]"))re.dataset.boardColumn!==k&&q.push(re.getBoundingClientRect());const ae=6,Re=N>=q.length?(q[q.length-1]?.right??F.left)+ae:(q[N]?.left??F.right)-ae,Y=R.scrollLeft,Ne=2,ge=Re-F.left+Y,me=Y+1,X=Y+F.width-Ne-1,De=Math.round(Math.min(Math.max(ge,me),Math.max(me,X)));M.style.left=`${De}px`},[]);d.useLayoutEffect(()=>{b&&Q(b.status,b.over)},[b,Q]);const J=(k,N)=>{if(k.key==="Enter"||k.key===" "){k.preventDefault(),v(zt);return}if(k.key!=="ArrowLeft"&&k.key!=="ArrowRight")return;k.preventDefault();const R=u.map(q=>q.status),M=R.indexOf(N),F=k.key==="ArrowLeft"?M-1:M+1;if(F<0||F>=R.length){v(`${Z(N).label} column is already ${F<0?"the first column":"the last column"}.`);return}T(N,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:j}),t.jsx("span",{id:cn,className:"sr-only",children:zt}),t.jsxs("div",{ref:g,"data-board-strip":"",className:$("relative flex min-h-0 flex-1 items-start overflow-auto px-6 pb-9",b&&"cursor-grabbing select-none"),children:[b&&t.jsx("div",{ref:x,"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:u.map(k=>{const N=Z(k.status);return t.jsxs("header",{"data-board-column":k.status,"data-board-column-handle":k.status,onPointerDown:R=>I(R,k.status),onPointerMove:B,onPointerUp:V,onPointerCancel:le,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",b?.status===k.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(U,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":k.status,"aria-label":`Move ${N.label} column`,"aria-describedby":cn,title:zt,className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:R=>J(R,k.status),children:t.jsx(Ar,{"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:N.label}),ln[k.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:ln[k.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:k.projects.length})]},k.status)})}),h.map(k=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":k.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:k.team==null?js:o(k.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:k.items.length})]})}),t.jsx("div",{className:"flex gap-3 rounded-md bg-sunken py-2",children:u.map(N=>{const R=k.items.filter(M=>M.status===N.status);return t.jsx("div",{"data-board-cell":N.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:R.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:R.map(M=>t.jsx("li",{children:t.jsx(fl,{project:M,nowMs:s,busy:L.has(M.id),onOpen:()=>n(M),onEdit:()=>a(M),onDelete:()=>r(M),onMove:F=>i(M,F)})},M.id))})},N.status)})})]},k.team??""))]})]})]})},fl=({project:e,nowMs:s,busy:n,onOpen:a,onEdit:r,onDelete:i,onMove:l})=>{const o=Ee(),c=zn(e,o),m=Ve(),u=ma(),h=he(m.data,"projects_request_update"),b=G(e),f=d.useRef(null),[j,v]=d.useState(!1);d.useEffect(()=>{const w=f.current;if(!w)return;const L=()=>{w.isConnected&&v(w.scrollWidth-w.clientWidth>.5)},T=requestAnimationFrame(L),_=new ResizeObserver(L);return _.observe(w),document.fonts?.ready.then(L).catch(()=>{}),()=>{cancelAnimationFrame(T),_.disconnect()}},[b,j]);const g=Gn(e,Ss(s)),x=dt(e.progress_updated_at,s),y=()=>{const w=window.getSelection();w&&!w.isCollapsed||a()},C=w=>{w.key!=="Enter"&&w.key!==" "||w.target===w.currentTarget&&(w.preventDefault(),a())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":`Open ${b}`,onClick:y,onKeyDown:C,className:$("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",g&&"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(At,{content:j?b:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:f,"data-project-title":e.name,tabIndex:j?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:b})}),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(us,{children:[t.jsx(ms,{"data-project-menu":e.id,"aria-label":`Actions for ${b}`,disabled:n,onClick:w=>w.stopPropagation(),className:$("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:n?t.jsx(we,{size:"xs"}):t.jsx(wn,{className:"size-4"})}),t.jsxs(fs,{align:"end",onClick:w=>w.stopPropagation(),children:[t.jsx(ke,{onSelect:a,children:"Open"}),t.jsxs(kr,{children:[t.jsx(wr,{children:"Set status"}),t.jsx(Nr,{children:t.jsx(Sr,{value:e.status,onValueChange:l,children:[...Gt,...Vt].map(w=>t.jsx(Tr,{value:w,children:Z(w).label},w))})})]}),h&&t.jsx(ke,{onSelect:()=>u(e),children:"Request update"}),t.jsx(_r,{}),t.jsx(ke,{onSelect:r,children:"Edit"}),t.jsx(ke,{onSelect:i,children:"Delete"})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[c.filter(w=>w.key!=="live").map(w=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:w.text},w.key)),g&&t.jsx(xe,{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:di(x)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!x)&&t.jsx("span",{"aria-label":wt,title:wt,className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(hl,{project:e})]})]})]})},hl=({project:e})=>{const[s,n]=d.useState(!1),a=Dt(),r=$n(e.id,s),i=r.data?.links??[],l=hi(e),o=G(e);return t.jsxs(hs,{open:s,onOpenChange:n,children:[t.jsx(ps,{"data-project-sessions":e.id,"aria-label":`Sessions linked to ${o}`,onClick:c=>c.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:l}),t.jsx(xs,{align:"end",className:"w-64 p-2 outline-none",onClick:c=>c.stopPropagation(),children:r.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:"Loading linked sessions…"}):r.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:r.error instanceof Error&&r.error.message?r.error.message:"The linked sessions could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void r.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(c=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!c.exists,onClick:()=>{c.exists&&(n(!1),An(a,c.session_id))},className:$("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",c.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:c.title||c.session_id})})},c.session_id))})})]})},fa=({open:e,projectName:s,onClose:n,onConfirm:a})=>{const[r,i]=d.useState(""),[l,o]=d.useState(null),[c,m]=d.useState(!1),u=d.useId();d.useEffect(()=>{e&&(i(""),o(null),m(!1))},[e]);const h=r.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,b=async()=>{m(!0),o(null);try{await a(r.trim()),n()}catch(f){o(f instanceof Error&&f.message?f.message:"The project was not deleted.")}finally{m(!1)}};return t.jsx(lt,{open:e,onClose:n,title:"Delete this project?",dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:n,disabled:c,children:"Cancel"}),t.jsxs(Ha,{onClick:()=>void b(),disabled:!h||c,children:[c&&t.jsx(we,{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(ne,{id:`${u}-confirm`,value:r,onChange:f=>i(f.target.value),placeholder:s,"aria-label":"Type the project name to confirm","aria-invalid":r.length>0&&!h,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})};function pl(e){return e==="editing"||e==="saving"||e==="error"}function xl(e,s,n=Object.is){return!n(e,s)}function gl(e,s){if(e.key==="Escape")return e.defaultPrevented===!0?null:"revert";if(e.key!=="Enter"||!s.keyboardCommit)return null;const n=e.metaKey===!0||e.ctrlKey===!0;return s.multiline?n?"accept":null:s.onEditor?"accept":null}function bl(e,s){return e==="saving"||e==="error"?!0:e==="editing"&&s}function jl(e){const{phase:s,base:n,draft:a,fresh:r,equals:i}=e;return s==="saving"||s==="saved"||i(n,r)?"none":s==="idle"||i(n,a)||i(r,a)?"adopt":"conflict"}function dn(e,s,n=Object.is){return!n(e,s)}const _s="group/inline-edit",Yt="inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-xs text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",yl="relative before:absolute before:-inset-1.5 before:content-['']",vl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-left-1.5 before:right-0 before:content-['']",kl="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-right-1.5 before:left-0 before:content-['']",os=({api:e,idle:s="affordance",className:n})=>{const{phase:a,labels:r}=e,i=a==="editing"||a==="saving"||a==="error",l=bl(a,e.dirty),o=e.acceptBlocked===!0;return t.jsx("span",{"data-inline-edit-slot":a,className:$("inline-flex shrink-0 items-center gap-0.5",n),children:l?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","data-inline-edit-control":"cancel","aria-label":a==="saving"?r.busy:r.cancel,title:a==="saving"?r.busy:r.cancel,"aria-disabled":a==="saving"||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||a!=="saving"&&e.cancel()},className:$(Yt,vl,a==="saving"&&"cursor-default text-ink-disabled"),children:t.jsx(Ot,{className:"size-3","aria-hidden":"true"})}),a==="saving"?t.jsx("span",{"data-inline-edit-control":"busy",className:"inline-flex size-5 shrink-0 items-center justify-center",children:t.jsx(we,{size:"xs"})}):t.jsx("button",{type:"button","data-inline-edit-control":"accept","aria-label":a==="error"?r.retry??r.accept:r.accept,title:a==="error"?r.retry??r.accept:r.accept,"aria-disabled":o||void 0,onMouseDown:c=>c.preventDefault(),onClick:c=>{c.detail>1||o||e.accept()},className:$(Yt,kl,o&&"cursor-default text-ink-disabled"),children:t.jsx(gs,{className:"size-3","aria-hidden":"true"})})]}):i?null:s==="affordance"?t.jsx("button",{ref:e.slotRef,type:"button","data-inline-edit-control":"begin","aria-label":r.begin,title:r.begin,onClick:c=>{c.detail>1||e.begin()},className:$(Yt,yl,"opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","focus-visible:opacity-100"),children:t.jsx(Wa,{className:"size-3","aria-hidden":"true"})}):null})},ls=({api:e,className:s})=>{Ee();const{phase:n,error:a,conflict:r}=e;return n==="saved"?t.jsx("p",{"data-inline-edit-feedback":"saved",className:$("text-meta text-success",s),children:e.labels.saved}):!a&&!r?null:t.jsxs("div",{id:e.feedbackId,"data-inline-edit-feedback":a&&r?"error+conflict":a?"error":"conflict",role:"alert",className:$("flex flex-wrap items-center gap-x-3 gap-y-1",s),children:[a&&t.jsx("p",{className:"text-meta text-danger",children:a}),a&&r===null&&t.jsx("button",{type:"button","data-inline-edit-control":"retry",onClick:()=>e.accept(),className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:bt("ui.common.actions.retry")}),r!==null&&t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-warning",children:bt("ui.common.editing.conflict")}),t.jsx("button",{type:"button","data-inline-edit-control":"keep-mine",onClick:e.keepMine,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:bt("ui.common.editing.keep_mine")}),t.jsx("button",{type:"button","data-inline-edit-control":"use-theirs",onClick:e.useTheirs,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:bt("ui.common.editing.use_theirs")})]})]})},ha=d.createContext(null),wl=50,Nl=({children:e})=>{const[s,n]=d.useState(""),a=d.useMemo(()=>({current:r=>{n(""),window.setTimeout(()=>n(r),wl)}}),[]);return t.jsxs(ha.Provider,{value:a,children:[e,t.jsx("span",{"data-inline-edit-announcement":"","aria-live":"polite",className:"sr-only",children:s})]})},Sl=1200;function Tl(e){return e instanceof Error&&e.message?e.message:"The change was not saved."}function ht(e){const{value:s,multiline:n=!1,keyboardCommit:a=!0,selectAllOnBegin:r=!1,beginOnMount:i=!1,savedDwellMs:l=Sl,labels:o}=e,c=d.useRef(e.equals??Object.is);c.current=e.equals??Object.is;const m=d.useRef(e.commit);m.current=e.commit;const u=d.useRef(e.validate);u.current=e.validate;const h=d.useRef(e.errorCopy);h.current=e.errorCopy;const b=d.useRef(e.onSettle);b.current=e.onSettle;const f=d.useRef(e.onBegin);f.current=e.onBegin;const j=d.useRef(o);j.current=o;const[v,g]=d.useState(i?"editing":"idle"),[x,y]=d.useState(s),[C,w]=d.useState(s),[L,T]=d.useState(null),[_,O]=d.useState(null),p=d.useRef(v),A=d.useRef(x),E=d.useRef(C),P=d.useRef(L),z=d.useRef(s);z.current=s;const I=d.useCallback(D=>{p.current=D,g(D)},[]),B=d.useCallback(D=>{A.current=D,y(D)},[]),W=d.useCallback(D=>{E.current=D,w(D)},[]),V=d.useCallback(D=>{P.current=D,T(D)},[]),le=d.useRef(null),Q=d.useRef(null),J=d.useRef(null),k=e.editorRef??J,N=d.useRef(k);N.current=k;const R=`${d.useId()}-inline-edit`,M=d.useContext(ha),F=d.useRef(null),q=F.current,Re=q!==null&&(e.equals??Object.is)(s,q.previous)&&!(e.equals??Object.is)(s,q.saved)&&q!==null?q.saved:s,Y=d.useRef(Re);Y.current=Re,d.useEffect(()=>{const D=F.current;if(D===null)return;const te=c.current;(te(s,D.saved)||!te(s,D.previous))&&(F.current=null)},[s]);const Ne=d.useRef(i);d.useEffect(()=>{if(v!=="editing"||!Ne.current)return;Ne.current=!1;const D=N.current.current;D&&(D.focus(),r&&(D instanceof HTMLInputElement||D instanceof HTMLTextAreaElement)&&D.select())},[v,r]);const ge=d.useRef(!1);d.useEffect(()=>{ge.current&&(v!=="idle"&&v!=="saved"||(ge.current=!1,Q.current?.focus()))});const me=d.useRef(null),X=d.useCallback(()=>{me.current!==null&&(clearTimeout(me.current),me.current=null)},[]);d.useEffect(()=>()=>X(),[X]);const De=d.useRef(v);d.useEffect(()=>{const D=De.current;if(De.current=v,D==="saving"&&v==="saved"){b.current?.("saved");return}(D==="editing"||D==="error")&&v==="idle"&&b.current?.("cancelled")},[v]),d.useEffect(()=>{const D=jl({phase:p.current,base:E.current,draft:A.current,fresh:Y.current,equals:c.current});D==="adopt"?(c.current(E.current,Y.current)||W(Y.current),c.current(Y.current,A.current)||B(Y.current)):D==="conflict"&&(P.current===null||!c.current(P.current,Y.current))&&V(Y.current)},[s,v,W,B,V]);const re=d.useCallback(D=>{V(null),O(null),B(E.current),I("idle"),D&&(ge.current=!0)},[V,B,I]),Xe=d.useCallback(()=>{p.current!=="saving"&&(p.current==="idle"||p.current==="saved"||(X(),re(!0)))},[X,re]),ee=d.useCallback((D,te=!0)=>{const tt=p.current;if(tt==="saving"||tt==="saved"||P.current!==null)return;const be=D!==void 0?D:A.current;if(!dn(E.current,be,c.current)){re(te&&tt!=="idle");return}const xt=u.current?.(be)??null;if(xt!==null){I("error"),O(xt);return}B(be),O(null),I("saving"),m.current(be).then(()=>{p.current==="saving"&&(F.current={saved:be,previous:E.current},W(be),B(be),te&&(ge.current=!0),I("saved"),X(),me.current=setTimeout(()=>{me.current=null,p.current==="saved"&&I("idle")},l),M?.current?.(j.current.saved))},Le=>{p.current==="saving"&&(I("error"),O(h.current?h.current(Le):Tl(Le)))})},[M,X,re,l,W,B,I]),Se=d.useCallback(()=>{p.current==="editing"||p.current==="saving"||(X(),Ne.current=!0,B(Y.current),W(Y.current),V(null),O(null),I("editing"),f.current?.())},[X,W,V,B,I]),Ie=d.useCallback(()=>{const D=P.current;D!==null&&(V(null),W(D),ee())},[ee,W,V]),Lt=d.useCallback(()=>{const D=P.current;D!==null&&(W(D),re(!0))},[re,W]),Ze=d.useCallback(D=>{const te=gl(D,{multiline:n,keyboardCommit:a,onEditor:D.target===N.current.current});if(te==="revert"){D.preventDefault(),Xe();return}te==="accept"&&(D.preventDefault(),ee())},[ee,Xe,a,n]),et=d.useCallback(D=>{if(p.current!=="editing")return;const te=D.relatedTarget;if(!(te!==null&&le.current?.contains(te))&&!(te instanceof Element&&te.closest("[data-radix-popper-content-wrapper]")!==null)&&P.current===null){if(!dn(E.current,A.current,c.current)){re(!1);return}ee(void 0,!1)}},[ee,re]),pt=v==="saved"?x:Re;return{phase:v,dirty:xl(C,x,c.current),conflict:L,error:_,draft:x,setDraft:B,displayValue:pt,editing:pl(v),begin:Se,accept:ee,cancel:Xe,keepMine:Ie,useTheirs:Lt,handleKeyDown:Ze,handleBlur:et,fieldProps:{onKeyDown:Ze,onBlur:et,"aria-busy":v==="saving"?!0:void 0},editorAria:{"aria-invalid":_!==null?!0:void 0,"aria-describedby":_!==null||L!==null?R:void 0},fieldRef:le,editorRef:k,slotRef:Q,feedbackId:R,labels:o}}const _l=/^(https?:|mailto:)/i,Cl={a:({href:e,children:s})=>typeof e=="string"&&_l.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:Ga},ot=d.memo(({children:e,className:s})=>t.jsx("div",{className:$("lo-markdown",s),children:t.jsx(Ka,{remarkPlugins:[Va],components:Cl,children:e})})),un=`## Summary
28
28
 
29
29
  ## Goals
30
30
 
31
- ## Notes`,Dl=new RegExp("\\p{Mn}","gu"),Al=/[^a-z0-9._-]+/g,Ol=/[._-]{2,}/g,$l=/^[^a-z0-9]+/,un=/[^a-z0-9]+$/;function Pl(e){return e.normalize("NFKD").replace(Dl,"").toLowerCase().replace(Al,"-").replace(Ol,"-").replace($l,"").replace(un,"").slice(0,64).replace(un,"")}const Ml=/&#x([0-9a-f]+);/gi,Il=/&#(\d+);/g,Ll=/&nbsp;/g,Fl=/&lt;/g,ql=/&gt;/g,Ul=/&quot;/g,Bl=/&#39;|&apos;/g,zl=/&amp;/g,mn=e=>e.replace(Ml,(s,n)=>String.fromCodePoint(Number.parseInt(n,16))).replace(Il,(s,n)=>String.fromCodePoint(Number.parseInt(n,10))).replace(Ll," ").replace(Fl,"<").replace(ql,">").replace(Ul,'"').replace(Bl,"'").replace(zl,"&"),Yl=/<[^>]*>|[^<]+/g,Hl=/^<\//,Wl=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,Kl=/\s+/g,fn=/class="[^"]*language-([\w+-]+)/,Gl=/href="([^"]*)"/,Vl=/src="([^"]*)"/,Ql=/alt="([^"]*)"/,Jl=/[ \t]+\n/g,Xl=/\n{3,}/g;function Zl(e){const s=[],n=(...m)=>{for(let u=s.length-1;u>=0;u--)if(m.includes(s[u].tag)){const[h]=s.splice(u,1);return h}},a=[],r=()=>s.some(m=>m.tag==="pre"),i=()=>s.filter(m=>m.tag==="blockquote").length;let l=!0;const o=m=>{m&&(i()>0&&l&&!r()&&a.push("> ".repeat(i())),a.push(m),l=m.endsWith(`
32
- `))},c=e.match(Yl)??[];for(let m=0;m<c.length;m++){const u=c[m];if(!u.startsWith("<")){o(r()?mn(u):mn(u).replace(Kl," "));continue}const h=Hl.test(u),b=(u.match(Wl)?.[1]??"").toLowerCase();if(h){switch(b){case"p":case"div":o(`
31
+ ## Notes`,El=new RegExp("\\p{Mn}","gu"),Rl=/[^a-z0-9._-]+/g,Dl=/[._-]{2,}/g,Al=/^[^a-z0-9]+/,mn=/[^a-z0-9]+$/;function Ol(e){return e.normalize("NFKD").replace(El,"").toLowerCase().replace(Rl,"-").replace(Dl,"-").replace(Al,"").replace(mn,"").slice(0,64).replace(mn,"")}const $l=/&#x([0-9a-f]+);/gi,Pl=/&#(\d+);/g,Ml=/&nbsp;/g,Il=/&lt;/g,Ll=/&gt;/g,Fl=/&quot;/g,ql=/&#39;|&apos;/g,Ul=/&amp;/g,fn=e=>e.replace($l,(s,n)=>String.fromCodePoint(Number.parseInt(n,16))).replace(Pl,(s,n)=>String.fromCodePoint(Number.parseInt(n,10))).replace(Ml," ").replace(Il,"<").replace(Ll,">").replace(Fl,'"').replace(ql,"'").replace(Ul,"&"),Bl=/<[^>]*>|[^<]+/g,zl=/^<\//,Yl=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,Hl=/\s+/g,hn=/class="[^"]*language-([\w+-]+)/,Wl=/href="([^"]*)"/,Kl=/src="([^"]*)"/,Gl=/alt="([^"]*)"/,Vl=/[ \t]+\n/g,Ql=/\n{3,}/g;function Jl(e){const s=[],n=(...m)=>{for(let u=s.length-1;u>=0;u--)if(m.includes(s[u].tag)){const[h]=s.splice(u,1);return h}},a=[],r=()=>s.some(m=>m.tag==="pre"),i=()=>s.filter(m=>m.tag==="blockquote").length;let l=!0;const o=m=>{m&&(i()>0&&l&&!r()&&a.push("> ".repeat(i())),a.push(m),l=m.endsWith(`
32
+ `))},c=e.match(Bl)??[];for(let m=0;m<c.length;m++){const u=c[m];if(!u.startsWith("<")){o(r()?fn(u):fn(u).replace(Hl," "));continue}const h=zl.test(u),b=(u.match(Yl)?.[1]??"").toLowerCase();if(h){switch(b){case"p":case"div":o(`
33
33
 
34
34
  `);break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":n(b),o(`
35
35
 
36
36
  `);break;case"li":{n("li"),o(`
37
37
  `);const f=[...s].reverse().find(j=>j.tag==="ul"||j.tag==="ol");f?.ordered&&(f.index=(f.index??1)+1);break}case"ul":case"ol":n(b),o(`
38
38
  `);break;case"strong":case"b":n("strong","b")&&o("**");break;case"em":case"i":n("em","i")&&o("*");break;case"del":case"s":n("del","s")&&o("~~");break;case"code":{n("code")?.inline&&o("`");break}case"pre":n("pre")&&o("\n```\n\n");break;case"a":{const f=n("a");f?.href&&o(`](${f.href})`);break}case"blockquote":n("blockquote")&&o(`
39
- `);break}continue}switch(b){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const f=Number(b[1]);s.push({tag:b}),o(`${"#".repeat(f)} `);break}case"ul":case"ol":s.push({tag:b,ordered:b==="ol",index:1});break;case"li":{const f=[...s].reverse().find(j=>j.tag==="ul"||j.tag==="ol");s.push({tag:"li"}),f?.ordered?o(`${f.index??1}. `):o("- ");break}case"strong":case"b":s.push({tag:b}),o("**");break;case"em":case"i":s.push({tag:b}),o("*");break;case"del":case"s":s.push({tag:b}),o("~~");break;case"code":{const f=s[s.length-1]?.tag!=="pre";s.push({tag:"code",inline:f}),f&&o("`");break}case"pre":{const f=u.match(fn)?.[1]??c[m+1]?.match(fn)?.[1]??"";s.push({tag:"pre"}),o(`
39
+ `);break}continue}switch(b){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const f=Number(b[1]);s.push({tag:b}),o(`${"#".repeat(f)} `);break}case"ul":case"ol":s.push({tag:b,ordered:b==="ol",index:1});break;case"li":{const f=[...s].reverse().find(j=>j.tag==="ul"||j.tag==="ol");s.push({tag:"li"}),f?.ordered?o(`${f.index??1}. `):o("- ");break}case"strong":case"b":s.push({tag:b}),o("**");break;case"em":case"i":s.push({tag:b}),o("*");break;case"del":case"s":s.push({tag:b}),o("~~");break;case"code":{const f=s[s.length-1]?.tag!=="pre";s.push({tag:"code",inline:f}),f&&o("`");break}case"pre":{const f=u.match(hn)?.[1]??c[m+1]?.match(hn)?.[1]??"";s.push({tag:"pre"}),o(`
40
40
  \`\`\`${f}
41
- `);break}case"a":{const f=u.match(Gl)?.[1]??"";s.push({tag:"a",href:f}),f&&o("[");break}case"img":{const f=u.match(Vl)?.[1]??"",j=u.match(Ql)?.[1]??"";f&&o(`![${j}](${f})`);break}case"br":o(`
42
- `);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(Jl,`
43
- `).replace(Xl,`
41
+ `);break}case"a":{const f=u.match(Wl)?.[1]??"";s.push({tag:"a",href:f}),f&&o("[");break}case"img":{const f=u.match(Kl)?.[1]??"",j=u.match(Gl)?.[1]??"";f&&o(`![${j}](${f})`);break}case"br":o(`
42
+ `);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(Vl,`
43
+ `).replace(Ql,`
44
44
 
45
- `).trim()}function ha(e,s,n){const a=e.clipboardData?.getData("text/html");if(!a)return;const r=Zl(a);if(!r)return;e.preventDefault();const i=e.currentTarget,l=i.selectionStart??i.value.length,o=i.selectionEnd??l;n(i.value.slice(0,l)+r+i.value.slice(o)),requestAnimationFrame(()=>{const c=s.current;if(!c)return;const m=l+r.length;c.setSelectionRange(m,m)})}const pa=({open:e,refusal:s,projectLabel:n,onClose:a,onConfirm:r,secondaryLabel:i,onSecondary:l})=>{const[o,c]=d.useState(!1),[m,u]=d.useState(null),h=d.useRef(!1),b=d.useRef(null);d.useEffect(()=>{e&&(c(!1),u(null),h.current=!1)},[e]);const f=async()=>{if(!h.current){h.current=!0,c(!0),u(null);try{await r(),a()}catch(v){u({copy:ia(v),gone:ra(v)})}finally{h.current=!1,c(!1)}}},j=s?.names??[];return t.jsx(lt,{open:e,onClose:a,title:"Mark done with open milestones?",dataTourTag:"project-done-anyway-dialog",maxWidth:"xs",dialogProps:{closeDisabled:o,onEscapeKeyDown:v=>{o&&v.preventDefault()},onInteractOutside:v=>{o&&v.preventDefault()},onOpenAutoFocus:v=>{v.preventDefault(),b.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(Be,{ref:b,onClick:a,disabled:o,children:"Cancel"}),!m?.gone&&t.jsx(Be,{onClick:l,disabled:o,children:i}),m?.gone?t.jsx(yt,{"data-project-force-close":"",onClick:a,children:"Close"}):t.jsxs(yt,{"data-project-force-done":"","aria-disabled":o,className:"aria-disabled:pointer-events-none aria-disabled:bg-sunken aria-disabled:text-ink-disabled",onClick:()=>void f(),children:[o?t.jsx(we,{size:"xs"}):t.jsx("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),"Mark done anyway"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink break-words",children:n?`${n} moves to Done and its milestones stay open.`:"The project moves to Done and its milestones stay open."}),t.jsx("p",{className:"text-body-sm text-ink break-words",children:s?Yi(s):""}),j.length>jt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(wn,{summary:`Show all ${j.length} open milestones`,children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:j.map((v,g)=>t.jsx("li",{className:"break-words",children:v},`${g}-${v}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:m?.copy??""})]})})},xa=({status:e})=>{const s=Z(e);return t.jsxs(xe,{variant:s.variant,children:[ri(e)&&t.jsx(xs,{"aria-hidden":!0}),s.label]})};function ue(e,s){return{name:s,begin:`Edit ${e}`,accept:`Save ${e}`,cancel:`Discard the ${e} edit`,busy:`Saving the ${e}`,saved:`${s} saved`,retry:`Retry saving the ${e}`}}const Mt=({field:e,fieldRef:s,fieldProps:n,editing:a,label:r,bare:i=!1,display:l,editor:o,slot:c,feedback:m,controlsIdle:u="affordance",hug:h=!1,feedbackExtra:b,className:f,controlsClassName:j})=>t.jsxs("div",{ref:s,...n,"data-project-field":e,className:$(!i&&Ts,"min-w-0",r!==void 0&&"flex items-start gap-3",f),children:[r!==void 0&&t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:r}),t.jsxs("div",{className:$("flex min-w-0 flex-col gap-1",h&&"items-start",r!==void 0&&"flex-1"),children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("div",{className:$("min-w-0",h?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:c.begin,children:a?o:l}),t.jsx(is,{api:c,idle:u,className:$("shrink-0",j)})]}),t.jsx("div",{className:$("min-h-[1lh] text-meta",h&&"max-w-96"),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx(os,{api:m}),b]})})]})]}),Oe=({field:e,value:s,display:n,commitFields:a,validate:r,labels:i,commit:l,placeholder:o,mono:c=!1,ramp:m="text-body-sm",label:u,bare:h=!1,autoBegin:b=!1,maxLength:f,onRetire:j,className:v,controlsClassName:g})=>{const[x,y]=d.useState(b);d.useEffect(()=>{x&&s!==""&&(y(!1),j?.("filled"))},[x,s,j]);const C=ht({value:s,commit:async w=>{await l(a(w))},equals:(w,L)=>w.trim()===L.trim(),validate:r,labels:i,selectAllOnBegin:!0,beginOnMount:b,errorCopy:Je,onSettle:w=>{w==="cancelled"&&(y(!1),j?.("cancelled"))}});return!x&&s===""?null:t.jsx(Mt,{field:e,fieldRef:C.fieldRef,fieldProps:C.fieldProps,editing:C.editing,label:u,bare:h,display:n,slot:C,feedback:C,className:v,controlsClassName:g,editor:t.jsx(ne,{ref:C.editorRef,...C.editorAria,value:C.draft,readOnly:C.phase==="saving",maxLength:f,placeholder:o,"aria-label":i.name,onChange:w=>C.setDraft(w.target.value),spellCheck:!1,autoComplete:"off",className:$("h-8",c?"font-mono text-mono-sm":m)})})},ec=({project:e,commit:s})=>{const n=e.title??"",[a,r]=d.useState(!1),i=d.useRef(null),l=o=>{r(!1),o==="cancelled"&&setTimeout(()=>i.current?.focus(),0)};return t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:$(Ts,"flex min-w-0 flex-col gap-0.5"),children:[n?t.jsx(Oe,{field:"title",value:n,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:n}),commitFields:o=>({title:o.trim()}),validate:o=>Zt(o),labels:ue("title","Title"),commit:s,maxLength:wt,placeholder:"A short name for the workstream",ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(Oe,{field:"key",value:e.name,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:e.name}),commitFields:o=>({name:o.trim()}),validate:o=>Wt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Xs,placeholder:"project-key",ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!n&&(a?t.jsx(Oe,{field:"title",value:"",display:null,commitFields:o=>({title:o.trim()}),validate:o=>Zt(o),labels:ue("title","Title"),commit:s,maxLength:wt,placeholder:e.name,ramp:"text-body-sm",bare:!0,autoBegin:!0,onRetire:l}):t.jsx("button",{ref:i,type:"button","data-project-add-title":"",onClick:()=>r(!0),className:$("w-fit cursor-pointer text-meta text-ink-dim","opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","hover:text-ink"),children:"Add a title"}))]}),n&&t.jsx(Oe,{field:"key",value:e.name,display:t.jsx("span",{className:"font-mono text-mono-sm text-ink-muted",children:e.name}),commitFields:o=>({name:o.trim()}),validate:o=>Wt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Xs,placeholder:"project-key",mono:!0})]})},tc=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=Ve(),i=he(r.data,"projects_force_done"),[l,o]=d.useState(null),[c,m]=d.useState(null),u=d.useRef(!1),h=d.useRef(!1),b=d.useRef(null),f=ht({value:e.status,commit:async g=>{const x=u.current;u.current=!1,o(null);try{const y=await s({status:g},x?{forceDone:!0}:void 0);x&&fe(Qn(y,l?.count??0,Z(g).label)),b.current?.resolve()}catch(y){throw o(oa(y)),b.current?.reject(y),y}finally{b.current=null}},labels:ue("status","Status"),keyboardCommit:!1,errorCopy:Je,onBegin:()=>a(!0)}),j=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!h.current||f.phase!=="idle"&&f.phase!=="saved")return;h.current=!1;const g=document.querySelector("[data-project-milestones]");g&&(g.scrollIntoView({block:"start"}),g.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const v=()=>new Promise((g,x)=>{if(f.phase!=="error"||f.conflict!==null){x(new Error(""));return}if(!f.dirty){g();return}u.current=!0,b.current={resolve:g,reject:x},f.accept(f.draft,!0)});return t.jsx(Mt,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(xa,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[j&&t.jsx(U,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>m(l),children:"Mark done anyway…"}),t.jsx(pa,{open:c!==null,refusal:c,projectLabel:G(e),onClose:()=>m(null),onConfirm:v,secondaryLabel:"Review milestones",onSecondary:()=>{m(null),h.current=!0,f.cancel()}})]}),editor:t.jsxs(ze,{open:n,onOpenChange:a,value:f.draft,onValueChange:g=>{a(!1),f.accept(g)},children:[t.jsx(Ye,{ref:f.editorRef,...f.editorAria,"aria-label":"Status","data-project-status":"",className:"h-7 w-fit min-w-36",children:t.jsx(He,{})}),t.jsx(We,{children:In.map(g=>t.jsx(_e,{value:g.value,"data-project-status-option":g.value,children:g.label},g.value))})]})})},sc=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=d.useRef(null),i=d.useRef(null),l=ht({value:e.description,commit:async m=>{await s({description:m.trim()})},equals:(m,u)=>m.trim()===u.trim(),validate:m=>na(m),multiline:!0,labels:ue("description","Description"),errorCopy:Je,editorRef:r,onSettle:m=>{m==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(n||!l.editing)return;const m=setTimeout(()=>r.current?.focus(),0);return()=>clearTimeout(m)},[n,l.editing]);const c=(l.editing?l.draft:l.displayValue).length>Ke;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:$(Ts,"min-w-0"),children:l.editing?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[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(m=>t.jsx("button",{type:"button","data-project-description-mode":m,"aria-pressed":n===(m==="preview"),onClick:()=>a(m==="preview"),className:$("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",n===(m==="preview")&&"bg-surface text-ink"),children:m==="write"?"Write":"Preview"},m))})]}),t.jsx(is,{api:{...l,acceptBlocked:c}})]}),n?t.jsx("div",{"data-project-description-preview":"",className:"h-40 overflow-y-auto rounded-md border border-hairline bg-sunken px-3 py-2",children:l.draft.trim()?t.jsx(ot,{className:"text-body-sm",children:l.draft}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(_n,{ref:r,...l.editorAria,"data-project-description":"",value:l.draft,readOnly:l.phase==="saving",rows:8,placeholder:"Markdown — headings, lists, code.","aria-label":l.labels.name,onChange:m=>l.setDraft(m.target.value),onPaste:m=>ha(m,r,u=>l.setDraft(u)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(os,{api:l}),t.jsxs("p",{className:$("shrink-0 text-meta tabular-nums",c?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",Ke]})]})]}):t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[(e.description??"").trim()?t.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[t.jsx("div",{className:"min-w-0 flex-1 cursor-text",onDoubleClick:l.begin,children:t.jsx(ot,{className:"text-body",children:e.description??""})}),t.jsx(is,{api:l})]}):t.jsx("button",{ref:i,type:"button","data-project-add-description":"",onClick:l.begin,className:"w-fit cursor-pointer text-body-sm text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink",children:"Add description"}),t.jsx("div",{className:"min-h-[1lh] text-meta",children:t.jsx(os,{api:l})})]})})},nc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>t.jsx(Oe,{field:"owner",value:e.owner??"",label:"Owner",display:t.jsx("span",{className:"text-body-sm text-ink",children:e.owner}),commitFields:r=>({owner:r.trim()}),validate:r=>St(r,"owner"),labels:ue("owner","Owner"),commit:s,maxLength:Nt,placeholder:"atlas",autoBegin:n,onRetire:a}),ac=({project:e,commit:s,label:n=null,autoBegin:a=!1,onRetire:r})=>t.jsx(Oe,{field:"team",value:e.team??"",label:"Team",display:t.jsx("span",{className:"text-body-sm text-ink",children:n??e.team}),commitFields:i=>({team:i.trim()}),validate:i=>St(i,"team"),labels:ue("team","Team"),commit:s,maxLength:Nt,placeholder:"platform",autoBegin:a,onRetire:r}),hn=({project:e,commit:s,which:n,nowMs:a,autoBegin:r=!1,onRetire:i})=>{const l=n==="start"?e.start_date??"":e.target_date??"",o=Pe(),c=Ce(l,o,new Date(a)),m=n==="start"?"Start":"Target";return t.jsx(Oe,{field:n==="start"?"start-date":"target-date",value:l,label:m,display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),commitFields:u=>n==="start"?{start_date:u}:{target_date:u},validate:u=>{const h=es(u);return h||(n==="start"?ts(u,e.target_date??""):ts(e.start_date??"",u))},labels:ue(`${m.toLowerCase()} date`,m),commit:s,placeholder:"YYYY-MM-DD",autoBegin:r,onRetire:i})},rc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const r={estimate:e.estimate,unit:e.estimate_unit==="days"?"days":"points"},[i,l]=d.useState(n);d.useEffect(()=>{i&&e.estimate!==null&&(l(!1),a?.("filled"))},[i,e.estimate,a]);const o=ht({value:{number:e.estimate===null?"":String(e.estimate),unit:r.unit},equals:zo,commit:async m=>{const u=Ho(r,m);u&&await s(u)},validate:m=>aa(m.number),labels:ue("estimate","Estimate"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Je,onSettle:m=>{m==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const c=qn(e.estimate,e.estimate_unit)||"—";return t.jsx(Mt,{field:"estimate",fieldRef:o.fieldRef,fieldProps:o.fieldProps,editing:o.editing,label:"Estimate",display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),slot:o,feedback:o,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{ref:o.editorRef,...o.editorAria,"data-project-estimate":"",value:o.draft.number,readOnly:o.phase==="saving",placeholder:"13",inputMode:"decimal","aria-label":o.labels.name,onChange:m=>o.setDraft({...o.draft,number:m.target.value}),className:"h-8 max-w-24"}),t.jsxs(ze,{value:o.draft.unit,onValueChange:m=>o.setDraft({...o.draft,unit:m}),children:[t.jsx(Ye,{"data-project-estimate-unit":"","aria-label":"Estimate unit","aria-invalid":o.editorAria["aria-invalid"],className:"h-8 w-fit min-w-28",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(_e,{value:"points",children:"Points"}),t.jsx(_e,{value:"days",children:"Days"})]})]})]}),o.draft.number.trim()===""&&r.estimate!==null&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Clearing an estimate is not supported yet — saving keeps its current value."})]})})},ic=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const[r,i]=d.useState(n);d.useEffect(()=>{r&&e.tags.length>0&&(i(!1),a?.("filled"))},[r,e.tags,a]);const l=ht({value:e.tags.join(", "),equals:(c,m)=>Yo(it(c),m),commit:async c=>{const{tags:m}=ss(c);await s({tags:m})},validate:c=>ss(c).error,labels:ue("tags","Tags"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Je,onSettle:c=>{c==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!r&&e.tags.length===0)return null;const o=l.editing?it(l.draft):e.tags;return t.jsx(Mt,{field:"tags",fieldRef:l.fieldRef,fieldProps:l.fieldProps,editing:l.editing,label:"Tags",display:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(c=>t.jsx(xe,{variant:"outline",children:c},c))}),slot:l,feedback:l,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(ne,{ref:l.editorRef,...l.editorAria,"data-project-tags":"",value:l.draft,readOnly:l.phase==="saving",placeholder:"q4, payments","aria-label":l.labels.name,onChange:c=>l.setDraft(c.target.value),className:"h-8 max-w-72"}),t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:o.map(c=>t.jsx(xe,{variant:"outline",children:c},c))})]})})},oc="project-quick-send:no-target",lc=[],cc=({links:e,target:s,onTargetChange:n,onSend:a,focusTick:r})=>{const i=d.useRef(null),l=Va(),{frontend:o,refresh:c}=Fr(),[m,u]=d.useState(!1),h=Ve(),b=s??oc;d.useEffect(()=>{s&&c(s)},[s,c]),d.useEffect(()=>{r>0&&i.current?.focusInput()},[r]);const f=e.filter(g=>g.exists),v=(f.find(g=>g.session_id===s)??null)?.runtime?.busy===!0;return t.jsxs("div",{"data-tour-tag":"project-quick-send",className:"flex flex-col gap-2 rounded-md bg-surface 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(ze,{value:s??void 0,onValueChange:g=>n(g),children:[t.jsx(Ye,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(He,{placeholder:"No session selected"})}),t.jsx(We,{children:f.map(g=>t.jsx(_e,{value:g.session_id,children:Pt(g)},g.session_id))})]}),m?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:"Sending…"}):v?t.jsx("span",{className:"text-meta text-ink-muted",children:"The session is working — this message steers the running turn."}):null]}),t.jsx(Qa,{ref:i,conversationId:b,messages:lc,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:"Message the session — paste an image to attach it",cwd:o?.cwd,cwdReadOnlyReason:"Quick send follows the conversation's directory.",sessionStatus:o&&s?{frontend:o,costChannels:he(h.data,"cost_channels")}:void 0,recordingProbe:l,hostNotice:s?void 0:{id:"project-quick-send-no-target",node:t.jsx("p",{className:"text-meta text-ink-muted",children:"Choose a session to send to."}),blocksInput:!0,placeholder:"Choose a session to send to."},onSendMessage:async(g,x)=>{if(!s)return!1;u(!0);try{return await a(s,g,v?"steer":"prompt",x)}finally{u(!1),i.current?.focusInput({preventScroll:!0})}}})]})},dc=({links:e,busy:s,onUnlink:n,onLink:a,onQuickSend:r,onStartSession:i})=>{const l=Rt(),o=vt(x=>x.sessions),[c,m]=d.useState(!1),[u,h]=d.useState(null),[b,f]=d.useState(0),j=u&&e.some(x=>x.session_id===u&&x.exists)?u:Ii(e),v=d.useMemo(()=>{const x=new Set(e.map(y=>y.session_id));return o.filter(y=>!x.has(y.session_id)).map(y=>({id:y.session_id,name:y.title||y.session_id,description:y.cwd??void 0}))},[o,e]),g=x=>{vt.getState().openSession(x).then(y=>{y&&l(`/chat/${x}`)})};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(U,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(Ar,{}),"New session"]}),t.jsxs(U,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx(Or,{}),"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(x=>{const y=hi(x),C=pi(x.subagents),w=xi(x.todos),L=x.title||x.session_id,T=x.exists;return t.jsxs("li",{className:$("flex items-center gap-2 rounded-sm px-2 py-2",T&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!T,onClick:()=>{T&&g(x.session_id)},className:$("flex min-w-0 flex-1 items-center gap-2 text-left",T?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:$("min-w-0 truncate text-body-sm",x.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:L})}),x.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),C&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:C}),w&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:w}),t.jsx(xe,{variant:y.variant,children:y.label}),T&&t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${L}`,title:`Message ${L}`,onClick:()=>{h(x.session_id),f(_=>_+1)},children:t.jsx($r,{})}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${L}`,onClick:()=>n(x.session_id),children:t.jsx(Jr,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(cc,{links:e,target:j,onTargetChange:h,onSend:r,focusTick:b}),t.jsx(lt,{open:c,onClose:()=>m(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Be,{onClick:()=>m(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(oe,{children:"Session"}),t.jsx(Cn,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:v,selected:null,onSelect:x=>{m(!1),a(x.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},uc=({milestones:e,summary:s,busy:n,onToggle:a,onRemove:r,onAdd:i})=>{const[l,o]=d.useState(""),[c,m]=d.useState(""),u=Pe(),h=!Ln.test(c.trim()),b=l.trim().length>0&&!h&&!n,f=()=>{b&&(i(l.trim(),c.trim()),o(""),m(""))};return t.jsxs("section",{"data-project-milestones":"",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",tabIndex:-1,"data-project-milestones-heading":"",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(j=>{const v=oi(j.status),g=j.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(En,{checked:g,disabled:n,onCheckedChange:x=>a(j.name,x===!0),"aria-label":g?`Mark ${j.name} not complete`:`Mark ${j.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:j.name}),j.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:Ce(j.target_date,u)}),t.jsx(xe,{variant:v.variant,children:v.label}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:n,"aria-label":`Remove ${j.name}`,onClick:()=>r(j.name),children:t.jsx(At,{})})]},j.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(oe,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(ne,{id:"project-milestone-name",value:l,onChange:j=>o(j.target.value),placeholder:"beta cut",onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),f())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(ne,{id:"project-milestone-date",value:c,onChange:j=>m(j.target.value),placeholder:"YYYY-MM-DD","aria-invalid":h}),h&&t.jsx("p",{className:"text-meta text-danger",children:"Dates are YYYY-MM-DD, or empty."})]}),t.jsxs(U,{variant:"secondary",disabled:!b,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(at,{}),"Add"]})]})]})},mc=[{field:"owner",label:"Owner"},{field:"team",label:"Team"},{field:"start",label:"Start date"},{field:"target",label:"Target date"},{field:"estimate",label:"Estimate"},{field:"tags",label:"Tags"}],pn=({label:e,children:s})=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:e}),t.jsx("dd",{className:"min-w-0 flex-1 text-body-sm text-ink",children:s})]}),fc=({project:e,nowMs:s,commit:n,teamLabel:a=null})=>{const r=Pe(),i=new Date(s),[l,o]=d.useState(null),c=d.useRef(null),m=d.useRef(!1),u={owner:e.owner!==null,team:e.team!==null,start:e.start_date!==null,target:e.target_date!==null,estimate:e.estimate!==null,tags:e.tags.length>0},h=(_,O)=>{o(p=>p===_?null:p),O==="cancelled"&&!u[_]&&setTimeout(()=>c.current?.focus(),0)},b=mc.filter(({field:_})=>!u[_]&&l!==_),f=Ce(e.completed_at,r,i),j=e.updated_at>0?ut(dt(e.updated_at,s)):"",v=e.updated_at>0?new Date(e.updated_at*1e3).toLocaleString(r):"",g=u.owner||l==="owner",x=u.team||l==="team",y=u.start||l==="start",C=u.target||l==="target",w=u.estimate||l==="estimate",L=u.tags||l==="tags",T=g||x||y||C||!!f||w||L||e.updated_at>0;return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Properties"}),b.length>0&&t.jsxs(ds,{children:[t.jsx(us,{asChild:!0,children:t.jsxs("button",{ref:c,type:"button","data-project-add-field":"",className:$("flex shrink-0 cursor-pointer items-center gap-1 rounded-xs text-meta text-ink-dim","transition-colors duration-fast ease-out-quart hover:text-ink"),children:[t.jsx(at,{className:"size-3","aria-hidden":"true"}),"Add"]})}),t.jsx(ms,{align:"end",onCloseAutoFocus:_=>{m.current&&(m.current=!1,_.preventDefault())},children:b.map(({field:_,label:O})=>t.jsx(ke,{"data-project-add-option":_,onSelect:()=>{m.current=!0,o(_)},children:O},_))})]})]}),T?t.jsxs("dl",{className:"flex flex-col gap-2",children:[g&&t.jsx(nc,{project:e,commit:n,autoBegin:l==="owner",onRetire:_=>h("owner",_)}),x&&t.jsx(ac,{project:e,commit:n,label:a,autoBegin:l==="team",onRetire:_=>h("team",_)}),y&&t.jsx(hn,{project:e,commit:n,which:"start",nowMs:s,autoBegin:l==="start",onRetire:_=>h("start",_)}),C&&t.jsx(hn,{project:e,commit:n,which:"target",nowMs:s,autoBegin:l==="target",onRetire:_=>h("target",_)}),f&&t.jsx(pn,{label:"Completed",children:f}),w&&t.jsx(rc,{project:e,commit:n,autoBegin:l==="estimate",onRetire:_=>h("estimate",_)}),L&&t.jsx(ic,{project:e,commit:n,autoBegin:l==="tags",onRetire:_=>h("tags",_)}),e.updated_at>0&&t.jsx(pn,{label:"Updated",children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:v,children:j})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No dates, estimate, tags, owner or team yet."})]})},hc=({project:e})=>{const s=Ve(),n=ua(),{sending:a,cooling:r,cooldownRemainingMs:i}=ll(e.id);if(!he(s.data,"projects_request_update"))return null;const l=G(e),o=Zo(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(Dt,{content:r&&i!==null?Tt(l,i):Qo,children:t.jsxs(U,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":r?!0:void 0,"aria-describedby":r?o:void 0,onClick:()=>n(e),children:[a?t.jsx(we,{size:"sm"}):r?t.jsx(xs,{}):t.jsx(Vr,{}),a?"Requesting…":r?"Requested":"Request update"]})}),r&&i!==null&&t.jsx("span",{id:o,className:"sr-only",children:Tt(l,i)})]})},ga="plain",ba=e=>`team:${e}`,ja=e=>`agent:${e}`;function pc(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function xc(e){return e.kind==="team"?ba(e.name):e.kind==="agent"?ja(e.name):ga}const xn={kind:"plain"},gc=({open:e,onClose:s,onStart:n,teamsEnabled:a,profilesEnabled:r})=>{const[i,l]=d.useState(xn),[o,c]=d.useState(null),[m,u]=d.useState(!1),h=Ja(e&&a),b=Xa(e&&r);d.useEffect(()=>{e&&(l(xn),c(null),u(!1))},[e]);const f=d.useMemo(()=>{const y=[{id:ga,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const C of h.data??[])y.push({id:ba(C.name),name:Ms(C),keywords:C.name===Ms(C)?void 0:[C.name],description:`Team · manager: ${C.manager}`,group:"Teams"});for(const C of(b.data??[]).filter(w=>w.source!=="builtin"))y.push({id:ja(C.name),name:C.name,description:C.description||C.kind,group:"Agents"});return y},[h.data,b.data]),j=f.find(y=>y.id===xc(i))??f[0],v=!a||!r,g=h.isLoading||b.isLoading,x=async()=>{u(!0),c(null);try{await n(i),s()}catch(y){c(y instanceof Error&&y.message?y.message:"The session could not be started.")}finally{u(!1)}};return t.jsx(lt,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:m,children:"Cancel"}),t.jsxs(yt,{onClick:()=>void x(),disabled:m,children:[m&&t.jsx(we,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Cn,{label:"Work with",placeholder:"Search teams and agents",options:f,selected:j,onSelect:y=>l(pc(y.id)),busy:g,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."}),v&&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."}),o&&t.jsx("p",{className:"text-body-sm text-danger",children:o})]})})},bc=({links:e})=>{const s=Mi(e),n=e.filter(a=>a.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:Ys(s)})]}),n.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:n.map(a=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:a.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:Pt(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Ys(a.todos)})]},a.session_id))})]})},jc=({filePath:e,tooltip:s="File actions",icon:n,"aria-label":a="File actions",onShowInCanvas:r})=>{const i=async()=>{if(e)try{await navigator.clipboard.writeText(e),fe("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),ie("Failed to copy file path")}},l=()=>{e&&window.api.openFile(e)};return t.jsxs(ds,{children:[t.jsx(Dt,{content:s,children:t.jsx(us,{asChild:!0,children:t.jsx(U,{variant:"ghost",size:"icon-sm","aria-label":a,onClick:o=>o.stopPropagation(),children:n??t.jsx(kn,{"aria-hidden":"true"})})})}),t.jsxs(ms,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[r&&t.jsxs(ke,{onSelect:r,children:[t.jsx(Za,{"aria-hidden":"true"}),t.jsx("span",{children:"Show in canvas"})]}),t.jsxs(ke,{onSelect:l,children:[t.jsx(Nn,{"aria-hidden":"true"}),t.jsx("span",{children:"Open file"})]}),t.jsxs(ke,{onSelect:()=>window.api.showItemInFolder(e),children:[t.jsx(er,{"aria-hidden":"true"}),t.jsx("span",{children:"Open folder"})]}),t.jsxs(ke,{onSelect:i,children:[t.jsx(tr,{"aria-hidden":"true"}),t.jsx("span",{children:"Copy file path"})]})]})]})},yc=/[/\\]/;function ya(e){if(e.name)return e.name;const s=e.path.split(yc);return s[s.length-1]||"Attachment"}const vc=({attachment:e})=>{const s=ya(e),n=$i(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(Nn,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),n&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:n}),t.jsx(jc,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},kc=({attachment:e})=>{const s=ya(e),n=sr(e.path,{mimeType:nr(e.name||e.path),sizeBytes:e.bytes});return n.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(ar,{file:e.path,src:n.url,label:s,conversationId:""})}):n.status==="loading"?t.jsx(rr,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(ir,{name:s})},wc=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(kc,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(vc,{attachment:s},`${s.path}:${s.added_at}`))}),Nc=({update:e,nowMs:s})=>{const n=Pe(),a=Ai(e,n,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[a.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:a.map((r,i)=>t.jsxs(d.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:r.text})]},r.key))}),e.text&&t.jsx(ot,{children:e.text}),e.attachments.length>0&&t.jsx(wc,{attachments:e.attachments})]})},Sc=({updates:e,nowMs:s})=>{const n=Pe(),a=_i(e.length),r=Oi(e,n,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"}),a&&t.jsx("span",{className:"text-meta text-ink-muted",children:a})]}),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:r.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((l,o)=>t.jsx(Nc,{update:l,nowMs:s},`${l.at}:${l.by}:${o}`))})]},i.key||"ungrouped"))})]})},Tc="project_not_found",_c=({projectKey:e,nowMs:s})=>{const n=Rt(),a=Ve(),r=Sn(he(a.data,"team_catalogue")),i=On(e,!0),l=$n(),o=Pn(),c=ni(),m=ai(),u=ti(),h=si(),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=l.isPending||o.isPending||c.isPending||m.isPending||u.isPending||h.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(we,{label:"Loading project"})});if(i.isError||!i.data){const p=i.error instanceof Et&&(i.error.code===Tc||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(Ht,{variant:"danger",className:"w-full",children:p?"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(U,{variant:"secondary",onClick:()=>void i.refetch(),children:"Try again"}),t.jsxs(U,{variant:"secondary",onClick:()=>void n("/projects"),children:[t.jsx(Ls,{}),"All projects"]})]})]})}const{project:x,links:y}=i.data,C=G(x),w=(p,A)=>l.mutateAsync({key:x.id,fields:p,...A?.forceDone===!0?{forceDone:!0}:{}}),L=x.team?r(x.team):null,T=Pi(x.milestones.filter(p=>p.completed_at!==null).length,x.milestones.length),_=async(p,A,E,P)=>{const z=vt.getState(),I=lr(null,p,z.drafts);if(!I)return!1;try{const{images:B,unreadable:W,overflow:V}=await cr(P,A),le=dr(W);if(le)return ie(le),!1;const Q=ur(V);if(Q)return ie(Q),!1;const J=mr(A,B);if(J)return ie(J),!1;if(await fr(I,{text:A,attachments:P,images:B,mode:E,cwd:z.cwd},p)===null)return ie("That session already has a message going out. Try again in a moment."),!1;const N=y.find(R=>R.session_id===p);return fe(`Sent to ${N?Pt(N):p}`),!0}catch(B){return ie(B instanceof Error&&B.message?B.message:"The message was not sent."),!1}},O=async p=>{const A=vt.getState(),E=p.kind==="plain"?void 0:{kind:p.kind,name:p.name},P=await A.createSession(A.cwd||"~",E);if(!P)throw new Error(A.error??"The session could not be started.");hr.getState().setCurrentInput(P,Li(x));let z=null;try{await u.mutateAsync({key:x.id,sessionId:P})}catch(I){z=I instanceof Error&&I.message?I.message:"the link was refused"}if(z)ie(`Session started, but linking it failed: ${z}`);else{const I=E?` with ${Fi(E)}`:"";fe(`Session started${I} and linked to ${C}.`)}await Dn(n,P)};return t.jsx(Tl,{children: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 n("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Ls,{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-1 flex-wrap items-start gap-x-3 gap-y-2",children:[t.jsx(ec,{project:x,commit:w}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(tc,{project:x,commit:w}),x.progress_stale&&t.jsx(xe,{variant:"warning",children:kt})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(hc,{project:x}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(or,{}),"Delete"]})]})]})]}),t.jsx(sc,{project:x,commit:w}),t.jsx(fc,{project:x,nowMs:s,commit:w,teamLabel:L}),x.updates.length===0&&x.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:"Progress"}),t.jsx(ot,{className:"text-body",children:x.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:di(x,s)})]}),t.jsx(uc,{milestones:x.milestones,summary:T,busy:g,onToggle:(p,A)=>{c.mutateAsync({key:x.id,name:p,completed:A}).catch(E=>{ie(E instanceof Error&&E.message?E.message:"The milestone was not updated.")})},onRemove:p=>{m.mutateAsync({key:x.id,name:p}).catch(A=>{ie(A instanceof Error&&A.message?A.message:"The milestone was not removed.")})},onAdd:(p,A)=>{c.mutateAsync({key:x.id,name:p,targetDate:A}).catch(E=>{ie(E instanceof Error&&E.message?E.message:"The milestone was not added.")})}}),t.jsx(dc,{projectKey:x.id,links:y,busy:g,onStartSession:()=>v(!0),onQuickSend:_,onLink:p=>{u.mutateAsync({key:x.id,sessionId:p}).catch(A=>{ie(A instanceof Error&&A.message?A.message:"The session was not linked.")})},onUnlink:p=>{h.mutateAsync({key:x.id,sessionId:p}).catch(A=>{ie(A instanceof Error&&A.message?A.message:"The session was not unlinked.")})}}),t.jsx(bc,{links:y}),t.jsx(Sc,{updates:x.updates,nowMs:s}),t.jsx(ma,{open:b,projectName:x.name,onClose:()=>f(!1),onConfirm:async p=>{await o.mutateAsync({key:x.id,confirmedName:p}),fe("Project deleted"),n("/projects")}}),t.jsx(gc,{open:j,onClose:()=>v(!1),onStart:O,teamsEnabled:he(a.data,"team_catalogue"),profilesEnabled:he(a.data,"profile_catalogue")})]})})},gn={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},Cc=({open:e,onClose:s,onSubmit:n})=>{const[a,r]=d.useState(gn),[i,l]=d.useState({}),[o,c]=d.useState(null),m=d.useRef(null),[u,h]=d.useState(!1),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=d.useId(),x=d.useRef(null);d.useEffect(()=>{e&&(r({...gn,description:dn}),l({}),c(null),h(!1),f(!1),v(!1))},[e]),d.useEffect(()=>{o&&m.current?.scrollIntoView({block:"nearest"})},[o]);const y=(p,A)=>{r(E=>({...E,[p]:A}))},C=b?a.name:Pl(a.title),w=p=>ha(p,x,A=>y("description",A)),L=(p,A)=>{const E={},P=Wt(A);P&&(E.name=P);const z=na(p.description);z&&(E.description=z);const I=ss(p.tags).error;I&&(E.tags=I);const B=es(p.startDate);B&&(E.startDate=B);const W=es(p.targetDate);if(W)E.targetDate=W;else if(!B){const J=ts(p.startDate,p.targetDate);J&&(E.targetDate=J)}if(p.estimate.trim()){const J=aa(p.estimate);J&&(E.estimate=J)}const V=Zt(p.title);V&&(E.title=V);const le=St(p.owner,"owner");le&&(E.owner=le);const Q=St(p.team,"team");return Q&&(E.team=Q),E},T=async()=>{const p=C.trim(),A=L(a,p);if(l(A),Object.keys(A).length>0)return;h(!0),c(null);const E=it(a.tags);try{const P={};a.title.trim()&&(P.title=a.title.trim()),a.owner.trim()&&(P.owner=a.owner.trim()),a.team.trim()&&(P.team=a.team.trim()),a.startDate&&(P.start_date=a.startDate),a.targetDate&&(P.target_date=a.targetDate),a.estimate&&(P.estimate=Number(a.estimate),P.estimate_unit=a.estimateUnit),await n({fields:{name:p,...a.description.trim()&&a.description.trim()!==dn?{description:a.description.trim()}:{},status:a.status,...E.length>0?{tags:E}:{}},...Object.keys(P).length>0?{followUp:P}:{}}),s()}catch(P){const z=P instanceof Error&&P.message?P.message:"";c(ft(z)||"The project was not saved.")}finally{h(!1)}},_="New project",O=a.description.length>Ke;return t.jsx(lt,{open:e,onClose:s,title:_,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:u,onEscapeKeyDown:p=>{u&&p.preventDefault()},onInteractOutside:p=>{u&&p.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:u,children:"Cancel"}),t.jsxs(yt,{"data-project-submit":"",onClick:()=>void T(),disabled:u,children:[u&&t.jsx(we,{size:"xs"}),"Create project"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:p=>{p.preventDefault(),T()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-title`,children:"Title"}),t.jsx(ne,{id:`${g}-title`,"data-project-title":"",value:a.title,onChange:p=>y("title",p.target.value),placeholder:"Payments migration",autoFocus:!0,className:"h-10 text-heading","aria-invalid":!!i.title}),i.title&&t.jsx("p",{className:"text-meta text-danger",children:i.title}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(oe,{htmlFor:`${g}-key`,className:"shrink-0 text-meta text-ink-muted",children:"Key"}),t.jsx(ne,{id:`${g}-key`,"data-project-key":"",value:C,onChange:p=>{f(!0),y("name",p.target.value)},placeholder:"payments-migration","aria-invalid":!!i.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:b?"Letters, digits, dot, underscore or dash; no spaces.":"Derived from the title until you edit it."})]}),i.name&&t.jsx("p",{className:"text-meta text-danger",children:i.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(oe,{htmlFor:`${g}-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(p=>t.jsx("button",{type:"button","data-project-description-mode":p,"aria-pressed":j===(p==="preview"),onClick:()=>v(p==="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",j===(p==="preview")&&"bg-surface text-ink"),children:p==="write"?"Write":"Preview"},p))})]})]}),j?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:a.description.trim()?t.jsx(ot,{className:"text-body-sm",children:a.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(_n,{ref:x,id:`${g}-description`,"data-project-description":"",value:a.description,onChange:p=>y("description",p.target.value),onPaste:w,rows:8,placeholder:"Markdown — headings, lists, code.","aria-invalid":O||!!i.description,className:"h-44 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.description?t.jsx("p",{className:"text-meta text-danger",children:i.description}):t.jsx("span",{}),t.jsxs("p",{className:$("text-meta tabular-nums",O?"text-danger":"text-ink-muted"),children:[a.description.length,"/",Ke]})]})]}),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(oe,{children:"Status"}),t.jsxs(ze,{value:a.status,onValueChange:p=>y("status",p),children:[t.jsx(Ye,{"aria-label":"Status",children:t.jsx(He,{})}),t.jsx(We,{children:In.map(p=>t.jsx(_e,{value:p.value,children:p.label},p.value))})]}),a.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(oe,{htmlFor:`${g}-owner`,children:"Owner"}),t.jsx(ne,{id:`${g}-owner`,"data-project-owner":"",value:a.owner,onChange:p=>y("owner",p.target.value),placeholder:"atlas","aria-invalid":!!i.owner}),i.owner&&t.jsx("p",{className:"text-meta text-danger",children:i.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-team`,children:"Team"}),t.jsx(ne,{id:`${g}-team`,value:a.team,onChange:p=>y("team",p.target.value),placeholder:"platform","aria-invalid":!!i.team}),i.team&&t.jsx("p",{className:"text-meta text-danger",children:i.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-target`,children:"Target date"}),t.jsx(ne,{id:`${g}-target`,"data-project-target":"",value:a.targetDate,onChange:p=>y("targetDate",p.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.targetDate}),i.targetDate&&t.jsx("p",{className:"text-meta text-danger",children:i.targetDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-start`,children:"Start date"}),t.jsx(ne,{id:`${g}-start`,value:a.startDate,onChange:p=>y("startDate",p.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.startDate}),i.startDate&&t.jsx("p",{className:"text-meta text-danger",children:i.startDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ne,{id:`${g}-estimate`,value:a.estimate,onChange:p=>y("estimate",p.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(ze,{value:a.estimateUnit,onValueChange:p=>y("estimateUnit",p),children:[t.jsx(Ye,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(_e,{value:"points",children:"Points"}),t.jsx(_e,{value:"days",children:"Days"})]})]})]}),i.estimate&&t.jsx("p",{className:"text-meta text-danger",children:i.estimate})]}),t.jsxs("div",{className:"col-span-2 flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-tags`,children:"Tags"}),t.jsx(ne,{id:`${g}-tags`,value:a.tags,onChange:p=>y("tags",p.target.value),placeholder:"q4, payments","aria-invalid":!!i.tags}),i.tags?t.jsx("p",{className:"text-meta text-danger",children:i.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]})]}),o&&t.jsx("p",{ref:m,className:"text-body-sm text-danger",children:o})]})})},va=({children:e})=>{const s=d.useRef(null),[n,a]=d.useState(!1),r=()=>{const i=s.current;i&&a(i.scrollTop+i.clientHeight<i.scrollHeight-1)};return d.useEffect(r),t.jsx("div",{ref:s,onScroll:r,className:$("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",n&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},Ec=({label:e,count:s,selected:n,onToggle:a})=>{const r=d.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(En,{id:r,checked:n,onCheckedChange:()=>a()}),t.jsx(oe,{htmlFor:r,className:"min-w-0 flex-1 cursor-pointer truncate font-normal text-body-sm text-ink",children:e}),t.jsx("span",{className:"text-meta text-ink-dim tabular-nums",children:s})]})},Rc=({column:e,spec:s,onChange:n})=>{const a=d.useId(),r=s!==null&&s.key===e,i=r?s.direction:Ft(e),l=i==="asc"?"desc":"asc",o=()=>n({key:e,direction:r?l:Ft(e)}),c=s===null?"default":r?"sorted":"other";return t.jsxs("fieldset",{className:"m-0 flex flex-col gap-0.5 border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:`Sort by ${Ge(e)}`}),t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-body-sm hover:bg-sunken",children:[t.jsx("input",{type:"radio",name:a,checked:c==="default",onChange:()=>n(null),className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="default"?"text-ink":"text-ink-muted"),children:bo})]}),t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-body-sm hover:bg-sunken",children:[t.jsx("input",{type:"radio",name:a,checked:c==="sorted",onChange:o,onClick:()=>{c==="sorted"&&o()},onKeyDown:m=>{c==="sorted"&&(m.key!==" "&&m.key!=="Enter"||(m.preventDefault(),o()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="sorted"?"text-ink":"text-ink-muted"),children:`Sort by ${Ge(e)}, ${ks(e,r?i:Ft(e))}`})]})]})},Dc=({facet:e,options:s,onToggle:n})=>t.jsxs("div",{className:"flex flex-col gap-0.5 border-b border-hairline px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"px-1 text-meta text-ink-muted",children:nt[e]}),s.map(a=>t.jsx(Ec,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>n(e,a.value)},`${e}:${a.value??"none"}`))]}),ka=({projects:e,state:s,query:n,todayMs:a,onToggle:r,onClearAll:i,scope:l,sort:o})=>{const c=d.useMemo(()=>l===void 0?go(e,s,a):l===null?[]:[sa(l,e,s,a)],[l,e,s,a]),m=!rt(s)||n.trim()!=="";return t.jsxs("div",{className:"flex flex-col",children:[l===void 0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-hairline px-3 py-2",children:[t.jsx("span",{className:"text-body-sm text-ink-muted",children:"Filters"}),m&&t.jsx(U,{variant:"link",size:"sm",onClick:i,children:"Clear all"})]}),o&&t.jsxs("div",{className:"flex flex-col gap-0.5 border-b border-hairline px-3 py-2",children:[t.jsx("span",{className:"px-1 text-meta text-ink-muted",children:`Sort by ${Ge(o.key)}`}),t.jsx(Rc,{column:o.key,spec:o.spec,onChange:o.onChange})]}),c.map(u=>t.jsx(Dc,{facet:u.facet,options:u.options,onToggle:r},u.facet))]})},Ac=({team:e,count:s,headingId:n,className:a,...r})=>t.jsxs("div",{...r,className:$("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",a),children:[t.jsx("h3",{id:n,className:"truncate text-ink",children:e??bs}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":mi(s),children:s})]}),ve=[{key:"name",label:"Project",className:"min-w-0 flex-1",sort:"name",facet:null},{key:"status",label:"Status",className:"w-20 shrink-0",sort:"status",facet:"status"},{key:"target",label:"Target",className:"hidden w-32 shrink-0 @[40rem]:block",sort:"target",facet:"target"},{key:"estimate",label:"Estimate",className:"hidden w-16 shrink-0 @[40rem]:block",sort:"estimate",facet:"estimate"},{key:"milestones",label:"Milestones",className:"hidden w-20 shrink-0 @[34rem]:block",sort:"milestones",facet:"milestones"},{key:"live",label:"Live",className:"hidden w-14 shrink-0 @[34rem]:block",sort:"live",facet:"live"},{key:"progress",label:"Progress",className:"w-40 shrink-0",sort:"progress",facet:"progress"}];function Oc(e,s){const n=dt(e.progress_updated_at,s);return n?ut(n):"not reported"}const $c=({direction:e})=>e==="asc"?t.jsx(An,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Tn,{size:10,className:"shrink-0","aria-hidden":"true"}),Pc=({projects:e,nowMs:s,onOpen:n,sort:a,onSortChange:r,searchPopulation:i,filters:l,query:o,todayMs:c,onToggleFilter:m,onClearFilters:u,teamLabelFor:h=b=>b})=>{const b=Pe(),f=a?_o(e,a):e,j=js(f,mt),v=d.useId(),g=T=>`${v}-team-${T}`,[x,y]=d.useState(0),C=d.useRef([]),w=(T,_)=>{const O=ve.length;for(let p=1;p<=O;p+=1){const A=(T+_*p+O*O)%O,E=C.current[A];if(E&&E.offsetParent!==null){y(A),E.focus();return}}},L=T=>_=>{_.key!=="ArrowLeft"&&_.key!=="ArrowRight"||(_.preventDefault(),w(T,_.key==="ArrowRight"?1:-1))};return t.jsxs("div",{className:"@container flex min-h-0 flex-1 flex-col","data-testid":"project-list",children:[t.jsx("table",{className:"block shrink-0","aria-label":"Project columns",children:t.jsx("thead",{className:"block",children:t.jsx("tr",{className:"flex items-center gap-3 px-9 py-2 text-meta text-ink-muted",children:ve.map((T,_)=>{const O=a!==null&&a.key===T.sort;return t.jsx("th",{scope:"col","aria-sort":O?a.direction==="desc"?"descending":"ascending":"none",className:$(T.className,"p-0 text-left font-normal"),children:t.jsxs(fs,{children:[t.jsx(hs,{asChild:!0,children:t.jsxs("button",{type:"button",ref:p=>{C.current[_]=p},tabIndex:_===x?0:-1,"data-project-column":T.key,onFocus:()=>y(_),onKeyDown:L(_),className:$("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",O?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:T.label}),O?t.jsx($c,{direction:a.direction}):t.jsx(pr,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(ps,{align:"start","aria-label":`${T.label} column`,className:"w-72 p-0",children:t.jsx(va,{children:t.jsx(ka,{projects:i,state:l,query:o,todayMs:c,onToggle:m,onClearAll:u,scope:T.facet,sort:{key:T.sort,spec:a,onChange:r}})})})]})},T.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:j.map((T,_)=>t.jsxs("li",{children:[t.jsx(Ac,{team:T.team==null?null:h(T.team),count:T.items.length,headingId:g(_),className:"sticky top-0 z-10","data-project-team":T.team??""}),t.jsx("ul",{"aria-labelledby":g(_),className:"divide-y divide-hairline",children:T.items.map(O=>{const p=new Map(Bn(O,b).map(P=>[P.key,P.text])),A=Un(O.milestones_completed,O.milestones_total),E=gs(O.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>n(O),"data-project-name":O.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:$(ve[0].className,"truncate text-body-sm text-ink"),children:G(O)}),t.jsx("span",{className:ve[1].className,children:t.jsx(xa,{status:O.status})}),t.jsx("span",{className:$(ve[2].className,"truncate text-meta text-ink-muted"),children:p.get("target")??p.get("completed")??""}),t.jsx("span",{className:$(ve[3].className,"truncate text-meta text-ink-muted"),children:p.get("estimate")??""}),t.jsx("span",{className:$(ve[4].className,"truncate text-meta text-ink-muted"),children:A}),t.jsx("span",{className:$(ve[5].className,"truncate text-meta text-ink-muted"),children:E}),t.jsxs("span",{className:$(ve[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Oc(O,s)}),O.progress_stale&&t.jsx(xe,{variant:"warning",children:kt})]})]})},O.id)})})]},T.team??""))})]})},Ct=224,bn=36,Mc={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},Ic=({items:e,nowMs:s,onOpen:n,pendingDetails:a,failedDetails:r,onRetryDetails:i,teamLabelFor:l=o=>o})=>{const[o,c]=d.useState(null),[m,u]=d.useState(0),h=d.useRef(null),b=Ns(s),f=d.useMemo(()=>Ro(e,b),[e,b]),j=d.useMemo(()=>Do(e),[e]),v=d.useMemo(()=>js(j.dated,T=>mt(T.project)),[j]);d.useLayoutEffect(()=>{const T=h.current;if(!T)return;const _=()=>u(T.clientWidth);if(_(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(_);return O.observe(T),()=>O.disconnect()},[]);const g=Math.max(m-Ct-24,160),x=f?Co(Js(f.startMs,f.endMs),g):"month",y=o??x,C=T=>{const _=Te.indexOf(y),O=Te[_-T];O&&c(O)},w=ws[y],L=f?Js(f.startMs,f.endMs)*w:0;return t.jsxs("div",{ref:h,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:r>0?`Milestones could not be read for ${r} project${r===1?"":"s"}.`:`${j.dated.length} dated · ${j.undated.length} without dates${a>0?` · loading milestones for ${a}…`:""}`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[r>0&&t.jsx(U,{variant:"secondary",size:"sm",onClick:i,children:"Try again"}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!f||y===Te[0],onClick:()=>C(1),children:t.jsx(at,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Mc[y]}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!f||y===Te[Te.length-1],onClick:()=>C(-1),children:t.jsx(_r,{})})]})]}),f&&j.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(Lc,{startMs:f.startMs,endMs:f.endMs,tier:y,pxPerDay:w,trackPx:L}),v.map(T=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":T.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:Ct},children:[t.jsx("span",{className:"truncate text-ink",children:T.team==null?bs:l(T.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:T.items.length})]})}),T.items.map(_=>t.jsx(Fc,{item:_,spanStart:f.startMs,pxPerDay:w,trackPx:L,today:b,onOpen:()=>n(_)},_.project.id))]},T.team??""))]})}):null,j.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(wn,{defaultOpen:j.dated.length===0,triggerClassName:"text-ink hover:bg-row-hover hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-8 py-0",summary:t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-meta",children:[t.jsx(Hr,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Ao(j.undated.length)})]}),children:[j.dated.length===0&&t.jsx("p",{className:"pb-1 text-meta text-ink-muted",children:"Set a start date, a target date or a milestone date and it will appear on the timeline."}),t.jsx("ul",{className:"flex max-h-24 flex-wrap gap-x-3 gap-y-1 overflow-y-auto",children:j.undated.map(T=>t.jsx("li",{children:t.jsx("button",{type:"button",className:"rounded-sm text-meta text-ink hover:bg-row-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent",onClick:()=>n(T),children:G(T.project)})},T.project.id))})]})})]})},Lc=({startMs:e,endMs:s,tier:n,pxPerDay:a,trackPx:r})=>{const i=Uo(e,s,n);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Ct}}),t.jsx("span",{className:"relative block h-6",style:{width:r},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:Ae(e,l.dayMs)*a},children:[t.jsx("span",{className:$("absolute top-0 h-full w-px",l.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:l.label})]},l.dayMs))})]})},Fc=({item:e,spanStart:s,pxPerDay:n,trackPx:a,today:r,onOpen:i})=>{const{project:l}=e,o=Oo(e),c=$o(e),m=u=>new Date(u).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:i,"data-project-name":l.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:Ct,height:bn},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:G(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:bn},children:[o&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:Ae(s,o.fromMs)*n,width:(Ae(o.fromMs,o.toMs)+1)*n},title:`${Ce(m(o.fromMs))} → ${Ce(m(o.toMs))}`}),c.map(u=>t.jsx("span",{"data-milestone":u.status,className:$("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",u.status==="completed"&&"bg-success",u.status==="overdue"&&"bg-warning",u.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:Ae(s,u.dayMs)*n},title:`${u.name} · ${u.status} · ${Ce(m(u.dayMs))}`},`${u.name}-${u.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:Ae(s,r)*n},"aria-hidden":"true"})]})]})},qc=({projects:e,query:s,onQueryChange:n,filters:a,onFiltersChange:r,onClearAll:i,todayMs:l,resultText:o,countRevealClass:c="@[37rem]:inline",trailing:m,disabled:u=!1,searchFieldRef:h})=>{const[b,f]=d.useState(!1),j=d.useRef(!1),v=fo(a),g=Rn(o??"",300),x=s.trim()!==""||!rt(a);return t.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-3",children:[t.jsxs("div",{className:"relative w-full min-w-0 max-w-[400px]",children:[t.jsx(xr,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(ne,{ref:h,inputSize:"sm",value:s,onChange:y=>n(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(s?n(""):y.currentTarget.blur())},placeholder:"Search projects","aria-label":"Search projects",autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(U,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>gr(h.current,n),"aria-label":"Clear search",children:t.jsx(At,{"aria-hidden":"true"})}):t.jsx("span",{className:"pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-ink-dim",children:t.jsx(br,{shortcut:"/"})})]}),t.jsxs(fs,{open:b,onOpenChange:f,children:[t.jsx(hs,{asChild:!0,children:t.jsxs(U,{variant:"secondary",size:"sm",disabled:u,"data-project-filters-button":"",children:[t.jsx(Kr,{size:14,"aria-hidden":"true"}),"Filters",v>0&&t.jsx(xe,{variant:"neutral",children:v})]})}),t.jsx(ps,{align:"end","aria-label":"Filters",className:"w-80 p-0",onCloseAutoFocus:y=>{j.current&&(j.current=!1,y.preventDefault())},children:t.jsx(va,{children:t.jsx(ka,{projects:e,state:a,query:s,todayMs:l,onToggle:(y,C)=>r(Zn(a,y,C)),onClearAll:()=>{i(),j.current=!0,f(!1),h.current?.focus()}})})})]}),x&&o!==null&&t.jsx("span",{className:$("hidden whitespace-nowrap text-meta text-ink-dim",c),"data-project-count":"",children:o}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:g}),m]})},Uc=({filters:e,sort:s,onFiltersChange:n,onSortChange:a,onClearAll:r,hideClearAll:i=!1,searchFieldRef:l})=>{const[o,c]=d.useState(null);d.useEffect(()=>{if(!o)return;let h=null;o.kind==="search"?h=l.current:(h=document.querySelector(`[data-project-chip="${o.index}"]`),h||(h=document.querySelector("[data-project-chip]")),h||(h=document.querySelector("[data-project-filters-button]"))),h&&(h.focus(),c(null))});const m=[];for(const h of Qe){const b=e[h];if(b.length===0)continue;const f=b.map(g=>Xn(h,g)),j=f[0],v=f.length>1?`${nt[h]} · ${j} +${f.length-1}`:`${nt[h]} · ${j}`;m.push({kind:"facet",facet:h,label:v,ariaLabel:`Remove filter: ${nt[h]} · ${f.join(", ")}`,clear:()=>n({...e,[h]:[]})})}if(s&&m.push({kind:"sort",spec:s,label:`Sort: ${Ge(s.key)}`,ariaLabel:`Remove sort: ${Ge(s.key)}, ${ks(s.key,s.direction)}`,clear:()=>a(null)}),m.length===0)return null;const u=(h,b)=>{b.clear();const f=m.length-1;c(f===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(h,f-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.map((h,b)=>t.jsx(xe,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":b,"aria-label":h.ariaLabel,onClick:()=>u(b,h),children:[h.kind==="sort"&&(h.spec.direction==="asc"?t.jsx(An,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Tn,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:h.label}),t.jsx(At,{className:$("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},h.kind==="facet"?h.facet:"sort")),!i&&t.jsx(U,{variant:"link",size:"sm",onClick:()=>{r(),c({kind:"search"})},children:"Clear all"})]})},wa="projects-view",Bc=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function zc(){try{const e=localStorage.getItem(wa);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function Yc(e){try{localStorage.setItem(wa,e)}catch{}}const Hc=({value:e,onChange:s})=>t.jsx(Cr,{value:e,onValueChange:n=>s(n),children:t.jsx(Er,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:Bc.map(n=>t.jsx(Rr,{value:n.value,children:n.label},n.value))})}),Wc=["r1","r2","r3","r4","r5","r6"],Kc=4e3,jn={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."},sd=({nowMs:e=Date.now()})=>{const{projectId:s}=jr(),n=Rt(),a=Ve(),r=yr(a.data,"projects",1),i=r==="enabled",l=he(a.data,"projects",Gi),o=Sn(he(a.data,"team_catalogue")),c=Xr(i),m=ei(),u=$n(),h=Pn(),[b,f]=d.useState(!1),[j,v]=d.useState(()=>zc()),[g,x]=d.useState(()=>vi()),[y,C]=d.useState(null),[w,L]=d.useState(""),[T,_]=d.useState(Ks),[O,p]=d.useState(()=>vo()),[A,E]=d.useState(""),P=d.useRef(""),z=d.useRef(null),I=d.useRef(null),B=S=>{z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null),S!==""&&S===P.current?(E(""),z.current=window.requestAnimationFrame(()=>{z.current=null,E(S)})):E(S),P.current=S,I.current!==null&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{I.current=null,P.current="",E("")},Kc)},W=()=>{z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null),I.current!==null&&(window.clearTimeout(I.current),I.current=null),P.current="",E("")},V=S=>{L(S),W()},le=S=>{_(S),W()},Q=d.useRef(null),J=cl(),k=c.data??[],N=Ns(e),R=oo(w,i&&l),M=Jn(w),F=d.useMemo(()=>R.answer?ro(k,R.answer.projects):null,[k,R.answer]),q=M!=="",ae=d.useMemo(()=>q?F??ao(k,M):k,[k,M,q,F]),Ee=F===null?"client":"backend",Y=d.useMemo(()=>ho(ae,T,N),[ae,T,N]),Ne=l&&q&&R.pending,ge=q||!rt(T),me=d.useMemo(()=>Us(k,g,e),[k,g,e]),X=d.useMemo(()=>Us(Y,g,e),[Y,g,e]),Re=yi(g),re=j==="board"?X.length:Y.length,Xe=!ge||!c.isSuccess?null:j==="board"?`${X.length} of ${me.length} in window`:`${Y.length} of ${k.length} projects`,ee=c.isSuccess&&k.length>0,Se=ee&&ge&&re===0&&!Ne,Ie=Ne&&re===0&&ee,[It,Ze]=d.useState(!1);d.useEffect(()=>{if(!It)return;const S=document.querySelector('[data-tour-tag="projects-board-window"]');S&&(S.focus(),Ze(!1))}),d.useEffect(()=>{if(!i||s)return;const S=H=>{const K=H.target;if(!K||K.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(K.tagName)||K.closest('[role="dialog"]'))return;const ye=H.key==="/"&&!H.metaKey&&!H.ctrlKey&&!H.altKey,se=(H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="f";!ye&&!se||(H.preventDefault(),Q.current?.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[i,s]);const et=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const S=et.current;S!==null&&(S.scrollTop=0)},[s]);const pt=Zr(j==="timeline"?k.map(S=>S.id):[],i),D=new Map(k.map((S,H)=>[S.id,pt[H]])),te=Y.map(S=>({project:S,milestones:D.get(S.id)?.data?.project.milestones??[]})),tt=j==="timeline"?Y.filter(S=>D.get(S.id)?.isLoading).length:0,be=j==="timeline"?Y.filter(S=>D.get(S.id)?.isError).length:0,xt=()=>{for(const S of pt)S.isError&&S.refetch()},Le=S=>{p(S),ko(S),B(wo(S))},Na=(S,H)=>{_(K=>Zn(K,S,H)),W()},gt=()=>{const S=w.trim()!=="",H=!rt(T),K=O!==null;L(""),_(Ks),O!==null&&Le(null),B(No({search:S,filters:H,sort:K}))},_s=()=>{x("all"),Bs("all"),Ze(!0)},[je,Cs]=d.useState(null),Lt=d.useRef(!1),Es=()=>{Lt.current=!1,Cs(null)},[Sa,Rs]=d.useState([]),Ta=he(a.data,"projects_force_done"),_a=(S,H)=>{const K=S.id,ye=Z(H).label;Rs(se=>se.includes(K)?se:[...se,K]),Wo({move:()=>u.mutateAsync({key:K,fields:{status:H}}),forceDoneOffered:Ta,claimQuestion:()=>Lt.current?!1:(Lt.current=!0,!0)}).then(se=>{if(se.kind==="accepted"){fe(`Moved to ${ye}`),c.refetch().then(()=>J(K));return}if(se.kind==="question"){Cs({project:S,status:H,refusal:se.refusal});return}ie(se.copy,se.refusal?{action:{label:"View project",onClick:()=>void n(`/projects/${K}`)}}:void 0),J(K)}).finally(()=>{Rs(se=>se.filter(Ca=>Ca!==K))})};return i?s?t.jsx("div",{ref:et,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(_c,{projectKey:s,nowMs:e})}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"@container flex shrink-0 flex-col gap-8 px-6 pt-6",children:[t.jsx(Is,{title:"Projects",icon:Fs,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Refresh projects",title:"Refresh projects",disabled:c.isFetching,onClick:()=>void c.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(Pr,{})}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(at,{}),"New project"]})]})}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3","data-project-search-row":"",children:[t.jsx(Hc,{value:j,onChange:S=>{v(S),Yc(S)}}),t.jsx(qc,{projects:ae,query:w,onQueryChange:V,filters:T,onFiltersChange:le,onClearAll:gt,todayMs:N,resultText:Xe,countRevealClass:j==="board"?"@[47rem]:inline":void 0,disabled:c.isError,searchFieldRef:Q,trailing:j==="board"&&!(c.isSuccess&&c.data.length===0)?t.jsx(Go,{value:g,onChange:S=>{x(S),Bs(S)}}):null})]}),t.jsx(Uc,{filters:T,sort:O,onFiltersChange:le,onSortChange:Le,onClearAll:gt,hideClearAll:Se,searchFieldRef:Q}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:A})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[c.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…"}),Wc.map(S=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(Fe,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-40 shrink-0 bg-elevated"})]},S))]}),c.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Ht,{variant:"danger",children:c.error instanceof Error&&c.error.message?c.error.message:"The projects could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void c.refetch(),children:"Try again"})]}),c.isSuccess&&c.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(U,{variant:"primary",onClick:()=>f(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(at,{}),"New project"]})]}),Ie&&t.jsx("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:"Searching…"})}),ee&&Se&&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:w.trim()?`No projects match "${w.trim()}".`:"No projects match."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:w.trim()?Ki[Ee]:"Try removing a filter. Clearing the filters restores the list."}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(U,{variant:"secondary",onClick:()=>{gt(),Q.current?.focus()},children:"Clear all"}),j==="board"&&Y.length>0&&t.jsx(U,{variant:"secondary",onClick:_s,children:"Show all time"})]})]}),ee&&!Se&&!Ie&&j==="list"&&t.jsx(Pc,{projects:Y,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),sort:O,onSortChange:Le,searchPopulation:ae,filters:T,query:w,todayMs:N,onToggleFilter:Na,onClearFilters:gt,teamLabelFor:o}),ee&&!Se&&j==="board"&&X.length>0&&t.jsx(ul,{projects:X,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),onEdit:S=>void n(`/projects/${S.id}`),onDelete:C,onMove:_a,teamLabelFor:o,movingKeys:Sa}),ee&&!Se&&!Ie&&j==="board"&&X.length===0&&Re!==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:Re}),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(U,{variant:"secondary",onClick:_s,children:"Show all time"})]}),ee&&!Se&&!Ie&&j==="timeline"&&t.jsx(Ic,{items:te,nowMs:e,onOpen:S=>void n(`/projects/${S.project.id}`),pendingDetails:tt,failedDetails:be,onRetryDetails:xt,teamLabelFor:o})]}),t.jsx(ma,{open:y!==null,projectName:y?.name??"",onClose:()=>C(null),onConfirm:async S=>{y&&(await h.mutateAsync({key:y.id,confirmedName:S}),fe("Project deleted"),C(null))}}),t.jsx(pa,{open:je!==null,refusal:je?.refusal??null,projectLabel:je?G(je.project):"",onClose:()=>{je&&J(je.project.id),Es()},onConfirm:async()=>{if(!je)return;const{project:S,status:H,refusal:K}=je,ye=await u.mutateAsync({key:S.id,fields:{status:H},forceDone:!0});fe(Qn(ye,K.count,Z(H).label)),c.refetch().then(()=>J(S.id))},secondaryLabel:"Open project",onSecondary:()=>{const S=je?.project.id;Es(),S&&n(`/projects/${S}`)}}),t.jsx(Cc,{open:b,onClose:()=>f(!1),onSubmit:async S=>{const H=await m.mutateAsync(S.fields),K=S.followUp?.title??S.fields.name;if(S.followUp)try{await u.mutateAsync({key:H.id,fields:S.followUp})}catch(ye){const se=ye instanceof Error&&ye.message?ye.message:"";ie(`Project ${K} was created, but the extra fields were not saved: ${ft(se)||"the server refused them."} Open the project to set them in place.`);return}fe(`Project ${K} created`)}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Is,{title:"Projects",icon:Fs}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(we,{label:"Checking the server's Projects support"})}):t.jsx(Ht,{variant:"warning",children:jn[r]??jn.unknown})]})};export{sd as ProjectsPage};
45
+ `).trim()}function pa(e,s,n){const a=e.clipboardData?.getData("text/html");if(!a)return;const r=Jl(a);if(!r)return;e.preventDefault();const i=e.currentTarget,l=i.selectionStart??i.value.length,o=i.selectionEnd??l;n(i.value.slice(0,l)+r+i.value.slice(o)),requestAnimationFrame(()=>{const c=s.current;if(!c)return;const m=l+r.length;c.setSelectionRange(m,m)})}const xa=({open:e,refusal:s,projectLabel:n,onClose:a,onConfirm:r,secondaryLabel:i,onSecondary:l})=>{const[o,c]=d.useState(!1),[m,u]=d.useState(null),h=d.useRef(!1),b=d.useRef(null);d.useEffect(()=>{e&&(c(!1),u(null),h.current=!1)},[e]);const f=async()=>{if(!h.current){h.current=!0,c(!0),u(null);try{await r(),a()}catch(v){u({copy:oa(v),gone:ia(v)})}finally{h.current=!1,c(!1)}}},j=s?.names??[];return t.jsx(lt,{open:e,onClose:a,title:"Mark done with open milestones?",dataTourTag:"project-done-anyway-dialog",maxWidth:"xs",dialogProps:{closeDisabled:o,onEscapeKeyDown:v=>{o&&v.preventDefault()},onInteractOutside:v=>{o&&v.preventDefault()},onOpenAutoFocus:v=>{v.preventDefault(),b.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(Be,{ref:b,onClick:a,disabled:o,children:"Cancel"}),!m?.gone&&t.jsx(Be,{onClick:l,disabled:o,children:i}),m?.gone?t.jsx(vt,{"data-project-force-close":"",onClick:a,children:"Close"}):t.jsxs(vt,{"data-project-force-done":"","aria-disabled":o,className:"aria-disabled:pointer-events-none aria-disabled:bg-sunken aria-disabled:text-ink-disabled",onClick:()=>void f(),children:[o?t.jsx(we,{size:"xs"}):t.jsx("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),"Mark done anyway"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink break-words",children:n?`${n} moves to Done and its milestones stay open.`:"The project moves to Done and its milestones stay open."}),t.jsx("p",{className:"text-body-sm text-ink break-words",children:s?Hi(s):""}),j.length>yt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(Nn,{summary:`Show all ${j.length} open milestones`,children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:j.map((v,g)=>t.jsx("li",{className:"break-words",children:v},`${g}-${v}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:m?.copy??""})]})})},ga=({status:e})=>{const s=Z(e);return t.jsxs(xe,{variant:s.variant,children:[ii(e)&&t.jsx(gs,{"aria-hidden":!0}),s.label]})};function ue(e,s){return{name:s,begin:`Edit ${e}`,accept:`Save ${e}`,cancel:`Discard the ${e} edit`,busy:`Saving the ${e}`,saved:`${s} saved`,retry:`Retry saving the ${e}`}}const It=({field:e,fieldRef:s,fieldProps:n,editing:a,label:r,bare:i=!1,display:l,editor:o,slot:c,feedback:m,controlsIdle:u="affordance",hug:h=!1,feedbackExtra:b,className:f,controlsClassName:j})=>t.jsxs("div",{ref:s,...n,"data-project-field":e,className:$(!i&&_s,"min-w-0",r!==void 0&&"flex items-start gap-3",f),children:[r!==void 0&&t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:r}),t.jsxs("div",{className:$("flex min-w-0 flex-col gap-1",h&&"items-start",r!==void 0&&"flex-1"),children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("div",{className:$("min-w-0",h?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:c.begin,children:a?o:l}),t.jsx(os,{api:c,idle:u,className:$("shrink-0",j)})]}),t.jsx("div",{className:$("min-h-[1lh] text-meta",h&&"max-w-96"),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx(ls,{api:m}),b]})})]})]}),$e=({field:e,value:s,display:n,commitFields:a,validate:r,labels:i,commit:l,placeholder:o,mono:c=!1,ramp:m="text-body-sm",label:u,bare:h=!1,autoBegin:b=!1,maxLength:f,onRetire:j,className:v,controlsClassName:g})=>{const[x,y]=d.useState(b);d.useEffect(()=>{x&&s!==""&&(y(!1),j?.("filled"))},[x,s,j]);const C=ht({value:s,commit:async w=>{await l(a(w))},equals:(w,L)=>w.trim()===L.trim(),validate:r,labels:i,selectAllOnBegin:!0,beginOnMount:b,errorCopy:Je,onSettle:w=>{w==="cancelled"&&(y(!1),j?.("cancelled"))}});return!x&&s===""?null:t.jsx(It,{field:e,fieldRef:C.fieldRef,fieldProps:C.fieldProps,editing:C.editing,label:u,bare:h,display:n,slot:C,feedback:C,className:v,controlsClassName:g,editor:t.jsx(ne,{ref:C.editorRef,...C.editorAria,value:C.draft,readOnly:C.phase==="saving",maxLength:f,placeholder:o,"aria-label":i.name,onChange:w=>C.setDraft(w.target.value),spellCheck:!1,autoComplete:"off",className:$("h-8",c?"font-mono text-mono-sm":m)})})},Xl=({project:e,commit:s})=>{const n=e.title??"",[a,r]=d.useState(!1),i=d.useRef(null),l=o=>{r(!1),o==="cancelled"&&setTimeout(()=>i.current?.focus(),0)};return t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[t.jsxs("div",{className:$(_s,"flex min-w-0 flex-col gap-0.5"),children:[n?t.jsx($e,{field:"title",value:n,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:n}),commitFields:o=>({title:o.trim()}),validate:o=>es(o),labels:ue("title","Title"),commit:s,maxLength:Nt,placeholder:"A short name for the workstream",ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx($e,{field:"key",value:e.name,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:e.name}),commitFields:o=>({name:o.trim()}),validate:o=>Kt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Zs,placeholder:"project-key",ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!n&&(a?t.jsx($e,{field:"title",value:"",display:null,commitFields:o=>({title:o.trim()}),validate:o=>es(o),labels:ue("title","Title"),commit:s,maxLength:Nt,placeholder:e.name,ramp:"text-body-sm",bare:!0,autoBegin:!0,onRetire:l}):t.jsx("button",{ref:i,type:"button","data-project-add-title":"",onClick:()=>r(!0),className:$("w-fit cursor-pointer text-meta text-ink-dim","opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","hover:text-ink"),children:"Add a title"}))]}),n&&t.jsx($e,{field:"key",value:e.name,display:t.jsx("span",{className:"font-mono text-mono-sm text-ink-muted",children:e.name}),commitFields:o=>({name:o.trim()}),validate:o=>Kt(o.trim()),labels:ue("key","Key"),commit:s,maxLength:Zs,placeholder:"project-key",mono:!0})]})},Zl=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=Ve(),i=he(r.data,"projects_force_done"),[l,o]=d.useState(null),[c,m]=d.useState(null),u=d.useRef(!1),h=d.useRef(!1),b=d.useRef(null),f=ht({value:e.status,commit:async g=>{const x=u.current;u.current=!1,o(null);try{const y=await s({status:g},x?{forceDone:!0}:void 0);x&&fe(Jn(y,l?.count??0,Z(g).label)),b.current?.resolve()}catch(y){throw o(la(y)),b.current?.reject(y),y}finally{b.current=null}},labels:ue("status","Status"),keyboardCommit:!1,errorCopy:Je,onBegin:()=>a(!0)}),j=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!h.current||f.phase!=="idle"&&f.phase!=="saved")return;h.current=!1;const g=document.querySelector("[data-project-milestones]");g&&(g.scrollIntoView({block:"start"}),g.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const v=()=>new Promise((g,x)=>{if(f.phase!=="error"||f.conflict!==null){x(new Error(""));return}if(!f.dirty){g();return}u.current=!0,b.current={resolve:g,reject:x},f.accept(f.draft,!0)});return t.jsx(It,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(ga,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[j&&t.jsx(U,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>m(l),children:"Mark done anyway…"}),t.jsx(xa,{open:c!==null,refusal:c,projectLabel:G(e),onClose:()=>m(null),onConfirm:v,secondaryLabel:"Review milestones",onSecondary:()=>{m(null),h.current=!0,f.cancel()}})]}),editor:t.jsxs(ze,{open:n,onOpenChange:a,value:f.draft,onValueChange:g=>{a(!1),f.accept(g)},children:[t.jsx(Ye,{ref:f.editorRef,...f.editorAria,"aria-label":"Status","data-project-status":"",className:"h-7 w-fit min-w-36",children:t.jsx(He,{})}),t.jsx(We,{children:Ln.map(g=>t.jsx(_e,{value:g.value,"data-project-status-option":g.value,children:g.label},g.value))})]})})},ec=({project:e,commit:s})=>{const[n,a]=d.useState(!1),r=d.useRef(null),i=d.useRef(null),l=ht({value:e.description,commit:async m=>{await s({description:m.trim()})},equals:(m,u)=>m.trim()===u.trim(),validate:m=>aa(m),multiline:!0,labels:ue("description","Description"),errorCopy:Je,editorRef:r,onSettle:m=>{m==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(n||!l.editing)return;const m=setTimeout(()=>r.current?.focus(),0);return()=>clearTimeout(m)},[n,l.editing]);const c=(l.editing?l.draft:l.displayValue).length>Ke;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:$(_s,"min-w-0"),children:l.editing?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[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(m=>t.jsx("button",{type:"button","data-project-description-mode":m,"aria-pressed":n===(m==="preview"),onClick:()=>a(m==="preview"),className:$("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",n===(m==="preview")&&"bg-surface text-ink"),children:m==="write"?"Write":"Preview"},m))})]}),t.jsx(os,{api:{...l,acceptBlocked:c}})]}),n?t.jsx("div",{"data-project-description-preview":"",className:"h-40 overflow-y-auto rounded-md border border-hairline bg-sunken px-3 py-2",children:l.draft.trim()?t.jsx(ot,{className:"text-body-sm",children:l.draft}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Cn,{ref:r,...l.editorAria,"data-project-description":"",value:l.draft,readOnly:l.phase==="saving",rows:8,placeholder:"Markdown — headings, lists, code.","aria-label":l.labels.name,onChange:m=>l.setDraft(m.target.value),onPaste:m=>pa(m,r,u=>l.setDraft(u)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(ls,{api:l}),t.jsxs("p",{className:$("shrink-0 text-meta tabular-nums",c?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",Ke]})]})]}):t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[(e.description??"").trim()?t.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[t.jsx("div",{className:"min-w-0 flex-1 cursor-text",onDoubleClick:l.begin,children:t.jsx(ot,{className:"text-body",children:e.description??""})}),t.jsx(os,{api:l})]}):t.jsx("button",{ref:i,type:"button","data-project-add-description":"",onClick:l.begin,className:"w-fit cursor-pointer text-body-sm text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink",children:"Add description"}),t.jsx("div",{className:"min-h-[1lh] text-meta",children:t.jsx(ls,{api:l})})]})})},tc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>t.jsx($e,{field:"owner",value:e.owner??"",label:"Owner",display:t.jsx("span",{className:"text-body-sm text-ink",children:e.owner}),commitFields:r=>({owner:r.trim()}),validate:r=>Tt(r,"owner"),labels:ue("owner","Owner"),commit:s,maxLength:St,placeholder:"atlas",autoBegin:n,onRetire:a}),sc=({project:e,commit:s,label:n=null,autoBegin:a=!1,onRetire:r})=>t.jsx($e,{field:"team",value:e.team??"",label:"Team",display:t.jsx("span",{className:"text-body-sm text-ink",children:n??e.team}),commitFields:i=>({team:i.trim()}),validate:i=>Tt(i,"team"),labels:ue("team","Team"),commit:s,maxLength:St,placeholder:"platform",autoBegin:a,onRetire:r}),pn=({project:e,commit:s,which:n,nowMs:a,autoBegin:r=!1,onRetire:i})=>{const l=n==="start"?e.start_date??"":e.target_date??"",o=Ee(),c=Ce(l,o,new Date(a)),m=n==="start"?"Start":"Target";return t.jsx($e,{field:n==="start"?"start-date":"target-date",value:l,label:m,display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),commitFields:u=>n==="start"?{start_date:u}:{target_date:u},validate:u=>{const h=ts(u);return h||(n==="start"?ss(u,e.target_date??""):ss(e.start_date??"",u))},labels:ue(`${m.toLowerCase()} date`,m),commit:s,placeholder:"YYYY-MM-DD",autoBegin:r,onRetire:i})},nc=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const r={estimate:e.estimate,unit:e.estimate_unit==="days"?"days":"points"},[i,l]=d.useState(n);d.useEffect(()=>{i&&e.estimate!==null&&(l(!1),a?.("filled"))},[i,e.estimate,a]);const o=ht({value:{number:e.estimate===null?"":String(e.estimate),unit:r.unit},equals:Yo,commit:async m=>{const u=Wo(r,m);u&&await s(u)},validate:m=>ra(m.number),labels:ue("estimate","Estimate"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Je,onSettle:m=>{m==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const c=Un(e.estimate,e.estimate_unit)||"—";return t.jsx(It,{field:"estimate",fieldRef:o.fieldRef,fieldProps:o.fieldProps,editing:o.editing,label:"Estimate",display:t.jsx("span",{className:"text-body-sm text-ink",children:c}),slot:o,feedback:o,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{ref:o.editorRef,...o.editorAria,"data-project-estimate":"",value:o.draft.number,readOnly:o.phase==="saving",placeholder:"13",inputMode:"decimal","aria-label":o.labels.name,onChange:m=>o.setDraft({...o.draft,number:m.target.value}),className:"h-8 max-w-24"}),t.jsxs(ze,{value:o.draft.unit,onValueChange:m=>o.setDraft({...o.draft,unit:m}),children:[t.jsx(Ye,{"data-project-estimate-unit":"","aria-label":"Estimate unit","aria-invalid":o.editorAria["aria-invalid"],className:"h-8 w-fit min-w-28",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(_e,{value:"points",children:"Points"}),t.jsx(_e,{value:"days",children:"Days"})]})]})]}),o.draft.number.trim()===""&&r.estimate!==null&&t.jsx("p",{className:"text-meta text-ink-muted",children:"Clearing an estimate is not supported yet — saving keeps its current value."})]})})},ac=({project:e,commit:s,autoBegin:n=!1,onRetire:a})=>{const[r,i]=d.useState(n);d.useEffect(()=>{r&&e.tags.length>0&&(i(!1),a?.("filled"))},[r,e.tags,a]);const l=ht({value:e.tags.join(", "),equals:(c,m)=>Ho(it(c),m),commit:async c=>{const{tags:m}=ns(c);await s({tags:m})},validate:c=>ns(c).error,labels:ue("tags","Tags"),selectAllOnBegin:!0,beginOnMount:n,errorCopy:Je,onSettle:c=>{c==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!r&&e.tags.length===0)return null;const o=l.editing?it(l.draft):e.tags;return t.jsx(It,{field:"tags",fieldRef:l.fieldRef,fieldProps:l.fieldProps,editing:l.editing,label:"Tags",display:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(c=>t.jsx(xe,{variant:"outline",children:c},c))}),slot:l,feedback:l,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(ne,{ref:l.editorRef,...l.editorAria,"data-project-tags":"",value:l.draft,readOnly:l.phase==="saving",placeholder:"q4, payments","aria-label":l.labels.name,onChange:c=>l.setDraft(c.target.value),className:"h-8 max-w-72"}),t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:o.map(c=>t.jsx(xe,{variant:"outline",children:c},c))})]})})},rc="project-quick-send:no-target",ic=[],oc=({links:e,target:s,onTargetChange:n,onSend:a,focusTick:r})=>{const i=d.useRef(null),l=Qa(),{frontend:o,refresh:c}=qr(),[m,u]=d.useState(!1),h=Ve(),b=s??rc;d.useEffect(()=>{s&&c(s)},[s,c]),d.useEffect(()=>{r>0&&i.current?.focusInput()},[r]);const f=e.filter(g=>g.exists),v=(f.find(g=>g.session_id===s)??null)?.runtime?.busy===!0;return t.jsxs("div",{"data-tour-tag":"project-quick-send",className:"flex flex-col gap-2 rounded-md bg-surface 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(ze,{value:s??void 0,onValueChange:g=>n(g),children:[t.jsx(Ye,{"aria-label":"Select the session to message",className:"max-w-72",children:t.jsx(He,{placeholder:"No session selected"})}),t.jsx(We,{children:f.map(g=>t.jsx(_e,{value:g.session_id,children:Mt(g)},g.session_id))})]}),m?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:"Sending…"}):v?t.jsx("span",{className:"text-meta text-ink-muted",children:"The session is working — this message steers the running turn."}):null]}),t.jsx(Ja,{ref:i,conversationId:b,messages:ic,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:"Message the session — paste an image to attach it",cwd:o?.cwd,cwdReadOnlyReason:"Quick send follows the conversation's directory.",sessionStatus:o&&s?{frontend:o,costChannels:he(h.data,"cost_channels")}:void 0,recordingProbe:l,hostNotice:s?void 0:{id:"project-quick-send-no-target",node:t.jsx("p",{className:"text-meta text-ink-muted",children:"Choose a session to send to."}),blocksInput:!0,placeholder:"Choose a session to send to."},onSendMessage:async(g,x)=>{if(!s)return!1;u(!0);try{return await a(s,g,v?"steer":"prompt",x)}finally{u(!1),i.current?.focusInput({preventScroll:!0})}}})]})},lc=({links:e,busy:s,onUnlink:n,onLink:a,onQuickSend:r,onStartSession:i})=>{const l=Dt(),o=kt(x=>x.sessions),[c,m]=d.useState(!1),[u,h]=d.useState(null),[b,f]=d.useState(0),j=u&&e.some(x=>x.session_id===u&&x.exists)?u:Li(e),v=d.useMemo(()=>{const x=new Set(e.map(y=>y.session_id));return o.filter(y=>!x.has(y.session_id)).map(y=>({id:y.session_id,name:y.title||y.session_id,description:y.cwd??void 0}))},[o,e]),g=x=>{kt.getState().openSession(x).then(y=>{y&&l(`/chat/${x}`)})};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(U,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(Or,{}),"New session"]}),t.jsxs(U,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx($r,{}),"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(x=>{const y=pi(x),C=xi(x.subagents),w=gi(x.todos),L=x.title||x.session_id,T=x.exists;return t.jsxs("li",{className:$("flex items-center gap-2 rounded-sm px-2 py-2",T&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!T,onClick:()=>{T&&g(x.session_id)},className:$("flex min-w-0 flex-1 items-center gap-2 text-left",T?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{className:$("min-w-0 truncate text-body-sm",x.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:L})}),x.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:"busy"}),C&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:C}),w&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:w}),t.jsx(xe,{variant:y.variant,children:y.label}),T&&t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Message ${L}`,title:`Message ${L}`,onClick:()=>{h(x.session_id),f(_=>_+1)},children:t.jsx(Pr,{})}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":`Unlink ${L}`,onClick:()=>n(x.session_id),children:t.jsx(Xr,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(oc,{links:e,target:j,onTargetChange:h,onSend:r,focusTick:b}),t.jsx(lt,{open:c,onClose:()=>m(!1),title:"Link a session",maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Be,{onClick:()=>m(!1),children:"Close"}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(oe,{children:"Session"}),t.jsx(En,{showLabel:!1,ariaLabel:"Search sessions",busyLabel:"Loading sessions",placeholder:"Search conversations",options:v,selected:null,onSelect:x=>{m(!1),a(x.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:"Conversations already linked to this project are not listed."})]})})]})},cc=({milestones:e,summary:s,busy:n,onToggle:a,onRemove:r,onAdd:i})=>{const[l,o]=d.useState(""),[c,m]=d.useState(""),u=Ee(),h=!Fn.test(c.trim()),b=l.trim().length>0&&!h&&!n,f=()=>{b&&(i(l.trim(),c.trim()),o(""),m(""))};return t.jsxs("section",{"data-project-milestones":"",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",tabIndex:-1,"data-project-milestones-heading":"",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(j=>{const v=li(j.status),g=j.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Rn,{checked:g,disabled:n,onCheckedChange:x=>a(j.name,x===!0),"aria-label":g?`Mark ${j.name} not complete`:`Mark ${j.name} complete`}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:j.name}),j.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:Ce(j.target_date,u)}),t.jsx(xe,{variant:v.variant,children:v.label}),t.jsx(U,{variant:"ghost",size:"icon-sm",disabled:n,"aria-label":`Remove ${j.name}`,onClick:()=>r(j.name),children:t.jsx(Ot,{})})]},j.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(oe,{htmlFor:"project-milestone-name",children:"New milestone"}),t.jsx(ne,{id:"project-milestone-name",value:l,onChange:j=>o(j.target.value),placeholder:"beta cut",onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),f())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:"project-milestone-date",children:"Target date"}),t.jsx(ne,{id:"project-milestone-date",value:c,onChange:j=>m(j.target.value),placeholder:"YYYY-MM-DD","aria-invalid":h}),h&&t.jsx("p",{className:"text-meta text-danger",children:"Dates are YYYY-MM-DD, or empty."})]}),t.jsxs(U,{variant:"secondary",disabled:!b,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(at,{}),"Add"]})]})]})},dc=[{field:"owner",label:"Owner"},{field:"team",label:"Team"},{field:"start",label:"Start date"},{field:"target",label:"Target date"},{field:"estimate",label:"Estimate"},{field:"tags",label:"Tags"}],xn=({label:e,children:s})=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:e}),t.jsx("dd",{className:"min-w-0 flex-1 text-body-sm text-ink",children:s})]}),uc=({project:e,nowMs:s,commit:n,teamLabel:a=null})=>{const r=Ee(),i=new Date(s),[l,o]=d.useState(null),c=d.useRef(null),m=d.useRef(!1),u={owner:e.owner!==null,team:e.team!==null,start:e.start_date!==null,target:e.target_date!==null,estimate:e.estimate!==null,tags:e.tags.length>0},h=(_,O)=>{o(p=>p===_?null:p),O==="cancelled"&&!u[_]&&setTimeout(()=>c.current?.focus(),0)},b=dc.filter(({field:_})=>!u[_]&&l!==_),f=Ce(e.completed_at,r,i),j=e.updated_at>0?ut(dt(e.updated_at,s)):"",v=e.updated_at>0?new Date(e.updated_at*1e3).toLocaleString(r):"",g=u.owner||l==="owner",x=u.team||l==="team",y=u.start||l==="start",C=u.target||l==="target",w=u.estimate||l==="estimate",L=u.tags||l==="tags",T=g||x||y||C||!!f||w||L||e.updated_at>0;return t.jsxs("section",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",children:"Properties"}),b.length>0&&t.jsxs(us,{children:[t.jsx(ms,{asChild:!0,children:t.jsxs("button",{ref:c,type:"button","data-project-add-field":"",className:$("flex shrink-0 cursor-pointer items-center gap-1 rounded-xs text-meta text-ink-dim","transition-colors duration-fast ease-out-quart hover:text-ink"),children:[t.jsx(at,{className:"size-3","aria-hidden":"true"}),"Add"]})}),t.jsx(fs,{align:"end",onCloseAutoFocus:_=>{m.current&&(m.current=!1,_.preventDefault())},children:b.map(({field:_,label:O})=>t.jsx(ke,{"data-project-add-option":_,onSelect:()=>{m.current=!0,o(_)},children:O},_))})]})]}),T?t.jsxs("dl",{className:"flex flex-col gap-2",children:[g&&t.jsx(tc,{project:e,commit:n,autoBegin:l==="owner",onRetire:_=>h("owner",_)}),x&&t.jsx(sc,{project:e,commit:n,label:a,autoBegin:l==="team",onRetire:_=>h("team",_)}),y&&t.jsx(pn,{project:e,commit:n,which:"start",nowMs:s,autoBegin:l==="start",onRetire:_=>h("start",_)}),C&&t.jsx(pn,{project:e,commit:n,which:"target",nowMs:s,autoBegin:l==="target",onRetire:_=>h("target",_)}),f&&t.jsx(xn,{label:"Completed",children:f}),w&&t.jsx(nc,{project:e,commit:n,autoBegin:l==="estimate",onRetire:_=>h("estimate",_)}),L&&t.jsx(ac,{project:e,commit:n,autoBegin:l==="tags",onRetire:_=>h("tags",_)}),e.updated_at>0&&t.jsx(xn,{label:"Updated",children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:v,children:j})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No dates, estimate, tags, owner or team yet."})]})},mc=({project:e})=>{const s=Ve(),n=ma(),{sending:a,cooling:r,cooldownRemainingMs:i}=cl(e.id);if(!he(s.data,"projects_request_update"))return null;const l=G(e),o=el(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(At,{content:r&&i!==null?_t(l,i):Jo,children:t.jsxs(U,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":r?!0:void 0,"aria-describedby":r?o:void 0,onClick:()=>n(e),children:[a?t.jsx(we,{size:"sm"}):r?t.jsx(gs,{}):t.jsx(Qr,{}),a?"Requesting…":r?"Requested":"Request update"]})}),r&&i!==null&&t.jsx("span",{id:o,className:"sr-only",children:_t(l,i)})]})},ba="plain",ja=e=>`team:${e}`,ya=e=>`agent:${e}`;function fc(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function hc(e){return e.kind==="team"?ja(e.name):e.kind==="agent"?ya(e.name):ba}const gn={kind:"plain"},pc=({open:e,onClose:s,onStart:n,teamsEnabled:a,profilesEnabled:r})=>{const[i,l]=d.useState(gn),[o,c]=d.useState(null),[m,u]=d.useState(!1),h=Xa(e&&a),b=Za(e&&r);d.useEffect(()=>{e&&(l(gn),c(null),u(!1))},[e]);const f=d.useMemo(()=>{const y=[{id:ba,name:"Nothing in particular",description:"A plain session; assign a team or agent later.",group:"Plain"}];for(const C of h.data??[])y.push({id:ja(C.name),name:Is(C),keywords:C.name===Is(C)?void 0:[C.name],description:`Team · manager: ${C.manager}`,group:"Teams"});for(const C of(b.data??[]).filter(w=>w.source!=="builtin"))y.push({id:ya(C.name),name:C.name,description:C.description||C.kind,group:"Agents"});return y},[h.data,b.data]),j=f.find(y=>y.id===hc(i))??f[0],v=!a||!r,g=h.isLoading||b.isLoading,x=async()=>{u(!0),c(null);try{await n(i),s()}catch(y){c(y instanceof Error&&y.message?y.message:"The session could not be started.")}finally{u(!1)}};return t.jsx(lt,{open:e,onClose:s,title:"Start a session",maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:m,children:"Cancel"}),t.jsxs(vt,{onClick:()=>void x(),disabled:m,children:[m&&t.jsx(we,{size:"xs"}),"Start session"]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(En,{label:"Work with",placeholder:"Search teams and agents",options:f,selected:j,onSelect:y=>l(fc(y.id)),busy:g,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."}),v&&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."}),o&&t.jsx("p",{className:"text-body-sm text-danger",children:o})]})})},xc=({links:e})=>{const s=Ii(e),n=e.filter(a=>a.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:Hs(s)})]}),n.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:n.map(a=>t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx("span",{className:a.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:Mt(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Hs(a.todos)})]},a.session_id))})]})},gc=({filePath:e,tooltip:s="File actions",icon:n,"aria-label":a="File actions",onShowInCanvas:r})=>{const i=async()=>{if(e)try{await navigator.clipboard.writeText(e),fe("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),ie("Failed to copy file path")}},l=()=>{e&&window.api.openFile(e)};return t.jsxs(us,{children:[t.jsx(At,{content:s,children:t.jsx(ms,{asChild:!0,children:t.jsx(U,{variant:"ghost",size:"icon-sm","aria-label":a,onClick:o=>o.stopPropagation(),children:n??t.jsx(wn,{"aria-hidden":"true"})})})}),t.jsxs(fs,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[r&&t.jsxs(ke,{onSelect:r,children:[t.jsx(er,{"aria-hidden":"true"}),t.jsx("span",{children:"Show in canvas"})]}),t.jsxs(ke,{onSelect:l,children:[t.jsx(Sn,{"aria-hidden":"true"}),t.jsx("span",{children:"Open file"})]}),t.jsxs(ke,{onSelect:()=>window.api.showItemInFolder(e),children:[t.jsx(tr,{"aria-hidden":"true"}),t.jsx("span",{children:"Open folder"})]}),t.jsxs(ke,{onSelect:i,children:[t.jsx(sr,{"aria-hidden":"true"}),t.jsx("span",{children:"Copy file path"})]})]})]})},bc=/[/\\]/;function va(e){if(e.name)return e.name;const s=e.path.split(bc);return s[s.length-1]||"Attachment"}const jc=({attachment:e})=>{const s=va(e),n=Pi(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(Sn,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),n&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:n}),t.jsx(gc,{filePath:e.path,"aria-label":`File actions for ${s}`})]})},yc=({attachment:e})=>{const s=va(e),n=nr(e.path,{mimeType:ar(e.name||e.path),sizeBytes:e.bytes});return n.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(rr,{file:e.path,src:n.url,label:s,conversationId:""})}):n.status==="loading"?t.jsx(ir,{children:t.jsxs("span",{className:"sr-only",children:["Loading ",s]})}):t.jsx(or,{name:s})},vc=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(yc,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(jc,{attachment:s},`${s.path}:${s.added_at}`))}),kc=({update:e,nowMs:s})=>{const n=Ee(),a=Oi(e,n,s);return t.jsxs("article",{className:"flex flex-col gap-2 rounded-sm px-2 py-3",children:[a.length>0&&t.jsx("p",{className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-muted",children:a.map((r,i)=>t.jsxs(d.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:r.text})]},r.key))}),e.text&&t.jsx(ot,{children:e.text}),e.attachments.length>0&&t.jsx(vc,{attachments:e.attachments})]})},wc=({updates:e,nowMs:s})=>{const n=Ee(),a=Ci(e.length),r=$i(e,n,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"}),a&&t.jsx("span",{className:"text-meta text-ink-muted",children:a})]}),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:r.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((l,o)=>t.jsx(kc,{update:l,nowMs:s},`${l.at}:${l.by}:${o}`))})]},i.key||"ungrouped"))})]})},Nc="project_not_found",Sc=({projectKey:e,nowMs:s})=>{const n=Dt(),a=Ve(),r=Tn(he(a.data,"team_catalogue")),i=$n(e,!0),l=Pn(),o=Mn(),c=ai(),m=ri(),u=si(),h=ni(),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=l.isPending||o.isPending||c.isPending||m.isPending||u.isPending||h.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(we,{label:"Loading project"})});if(i.isError||!i.data){const p=i.error instanceof Rt&&(i.error.code===Nc||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(Wt,{variant:"danger",className:"w-full",children:p?"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(U,{variant:"secondary",onClick:()=>void i.refetch(),children:"Try again"}),t.jsxs(U,{variant:"secondary",onClick:()=>void n("/projects"),children:[t.jsx(Fs,{}),"All projects"]})]})]})}const{project:x,links:y}=i.data,C=G(x),w=(p,A)=>l.mutateAsync({key:x.id,fields:p,...A?.forceDone===!0?{forceDone:!0}:{}}),L=x.team?r(x.team):null,T=Mi(x.milestones.filter(p=>p.completed_at!==null).length,x.milestones.length),_=async(p,A,E,P)=>{const z=kt.getState(),I=cr(null,p,z.drafts);if(!I)return!1;try{const{images:B,unreadable:W,overflow:V}=await dr(P,A),le=ur(W);if(le)return ie(le),!1;const Q=mr(V);if(Q)return ie(Q),!1;const J=fr(A,B);if(J)return ie(J),!1;if(await hr(I,{text:A,attachments:P,images:B,mode:E,cwd:z.cwd},p)===null)return ie("That session already has a message going out. Try again in a moment."),!1;const N=y.find(R=>R.session_id===p);return fe(`Sent to ${N?Mt(N):p}`),!0}catch(B){return ie(B instanceof Error&&B.message?B.message:"The message was not sent."),!1}},O=async p=>{const A=kt.getState(),E=p.kind==="plain"?void 0:{kind:p.kind,name:p.name},P=await A.createSession(A.cwd||"~",E);if(!P)throw new Error(A.error??"The session could not be started.");pr.getState().setCurrentInput(P,Fi(x));let z=null;try{await u.mutateAsync({key:x.id,sessionId:P})}catch(I){z=I instanceof Error&&I.message?I.message:"the link was refused"}if(z)ie(`Session started, but linking it failed: ${z}`);else{const I=E?` with ${qi(E)}`:"";fe(`Session started${I} and linked to ${C}.`)}await An(n,P)};return t.jsx(Nl,{children: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 n("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Fs,{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-1 flex-wrap items-start gap-x-3 gap-y-2",children:[t.jsx(Xl,{project:x,commit:w}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(Zl,{project:x,commit:w}),x.progress_stale&&t.jsx(xe,{variant:"warning",children:wt})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(mc,{project:x}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(lr,{}),"Delete"]})]})]})]}),t.jsx(ec,{project:x,commit:w}),t.jsx(uc,{project:x,nowMs:s,commit:w,teamLabel:L}),x.updates.length===0&&x.progress&&t.jsxs("section",{className:"flex flex-col gap-2",children:[t.jsx("h2",{className:"text-title text-ink",children:"Progress"}),t.jsx(ot,{className:"text-body",children:x.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:ui(x,s)})]}),t.jsx(cc,{milestones:x.milestones,summary:T,busy:g,onToggle:(p,A)=>{c.mutateAsync({key:x.id,name:p,completed:A}).catch(E=>{ie(E instanceof Error&&E.message?E.message:"The milestone was not updated.")})},onRemove:p=>{m.mutateAsync({key:x.id,name:p}).catch(A=>{ie(A instanceof Error&&A.message?A.message:"The milestone was not removed.")})},onAdd:(p,A)=>{c.mutateAsync({key:x.id,name:p,targetDate:A}).catch(E=>{ie(E instanceof Error&&E.message?E.message:"The milestone was not added.")})}}),t.jsx(lc,{projectKey:x.id,links:y,busy:g,onStartSession:()=>v(!0),onQuickSend:_,onLink:p=>{u.mutateAsync({key:x.id,sessionId:p}).catch(A=>{ie(A instanceof Error&&A.message?A.message:"The session was not linked.")})},onUnlink:p=>{h.mutateAsync({key:x.id,sessionId:p}).catch(A=>{ie(A instanceof Error&&A.message?A.message:"The session was not unlinked.")})}}),t.jsx(xc,{links:y}),t.jsx(wc,{updates:x.updates,nowMs:s}),t.jsx(fa,{open:b,projectName:x.name,onClose:()=>f(!1),onConfirm:async p=>{await o.mutateAsync({key:x.id,confirmedName:p}),fe("Project deleted"),n("/projects")}}),t.jsx(pc,{open:j,onClose:()=>v(!1),onStart:O,teamsEnabled:he(a.data,"team_catalogue"),profilesEnabled:he(a.data,"profile_catalogue")})]})})},bn={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},Tc=({open:e,onClose:s,onSubmit:n})=>{const[a,r]=d.useState(bn),[i,l]=d.useState({}),[o,c]=d.useState(null),m=d.useRef(null),[u,h]=d.useState(!1),[b,f]=d.useState(!1),[j,v]=d.useState(!1),g=d.useId(),x=d.useRef(null);d.useEffect(()=>{e&&(r({...bn,description:un}),l({}),c(null),h(!1),f(!1),v(!1))},[e]),d.useEffect(()=>{o&&m.current?.scrollIntoView({block:"nearest"})},[o]);const y=(p,A)=>{r(E=>({...E,[p]:A}))},C=b?a.name:Ol(a.title),w=p=>pa(p,x,A=>y("description",A)),L=(p,A)=>{const E={},P=Kt(A);P&&(E.name=P);const z=aa(p.description);z&&(E.description=z);const I=ns(p.tags).error;I&&(E.tags=I);const B=ts(p.startDate);B&&(E.startDate=B);const W=ts(p.targetDate);if(W)E.targetDate=W;else if(!B){const J=ss(p.startDate,p.targetDate);J&&(E.targetDate=J)}if(p.estimate.trim()){const J=ra(p.estimate);J&&(E.estimate=J)}const V=es(p.title);V&&(E.title=V);const le=Tt(p.owner,"owner");le&&(E.owner=le);const Q=Tt(p.team,"team");return Q&&(E.team=Q),E},T=async()=>{const p=C.trim(),A=L(a,p);if(l(A),Object.keys(A).length>0)return;h(!0),c(null);const E=it(a.tags);try{const P={};a.title.trim()&&(P.title=a.title.trim()),a.owner.trim()&&(P.owner=a.owner.trim()),a.team.trim()&&(P.team=a.team.trim()),a.startDate&&(P.start_date=a.startDate),a.targetDate&&(P.target_date=a.targetDate),a.estimate&&(P.estimate=Number(a.estimate),P.estimate_unit=a.estimateUnit),await n({fields:{name:p,...a.description.trim()&&a.description.trim()!==un?{description:a.description.trim()}:{},status:a.status,...E.length>0?{tags:E}:{}},...Object.keys(P).length>0?{followUp:P}:{}}),s()}catch(P){const z=P instanceof Error&&P.message?P.message:"";c(ft(z)||"The project was not saved.")}finally{h(!1)}},_="New project",O=a.description.length>Ke;return t.jsx(lt,{open:e,onClose:s,title:_,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:u,onEscapeKeyDown:p=>{u&&p.preventDefault()},onInteractOutside:p=>{u&&p.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Be,{onClick:s,disabled:u,children:"Cancel"}),t.jsxs(vt,{"data-project-submit":"",onClick:()=>void T(),disabled:u,children:[u&&t.jsx(we,{size:"xs"}),"Create project"]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:p=>{p.preventDefault(),T()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-title`,children:"Title"}),t.jsx(ne,{id:`${g}-title`,"data-project-title":"",value:a.title,onChange:p=>y("title",p.target.value),placeholder:"Payments migration",autoFocus:!0,className:"h-10 text-heading","aria-invalid":!!i.title}),i.title&&t.jsx("p",{className:"text-meta text-danger",children:i.title}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(oe,{htmlFor:`${g}-key`,className:"shrink-0 text-meta text-ink-muted",children:"Key"}),t.jsx(ne,{id:`${g}-key`,"data-project-key":"",value:C,onChange:p=>{f(!0),y("name",p.target.value)},placeholder:"payments-migration","aria-invalid":!!i.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:b?"Letters, digits, dot, underscore or dash; no spaces.":"Derived from the title until you edit it."})]}),i.name&&t.jsx("p",{className:"text-meta text-danger",children:i.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(oe,{htmlFor:`${g}-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(p=>t.jsx("button",{type:"button","data-project-description-mode":p,"aria-pressed":j===(p==="preview"),onClick:()=>v(p==="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",j===(p==="preview")&&"bg-surface text-ink"),children:p==="write"?"Write":"Preview"},p))})]})]}),j?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:a.description.trim()?t.jsx(ot,{className:"text-body-sm",children:a.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Nothing to preview yet."})}):t.jsx(Cn,{ref:x,id:`${g}-description`,"data-project-description":"",value:a.description,onChange:p=>y("description",p.target.value),onPaste:w,rows:8,placeholder:"Markdown — headings, lists, code.","aria-invalid":O||!!i.description,className:"h-44 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.description?t.jsx("p",{className:"text-meta text-danger",children:i.description}):t.jsx("span",{}),t.jsxs("p",{className:$("text-meta tabular-nums",O?"text-danger":"text-ink-muted"),children:[a.description.length,"/",Ke]})]})]}),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(oe,{children:"Status"}),t.jsxs(ze,{value:a.status,onValueChange:p=>y("status",p),children:[t.jsx(Ye,{"aria-label":"Status",children:t.jsx(He,{})}),t.jsx(We,{children:Ln.map(p=>t.jsx(_e,{value:p.value,children:p.label},p.value))})]}),a.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(oe,{htmlFor:`${g}-owner`,children:"Owner"}),t.jsx(ne,{id:`${g}-owner`,"data-project-owner":"",value:a.owner,onChange:p=>y("owner",p.target.value),placeholder:"atlas","aria-invalid":!!i.owner}),i.owner&&t.jsx("p",{className:"text-meta text-danger",children:i.owner})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-team`,children:"Team"}),t.jsx(ne,{id:`${g}-team`,value:a.team,onChange:p=>y("team",p.target.value),placeholder:"platform","aria-invalid":!!i.team}),i.team&&t.jsx("p",{className:"text-meta text-danger",children:i.team})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-target`,children:"Target date"}),t.jsx(ne,{id:`${g}-target`,"data-project-target":"",value:a.targetDate,onChange:p=>y("targetDate",p.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.targetDate}),i.targetDate&&t.jsx("p",{className:"text-meta text-danger",children:i.targetDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-start`,children:"Start date"}),t.jsx(ne,{id:`${g}-start`,value:a.startDate,onChange:p=>y("startDate",p.target.value),placeholder:"YYYY-MM-DD","aria-invalid":!!i.startDate}),i.startDate&&t.jsx("p",{className:"text-meta text-danger",children:i.startDate})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-estimate`,children:"Estimate"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ne,{id:`${g}-estimate`,value:a.estimate,onChange:p=>y("estimate",p.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(ze,{value:a.estimateUnit,onValueChange:p=>y("estimateUnit",p),children:[t.jsx(Ye,{"aria-label":"Estimate unit",className:"max-w-32",children:t.jsx(He,{})}),t.jsxs(We,{children:[t.jsx(_e,{value:"points",children:"Points"}),t.jsx(_e,{value:"days",children:"Days"})]})]})]}),i.estimate&&t.jsx("p",{className:"text-meta text-danger",children:i.estimate})]}),t.jsxs("div",{className:"col-span-2 flex flex-col gap-1.5",children:[t.jsx(oe,{htmlFor:`${g}-tags`,children:"Tags"}),t.jsx(ne,{id:`${g}-tags`,value:a.tags,onChange:p=>y("tags",p.target.value),placeholder:"q4, payments","aria-invalid":!!i.tags}),i.tags?t.jsx("p",{className:"text-meta text-danger",children:i.tags}):t.jsx("p",{className:"text-meta text-ink-muted",children:"Comma-separated, up to 8. Lowercase letters, digits, underscore or dash."})]})]}),o&&t.jsx("p",{ref:m,className:"text-body-sm text-danger",children:o})]})})},ka=({children:e})=>{const s=d.useRef(null),[n,a]=d.useState(!1),r=()=>{const i=s.current;i&&a(i.scrollTop+i.clientHeight<i.scrollHeight-1)};return d.useEffect(r),t.jsx("div",{ref:s,onScroll:r,className:$("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",n&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},_c=({label:e,count:s,selected:n,onToggle:a})=>{const r=d.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(Rn,{id:r,checked:n,onCheckedChange:()=>a()}),t.jsx(oe,{htmlFor:r,className:"min-w-0 flex-1 cursor-pointer truncate font-normal text-body-sm text-ink",children:e}),t.jsx("span",{className:"text-meta text-ink-dim tabular-nums",children:s})]})},Cc=({column:e,spec:s,onChange:n})=>{const a=d.useId(),r=s!==null&&s.key===e,i=r?s.direction:qt(e),l=i==="asc"?"desc":"asc",o=()=>n({key:e,direction:r?l:qt(e)}),c=s===null?"default":r?"sorted":"other";return t.jsxs("fieldset",{className:"m-0 flex flex-col gap-0.5 border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:`Sort by ${Ge(e)}`}),t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-body-sm hover:bg-sunken",children:[t.jsx("input",{type:"radio",name:a,checked:c==="default",onChange:()=>n(null),className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="default"?"text-ink":"text-ink-muted"),children:jo})]}),t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-body-sm hover:bg-sunken",children:[t.jsx("input",{type:"radio",name:a,checked:c==="sorted",onChange:o,onClick:()=>{c==="sorted"&&o()},onKeyDown:m=>{c==="sorted"&&(m.key!==" "&&m.key!=="Enter"||(m.preventDefault(),o()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:$("min-w-0 flex-1 truncate",c==="sorted"?"text-ink":"text-ink-muted"),children:`Sort by ${Ge(e)}, ${ws(e,r?i:qt(e))}`})]})]})},Ec=({facet:e,options:s,onToggle:n})=>t.jsxs("div",{className:"flex flex-col gap-0.5 border-b border-hairline px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"px-1 text-meta text-ink-muted",children:nt[e]}),s.map(a=>t.jsx(_c,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>n(e,a.value)},`${e}:${a.value??"none"}`))]}),wa=({projects:e,state:s,query:n,todayMs:a,onToggle:r,onClearAll:i,scope:l,sort:o})=>{const c=d.useMemo(()=>l===void 0?bo(e,s,a):l===null?[]:[na(l,e,s,a)],[l,e,s,a]),m=!rt(s)||n.trim()!=="";return t.jsxs("div",{className:"flex flex-col",children:[l===void 0&&t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-hairline px-3 py-2",children:[t.jsx("span",{className:"text-body-sm text-ink-muted",children:"Filters"}),m&&t.jsx(U,{variant:"link",size:"sm",onClick:i,children:"Clear all"})]}),o&&t.jsxs("div",{className:"flex flex-col gap-0.5 border-b border-hairline px-3 py-2",children:[t.jsx("span",{className:"px-1 text-meta text-ink-muted",children:`Sort by ${Ge(o.key)}`}),t.jsx(Cc,{column:o.key,spec:o.spec,onChange:o.onChange})]}),c.map(u=>t.jsx(Ec,{facet:u.facet,options:u.options,onToggle:r},u.facet))]})},Rc=({team:e,count:s,headingId:n,className:a,...r})=>t.jsxs("div",{...r,className:$("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",a),children:[t.jsx("h3",{id:n,className:"truncate text-ink",children:e??js}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":fi(s),children:s})]}),ve=[{key:"name",label:"Project",className:"min-w-0 flex-1",sort:"name",facet:null},{key:"status",label:"Status",className:"w-20 shrink-0",sort:"status",facet:"status"},{key:"target",label:"Target",className:"hidden w-32 shrink-0 @[40rem]:block",sort:"target",facet:"target"},{key:"estimate",label:"Estimate",className:"hidden w-16 shrink-0 @[40rem]:block",sort:"estimate",facet:"estimate"},{key:"milestones",label:"Milestones",className:"hidden w-20 shrink-0 @[34rem]:block",sort:"milestones",facet:"milestones"},{key:"live",label:"Live",className:"hidden w-14 shrink-0 @[34rem]:block",sort:"live",facet:"live"},{key:"progress",label:"Progress",className:"w-40 shrink-0",sort:"progress",facet:"progress"}];function Dc(e,s){const n=dt(e.progress_updated_at,s);return n?ut(n):"not reported"}const Ac=({direction:e})=>e==="asc"?t.jsx(On,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(_n,{size:10,className:"shrink-0","aria-hidden":"true"}),Oc=({projects:e,nowMs:s,onOpen:n,sort:a,onSortChange:r,searchPopulation:i,filters:l,query:o,todayMs:c,onToggleFilter:m,onClearFilters:u,teamLabelFor:h=b=>b})=>{const b=Ee(),f=a?Co(e,a):e,j=ys(f,mt),v=d.useId(),g=T=>`${v}-team-${T}`,[x,y]=d.useState(0),C=d.useRef([]),w=(T,_)=>{const O=ve.length;for(let p=1;p<=O;p+=1){const A=(T+_*p+O*O)%O,E=C.current[A];if(E&&E.offsetParent!==null){y(A),E.focus();return}}},L=T=>_=>{_.key!=="ArrowLeft"&&_.key!=="ArrowRight"||(_.preventDefault(),w(T,_.key==="ArrowRight"?1:-1))};return t.jsxs("div",{className:"@container flex min-h-0 flex-1 flex-col","data-testid":"project-list",children:[t.jsx("table",{className:"block shrink-0","aria-label":"Project columns",children:t.jsx("thead",{className:"block",children:t.jsx("tr",{className:"flex items-center gap-3 px-9 py-2 text-meta text-ink-muted",children:ve.map((T,_)=>{const O=a!==null&&a.key===T.sort;return t.jsx("th",{scope:"col","aria-sort":O?a.direction==="desc"?"descending":"ascending":"none",className:$(T.className,"p-0 text-left font-normal"),children:t.jsxs(hs,{children:[t.jsx(ps,{asChild:!0,children:t.jsxs("button",{type:"button",ref:p=>{C.current[_]=p},tabIndex:_===x?0:-1,"data-project-column":T.key,onFocus:()=>y(_),onKeyDown:L(_),className:$("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",O?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:T.label}),O?t.jsx(Ac,{direction:a.direction}):t.jsx(xr,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(xs,{align:"start","aria-label":`${T.label} column`,className:"w-72 p-0",children:t.jsx(ka,{children:t.jsx(wa,{projects:i,state:l,query:o,todayMs:c,onToggle:m,onClearAll:u,scope:T.facet,sort:{key:T.sort,spec:a,onChange:r}})})})]})},T.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:j.map((T,_)=>t.jsxs("li",{children:[t.jsx(Rc,{team:T.team==null?null:h(T.team),count:T.items.length,headingId:g(_),className:"sticky top-0 z-10","data-project-team":T.team??""}),t.jsx("ul",{"aria-labelledby":g(_),className:"divide-y divide-hairline",children:T.items.map(O=>{const p=new Map(zn(O,b).map(P=>[P.key,P.text])),A=Bn(O.milestones_completed,O.milestones_total),E=bs(O.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>n(O),"data-project-name":O.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:$(ve[0].className,"truncate text-body-sm text-ink"),children:G(O)}),t.jsx("span",{className:ve[1].className,children:t.jsx(ga,{status:O.status})}),t.jsx("span",{className:$(ve[2].className,"truncate text-meta text-ink-muted"),children:p.get("target")??p.get("completed")??""}),t.jsx("span",{className:$(ve[3].className,"truncate text-meta text-ink-muted"),children:p.get("estimate")??""}),t.jsx("span",{className:$(ve[4].className,"truncate text-meta text-ink-muted"),children:A}),t.jsx("span",{className:$(ve[5].className,"truncate text-meta text-ink-muted"),children:E}),t.jsxs("span",{className:$(ve[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Dc(O,s)}),O.progress_stale&&t.jsx(xe,{variant:"warning",children:wt})]})]})},O.id)})})]},T.team??""))})]})},Et=224,jn=36,$c={day:"Days",week:"Weeks",month:"Months",quarter:"Quarters"},Pc=({items:e,nowMs:s,onOpen:n,pendingDetails:a,failedDetails:r,onRetryDetails:i,teamLabelFor:l=o=>o})=>{const[o,c]=d.useState(null),[m,u]=d.useState(0),h=d.useRef(null),b=Ss(s),f=d.useMemo(()=>Do(e,b),[e,b]),j=d.useMemo(()=>Ao(e),[e]),v=d.useMemo(()=>ys(j.dated,T=>mt(T.project)),[j]);d.useLayoutEffect(()=>{const T=h.current;if(!T)return;const _=()=>u(T.clientWidth);if(_(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(_);return O.observe(T),()=>O.disconnect()},[]);const g=Math.max(m-Et-24,160),x=f?Eo(Xs(f.startMs,f.endMs),g):"month",y=o??x,C=T=>{const _=Te.indexOf(y),O=Te[_-T];O&&c(O)},w=Ns[y],L=f?Xs(f.startMs,f.endMs)*w:0;return t.jsxs("div",{ref:h,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:r>0?`Milestones could not be read for ${r} project${r===1?"":"s"}.`:`${j.dated.length} dated · ${j.undated.length} without dates${a>0?` · loading milestones for ${a}…`:""}`}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[r>0&&t.jsx(U,{variant:"secondary",size:"sm",onClick:i,children:"Try again"}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom in",title:"Zoom in (finer)",disabled:!f||y===Te[0],onClick:()=>C(1),children:t.jsx(at,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:$c[y]}),t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Zoom out",title:"Zoom out (coarser)",disabled:!f||y===Te[Te.length-1],onClick:()=>C(-1),children:t.jsx(Cr,{})})]})]}),f&&j.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(Mc,{startMs:f.startMs,endMs:f.endMs,tier:y,pxPerDay:w,trackPx:L}),v.map(T=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":T.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:Et},children:[t.jsx("span",{className:"truncate text-ink",children:T.team==null?js:l(T.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:T.items.length})]})}),T.items.map(_=>t.jsx(Ic,{item:_,spanStart:f.startMs,pxPerDay:w,trackPx:L,today:b,onOpen:()=>n(_)},_.project.id))]},T.team??""))]})}):null,j.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(Nn,{defaultOpen:j.dated.length===0,triggerClassName:"text-ink hover:bg-row-hover hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-8 py-0",summary:t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-meta",children:[t.jsx(Wr,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Oo(j.undated.length)})]}),children:[j.dated.length===0&&t.jsx("p",{className:"pb-1 text-meta text-ink-muted",children:"Set a start date, a target date or a milestone date and it will appear on the timeline."}),t.jsx("ul",{className:"flex max-h-24 flex-wrap gap-x-3 gap-y-1 overflow-y-auto",children:j.undated.map(T=>t.jsx("li",{children:t.jsx("button",{type:"button",className:"rounded-sm text-meta text-ink hover:bg-row-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent",onClick:()=>n(T),children:G(T.project)})},T.project.id))})]})})]})},Mc=({startMs:e,endMs:s,tier:n,pxPerDay:a,trackPx:r})=>{const i=Bo(e,s,n);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Et}}),t.jsx("span",{className:"relative block h-6",style:{width:r},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:Oe(e,l.dayMs)*a},children:[t.jsx("span",{className:$("absolute top-0 h-full w-px",l.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:l.label})]},l.dayMs))})]})},Ic=({item:e,spanStart:s,pxPerDay:n,trackPx:a,today:r,onOpen:i})=>{const{project:l}=e,o=$o(e),c=Po(e),m=u=>new Date(u).toISOString().slice(0,10);return t.jsxs("button",{type:"button",onClick:i,"data-project-name":l.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:Et,height:jn},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:G(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:jn},children:[o&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:Oe(s,o.fromMs)*n,width:(Oe(o.fromMs,o.toMs)+1)*n},title:`${Ce(m(o.fromMs))} → ${Ce(m(o.toMs))}`}),c.map(u=>t.jsx("span",{"data-milestone":u.status,className:$("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",u.status==="completed"&&"bg-success",u.status==="overdue"&&"bg-warning",u.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:Oe(s,u.dayMs)*n},title:`${u.name} · ${u.status} · ${Ce(m(u.dayMs))}`},`${u.name}-${u.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:Oe(s,r)*n},"aria-hidden":"true"})]})]})},Lc=({projects:e,query:s,onQueryChange:n,filters:a,onFiltersChange:r,onClearAll:i,todayMs:l,resultText:o,countRevealClass:c="@[37rem]:inline",trailing:m,disabled:u=!1,searchFieldRef:h})=>{const[b,f]=d.useState(!1),j=d.useRef(!1),v=ho(a),g=Dn(o??"",300),x=s.trim()!==""||!rt(a);return t.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-3",children:[t.jsxs("div",{className:"relative w-full min-w-0 max-w-[400px]",children:[t.jsx(gr,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(ne,{ref:h,inputSize:"sm",value:s,onChange:y=>n(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(s?n(""):y.currentTarget.blur())},placeholder:"Search projects","aria-label":"Search projects",autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(U,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>br(h.current,n),"aria-label":"Clear search",children:t.jsx(Ot,{"aria-hidden":"true"})}):t.jsx("span",{className:"pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-ink-dim",children:t.jsx(jr,{shortcut:"/"})})]}),t.jsxs(hs,{open:b,onOpenChange:f,children:[t.jsx(ps,{asChild:!0,children:t.jsxs(U,{variant:"secondary",size:"sm",disabled:u,"data-project-filters-button":"",children:[t.jsx(Gr,{size:14,"aria-hidden":"true"}),"Filters",v>0&&t.jsx(xe,{variant:"neutral",children:v})]})}),t.jsx(xs,{align:"end","aria-label":"Filters",className:"w-80 p-0",onCloseAutoFocus:y=>{j.current&&(j.current=!1,y.preventDefault())},children:t.jsx(ka,{children:t.jsx(wa,{projects:e,state:a,query:s,todayMs:l,onToggle:(y,C)=>r(ea(a,y,C)),onClearAll:()=>{i(),j.current=!0,f(!1),h.current?.focus()}})})})]}),x&&o!==null&&t.jsx("span",{className:$("hidden whitespace-nowrap text-meta text-ink-dim",c),"data-project-count":"",children:o}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:g}),m]})},Fc=({filters:e,sort:s,onFiltersChange:n,onSortChange:a,onClearAll:r,hideClearAll:i=!1,searchFieldRef:l})=>{const[o,c]=d.useState(null);d.useEffect(()=>{if(!o)return;let h=null;o.kind==="search"?h=l.current:(h=document.querySelector(`[data-project-chip="${o.index}"]`),h||(h=document.querySelector("[data-project-chip]")),h||(h=document.querySelector("[data-project-filters-button]"))),h&&(h.focus(),c(null))});const m=[];for(const h of Qe){const b=e[h];if(b.length===0)continue;const f=b.map(g=>Zn(h,g)),j=f[0],v=f.length>1?`${nt[h]} · ${j} +${f.length-1}`:`${nt[h]} · ${j}`;m.push({kind:"facet",facet:h,label:v,ariaLabel:`Remove filter: ${nt[h]} · ${f.join(", ")}`,clear:()=>n({...e,[h]:[]})})}if(s&&m.push({kind:"sort",spec:s,label:`Sort: ${Ge(s.key)}`,ariaLabel:`Remove sort: ${Ge(s.key)}, ${ws(s.key,s.direction)}`,clear:()=>a(null)}),m.length===0)return null;const u=(h,b)=>{b.clear();const f=m.length-1;c(f===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(h,f-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.map((h,b)=>t.jsx(xe,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":b,"aria-label":h.ariaLabel,onClick:()=>u(b,h),children:[h.kind==="sort"&&(h.spec.direction==="asc"?t.jsx(On,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(_n,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:h.label}),t.jsx(Ot,{className:$("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},h.kind==="facet"?h.facet:"sort")),!i&&t.jsx(U,{variant:"link",size:"sm",onClick:()=>{r(),c({kind:"search"})},children:"Clear all"})]})},Na="projects-view",qc=[{value:"list",label:"List"},{value:"board",label:"Board"},{value:"timeline",label:"Timeline"}];function Uc(){try{const e=localStorage.getItem(Na);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function Bc(e){try{localStorage.setItem(Na,e)}catch{}}const zc=({value:e,onChange:s})=>t.jsx(Er,{value:e,onValueChange:n=>s(n),children:t.jsx(Rr,{"aria-label":"Project view","data-tour-tag":"projects-view-switcher",children:qc.map(n=>t.jsx(Dr,{value:n.value,children:n.label},n.value))})}),Yc=["r1","r2","r3","r4","r5","r6"],Hc=4e3,yn={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."},ed=({nowMs:e=Date.now()})=>{const{projectId:s}=yr(),n=Dt(),a=Ve(),r=vr(a.data,"projects",1),i=r==="enabled",l=he(a.data,"projects",Vi),o=Tn(he(a.data,"team_catalogue")),c=Zr(i),m=ti(),u=Pn(),h=Mn(),[b,f]=d.useState(!1),[j,v]=d.useState(()=>Uc()),[g,x]=d.useState(()=>ki()),[y,C]=d.useState(null),[w,L]=d.useState(""),[T,_]=d.useState(Gs),[O,p]=d.useState(()=>ko()),[A,E]=d.useState(""),P=d.useRef(""),z=d.useRef(null),I=d.useRef(null),B=S=>{z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null),S!==""&&S===P.current?(E(""),z.current=window.requestAnimationFrame(()=>{z.current=null,E(S)})):E(S),P.current=S,I.current!==null&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{I.current=null,P.current="",E("")},Hc)},W=()=>{z.current!==null&&(window.cancelAnimationFrame(z.current),z.current=null),I.current!==null&&(window.clearTimeout(I.current),I.current=null),P.current="",E("")},V=S=>{L(S),W()},le=S=>{_(S),W()},Q=d.useRef(null),J=dl(),k=c.data??[],N=Ss(e),R=lo(w,i&&l),M=Xn(w),F=d.useMemo(()=>R.answer?io(k,R.answer.projects):null,[k,R.answer]),q=M!=="",ae=d.useMemo(()=>q?F??ro(k,M):k,[k,M,q,F]),Re=F===null?"client":"backend",Y=d.useMemo(()=>po(ae,T,N),[ae,T,N]),Ne=l&&q&&R.pending,ge=q||!rt(T),me=d.useMemo(()=>Bs(k,g,e),[k,g,e]),X=d.useMemo(()=>Bs(Y,g,e),[Y,g,e]),De=vi(g),re=j==="board"?X.length:Y.length,Xe=!ge||!c.isSuccess?null:j==="board"?`${X.length} of ${me.length} in window`:`${Y.length} of ${k.length} projects`,ee=c.isSuccess&&k.length>0,Se=ee&&ge&&re===0&&!Ne,Ie=Ne&&re===0&&ee,[Lt,Ze]=d.useState(!1);d.useEffect(()=>{if(!Lt)return;const S=document.querySelector('[data-tour-tag="projects-board-window"]');S&&(S.focus(),Ze(!1))}),d.useEffect(()=>{if(!i||s)return;const S=H=>{const K=H.target;if(!K||K.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(K.tagName)||K.closest('[role="dialog"]'))return;const ye=H.key==="/"&&!H.metaKey&&!H.ctrlKey&&!H.altKey,se=(H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="f";!ye&&!se||(H.preventDefault(),Q.current?.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[i,s]);const et=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const S=et.current;S!==null&&(S.scrollTop=0)},[s]);const pt=ei(j==="timeline"?k.map(S=>S.id):[],i),D=new Map(k.map((S,H)=>[S.id,pt[H]])),te=Y.map(S=>({project:S,milestones:D.get(S.id)?.data?.project.milestones??[]})),tt=j==="timeline"?Y.filter(S=>D.get(S.id)?.isLoading).length:0,be=j==="timeline"?Y.filter(S=>D.get(S.id)?.isError).length:0,xt=()=>{for(const S of pt)S.isError&&S.refetch()},Le=S=>{p(S),wo(S),B(No(S))},Sa=(S,H)=>{_(K=>ea(K,S,H)),W()},gt=()=>{const S=w.trim()!=="",H=!rt(T),K=O!==null;L(""),_(Gs),O!==null&&Le(null),B(So({search:S,filters:H,sort:K}))},Cs=()=>{x("all"),zs("all"),Ze(!0)},[je,Es]=d.useState(null),Ft=d.useRef(!1),Rs=()=>{Ft.current=!1,Es(null)},[Ta,Ds]=d.useState([]),_a=he(a.data,"projects_force_done"),Ca=(S,H)=>{const K=S.id,ye=Z(H).label;Ds(se=>se.includes(K)?se:[...se,K]),Ko({move:()=>u.mutateAsync({key:K,fields:{status:H}}),forceDoneOffered:_a,claimQuestion:()=>Ft.current?!1:(Ft.current=!0,!0)}).then(se=>{if(se.kind==="accepted"){fe(`Moved to ${ye}`),c.refetch().then(()=>J(K));return}if(se.kind==="question"){Es({project:S,status:H,refusal:se.refusal});return}ie(se.copy,se.refusal?{action:{label:"View project",onClick:()=>void n(`/projects/${K}`)}}:void 0),J(K)}).finally(()=>{Ds(se=>se.filter(Ea=>Ea!==K))})};return i?s?t.jsx("div",{ref:et,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(Sc,{projectKey:s,nowMs:e})}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"@container flex shrink-0 flex-col gap-8 px-6 pt-6",children:[t.jsx(Ls,{title:"Projects",icon:qs,subtitle:"Workstreams you and your agents track across sessions.",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{variant:"secondary",size:"icon","aria-label":"Refresh projects",title:"Refresh projects",disabled:c.isFetching,onClick:()=>void c.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx(Mr,{})}),t.jsxs(U,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(at,{}),"New project"]})]})}),t.jsxs("div",{className:"flex shrink-0 flex-col gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3","data-project-search-row":"",children:[t.jsx(zc,{value:j,onChange:S=>{v(S),Bc(S)}}),t.jsx(Lc,{projects:ae,query:w,onQueryChange:V,filters:T,onFiltersChange:le,onClearAll:gt,todayMs:N,resultText:Xe,countRevealClass:j==="board"?"@[47rem]:inline":void 0,disabled:c.isError,searchFieldRef:Q,trailing:j==="board"&&!(c.isSuccess&&c.data.length===0)?t.jsx(Vo,{value:g,onChange:S=>{x(S),zs(S)}}):null})]}),t.jsx(Fc,{filters:T,sort:O,onFiltersChange:le,onSortChange:Le,onClearAll:gt,hideClearAll:Se,searchFieldRef:Q}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:A})]})]}),t.jsxs("div",{className:"mt-8 flex min-h-0 flex-1 flex-col",children:[c.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…"}),Yc.map(S=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(Fe,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Fe,{className:"h-4 w-40 shrink-0 bg-elevated"})]},S))]}),c.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Wt,{variant:"danger",children:c.error instanceof Error&&c.error.message?c.error.message:"The projects could not be read."}),t.jsx(U,{variant:"secondary",size:"sm",onClick:()=>void c.refetch(),children:"Try again"})]}),c.isSuccess&&c.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(U,{variant:"primary",onClick:()=>f(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(at,{}),"New project"]})]}),Ie&&t.jsx("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:"Searching…"})}),ee&&Se&&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:w.trim()?`No projects match "${w.trim()}".`:"No projects match."}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:w.trim()?Gi[Re]:"Try removing a filter. Clearing the filters restores the list."}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(U,{variant:"secondary",onClick:()=>{gt(),Q.current?.focus()},children:"Clear all"}),j==="board"&&Y.length>0&&t.jsx(U,{variant:"secondary",onClick:Cs,children:"Show all time"})]})]}),ee&&!Se&&!Ie&&j==="list"&&t.jsx(Oc,{projects:Y,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),sort:O,onSortChange:Le,searchPopulation:ae,filters:T,query:w,todayMs:N,onToggleFilter:Sa,onClearFilters:gt,teamLabelFor:o}),ee&&!Se&&j==="board"&&X.length>0&&t.jsx(ml,{projects:X,nowMs:e,onOpen:S=>void n(`/projects/${S.id}`),onEdit:S=>void n(`/projects/${S.id}`),onDelete:C,onMove:Ca,teamLabelFor:o,movingKeys:Ta}),ee&&!Se&&!Ie&&j==="board"&&X.length===0&&De!==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:De}),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(U,{variant:"secondary",onClick:Cs,children:"Show all time"})]}),ee&&!Se&&!Ie&&j==="timeline"&&t.jsx(Pc,{items:te,nowMs:e,onOpen:S=>void n(`/projects/${S.project.id}`),pendingDetails:tt,failedDetails:be,onRetryDetails:xt,teamLabelFor:o})]}),t.jsx(fa,{open:y!==null,projectName:y?.name??"",onClose:()=>C(null),onConfirm:async S=>{y&&(await h.mutateAsync({key:y.id,confirmedName:S}),fe("Project deleted"),C(null))}}),t.jsx(xa,{open:je!==null,refusal:je?.refusal??null,projectLabel:je?G(je.project):"",onClose:()=>{je&&J(je.project.id),Rs()},onConfirm:async()=>{if(!je)return;const{project:S,status:H,refusal:K}=je,ye=await u.mutateAsync({key:S.id,fields:{status:H},forceDone:!0});fe(Jn(ye,K.count,Z(H).label)),c.refetch().then(()=>J(S.id))},secondaryLabel:"Open project",onSecondary:()=>{const S=je?.project.id;Rs(),S&&n(`/projects/${S}`)}}),t.jsx(Tc,{open:b,onClose:()=>f(!1),onSubmit:async S=>{const H=await m.mutateAsync(S.fields),K=S.followUp?.title??S.fields.name;if(S.followUp)try{await u.mutateAsync({key:H.id,fields:S.followUp})}catch(ye){const se=ye instanceof Error&&ye.message?ye.message:"";ie(`Project ${K} was created, but the extra fields were not saved: ${ft(se)||"the server refused them."} Open the project to set them in place.`);return}fe(`Project ${K} created`)}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Ls,{title:"Projects",icon:qs}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(we,{label:"Checking the server's Projects support"})}):t.jsx(Wt,{variant:"warning",children:yn[r]??yn.unknown})]})};export{ed as ProjectsPage};