local-operator-ui 0.36.9 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/out/main/index.js +2046 -71
  2. package/out/preload/index.js +60 -3
  3. package/out/renderer/assets/{_basePickBy-DMcJ3S7k.js → _basePickBy-DhcDqJuW.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-D1lM95PP.js → _baseUniq-DlAVpNmp.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-BtlkMdIG.js → agent-details-page-ydYZH4Kq.js} +2 -2
  6. package/out/renderer/assets/agent-hub-page-C46GCUT2.js +6 -0
  7. package/out/renderer/assets/agents-page-BaARss9y.js +7 -0
  8. package/out/renderer/assets/{arc-DsWPhFjP.js → arc-C-BSLMbh.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DNfaqYw7.js → architectureDiagram-IEHRJDOE-nDfnCWAM.js} +1 -1
  10. package/out/renderer/assets/{arrow-up-Begz0H6P.js → arrow-up-JQ86w8h2.js} +1 -1
  11. package/out/renderer/assets/{blockDiagram-JOT3LUYC-BJENelAS.js → blockDiagram-JOT3LUYC-BJgd2uGT.js} +1 -1
  12. package/out/renderer/assets/{book-open-5BRzSc1Z.js → book-open-yjstLkVS.js} +1 -1
  13. package/out/renderer/assets/browser-page-BVFs2_w9.js +1 -0
  14. package/out/renderer/assets/{browser-webauthn-prompt-yiiGM34k.js → browser-webauthn-prompt-Ch0P_oH9.js} +1 -1
  15. package/out/renderer/assets/{building-2-T3OwRXqF.js → building-2-Cupv31tS.js} +1 -1
  16. package/out/renderer/assets/{c4Diagram-VJAJSXHY-CEijvBuX.js → c4Diagram-VJAJSXHY-lIXnBLZ5.js} +1 -1
  17. package/out/renderer/assets/channel-BqEnrEwi.js +1 -0
  18. package/out/renderer/assets/{chunk-4BMEZGHF-CtdEc_y-.js → chunk-4BMEZGHF-DF2ktHZp.js} +1 -1
  19. package/out/renderer/assets/{chunk-A2AXSNBT-DzhnEf46.js → chunk-A2AXSNBT-CNRON9Qy.js} +1 -1
  20. package/out/renderer/assets/{chunk-AEK57VVT-BNPXglh5.js → chunk-AEK57VVT-BGXI1SR5.js} +1 -1
  21. package/out/renderer/assets/{chunk-D6G4REZN-xyBvlSTD.js → chunk-D6G4REZN-CW_SyuGg.js} +1 -1
  22. package/out/renderer/assets/{chunk-RZ5BOZE2-8dmoMKQZ.js → chunk-RZ5BOZE2-gU0oYsA6.js} +1 -1
  23. package/out/renderer/assets/{chunk-XZIHB7SX-DLfyXOIE.js → chunk-XZIHB7SX-BrVtbfMc.js} +1 -1
  24. package/out/renderer/assets/classDiagram-GIVACNV2-DNUqXdeF.js +1 -0
  25. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DNUqXdeF.js +1 -0
  26. package/out/renderer/assets/clone-_PvxPvQz.js +1 -0
  27. package/out/renderer/assets/{console-mirror-Ddv0LHdM.js → console-mirror-CkCxHgcU.js} +1 -1
  28. package/out/renderer/assets/{consoleCapture-Cm0PxzNK.js → consoleCapture-EZYleEWx.js} +1 -1
  29. package/out/renderer/assets/{conversation-input-sync-i6ilfEnc.js → conversation-input-sync-bgD4kyw3.js} +280 -280
  30. package/out/renderer/assets/{dagre-OKDRZEBW-Dob_U_wx.js → dagre-OKDRZEBW-BDR0956-.js} +1 -1
  31. package/out/renderer/assets/{diagram-SSKATNLV-Dh8_PC2b.js → diagram-SSKATNLV-DbCZDtm7.js} +1 -1
  32. package/out/renderer/assets/{diagram-VNBRO52H-NZ9qo5oG.js → diagram-VNBRO52H-BpXb_OjM.js} +1 -1
  33. package/out/renderer/assets/{erDiagram-Q7BY3M3F-BOUqITNj.js → erDiagram-Q7BY3M3F-CZukR1Y4.js} +1 -1
  34. package/out/renderer/assets/{error-boundary-LwhkYl0Z.js → error-boundary-DJAF_aYL.js} +2 -2
  35. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CZiUXOWe.js → flowDiagram-4HSFHLVR-CqKOnXAd.js} +1 -1
  36. package/out/renderer/assets/{ganttDiagram-APWFNJXF-DqweVTOi.js → ganttDiagram-APWFNJXF-B9I0smi4.js} +1 -1
  37. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-KbIhBWBs.js → gitGraphDiagram-7IBYFJ6S-Bj6-u-5w.js} +1 -1
  38. package/out/renderer/assets/{graph-O8aHYPDC.js → graph-BsgoQZc2.js} +1 -1
  39. package/out/renderer/assets/{hash-WYoE1Khd.js → hash-BLfEUuGg.js} +1 -1
  40. package/out/renderer/assets/index-CL2MVLxd.css +1 -0
  41. package/out/renderer/assets/{index-D8fns19J.js → index-D7pJoOu_.js} +1 -1
  42. package/out/renderer/assets/index-N0lyyVVo.js +57 -0
  43. package/out/renderer/assets/index-jVCAPb0a.js +825 -0
  44. package/out/renderer/assets/{index-D4j9Ycfd.js → index-lMi7GI2V.js} +1 -1
  45. package/out/renderer/assets/{infoDiagram-PH2N3AL5-DU0dbmt7.js → infoDiagram-PH2N3AL5-DQ3aMjor.js} +1 -1
  46. package/out/renderer/assets/{installer-C-rmt1Yr.js → installer-Ch3nb3kq.js} +1 -1
  47. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DUybkPWl.js → journeyDiagram-U35MCT3I-B_RccO_x.js} +1 -1
  48. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-onKwvi0l.js → kanban-definition-NDS4AKOZ-BvVJZaiy.js} +1 -1
  49. package/out/renderer/assets/{layout-RKbPA5d2.js → layout-DCACUDHF.js} +1 -1
  50. package/out/renderer/assets/legacy-agents-page-BovdqsXe.js +33 -0
  51. package/out/renderer/assets/library-page-Cm-o3Z-q.js +157 -0
  52. package/out/renderer/assets/{mermaid.core-DdYe4AYl.js → mermaid.core-BXcegHmP.js} +5 -5
  53. package/out/renderer/assets/{mesh-page-CW4tQHZJ.js → mesh-page-ChyvMUoR.js} +1 -1
  54. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DrsGVqDZ.js → mindmap-definition-ALO5MXBD-Bx_gU6ka.js} +1 -1
  55. package/out/renderer/assets/{mini-CHtVBEDV.js → mini-DRt4PdyG.js} +1 -1
  56. package/out/renderer/assets/{notebook-pen-BHmA9Aor.js → notebook-pen-CKr2WSrK.js} +1 -1
  57. package/out/renderer/assets/org-access-CU1oOVqv.js +1 -0
  58. package/out/renderer/assets/{org-surface-gate-UD-oXlvB.js → org-surface-gate-C86b758Z.js} +1 -1
  59. package/out/renderer/assets/{page-header-CoSSp6Ks.js → page-header-CZcbRwLy.js} +1 -1
  60. package/out/renderer/assets/{pieDiagram-IB7DONF6-C0gYyuJA.js → pieDiagram-IB7DONF6-jEzs31M9.js} +1 -1
  61. package/out/renderer/assets/{projects-page-DU4wZXNY.js → projects-page-BSvdM2gY.js} +2 -2
  62. package/out/renderer/assets/publication-validation-g2Kk53C8.js +1 -0
  63. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DbEt_1Ti.js → quadrantDiagram-7GDLP6J5-C07DLJe_.js} +1 -1
  64. package/out/renderer/assets/{radar-MK3ICKWK-BCsS7AKJ.js → radar-MK3ICKWK-DFqDL3G4.js} +1 -1
  65. package/out/renderer/assets/{radient-auth-buttons-vBcfzZdx.js → radient-auth-buttons-DP81yj6b.js} +1 -1
  66. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-C3WoUU_2.js → requirementDiagram-KVF5MWMF-DZVSGDrD.js} +1 -1
  67. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-vE9T4I2u.js → sankeyDiagram-QLVOVGJD-Efyu9UfS.js} +1 -1
  68. package/out/renderer/assets/{schedules-page-CGCopxbo.js → schedules-page-CNIApkVt.js} +1 -1
  69. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-CqwLiiP3.js → sequenceDiagram-X6HHIX6F-C5QQ4cH3.js} +1 -1
  70. package/out/renderer/assets/{settings-page-DrZcB4mR.js → settings-page-Cd8GUEn_.js} +7 -7
  71. package/out/renderer/assets/smartart-DAuiyto3.js +1 -0
  72. package/out/renderer/assets/{stateDiagram-DGXRK772-W9r7i0O7.js → stateDiagram-DGXRK772-DlvSEVs4.js} +1 -1
  73. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CCLt0TcZ.js +1 -0
  74. package/out/renderer/assets/team-bridge-page-CosfhCZV.js +11 -0
  75. package/out/renderer/assets/{timeline-definition-BDJGKUSR-QYcBKPg2.js → timeline-definition-BDJGKUSR-XgOjVv3O.js} +1 -1
  76. package/out/renderer/assets/ui-preferences-store-C91RrpgH.js +1 -0
  77. package/out/renderer/assets/{use-download-agent-mutation-CNw_prc9.js → use-download-agent-mutation-B-kxWpF6.js} +4 -4
  78. package/out/renderer/assets/{use-session-snapshot-CzQdg29b.js → use-session-snapshot-BiiULlsj.js} +1 -1
  79. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-B37S1SAD.js → xychartDiagram-VJFVF3MP-B0CsPCbY.js} +1 -1
  80. package/out/renderer/console-capture.html +5 -5
  81. package/out/renderer/index.html +7 -7
  82. package/out/renderer/installer.html +4 -4
  83. package/out/renderer/mini.html +7 -7
  84. package/package.json +4 -3
  85. package/out/renderer/assets/agent-hub-page-CvnosPnb.js +0 -6
  86. package/out/renderer/assets/agents-page-C3p0casO.js +0 -7
  87. package/out/renderer/assets/browser-page-Dwy1BXTz.js +0 -1
  88. package/out/renderer/assets/channel-BuIK1RR0.js +0 -1
  89. package/out/renderer/assets/classDiagram-GIVACNV2-CcLuC1It.js +0 -1
  90. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CcLuC1It.js +0 -1
  91. package/out/renderer/assets/clone-C-B3TV1U.js +0 -1
  92. package/out/renderer/assets/index-6crVx9hx.js +0 -57
  93. package/out/renderer/assets/index-O8V3Lal4.css +0 -1
  94. package/out/renderer/assets/index-Re5k_KqO.js +0 -824
  95. package/out/renderer/assets/legacy-agents-page-DmUlGbZ_.js +0 -33
  96. package/out/renderer/assets/library-page-CsUF7SOa.js +0 -157
  97. package/out/renderer/assets/org-access-Bqdb8uRz.js +0 -1
  98. package/out/renderer/assets/publication-validation-D4Bef-1h.js +0 -1
  99. package/out/renderer/assets/smartart-C6SIDcio.js +0 -1
  100. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-cX4iVUJF.js +0 -1
  101. package/out/renderer/assets/tags-input-chips-CqW7e8j3.js +0 -1
  102. package/out/renderer/assets/team-bridge-page-Dt4lEU3y.js +0 -11
  103. package/out/renderer/assets/ui-preferences-store-BWYRkg79.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as n,d as $e,j as t,c as R,r as d}from"./index-6crVx9hx.js";import{$ as gs,aO as ze,d as _e,c8 as qn,a0 as xs,u as Bn,cr as V,cs as Rt,ct as Un,V as qt,cu as $s,cv as zs,cw as Gs,bT as $n,aP as ve,cx as zn,a as nt,c as ye,aI as Cr,aR as Bt,a1 as _t,aV as Xe,cy as Gn,cb as Yn,cn as Kn,cz as Hn,co as Wn,aX as Er,aW as Dt,bx as Vn,az as Xn,ap as At,bF as Jn,bL as Qn,bK as Zn,bI as Ys,cq as ea,cd as ta,ca as sa,cc as ra,a2 as de,cA as Tr,cB as Rr,cj as Ut,cC as Be,cD as na,cE as jt,cF as aa,cG as Ks,cH as ht,cI as Dr,cJ as oa,cK as ia,cL as Ar,aQ as ca,ao as la,aj as ua,ak as da,am as pa,an as ma,aq as fa,aw as _a,cM as ja,cN as Pr,bO as ha,cO as ga,ay as xa,aS as ba,b7 as va}from"./conversation-input-sync-i6ilfEnc.js";import{c as gt,u as I,K as Je,y as $t,M as Qe,N as Ze,O as et,P as Oe,a as G,i as bs,j as vs,S as Te,k as ys,l as be,a9 as ya,aa as wa,ab as ka,o as Na,p as Sa,m as Ca,B as ke,a5 as ws,af as ks,a7 as Ns,I as ue,X as zt,h as Ss,T as Or,L as pe,R as Mr,C as Ir,ag as Ea,D as Ta,b as Ra,e as Da,A as ts,U as Aa,a0 as Pa,a1 as Oa,a2 as Ma,x as He}from"./error-boundary-LwhkYl0Z.js";import{P as Hs}from"./page-header-CoSSp6Ks.js";import{c6 as Ia,bO as Lr,c7 as La,bW as Fr,c8 as Fa,bX as qa,by as Ba,a as pt,c9 as Ua,$ as Ws,ca as Vs,c5 as $a}from"./index-Re5k_KqO.js";import{h as za,j as Ga,k as tt,l as Ya,m as ss}from"./ui-preferences-store-BWYRkg79.js";import{u as Ka}from"./use-session-snapshot-CzQdg29b.js";import{A as qr}from"./arrow-up-Begz0H6P.js";import"./console-mirror-Ddv0LHdM.js";/**
1
+ import{t as n,d as $e,j as t,c as R,r as d}from"./index-N0lyyVVo.js";import{_ as gs,aO as ze,d as _e,c8 as qn,$ as xs,u as Bn,cu as V,cv as Rt,cw as Un,a0 as qt,cx as $s,cy as zs,cz as Gs,bT as $n,aP as ve,cA as zn,a as nt,c as ye,aI as Cr,aR as Bt,a1 as _t,aV as Xe,cB as Gn,cb as Yn,cr as Kn,cC as Hn,cs as Wn,aX as Er,aW as Dt,bx as Vn,az as Xn,ap as At,bF as Jn,bL as Qn,bK as Zn,bI as Ys,ct as ea,cd as ta,ca as sa,cc as ra,a2 as de,cD as Tr,cE as Rr,cj as Ut,cF as Be,cG as na,cH as jt,cl as aa,cm as Ks,cI as ht,cJ as Dr,cK as oa,cL as ia,cM as Ar,aQ as ca,ao as la,aj as ua,ak as da,am as pa,an as ma,aq as fa,aw as _a,cN as ja,cO as Pr,bO as ha,cP as ga,ay as xa,aS as ba,b7 as va}from"./conversation-input-sync-bgD4kyw3.js";import{c as gt,u as I,K as Je,y as $t,M as Qe,N as Ze,O as et,P as Oe,B as G,h as bs,i as vs,S as Te,j as ys,k as be,a9 as ya,aa as wa,ab as ka,n as Na,o as Sa,l as Ca,q as ke,a5 as ws,af as ks,a7 as Ns,I as ue,X as zt,g as Ss,T as Or,L as pe,R as Mr,C as Ir,ag as Ea,D as Ta,a as Ra,d as Da,A as ts,U as Aa,a0 as Pa,a1 as Oa,a2 as Ma,x as He}from"./error-boundary-DJAF_aYL.js";import{P as Hs}from"./page-header-CZcbRwLy.js";import{ce as Ia,bW as Lr,cf as La,c2 as Fr,cg as Fa,c3 as qa,bG as Ba,p as pt,ch as Ua,ac as Ws,ci as Vs,cd as $a}from"./index-jVCAPb0a.js";import{h as za,j as Ga,k as tt,l as Ya,m as ss}from"./ui-preferences-store-C91RrpgH.js";import{u as Ka}from"./use-session-snapshot-BiiULlsj.js";import{A as qr}from"./arrow-up-JQ86w8h2.js";import"./console-mirror-CkCxHgcU.js";/**
2
2
  * @license lucide-react v0.507.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -42,4 +42,4 @@ import{t as n,d as $e,j as t,c as R,r as d}from"./index-6crVx9hx.js";import{$ as
42
42
  `);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(Wc,`
43
43
  `).replace(Vc,`
44
44
 
45
- `).trim()}function wn(e,s,r){const a=e.clipboardData?.getData("text/html");if(!a)return;const o=Xc(a);if(!o)return;e.preventDefault();const i=e.currentTarget,l=i.selectionStart??i.value.length,c=i.selectionEnd??l;r(i.value.slice(0,l)+o+i.value.slice(c)),requestAnimationFrame(()=>{const u=s.current;if(!u)return;const p=l+o.length;u.setSelectionRange(p,p)})}const kn=({open:e,refusal:s,projectLabel:r,onClose:a,onConfirm:o,secondaryLabel:i,onSecondary:l})=>{I();const[c,u]=d.useState(!1),[p,m]=d.useState(null),_=d.useRef(!1),j=d.useRef(null);d.useEffect(()=>{e&&(u(!1),m(null),_.current=!1)},[e]);const f=async()=>{if(!_.current){_.current=!0,u(!0),m(null);try{await o(),a()}catch(S){m({copy:_n(S),gone:fn(S)})}finally{_.current=!1,u(!1)}}},g=s?.names??[];return t.jsx(_t,{open:e,onClose:a,title:n("ui.projects.project_done_anyway_dialog.mark_done_with_open_milestones"),dataTourTag:"project-done-anyway-dialog",maxWidth:"xs",dialogProps:{closeDisabled:c,onEscapeKeyDown:S=>{c&&S.preventDefault()},onInteractOutside:S=>{c&&S.preventDefault()},onOpenAutoFocus:S=>{S.preventDefault(),j.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(Xe,{ref:j,onClick:a,disabled:c,children:n("ui.projects.project_done_anyway_dialog.cancel")}),!p?.gone&&t.jsx(Xe,{onClick:l,disabled:c,children:i}),p?.gone?t.jsx(Dt,{"data-project-force-close":"",onClick:a,children:n("ui.projects.project_done_anyway_dialog.close")}):t.jsxs(Dt,{"data-project-force-done":"","aria-disabled":c,className:"aria-disabled:pointer-events-none aria-disabled:bg-sunken aria-disabled:text-ink-disabled",onClick:()=>void f(),children:[c?t.jsx(Te,{size:"xs"}):t.jsx("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),n("ui.projects.project_done_anyway_dialog.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:r?n("ui.projects.project_done_anyway_dialog.projectlabel_moves_to_done_and_its_milestones_stay_open",{projectLabel:String(r)}):n("ui.projects.project_done_anyway_dialog.the_project_moves_to_done_and_its_milestones_stay_open")}),t.jsx("p",{className:"text-body-sm text-ink break-words",children:s?Vo(s):""}),g.length>Tt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(Er,{summary:n("ui.projects.project_done_anyway_dialog.show_all_length_open_milestones",{length:g.length}),children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:g.map((S,b)=>t.jsx("li",{className:"break-words",children:S},`${b}-${S}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:p?.copy??""})]})})},Nn=({status:e})=>{const s=ae(e);return t.jsxs(ke,{variant:s.variant,children:[lo(e)&&t.jsx(Ss,{"aria-hidden":!0}),s.label]})},Jc="project-key",Qc="project-key";function ge(e,s){return{name:s,begin:n("ui.projects.project_editors.edit_field",{field:String(e)}),accept:n("ui.projects.project_editors.save_field",{field:String(e)}),cancel:n("ui.projects.project_editors.discard_the_field_edit",{field:String(e)}),busy:n("ui.projects.project_editors.saving_the_field",{field:String(e)}),saved:n("ui.projects.project_editors.display_saved",{display:String(s)}),retry:n("ui.projects.project_editors.retry_saving_the_field",{field:String(e)})}}const Ht=({field:e,fieldRef:s,fieldProps:r,editing:a,label:o,bare:i=!1,display:l,editor:c,slot:u,feedback:p,controlsIdle:m="affordance",hug:_=!1,feedbackExtra:j,className:f,controlsClassName:g})=>t.jsxs("div",{ref:s,...r,"data-project-field":e,className:R(!i&&Ms,"min-w-0",o!==void 0&&"flex items-start gap-3",f),children:[o!==void 0&&t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:o}),t.jsxs("div",{className:R("flex min-w-0 flex-col gap-1",_&&"items-start",o!==void 0&&"flex-1"),children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("div",{className:R("min-w-0",_?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:u.begin,children:a?c:l}),t.jsx(js,{api:u,idle:m,className:R("shrink-0",g)})]}),t.jsx("div",{className:R("min-h-[1lh] text-meta",_&&"max-w-96"),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx(hs,{api:p}),j]})})]})]}),qe=({field:e,value:s,display:r,commitFields:a,validate:o,labels:i,commit:l,placeholder:c,mono:u=!1,ramp:p="text-body-sm",label:m,bare:_=!1,autoBegin:j=!1,maxLength:f,onRetire:g,className:S,controlsClassName:b})=>{const[x,w]=d.useState(j);d.useEffect(()=>{x&&s!==""&&(w(!1),g?.("filled"))},[x,s,g]);const T=wt({value:s,commit:async k=>{await l(a(k))},equals:(k,q)=>k.trim()===q.trim(),validate:o,labels:i,selectAllOnBegin:!0,beginOnMount:j,errorCopy:ot,onSettle:k=>{k==="cancelled"&&(w(!1),g?.("cancelled"))}});return!x&&s===""?null:t.jsx(Ht,{field:e,fieldRef:T.fieldRef,fieldProps:T.fieldProps,editing:T.editing,label:m,bare:_,display:r,slot:T,feedback:T,className:S,controlsClassName:b,editor:t.jsx(ue,{ref:T.editorRef,...T.editorAria,value:T.draft,readOnly:T.phase==="saving",maxLength:f,placeholder:c,"aria-label":i.name,onChange:k=>T.setDraft(k.target.value),spellCheck:!1,autoComplete:"off",className:R("h-8",u?"font-mono text-mono-sm":p)})})},Zc=({project:e,commit:s})=>{I();const r=e.title??"",[a,o]=d.useState(!1),i=d.useRef(null),l=c=>{o(!1),c==="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:R(Ms,"flex min-w-0 flex-col gap-0.5"),children:[r?t.jsx(qe,{field:"title",value:r,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:r}),commitFields:c=>({title:c.trim()}),validate:c=>ls(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:Pt,placeholder:n("ui.projects.project_editors.a_short_name_for_the_workstream"),ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(qe,{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:c=>({name:c.trim()}),validate:c=>ss(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:Jc,ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!r&&(a?t.jsx(qe,{field:"title",value:"",display:null,commitFields:c=>({title:c.trim()}),validate:c=>ls(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:Pt,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:()=>o(!0),className:R("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:n("ui.projects.project_editors.add_a_title")}))]}),r&&t.jsx(qe,{field:"key",value:e.name,display:t.jsx("span",{className:"font-mono text-mono-sm text-ink-muted",children:e.name}),commitFields:c=>({name:c.trim()}),validate:c=>ss(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:Qc,mono:!0})]})},el=({project:e,commit:s})=>{I();const[r,a]=d.useState(!1),o=nt(),i=ye(o.data,"projects_force_done"),[l,c]=d.useState(null),[u,p]=d.useState(null),m=d.useRef(!1),_=d.useRef(!1),j=d.useRef(null),f=wt({value:e.status,commit:async b=>{const x=m.current;m.current=!1,c(null);try{const w=await s({status:b},x?{forceDone:!0}:void 0);x&&ve(nn(w,l?.count??0,ae(b).label)),j.current?.resolve()}catch(w){throw c(jn(w)),j.current?.reject(w),w}finally{j.current=null}},labels:ge("status",n("ui.projects.project_editors.status")),keyboardCommit:!1,errorCopy:ot,onBegin:()=>a(!0)}),g=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!_.current||f.phase!=="idle"&&f.phase!=="saved")return;_.current=!1;const b=document.querySelector("[data-project-milestones]");b&&(b.scrollIntoView({block:"start"}),b.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const S=()=>new Promise((b,x)=>{if(f.phase!=="error"||f.conflict!==null){x(new Error(""));return}if(!f.dirty){b();return}m.current=!0,j.current={resolve:b,reject:x},f.accept(f.draft,!0)});return t.jsx(Ht,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(Nn,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[g&&t.jsx(G,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>p(l),children:n("ui.projects.project_editors.mark_done_anyway")}),t.jsx(kn,{open:u!==null,refusal:u,projectLabel:ne(e),onClose:()=>p(null),onConfirm:S,secondaryLabel:n("ui.projects.project_editors.review_milestones"),onSecondary:()=>{p(null),_.current=!0,f.cancel()}})]}),editor:t.jsxs(Je,{open:r,onOpenChange:a,value:f.draft,onValueChange:b=>{a(!1),f.accept(b)},children:[t.jsx(Qe,{ref:f.editorRef,...f.editorAria,"aria-label":n("ui.projects.project_editors.status"),"data-project-status":"",className:"h-7 w-fit min-w-36",children:t.jsx(Ze,{})}),t.jsx(et,{children:Yr.map(b=>t.jsx(Oe,{value:b.value,"data-project-status-option":b.value,children:b.label},b.value))})]})})},tl=({project:e,commit:s})=>{I();const[r,a]=d.useState(!1),o=d.useRef(null),i=d.useRef(null),l=wt({value:e.description,commit:async p=>{await s({description:p.trim()})},equals:(p,m)=>p.trim()===m.trim(),validate:p=>pn(p),multiline:!0,labels:ge("description",n("ui.projects.project_editors.description")),errorCopy:ot,editorRef:o,onSettle:p=>{p==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(r||!l.editing)return;const p=setTimeout(()=>o.current?.focus(),0);return()=>clearTimeout(p)},[r,l.editing]);const u=(l.editing?l.draft:l.displayValue).length>tt;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:R(Ms,"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:n("ui.projects.project_editors.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":r===(p==="preview"),onClick:()=>a(p==="preview"),className:R("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",r===(p==="preview")&&"bg-surface text-ink"),children:p==="write"?n("ui.projects.project_editors.write"):n("ui.projects.project_editors.preview")},p))})]}),t.jsx(js,{api:{...l,acceptBlocked:u}})]}),r?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(rt,{className:"text-body-sm",children:l.draft}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_editors.nothing_to_preview_yet")})}):t.jsx(Or,{ref:o,...l.editorAria,"data-project-description":"",value:l.draft,readOnly:l.phase==="saving",rows:8,placeholder:n("ui.projects.project_editors.markdown_headings_lists_code"),"aria-label":l.labels.name,onChange:p=>l.setDraft(p.target.value),onPaste:p=>wn(p,o,m=>l.setDraft(m)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(hs,{api:l}),t.jsxs("p",{className:R("shrink-0 text-meta tabular-nums",u?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",tt]})]})]}):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(rt,{className:"text-body",children:e.description??""})}),t.jsx(js,{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:n("ui.projects.project_editors.add_description")}),t.jsx("div",{className:"min-h-[1lh] text-meta",children:t.jsx(hs,{api:l})})]})})},sl=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>(I(),t.jsx(qe,{field:"owner",value:e.owner??"",label:n("ui.projects.project_editors.owner"),display:t.jsx("span",{className:"text-body-sm text-ink",children:e.owner}),commitFields:o=>({owner:o.trim()}),validate:o=>Mt(o,"owner"),labels:ge("owner",n("ui.projects.project_editors.owner")),commit:s,maxLength:Ot,placeholder:n("ui.projects.examples.owner"),autoBegin:r,onRetire:a})),rl=({project:e,commit:s,label:r=null,autoBegin:a=!1,onRetire:o})=>(I(),t.jsx(qe,{field:"team",value:e.team??"",label:n("ui.projects.project_editors.team"),display:t.jsx("span",{className:"text-body-sm text-ink",children:r??e.team}),commitFields:i=>({team:i.trim()}),validate:i=>Mt(i,"team"),labels:ge("team",n("ui.projects.project_editors.team")),commit:s,maxLength:Ot,placeholder:n("ui.projects.examples.team"),autoBegin:a,onRetire:o})),vr=({project:e,commit:s,which:r,nowMs:a,autoBegin:o=!1,onRetire:i})=>{const l=r==="start"?e.start_date??"":e.target_date??"",c=I(),u=Me(l,c,new Date(a)),p=r==="start"?n("ui.projects.project_editors.start"):n("ui.projects.project_editors.target");return t.jsx(qe,{field:r==="start"?"start-date":"target-date",value:l,label:p,display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),commitFields:m=>r==="start"?{start_date:m}:{target_date:m},validate:m=>{const _=us(m);return _||(r==="start"?ds(m,e.target_date??""):ds(e.start_date??"",m))},labels:ge(n("ui.projects.project_editors.tolowercase_date",{toLowerCase:String(p.toLowerCase())}),p),commit:s,placeholder:"YYYY-MM-DD",autoBegin:o,onRetire:i})},nl=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{I();const o={estimate:e.estimate,unit:e.estimate_unit==="days"?"days":"points"},[i,l]=d.useState(r);d.useEffect(()=>{i&&e.estimate!==null&&(l(!1),a?.("filled"))},[i,e.estimate,a]);const c=wt({value:{number:e.estimate===null?"":String(e.estimate),unit:o.unit},equals:Yi,commit:async p=>{const m=Hi(o,p);m&&await s(m)},validate:p=>mn(p.number),labels:ge("estimate",n("ui.projects.project_editors.estimate")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:ot,onSettle:p=>{p==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const u=Wr(e.estimate,e.estimate_unit)||"—";return t.jsx(Ht,{field:"estimate",fieldRef:c.fieldRef,fieldProps:c.fieldProps,editing:c.editing,label:n("ui.projects.project_editors.estimate"),display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),slot:c,feedback:c,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ue,{ref:c.editorRef,...c.editorAria,"data-project-estimate":"",value:c.draft.number,readOnly:c.phase==="saving",placeholder:"13",inputMode:"decimal","aria-label":c.labels.name,onChange:p=>c.setDraft({...c.draft,number:p.target.value}),className:"h-8 max-w-24"}),t.jsxs(Je,{value:c.draft.unit,onValueChange:p=>c.setDraft({...c.draft,unit:p}),children:[t.jsx(Qe,{"data-project-estimate-unit":"","aria-label":n("ui.projects.project_editors.estimate_unit"),"aria-invalid":c.editorAria["aria-invalid"],className:"h-8 w-fit min-w-28",children:t.jsx(Ze,{})}),t.jsxs(et,{children:[t.jsx(Oe,{value:"points",children:n("ui.projects.project_editors.points")}),t.jsx(Oe,{value:"days",children:n("ui.projects.project_editors.days")})]})]})]}),c.draft.number.trim()===""&&o.estimate!==null&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_editors.clearing_an_estimate_is_not_supported_yet_saving_keeps_its_curren")})]})})},al=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{I();const[o,i]=d.useState(r);d.useEffect(()=>{o&&e.tags.length>0&&(i(!1),a?.("filled"))},[o,e.tags,a]);const l=wt({value:e.tags.join(", "),equals:(u,p)=>Ki(ft(u),p),commit:async u=>{const{tags:p}=ps(u);await s({tags:p})},validate:u=>ps(u).error,labels:ge("tags",n("ui.projects.project_editors.tags")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:ot,onSettle:u=>{u==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!o&&e.tags.length===0)return null;const c=l.editing?ft(l.draft):e.tags;return t.jsx(Ht,{field:"tags",fieldRef:l.fieldRef,fieldProps:l.fieldProps,editing:l.editing,label:n("ui.projects.project_editors.tags"),display:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(u=>t.jsx(ke,{variant:"outline",children:u},u))}),slot:l,feedback:l,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(ue,{ref:l.editorRef,...l.editorAria,"data-project-tags":"",value:l.draft,readOnly:l.phase==="saving",placeholder:n("ui.projects.project_editors.q4_payments"),"aria-label":l.labels.name,onChange:u=>l.setDraft(u.target.value),className:"h-8 max-w-72"}),t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:c.map(u=>t.jsx(ke,{variant:"outline",children:u},u))})]})})},ol="project-quick-send:no-target",il=[],cl=({links:e,target:s,onTargetChange:r,onSend:a,focusTick:o})=>{I();const i=d.useRef(null),l=Vn(),{frontend:c,refresh:u}=Ka(),[p,m]=d.useState(!1),_=nt(),j=s??ol;d.useEffect(()=>{s&&u(s)},[s,u]),d.useEffect(()=>{o>0&&i.current?.focusInput()},[o]);const f=e.filter(b=>b.exists),S=(f.find(b=>b.session_id===s)??null)?.runtime?.busy===!0;return t.jsxs("div",{"data-tour-tag":"project-quick-send","data-glass-block":"",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:n("ui.projects.project_quick_send.send_to")}),t.jsxs(Je,{value:s??void 0,onValueChange:b=>r(b),children:[t.jsx(Qe,{"aria-label":n("ui.projects.project_quick_send.select_the_session_to_message"),className:"max-w-72",children:t.jsx(Ze,{placeholder:n("ui.projects.project_quick_send.no_session_selected")})}),t.jsx(et,{children:f.map(b=>t.jsx(Oe,{value:b.session_id,children:Kt(b)},b.session_id))})]}),p?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.sending")}):S?t.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.the_session_is_working_this_message_steers_the_running_turn")}):null]}),t.jsx(Xn,{ref:i,conversationId:j,messages:il,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:n("ui.projects.project_quick_send.message_the_session_paste_an_image_to_attach_it"),cwd:c?.cwd,cwdReadOnlyReason:n("ui.projects.project_quick_send.quick_send_follows_the_conversation_s_directory"),sessionStatus:c&&s?{frontend:c,costChannels:ye(_.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:n("ui.projects.project_quick_send.choose_a_session_to_send_to")}),blocksInput:!0,get placeholder(){return n("ui.projects.project_quick_send.choose_a_session_to_send_to")}},onSendMessage:async(b,x)=>{if(!s)return!1;m(!0);try{return await a(s,b,S?"steer":"prompt",x)}finally{m(!1),i.current?.focusInput({preventScroll:!0})}}})]})},ll=({links:e,busy:s,onUnlink:r,onLink:a,onQuickSend:o,onStartSession:i})=>{I();const l=Bt(),c=At(x=>x.sessions),[u,p]=d.useState(!1),[m,_]=d.useState(null),[j,f]=d.useState(0),g=m&&e.some(x=>x.session_id===m&&x.exists)?m:$o(e),S=d.useMemo(()=>{const x=new Set(e.map(w=>w.session_id));return c.filter(w=>!x.has(w.session_id)).map(w=>({id:w.session_id,name:w.title||w.session_id,description:w.cwd??void 0}))},[c,e]),b=x=>{At.getState().openSession(x).then(w=>{w&&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:n("ui.projects.project_links.linked_sessions")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(Fa,{}),n("ui.projects.project_links.new_session")]}),t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:()=>p(!0),"data-tour-tag":"project-link-session",children:[t.jsx(qa,{}),n("ui.projects.project_links.link_session")]})]})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_links.no_sessions_linked_yet_link_the_conversations_that_are_working_on")}):t.jsx("ul",{"data-glass-block":"",className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(x=>{const w=xo(x),T=bo(x.subagents),k=vo(x.todos),q=x.title||x.session_id,C=x.exists;return t.jsxs("li",{"data-glass-block-row":"",className:R("flex items-center gap-2 rounded-sm px-2 py-2",C&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!C,onClick:()=>{C&&b(x.session_id)},className:R("flex min-w-0 flex-1 items-center gap-2 text-left",C?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{"data-glass-block-row-label":"",className:R("min-w-0 truncate text-body-sm",x.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:q})}),x.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_links.busy")}),T&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:T}),k&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:k}),t.jsx(ke,{variant:w.variant,children:w.label}),C&&t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.message_title",{title:String(q)}),title:n("ui.projects.project_links.message_title",{title:String(q)}),onClick:()=>{_(x.session_id),f(E=>E+1)},children:t.jsx(Ba,{})}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.unlink_title",{title:String(q)}),onClick:()=>r(x.session_id),children:t.jsx(to,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(cl,{links:e,target:g,onTargetChange:_,onSend:o,focusTick:j}),t.jsx(_t,{open:u,onClose:()=>p(!1),title:n("ui.projects.project_links.link_a_session"),maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Xe,{onClick:()=>p(!1),children:n("ui.projects.project_links.close")}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(pe,{children:n("ui.projects.project_links.session")}),t.jsx(Mr,{showLabel:!1,ariaLabel:n("ui.projects.project_links.search_sessions"),busyLabel:n("ui.projects.project_links.loading_sessions"),placeholder:n("ui.projects.project_links.search_conversations"),options:S,selected:null,onSelect:x=>{p(!1),a(x.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_links.conversations_already_linked_to_this_project_are_not_listed")})]})})]})},ul=({milestones:e,summary:s,busy:r,onToggle:a,onRemove:o,onAdd:i})=>{const[l,c]=d.useState(""),[u,p]=d.useState(""),m=I(),_=!Kr.test(u.trim()),j=l.trim().length>0&&!_&&!r,f=()=>{j&&(i(l.trim(),u.trim()),c(""),p(""))};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:n("ui.projects.project_milestones.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:n("ui.projects.project_milestones.no_milestones_yet_add_one_below_to_mark_the_dates_this_project_is")}):t.jsx("ul",{"data-glass-block":"",className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(g=>{const S=po(g.status),b=g.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Ir,{checked:b,disabled:r,onCheckedChange:x=>a(g.name,x===!0),"aria-label":b?n("ui.projects.project_milestones.mark_name_not_complete",{name:String(g.name)}):n("ui.projects.project_milestones.mark_name_complete",{name:String(g.name)})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:g.name}),g.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:Me(g.target_date,m)}),t.jsx(ke,{variant:S.variant,children:S.label}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:r,"aria-label":n("ui.projects.project_milestones.remove_name",{name:String(g.name)}),onClick:()=>o(g.name),children:t.jsx(zt,{})})]},g.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(pe,{htmlFor:"project-milestone-name",children:n("ui.projects.project_milestones.new_milestone")}),t.jsx(ue,{id:"project-milestone-name",value:l,onChange:g=>c(g.target.value),placeholder:n("ui.projects.project_milestones.beta_cut"),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),f())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:"project-milestone-date",children:n("ui.projects.project_milestones.target_date")}),t.jsx(ue,{id:"project-milestone-date",value:u,onChange:g=>p(g.target.value),placeholder:"YYYY-MM-DD","aria-invalid":_}),_&&t.jsx("p",{className:"text-meta text-danger",children:n("ui.projects.project_milestones.dates_are_yyyy_mm_dd_or_empty")})]}),t.jsxs(G,{variant:"secondary",disabled:!j,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(pt,{}),n("ui.projects.project_milestones.add")]})]})]})},dl=[{field:"owner",get label(){return n("ui.projects.project_properties.owner")}},{field:"team",get label(){return n("ui.projects.project_properties.team")}},{field:"start",get label(){return n("ui.projects.project_properties.start_date")}},{field:"target",get label(){return n("ui.projects.project_properties.target_date")}},{field:"estimate",get label(){return n("ui.projects.project_properties.estimate")}},{field:"tags",get label(){return n("ui.projects.project_properties.tags")}}],yr=({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})]}),pl=({project:e,nowMs:s,commit:r,teamLabel:a=null})=>{const o=I(),i=new Date(s),[l,c]=d.useState(null),u=d.useRef(null),p=d.useRef(!1),m={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},_=(E,M)=>{c(h=>h===E?null:h),M==="cancelled"&&!m[E]&&setTimeout(()=>u.current?.focus(),0)},j=dl.filter(({field:E})=>!m[E]&&l!==E),f=Me(e.completed_at,o,i),g=e.updated_at>0?bt(xt(e.updated_at,s)):"",S=e.updated_at>0?Jn(new Date(e.updated_at*1e3),{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},o):"",b=m.owner||l==="owner",x=m.team||l==="team",w=m.start||l==="start",T=m.target||l==="target",k=m.estimate||l==="estimate",q=m.tags||l==="tags",C=b||x||w||T||!!f||k||q||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:n("ui.projects.project_properties.properties")}),j.length>0&&t.jsxs(bs,{children:[t.jsx(vs,{asChild:!0,children:t.jsxs("button",{ref:u,type:"button","data-project-add-field":"",className:R("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(pt,{className:"size-3","aria-hidden":"true"}),n("ui.projects.project_properties.add")]})}),t.jsx(ys,{align:"end",onCloseAutoFocus:E=>{p.current&&(p.current=!1,E.preventDefault())},children:j.map(({field:E,label:M})=>t.jsx(be,{"data-project-add-option":E,onSelect:()=>{p.current=!0,c(E)},children:M},E))})]})]}),C?t.jsxs("dl",{className:"flex flex-col gap-2",children:[b&&t.jsx(sl,{project:e,commit:r,autoBegin:l==="owner",onRetire:E=>_("owner",E)}),x&&t.jsx(rl,{project:e,commit:r,label:a,autoBegin:l==="team",onRetire:E=>_("team",E)}),w&&t.jsx(vr,{project:e,commit:r,which:"start",nowMs:s,autoBegin:l==="start",onRetire:E=>_("start",E)}),T&&t.jsx(vr,{project:e,commit:r,which:"target",nowMs:s,autoBegin:l==="target",onRetire:E=>_("target",E)}),f&&t.jsx(yr,{label:n("ui.projects.project_properties.completed"),children:f}),k&&t.jsx(nl,{project:e,commit:r,autoBegin:l==="estimate",onRetire:E=>_("estimate",E)}),q&&t.jsx(al,{project:e,commit:r,autoBegin:l==="tags",onRetire:E=>_("tags",E)}),e.updated_at>0&&t.jsx(yr,{label:n("ui.projects.project_properties.updated"),children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:S,children:g})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_properties.no_dates_estimate_tags_owner_or_team_yet")})]})},ml=({project:e})=>{I();const s=nt(),r=bn(),{sending:a,cooling:o,cooldownRemainingMs:i}=cc(e.id);if(!ye(s.data,"projects_request_update"))return null;const l=ne(e),c=Zi(e.id);return t.jsxs(t.Fragment,{children:[t.jsx($t,{content:o&&i!==null?It(l,i):n("ui.projects.request_update.ask_the_sessions_linked_to_this_project_to_post_a_progress_update"),children:t.jsxs(G,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":o?!0:void 0,"aria-describedby":o?c:void 0,onClick:()=>r(e),children:[a?t.jsx(Te,{size:"sm"}):o?t.jsx(Ss,{}):t.jsx(Qa,{}),a?n("ui.projects.project_request_update_button.requesting"):o?n("ui.projects.project_request_update_button.requested"):n("ui.projects.project_request_update_button.request_update")]})}),o&&i!==null&&t.jsx("span",{id:c,className:"sr-only",children:It(l,i)})]})},Sn="plain",Cn=e=>`team:${e}`,En=e=>`agent:${e}`;function fl(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function _l(e){return e.kind==="team"?Cn(e.name):e.kind==="agent"?En(e.name):Sn}const wr={kind:"plain"},jl=({open:e,onClose:s,onStart:r,teamsEnabled:a,profilesEnabled:o})=>{I();const[i,l]=d.useState(wr),[c,u]=d.useState(null),[p,m]=d.useState(!1),_=Qn(e&&a),j=Zn(e&&o);d.useEffect(()=>{e&&(l(wr),u(null),m(!1))},[e]);const f=d.useMemo(()=>{const w=[{id:Sn,get name(){return n("ui.projects.project_start_session.nothing_in_particular")},get description(){return n("ui.projects.project_start_session.a_plain_session_assign_a_team_or_agent_later")},get group(){return n("ui.projects.project_start_session.plain")}}];for(const T of _.data??[])w.push({id:Cn(T.name),name:Ys(T),keywords:T.name===Ys(T)?void 0:[T.name],description:n("ui.projects.project_start_session.team_manager_manager",{manager:String(T.manager)}),get group(){return n("ui.projects.project_start_session.teams")}});for(const T of(j.data??[]).filter(k=>k.source!=="builtin"))w.push({id:En(T.name),name:T.name,description:T.description||T.kind,get group(){return n("ui.projects.project_start_session.agents")}});return w},[_.data,j.data]),g=f.find(w=>w.id===_l(i))??f[0],S=!a||!o,b=_.isLoading||j.isLoading,x=async()=>{m(!0),u(null);try{await r(i),s()}catch(w){u(w instanceof Error&&w.message?w.message:n("ui.projects.project_start_session.the_session_could_not_be_started"))}finally{m(!1)}};return t.jsx(_t,{open:e,onClose:s,title:n("ui.projects.project_start_session.start_a_session"),maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Xe,{onClick:s,disabled:p,children:n("ui.projects.project_start_session.cancel")}),t.jsxs(Dt,{onClick:()=>void x(),disabled:p,children:[p&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_start_session.start_session")]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Mr,{label:n("ui.projects.project_start_session.work_with"),placeholder:n("ui.projects.project_start_session.search_teams_and_agents"),options:f,selected:g,onSelect:w=>l(fl(w.id)),busy:b,busyLabel:n("ui.projects.project_start_session.loading_teams_and_agents")}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_start_session.the_session_starts_now_links_itself_to_this_project_and_opens_wit")}),S&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_start_session.this_server_does_not_offer_the_team_or_agent_catalogues_yet_so_on")}),c&&t.jsx("p",{className:"text-body-sm text-danger",children:c})]})})},hl=({links:e})=>{I();const s=Uo(e),r=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:n("ui.projects.project_todos.to_dos")}),s&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:Zs(s)})]}),r.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_todos.no_to_do_snapshots_from_the_linked_sessions_yet_a_session_publish")}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:r.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:Kt(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Zs(a.todos)})]},a.session_id))})]})},Is=({filePath:e,tooltip:s="File actions",icon:r,"aria-label":a="File actions",onShowInCanvas:o,onPreview:i})=>{const l=async()=>{if(e)try{await navigator.clipboard.writeText(e),ve("File path copied to clipboard")}catch(u){console.error("Failed to copy file path: ",u),de("Failed to copy file path")}},c=()=>{e&&window.api.openFile(e)};return t.jsxs(bs,{children:[t.jsx($t,{content:s,children:t.jsx(vs,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon-sm","aria-label":a,onClick:u=>u.stopPropagation(),children:r??t.jsx(Cr,{"aria-hidden":"true"})})})}),t.jsxs(ys,{align:"end",className:"min-w-45",onClick:u=>u.stopPropagation(),children:[i&&t.jsxs(be,{onSelect:i,children:[t.jsx(Ua,{"aria-hidden":"true"}),t.jsx("span",{children:"Preview"})]}),o&&t.jsxs(be,{onSelect:o,children:[t.jsx(ea,{"aria-hidden":"true"}),t.jsx("span",{children:"Show in canvas"})]}),t.jsxs(be,{onSelect:c,children:[t.jsx(ta,{"aria-hidden":"true"}),t.jsx("span",{children:"Open file"})]}),t.jsxs(be,{onSelect:()=>window.api.showItemInFolder(e),children:[t.jsx(sa,{"aria-hidden":"true"}),t.jsx("span",{children:"Open folder"})]}),t.jsxs(be,{onSelect:l,children:[t.jsx(ra,{"aria-hidden":"true"}),t.jsx("span",{children:"Copy file path"})]})]})]})},gl=/[/\\]/,xl=e=>{if(e.name)return e.name;const s=e.path.split(gl);return s[s.length-1]||e.path},bl="h-[min(90vh,calc(100vh-104px))] w-[min(760px,calc(100vw-104px))] max-w-none gap-0 p-0",Tn=({open:e,attachment:s,onClose:r,restoreFocusTo:a})=>{I(),Ea(e,"project-file-preview");const[o,i]=d.useState({status:"loading"}),l=s?.path??null,c=s?Tr(s.name||s.path):!1;d.useEffect(()=>{if(!e||l===null)return;let p=!0;i({status:"loading"});const m=window.api?.readFile;if(typeof m!="function"){i({status:"unavailable"});return}return(async()=>{try{const _=await m(l);if(!p)return;if(!_.success){console.error("Project file preview failed",_.error),i({status:"error"});return}i({status:"ready",text:_.data})}catch(_){if(!p)return;console.error("Project file preview failed",_),i({status:"error"})}})(),()=>{p=!1}},[e,l]);const u=s?xl(s):"";return t.jsx(Ta,{open:e,onOpenChange:p=>!p&&r(),children:t.jsxs(Ra,{className:bl,onCloseAutoFocus:p=>{const m=a?.current;m&&(p.preventDefault(),m.focus())},children:[t.jsx("div",{className:"shrink-0 border-hairline border-b px-4 py-3 pr-12",children:t.jsx(Da,{className:"truncate text-title",title:l??"",children:u})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3","data-project-file-preview":"",children:o.status==="loading"?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_updates.preview_loading")}):o.status==="unavailable"?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_updates.preview_unavailable")}):o.status==="error"?t.jsxs("div",{className:"flex flex-col gap-1 text-body-sm text-ink-muted",children:[t.jsx("p",{children:n("ui.projects.project_updates.preview_failed")}),t.jsx("p",{children:n("ui.projects.project_updates.preview_moved")})]}):c?t.jsx(rt,{children:o.text}):t.jsx("pre",{className:"whitespace-pre-wrap font-mono text-ink text-mono-sm",children:o.text})})]})})};Tn.displayName="ProjectFilePreviewDialog";const vl=/[/\\]/,Re=e=>{if(e.name)return e.name;const s=e.path.split(vl);return s[s.length-1]||n("ui.projects.project_updates.attachment")};function yl(e){const s=e.kind.trim().toLowerCase();if(s==="image"||s==="video"||s==="audio")return s;const r=Rr(e.name||e.path);return r==="image"||r==="video"||r==="audio"?r:"file"}const kt=e=>{const s=Date.parse(e.added_at);return{mimeType:ia(e.name||e.path),sizeBytes:e.bytes,...Number.isFinite(s)?{mtimeMs:s}:{}}},Ae=e=>`${e.path}:${e.added_at}`,Ue="h-[78px] w-[117px]",Ls="pointer-events-none absolute top-1 right-1 z-[2] flex opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",Nt=({kind:e})=>e==="audio"?t.jsx("div",{className:"h-11 w-[242px] max-w-full rounded-sm border border-hairline bg-sunken"}):t.jsx(Be,{boundary:"control",className:Ue}),wl=({attachment:e,onOpen:s})=>{I();const r=Re(e),a=jt(e.path,kt(e));if(a.status==="ready"){const o=n("ui.projects.project_updates.open_name",{name:String(r)});return t.jsx(Dr,{file:e.path,src:a.url,label:r,conversationId:"",size:"thumbnail",press:{onPress:s,label:o,title:o}})}return a.status==="loading"?t.jsx(Be,{boundary:"control",className:Ue,children:t.jsxs("span",{className:"sr-only",children:[n("ui.projects.project_updates.loading"),r]})}):t.jsx(ht,{name:r,compact:!0})},kl=({attachment:e,onOpen:s})=>{const[r,a]=Ut();return t.jsx("div",{ref:r,className:"group relative flex leading-none","data-project-asset-tile":"image",children:a?t.jsx(wl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"image"})})},Nl=({attachment:e,onOpen:s})=>{I();const r=Re(e),a=jt(e.path,kt(e));if(a.status!=="ready")return a.status==="loading"?t.jsx(Nt,{kind:"video"}):t.jsx(ht,{name:r,compact:!0});const o=n("ui.projects.project_updates.play_name",{name:String(r)});return t.jsx(t.Fragment,{children:t.jsx("button",{type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":o,title:o,onClick:s,children:t.jsxs(Be,{boundary:"control",className:R(Ue,"relative"),children:[t.jsx("video",{src:a.url,preload:"metadata",muted:!0,playsInline:!0,className:R("h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]"),"data-project-video-thumb":""}),t.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx(Br,{className:"size-6 text-ink",fill:"currentColor","aria-hidden":"true"})})]})})})},Sl=({attachment:e,onOpen:s})=>{const[r,a]=Ut();return t.jsxs("div",{ref:r,className:"group relative block leading-none","data-project-asset-tile":"video",children:[a?t.jsx(Nl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"video"}),t.jsx("div",{className:Ls,children:t.jsx(Is,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Cl=({attachment:e})=>{I();const s=Re(e),r=jt(e.path,kt(e));return r.status!=="ready"?r.status==="loading"?t.jsx(Nt,{kind:"audio"}):t.jsx(ht,{name:s}):t.jsx("div",{className:"w-[242px] max-w-full rounded-sm border border-hairline bg-surface px-2",children:t.jsx(oa,{ownerId:`project-sound:${e.path}`,src:r.url,label:s,peaks:null,variant:"compact"})})},El=({attachment:e})=>{const[s,r]=Ut();return t.jsxs("div",{ref:s,className:"group relative block leading-none sm:col-span-2","data-project-asset-tile":"audio",children:[r?t.jsx(Cl,{attachment:e}):t.jsx(Nt,{kind:"audio"}),t.jsx("div",{className:Ls,children:t.jsx(Is,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Tl=e=>{const s=e.name||e.path;if(Tr(s))return!0;const r=Rr(s);return r==="text"||r==="code"},Rl=({attachment:e,onPreview:s})=>{I();const r=Re(e),a=qo(e.bytes),o=d.useRef(null),i=Tl(e),l=i?n("ui.projects.project_updates.preview_name",{name:String(r)}):n("ui.projects.project_updates.open_name",{name:String(r)});return t.jsxs("div",{className:"group relative inline-block","data-project-asset-tile":"file",children:[t.jsx("button",{ref:o,type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":l,title:r,onClick:()=>{if(i){s(o.current);return}window.api?.openFile(e.path)},children:t.jsxs(Be,{boundary:"control",className:R(Ue,"flex-col gap-0.5 px-2 py-1 text-center"),children:[t.jsx(na,{path:e.path}),t.jsx("span",{className:"w-full truncate text-meta text-ink",children:r}),a&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:a})]})}),t.jsx("div",{className:Ls,children:t.jsx(Is,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(r)}),onPreview:i?()=>s(o.current):void 0})})]})},Dl=({asset:e,current:s,index:r,count:a,onSelect:o,scrollIntoView:i})=>{I();const[l,c]=Ut(),u=d.useRef(null),p=Re(e.attachment);return d.useEffect(()=>{!s||!i||u.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[s,i]),t.jsx("li",{ref:u,className:R("flex shrink-0 rounded-sm leading-none",s&&"ring-1 ring-ink"),children:t.jsx("div",{ref:l,className:"group relative",children:c?t.jsx(Al,{asset:e,onSelect:o,current:s,index:r,count:a}):t.jsx("button",{type:"button","aria-label":n("ui.projects.project_updates.show_asset_name",{name:String(p),index:String(r+1),count:String(a)}),className:"group/tile inline-block cursor-pointer rounded-sm leading-none",onClick:o,children:t.jsx(Be,{boundary:"control",className:Ue,"data-attachment-reserved":""})})})})},Al=({asset:e,current:s,index:r,count:a,onSelect:o})=>{I();const i=Re(e.attachment),l=jt(e.attachment.path,kt(e.attachment)),c=n("ui.projects.project_updates.show_asset_name",{name:String(i),index:String(r+1),count:String(a)});return e.kind==="image"&&l.status==="ready"?t.jsx(Dr,{file:e.attachment.path,src:l.url,label:i,conversationId:"",size:"thumbnail",press:{onPress:o,label:c,title:c,current:s}}):l.status!=="ready"?l.status==="loading"?t.jsx("button",{type:"button","aria-label":c,className:"group/tile inline-block cursor-pointer rounded-sm leading-none",onClick:o,children:t.jsx(Be,{boundary:"control",className:Ue})}):t.jsx(ht,{name:i,compact:!0}):t.jsx("button",{type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":c,title:c,"aria-current":s?"true":void 0,onClick:o,children:t.jsxs(Be,{boundary:"control",className:R(Ue,"relative"),children:[t.jsx("video",{src:l.url,preload:"metadata",muted:!0,playsInline:!0,className:R("h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]")}),t.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx(Br,{className:"size-4 text-ink",fill:"currentColor","aria-hidden":"true"})})]})})},Pl=({media:e,index:s,onSelect:r})=>(I(),t.jsx("ul",{role:"list","aria-label":n("ui.projects.project_updates.attachments"),"data-project-asset-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((a,o)=>t.jsx(Dl,{asset:a,current:o===s,index:o,count:e.length,onSelect:()=>r(o),scrollIntoView:s===o},Ae(a.attachment)))})),Ol=({media:e,index:s,onIndexChange:r,onClose:a,restoreFocusTo:o})=>{I();const i=e[s],l=Re(i.attachment),c=jt(i.attachment.path,kt(i.attachment)),u=e.length>1?t.jsx(Pl,{media:e,index:s,onSelect:r}):void 0;return t.jsx(aa,{open:!0,onOpenChange:p=>{p||a()},src:c.status==="ready"?c.url:void 0,pending:c.status==="loading",label:l,mediaKind:i.kind,mediaLabel:"asset",restoreFocusTo:o,fallback:t.jsx(ht,{name:l}),group:{index:s,count:e.length,onPrev:()=>r(Ks(s,e.length,-1)),onNext:()=>r(Ks(s,e.length,1)),filmstrip:u}})},Rn=({attachments:e})=>{I();const s=d.useMemo(()=>e.map(j=>({attachment:j,kind:yl(j)})),[e]),r=d.useMemo(()=>s.filter(j=>j.kind==="image"||j.kind==="video"),[s]),[a,o]=d.useState(null),[i,l]=d.useState(null),c=d.useRef(null),u=d.useRef(null),p=a?r.findIndex(j=>Ae(j.attachment)===a):-1,m=j=>{const f=document.activeElement;c.current=f instanceof HTMLElement?f:null,o(Ae(j))},_=(j,f=null)=>{const g=document.activeElement;u.current=f??(g instanceof HTMLElement?g:null),l(j)};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid max-w-[492px] grid-cols-[repeat(auto-fill,117px)] items-start gap-2","data-project-asset-grid":"",children:s.map(({attachment:j,kind:f})=>f==="image"?t.jsx(kl,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="video"?t.jsx(Sl,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="audio"?t.jsx(El,{attachment:j},Ae(j)):t.jsx(Rl,{attachment:j,onPreview:g=>_(j,g)},Ae(j)))}),p>=0&&t.jsx(Ol,{media:r,index:p,onIndexChange:j=>{const f=r[j];f&&o(Ae(f.attachment))},onClose:()=>o(null),restoreFocusTo:c}),t.jsx(Tn,{open:i!==null,attachment:i,onClose:()=>l(null),restoreFocusTo:u})]})};Rn.displayName="ProjectUpdateAssets";const Ml=({update:e,nowMs:s})=>{const r=I(),a=Lo(e,r,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((o,i)=>t.jsxs(d.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:o.text})]},o.key))}),e.text&&t.jsx(rt,{children:e.text}),e.attachments.length>0&&t.jsx(Rn,{attachments:e.attachments})]})},Il=({updates:e,nowMs:s})=>{const r=I(),a=Ao(e.length),o=Fo(e,r,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:n("ui.projects.project_updates.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:n("ui.projects.project_updates.no_updates_yet_progress_reported_by_you_or_by_the_sessions_workin")}):t.jsx("div",{className:"flex flex-col gap-4",children:o.map(i=>t.jsxs("div",{className:"flex flex-col gap-2",children:[i.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:i.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:i.entries.map((l,c)=>t.jsx(Ml,{update:l,nowMs:s},`${l.at}:${l.by}:${c}`))})]},i.key||"ungrouped"))})]})},Ll="project_not_found",Fl=({projectKey:e,nowMs:s})=>{I();const r=Bt(),a=nt(),o=Ar(ye(a.data,"team_catalogue")),i=Ur(e,!0),l=$r(),c=zr(),u=io(),p=co(),m=ao(),_=oo(),[j,f]=d.useState(!1),[g,S]=d.useState(!1),b=l.isPending||c.isPending||u.isPending||p.isPending||m.isPending||_.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(Te,{label:n("ui.projects.project_detail.loading_project")})});if(i.isError||!i.data){const h=i.error instanceof qt&&(i.error.code===Ll||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(ts,{variant:"danger",className:"w-full",children:h?n("ui.projects.project_detail.this_project_could_not_be_found_it_may_have_been_deleted"):i.error instanceof Error&&i.error.message?i.error.message:n("ui.projects.project_detail.the_project_could_not_be_read")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",onClick:()=>void i.refetch(),children:n("ui.projects.project_detail.try_again")}),t.jsxs(G,{variant:"secondary",onClick:()=>void r("/projects"),children:[t.jsx(Ws,{}),n("ui.projects.project_detail.all_projects")]})]})]})}const{project:x,links:w}=i.data,T=ne(x),k=(h,A)=>l.mutateAsync({key:x.id,fields:h,...A?.forceDone===!0?{forceDone:!0}:{}}),q=x.team?o(x.team):null,C=Bo(x.milestones.filter(h=>h.completed_at!==null).length,x.milestones.length),E=async(h,A,D,F)=>{const H=At.getState(),U=la(null,h,H.drafts);if(!U)return!1;try{const{images:Y,unreadable:J,overflow:Z}=await ua(F,A),me=da(J);if(me)return de(me),!1;const oe=pa(Z);if(oe)return de(oe),!1;const ee=ma(A,Y);if(ee)return de(ee),!1;if(await fa(U,{text:A,attachments:F,images:Y,mode:D,cwd:H.cwd},h)===null)return de(n("ui.projects.project_detail.that_session_already_has_a_message_going_out_try_again_in_a_momen")),!1;const v=w.find(y=>y.session_id===h);return ve(n("ui.projects.project_detail.sent_to_value1",{value1:String(v?Kt(v):h)})),!0}catch(Y){return de(Y instanceof Error&&Y.message?Y.message:n("ui.projects.project_detail.the_message_was_not_sent")),!1}},M=async h=>{const A=At.getState(),D=h.kind==="plain"?void 0:{kind:h.kind,name:h.name},F=await A.createSession(A.cwd||"~",D);if(!F)throw new Error(A.error??n("ui.projects.project_detail.the_session_could_not_be_started"));_a.getState().setCurrentInput(F,zo(x));let H=null;try{await m.mutateAsync({key:x.id,sessionId:F})}catch(U){H=U instanceof Error&&U.message?U.message:n("ui.projects.project_detail.the_link_was_refused")}if(H)de(n("ui.projects.project_detail.session_started_but_linking_it_failed_linkfailure",{linkFailure:String(H)}));else{const U=D?n("ui.projects.project_detail.with_value1",{value1:String(Go(D))}):"";ve(n("ui.projects.project_detail.session_started_withtarget_and_linked_to_displayname",{withTarget:String(U),displayName:String(T)}))}await Fr(r,F)};return t.jsx(wc,{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 r("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Ws,{className:"size-4"}),n("ui.projects.project_detail.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(Zc,{project:x,commit:k}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(el,{project:x,commit:k}),x.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ml,{project:x}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(ca,{}),n("ui.projects.project_detail.delete")]})]})]})]}),t.jsx(tl,{project:x,commit:k}),t.jsx(pl,{project:x,nowMs:s,commit:k,teamLabel:q}),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:n("ui.projects.project_detail.progress")}),t.jsx(rt,{className:"text-body",children:x.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:_o(x,s)})]}),t.jsx(ul,{milestones:x.milestones,summary:C,busy:b,onToggle:(h,A)=>{u.mutateAsync({key:x.id,name:h,completed:A}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_updated"))})},onRemove:h=>{p.mutateAsync({key:x.id,name:h}).catch(A=>{de(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_milestone_was_not_removed"))})},onAdd:(h,A)=>{u.mutateAsync({key:x.id,name:h,targetDate:A}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_added"))})}}),t.jsx(ll,{projectKey:x.id,links:w,busy:b,onStartSession:()=>S(!0),onQuickSend:E,onLink:h=>{m.mutateAsync({key:x.id,sessionId:h}).catch(A=>{de(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_session_was_not_linked"))})},onUnlink:h=>{_.mutateAsync({key:x.id,sessionId:h}).catch(A=>{de(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_session_was_not_unlinked"))})}}),t.jsx(hl,{links:w}),t.jsx(Il,{updates:x.updates,nowMs:s}),t.jsx(vn,{open:j,projectName:x.name,onClose:()=>f(!1),onConfirm:async h=>{await c.mutateAsync({key:x.id,confirmedName:h}),ve(n("ui.projects.project_detail.project_deleted")),r("/projects")}}),t.jsx(jl,{open:g,onClose:()=>S(!1),onStart:M,teamsEnabled:ye(a.data,"team_catalogue"),profilesEnabled:ye(a.data,"profile_catalogue")})]})})},ql="payments-migration",kr={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},Bl=({open:e,onClose:s,onSubmit:r})=>{I();const[a,o]=d.useState(kr),[i,l]=d.useState({}),[c,u]=d.useState(null),p=d.useRef(null),[m,_]=d.useState(!1),[j,f]=d.useState(!1),[g,S]=d.useState(!1),b=d.useId(),x=d.useRef(null);d.useEffect(()=>{e&&(o({...kr,description:hr}),l({}),u(null),_(!1),f(!1),S(!1))},[e]),d.useEffect(()=>{c&&p.current?.scrollIntoView({block:"nearest"})},[c]);const w=(h,A)=>{o(D=>({...D,[h]:A}))},T=j?a.name:Ac(a.title),k=h=>wn(h,x,A=>w("description",A)),q=(h,A)=>{const D={},F=ss(A);F&&(D.name=F);const H=pn(h.description);H&&(D.description=H);const U=ps(h.tags).error;U&&(D.tags=U);const Y=us(h.startDate);Y&&(D.startDate=Y);const J=us(h.targetDate);if(J)D.targetDate=J;else if(!Y){const ee=ds(h.startDate,h.targetDate);ee&&(D.targetDate=ee)}if(h.estimate.trim()){const ee=mn(h.estimate);ee&&(D.estimate=ee)}const Z=ls(h.title);Z&&(D.title=Z);const me=Mt(h.owner,"owner");me&&(D.owner=me);const oe=Mt(h.team,"team");return oe&&(D.team=oe),D},C=async()=>{const h=T.trim(),A=q(a,h);if(l(A),Object.keys(A).length>0)return;_(!0),u(null);const D=ft(a.tags);try{const F={};a.title.trim()&&(F.title=a.title.trim()),a.owner.trim()&&(F.owner=a.owner.trim()),a.team.trim()&&(F.team=a.team.trim()),a.startDate&&(F.start_date=a.startDate),a.targetDate&&(F.target_date=a.targetDate),a.estimate&&(F.estimate=Number(a.estimate),F.estimate_unit=a.estimateUnit),await r({fields:{name:h,...a.description.trim()&&a.description.trim()!==hr?{description:a.description.trim()}:{},status:a.status,...D.length>0?{tags:D}:{}},...Object.keys(F).length>0?{followUp:F}:{}}),s()}catch(F){const H=F instanceof Error&&F.message?F.message:"";u(yt(H)||n("ui.projects.project_form_dialog.the_project_was_not_saved"))}finally{_(!1)}},E=n("ui.projects.project_form_dialog.new_project"),M=a.description.length>tt;return t.jsx(_t,{open:e,onClose:s,title:E,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:m,onEscapeKeyDown:h=>{m&&h.preventDefault()},onInteractOutside:h=>{m&&h.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Xe,{onClick:s,disabled:m,children:n("ui.projects.project_form_dialog.cancel")}),t.jsxs(Dt,{"data-project-submit":"",onClick:()=>void C(),disabled:m,children:[m&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_form_dialog.create_project")]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:h=>{h.preventDefault(),C()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-title`,children:n("ui.projects.project_form_dialog.title")}),t.jsx(ue,{id:`${b}-title`,"data-project-title":"",value:a.title,onChange:h=>w("title",h.target.value),placeholder:n("ui.projects.project_form_dialog.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(pe,{htmlFor:`${b}-key`,className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.key")}),t.jsx(ue,{id:`${b}-key`,"data-project-key":"",value:T,onChange:h=>{f(!0),w("name",h.target.value)},placeholder:ql,"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:j?n("ui.projects.project_form_dialog.letters_digits_dot_underscore_or_dash_no_spaces"):n("ui.projects.project_form_dialog.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(pe,{htmlFor:`${b}-description`,children:n("ui.projects.project_form_dialog.description")}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:n("ui.projects.project_form_dialog.description_mode")}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(h=>t.jsx("button",{type:"button","data-project-description-mode":h,"aria-pressed":g===(h==="preview"),onClick:()=>S(h==="preview"),className:R("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",g===(h==="preview")&&"bg-surface text-ink"),children:h==="write"?n("ui.projects.project_form_dialog.write"):n("ui.projects.project_form_dialog.preview")},h))})]})]}),g?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(rt,{className:"text-body-sm",children:a.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_form_dialog.nothing_to_preview_yet")})}):t.jsx(Or,{ref:x,id:`${b}-description`,"data-project-description":"",value:a.description,onChange:h=>w("description",h.target.value),onPaste:k,rows:8,placeholder:n("ui.projects.project_form_dialog.markdown_headings_lists_code"),"aria-invalid":M||!!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:R("text-meta tabular-nums",M?"text-danger":"text-ink-muted"),children:[a.description.length,"/",tt]})]})]}),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(pe,{children:n("ui.projects.project_form_dialog.status")}),t.jsxs(Je,{value:a.status,onValueChange:h=>w("status",h),children:[t.jsx(Qe,{"aria-label":n("ui.projects.project_form_dialog.status"),children:t.jsx(Ze,{})}),t.jsx(et,{children:Yr.map(h=>t.jsx(Oe,{value:h.value,children:h.label},h.value))})]}),a.status==="done"&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.moving_a_project_to_done_stamps_today_as_its_completion_date")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-owner`,children:n("ui.projects.project_form_dialog.owner")}),t.jsx(ue,{id:`${b}-owner`,"data-project-owner":"",value:a.owner,onChange:h=>w("owner",h.target.value),placeholder:n("ui.projects.examples.owner"),"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(pe,{htmlFor:`${b}-team`,children:n("ui.projects.project_form_dialog.team")}),t.jsx(ue,{id:`${b}-team`,value:a.team,onChange:h=>w("team",h.target.value),placeholder:n("ui.projects.examples.team"),"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(pe,{htmlFor:`${b}-target`,children:n("ui.projects.project_form_dialog.target_date")}),t.jsx(ue,{id:`${b}-target`,"data-project-target":"",value:a.targetDate,onChange:h=>w("targetDate",h.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(pe,{htmlFor:`${b}-start`,children:n("ui.projects.project_form_dialog.start_date")}),t.jsx(ue,{id:`${b}-start`,value:a.startDate,onChange:h=>w("startDate",h.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(pe,{htmlFor:`${b}-estimate`,children:n("ui.projects.project_form_dialog.estimate")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ue,{id:`${b}-estimate`,value:a.estimate,onChange:h=>w("estimate",h.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(Je,{value:a.estimateUnit,onValueChange:h=>w("estimateUnit",h),children:[t.jsx(Qe,{"aria-label":n("ui.projects.project_form_dialog.estimate_unit"),className:"max-w-32",children:t.jsx(Ze,{})}),t.jsxs(et,{children:[t.jsx(Oe,{value:"points",children:n("ui.projects.project_form_dialog.points")}),t.jsx(Oe,{value:"days",children:n("ui.projects.project_form_dialog.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(pe,{htmlFor:`${b}-tags`,children:n("ui.projects.project_form_dialog.tags")}),t.jsx(ue,{id:`${b}-tags`,value:a.tags,onChange:h=>w("tags",h.target.value),placeholder:n("ui.projects.project_form_dialog.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:n("ui.projects.project_form_dialog.comma_separated_up_to_8_lowercase_letters_digits_underscore_or_da")})]})]}),c&&t.jsx("p",{ref:p,className:"text-body-sm text-danger",children:c})]})})},Dn=({children:e})=>{const s=d.useRef(null),[r,a]=d.useState(!1),o=()=>{const i=s.current;i&&a(i.scrollTop+i.clientHeight<i.scrollHeight-1)};return d.useEffect(o),t.jsx("div",{ref:s,onScroll:o,className:R("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",r&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},Ul=({label:e,count:s,selected:r,onToggle:a})=>{const o=d.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(Ir,{id:o,checked:r,onCheckedChange:()=>a()}),t.jsx(pe,{htmlFor:o,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})]})},$l=({column:e,spec:s,onChange:r})=>{I();const a=d.useId(),o=s!==null&&s.key===e,i=o?s.direction:Xt(e),l=i==="asc"?"desc":"asc",c=()=>r({key:e,direction:o?l:Xt(e)}),u=s===null?"default":o?"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:n("ui.projects.project_filters_panel.sort_by_sortcolumnlabel_column",{sortColumnLabel_column:String(st(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:u==="default",onChange:()=>r(null),className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:R("min-w-0 flex-1 truncate",u==="default"?"text-ink":"text-ink-muted"),children:n("ui.projects.project_sort.default_as_listed")})]}),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:u==="sorted",onChange:c,onClick:()=>{u==="sorted"&&c()},onKeyDown:p=>{u==="sorted"&&(p.key!==" "&&p.key!=="Enter"||(p.preventDefault(),c()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:R("min-w-0 flex-1 truncate",u==="sorted"?"text-ink":"text-ink-muted"),children:n("ui.projects.project_filters_panel.sort_by_sortcolumnlabel_column_value2",{sortColumnLabel_column:String(st(e)),value2:String(Ds(e,o?i:Xt(e)))})})]})]})},zl=({facet:e,options:s,onToggle:r})=>(I(),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:dt[e]}),s.map(a=>t.jsx(Ul,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>r(e,a.value)},`${e}:${a.value??"none"}`))]})),An=({projects:e,state:s,query:r,todayMs:a,onToggle:o,onClearAll:i,scope:l,sort:c})=>{I();const u=l===void 0?bi(e,s,a):l===null?[]:[dn(l,e,s,a)],p=!mt(s)||r.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:n("ui.projects.project_filters_panel.filters")}),p&&t.jsx(G,{variant:"link",size:"sm",onClick:i,children:n("ui.projects.project_filters_panel.clear_all")})]}),c&&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:n("ui.projects.project_filters_panel.sort_by_key",{key:String(st(c.key))})}),t.jsx($l,{column:c.key,spec:c.spec,onChange:c.onChange})]}),u.map(m=>t.jsx(zl,{facet:m.facet,options:m.options,onToggle:o},m.facet))]})},Gl=({team:e,count:s,headingId:r,className:a,...o})=>(I(),t.jsxs("div",{...o,"data-glass-well":"",className:R("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",a),children:[t.jsx("h3",{id:r,className:"truncate text-ink",children:e??n("ui.projects.project_model.no_team")}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":ho(s),children:s})]})),Ee=[{key:"name",get label(){return n("ui.projects.project_list.project")},className:"min-w-0 flex-1",sort:"name",facet:null},{key:"status",get label(){return n("ui.projects.project_list.status")},className:"w-20 shrink-0",sort:"status",facet:"status"},{key:"target",get label(){return n("ui.projects.project_list.target")},className:"hidden w-32 shrink-0 @[40rem]:block",sort:"target",facet:"target"},{key:"estimate",get label(){return n("ui.projects.project_list.estimate")},className:"hidden w-16 shrink-0 @[40rem]:block",sort:"estimate",facet:"estimate"},{key:"milestones",get label(){return n("ui.projects.project_list.milestones")},className:"hidden w-20 shrink-0 @[34rem]:block",sort:"milestones",facet:"milestones"},{key:"live",get label(){return n("ui.projects.project_list.live")},className:"hidden w-14 shrink-0 @[34rem]:block",sort:"live",facet:"live"},{key:"progress",get label(){return n("ui.projects.project_list.progress")},className:"w-40 shrink-0",sort:"progress",facet:"progress"}];function Yl(e,s){const r=xt(e.progress_updated_at,s);return r?bt(r):n("ui.projects.project_list.not_reported")}const Kl=({direction:e})=>e==="asc"?t.jsx(qr,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Pr,{size:10,className:"shrink-0","aria-hidden":"true"}),Hl=({projects:e,nowMs:s,onOpen:r,sort:a,onSortChange:o,searchPopulation:i,filters:l,query:c,todayMs:u,onToggleFilter:p,onClearFilters:m,teamLabelFor:_=j=>j})=>{const j=I(),f=a?Ti(e,a):e,g=Es(f,vt),S=d.useId(),b=C=>`${S}-team-${C}`,[x,w]=d.useState(0),T=d.useRef([]),k=(C,E)=>{const M=Ee.length;for(let h=1;h<=M;h+=1){const A=(C+E*h+M*M)%M,D=T.current[A];if(D&&D.offsetParent!==null){w(A),D.focus();return}}},q=C=>E=>{E.key!=="ArrowLeft"&&E.key!=="ArrowRight"||(E.preventDefault(),k(C,E.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":n("ui.projects.project_list.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:Ee.map((C,E)=>{const M=a!==null&&a.key===C.sort;return t.jsx("th",{scope:"col","aria-sort":M?a.direction==="desc"?"descending":"ascending":"none",className:R(C.className,"p-0 text-left font-normal"),children:t.jsxs(ws,{children:[t.jsx(ks,{asChild:!0,children:t.jsxs("button",{type:"button",ref:h=>{T.current[E]=h},tabIndex:E===x?0:-1,"data-project-column":C.key,onFocus:()=>w(E),onKeyDown:q(E),className:R("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",M?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:C.label}),M?t.jsx(Kl,{direction:a.direction}):t.jsx(ja,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(Ns,{align:"start","aria-label":n("ui.projects.project_list.label_column",{label:String(C.label)}),className:"w-72 p-0",children:t.jsx(Dn,{children:t.jsx(An,{projects:i,state:l,query:c,todayMs:u,onToggle:p,onClearAll:m,scope:C.facet,sort:{key:C.sort,spec:a,onChange:o}})})})]})},C.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:g.map((C,E)=>t.jsxs("li",{children:[t.jsx(Gl,{team:C.team==null?null:_(C.team),count:C.items.length,headingId:b(E),className:"sticky top-0 z-10","data-project-team":C.team??""}),t.jsx("ul",{"aria-labelledby":b(E),className:"divide-y divide-hairline",children:C.items.map(M=>{const h=new Map(Xr(M,j).map(F=>[F.key,F.text])),A=Vr(M.milestones_completed,M.milestones_total),D=Cs(M.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>r(M),"data-project-name":M.name,className:R("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-row-hover"),children:[t.jsx("span",{className:R(Ee[0].className,"truncate text-body-sm text-ink"),children:ne(M)}),t.jsx("span",{className:Ee[1].className,children:t.jsx(Nn,{status:M.status})}),t.jsx("span",{className:R(Ee[2].className,"truncate text-meta text-ink-muted"),children:h.get("target")??h.get("completed")??""}),t.jsx("span",{className:R(Ee[3].className,"truncate text-meta text-ink-muted"),children:h.get("estimate")??""}),t.jsx("span",{className:R(Ee[4].className,"truncate text-meta text-ink-muted"),children:A}),t.jsx("span",{className:R(Ee[5].className,"truncate text-meta text-ink-muted"),children:D}),t.jsxs("span",{className:R(Ee[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Yl(M,s)}),M.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]})},M.id)})})]},C.team??""))})]})},Ft=224,Nr=36,Wl={get day(){return n("ui.projects.project_timeline.days")},get week(){return n("ui.projects.project_timeline.weeks")},get month(){return n("ui.projects.project_timeline.months")},get quarter(){return n("ui.projects.project_timeline.quarters")}},Vl=({items:e,nowMs:s,onOpen:r,pendingDetails:a,failedDetails:o,onRetryDetails:i,teamLabelFor:l=c=>c})=>{I();const[c,u]=d.useState(null),[p,m]=d.useState(0),_=d.useRef(null),j=Ps(s),f=d.useMemo(()=>Ai(e,j),[e,j]),g=d.useMemo(()=>Pi(e),[e]),S=d.useMemo(()=>Es(g.dated,C=>vt(C.project)),[g]);d.useLayoutEffect(()=>{const C=_.current;if(!C)return;const E=()=>m(C.clientWidth);if(E(),typeof ResizeObserver>"u")return;const M=new ResizeObserver(E);return M.observe(C),()=>M.disconnect()},[]);const b=Math.max(p-Ft-24,160),x=f?Ri(or(f.startMs,f.endMs),b):"month",w=c??x,T=C=>{const E=Pe.indexOf(w),M=Pe[E-C];M&&u(M)},k=As[w],q=f?or(f.startMs,f.endMs)*k:0;return t.jsxs("div",{ref:_,className:"flex min-h-0 flex-1 flex-col","data-testid":"project-timeline",children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-9 py-2",children:[t.jsx("span",{className:"truncate text-meta text-ink-muted","data-timeline-note":!0,children:o>0?n("ui.projects.timeline.read_failed",{count:o}):n("ui.projects.project_timeline.length_dated_length_2_without_dates_value3",{length:V(g.dated.length,{useGrouping:!1}),length_2:V(g.undated.length,{useGrouping:!1}),value3:String(a>0?n("ui.projects.project_timeline.loading_milestones_for_pendingdetails",{pendingDetails:V(a,{useGrouping:!1})}):"")})}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[o>0&&t.jsx(G,{variant:"secondary",size:"sm",onClick:i,children:n("ui.projects.project_timeline.try_again")}),t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.project_timeline.zoom_in"),title:n("ui.projects.project_timeline.zoom_in_finer"),disabled:!f||w===Pe[0],onClick:()=>T(1),children:t.jsx(pt,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Wl[w]}),t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.project_timeline.zoom_out"),title:n("ui.projects.project_timeline.zoom_out_coarser"),disabled:!f||w===Pe[Pe.length-1],onClick:()=>T(-1),children:t.jsx(Aa,{})})]})]}),f&&g.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(Xl,{startMs:f.startMs,endMs:f.endMs,tier:w,pxPerDay:k,trackPx:q}),S.map(C=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":C.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:Ft},children:[t.jsx("span",{className:"truncate text-ink",children:C.team==null?n("ui.projects.project_model.no_team"):l(C.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:C.items.length})]})}),C.items.map(E=>t.jsx(Jl,{item:E,spanStart:f.startMs,pxPerDay:k,trackPx:q,today:j,onOpen:()=>r(E)},E.project.id))]},C.team??""))]})}):null,g.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(Er,{defaultOpen:g.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(Wa,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Oi(g.undated.length)})]}),children:[g.dated.length===0&&t.jsx("p",{className:"pb-1 text-meta text-ink-muted",children:n("ui.projects.project_timeline.set_a_start_date_a_target_date_or_a_milestone_date_and_it_will_ap")}),t.jsx("ul",{className:"flex max-h-24 flex-wrap gap-x-3 gap-y-1 overflow-y-auto",children:g.undated.map(C=>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:()=>r(C),children:ne(C.project)})},C.project.id))})]})})]})},Xl=({startMs:e,endMs:s,tier:r,pxPerDay:a,trackPx:o})=>{const i=zi(e,s,r);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Ft}}),t.jsx("span",{className:"relative block h-6",style:{width:o},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:Fe(e,l.dayMs)*a},children:[t.jsx("span",{className:R("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))})]})},Jl=({item:e,spanStart:s,pxPerDay:r,trackPx:a,today:o,onOpen:i})=>{const{project:l}=e,c=Mi(e),u=Ii(e),p=m=>new Date(m).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-row-hover",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:Ft,height:Nr},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:ne(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:Nr},children:[c&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:Fe(s,c.fromMs)*r,width:(Fe(c.fromMs,c.toMs)+1)*r},title:`${Me(p(c.fromMs))} → ${Me(p(c.toMs))}`}),u.map(m=>t.jsx("span",{"data-milestone":m.status,className:R("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",m.status==="completed"&&"bg-success",m.status==="overdue"&&"bg-warning",m.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:Fe(s,m.dayMs)*r},title:`${m.name} · ${m.status} · ${Me(p(m.dayMs))}`},`${m.name}-${m.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:Fe(s,o)*r},"aria-hidden":"true"})]})]})},Ql=({projects:e,query:s,onQueryChange:r,filters:a,onFiltersChange:o,onClearAll:i,todayMs:l,resultText:c,countRevealClass:u="@[37rem]:inline",trailing:p,disabled:m=!1,searchFieldRef:_})=>{I();const[j,f]=d.useState(!1),g=d.useRef(!1),S=ji(a),b=Lr(c??"",300),x=s.trim()!==""||!mt(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(ha,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(ue,{ref:_,inputSize:"sm",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>{w.key==="Escape"&&(s?r(""):w.currentTarget.blur())},placeholder:n("ui.projects.projects_toolbar.search_projects"),"aria-label":n("ui.projects.projects_toolbar.search_projects"),autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(G,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>ga(_.current,r),"aria-label":n("ui.projects.projects_toolbar.clear_search"),children:t.jsx(zt,{"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(xa,{shortcut:"/"})})]}),t.jsxs(ws,{open:j,onOpenChange:f,children:[t.jsx(ks,{asChild:!0,children:t.jsxs(G,{variant:"secondary",size:"sm",disabled:m,"data-project-filters-button":"",children:[t.jsx(Xa,{size:14,"aria-hidden":"true"}),n("ui.projects.projects_toolbar.filters"),S>0&&t.jsx(ke,{variant:"neutral",children:S})]})}),t.jsx(Ns,{align:"end","aria-label":n("ui.projects.projects_toolbar.filters"),className:"w-80 p-0",onCloseAutoFocus:w=>{g.current&&(g.current=!1,w.preventDefault())},children:t.jsx(Dn,{children:t.jsx(An,{projects:e,state:a,query:s,todayMs:l,onToggle:(w,T)=>o(cn(a,w,T)),onClearAll:()=>{i(),g.current=!0,f(!1),_.current?.focus()}})})})]}),x&&c!==null&&t.jsx("span",{className:R("hidden whitespace-nowrap text-meta text-ink-dim",u),"data-project-count":"",children:c}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:b}),p]})},Zl=({filters:e,sort:s,onFiltersChange:r,onSortChange:a,onClearAll:o,hideClearAll:i=!1,searchFieldRef:l})=>{I();const[c,u]=d.useState(null);d.useEffect(()=>{if(!c)return;let _=null;c.kind==="search"?_=l.current:(_=document.querySelector(`[data-project-chip="${c.index}"]`),_||(_=document.querySelector("[data-project-chip]")),_||(_=document.querySelector("[data-project-filters-button]"))),_&&(_.focus(),u(null))});const p=[];for(const _ of at){const j=e[_];if(j.length===0)continue;const f=j.map(b=>on(_,b)),g=f[0],S=f.length>1?n("ui.projects.projects_toolbar.facet_labels_facet_first_length_1",{FACET_LABELS_facet:String(dt[_]),first:String(g),length___1:V(f.length-1,{useGrouping:!1})}):n("ui.projects.projects_toolbar.facet_labels_facet_first",{FACET_LABELS_facet:String(dt[_]),first:String(g)});p.push({kind:"facet",facet:_,label:S,ariaLabel:n("ui.projects.projects_toolbar.remove_filter_facet_labels_facet_join",{FACET_LABELS_facet:String(dt[_]),join:String(f.join(", "))}),clear:()=>r({...e,[_]:[]})})}if(s&&p.push({kind:"sort",spec:s,label:n("ui.projects.projects_toolbar.sort_key",{key:String(st(s.key))}),ariaLabel:n("ui.projects.projects_toolbar.remove_sort_key_direction",{key:String(st(s.key)),direction:String(Ds(s.key,s.direction))}),clear:()=>a(null)}),p.length===0)return null;const m=(_,j)=>{j.clear();const f=p.length-1;u(f===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(_,f-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map((_,j)=>t.jsx(ke,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":j,"aria-label":_.ariaLabel,onClick:()=>m(j,_),children:[_.kind==="sort"&&(_.spec.direction==="asc"?t.jsx(qr,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Pr,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:_.label}),t.jsx(zt,{className:R("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},_.kind==="facet"?_.facet:"sort")),!i&&t.jsx(G,{variant:"link",size:"sm",onClick:()=>{o(),u({kind:"search"})},children:n("ui.projects.projects_toolbar.clear_all")})]})},Pn="projects-view",eu=[{value:"list",get label(){return n("ui.projects.projects_view_switcher.list")}},{value:"board",get label(){return n("ui.projects.projects_view_switcher.board")}},{value:"timeline",get label(){return n("ui.projects.projects_view_switcher.timeline")}}];function tu(){try{const e=localStorage.getItem(Pn);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function su(e){try{localStorage.setItem(Pn,e)}catch{}}const ru=({value:e,onChange:s})=>(I(),t.jsx(Pa,{value:e,onValueChange:r=>s(r),children:t.jsx(Oa,{"aria-label":n("ui.projects.projects_view_switcher.project_view"),"data-tour-tag":"projects-view-switcher",children:eu.map(r=>t.jsx(Ma,{value:r.value,children:r.label},r.value))})})),nu=["r1","r2","r3","r4","r5","r6"],au=4e3,Sr={get unpaired(){return n("ui.projects.projects_page.this_app_is_not_paired_with_the_local_operator_server_so_projects")},get"below-version"(){return n("ui.projects.projects_page.the_local_operator_server_is_older_than_this_app_expects_so_proje")},get unknown(){return n("ui.projects.projects_page.the_server_s_capabilities_could_not_be_read_so_projects_are_unava")}},_u=({nowMs:e=Date.now()})=>{I();const{projectId:s}=ba(),r=Bt(),a=nt(),o=va(a.data,"projects",1),i=o==="enabled",l=ye(a.data,"projects",Qo),c=Ar(ye(a.data,"team_catalogue")),u=so(i),p=no(),m=$r(),_=zr(),[j,f]=d.useState(!1),[g,S]=d.useState(()=>tu()),[b,x]=d.useState(()=>So()),[w,T]=d.useState(null),[k,q]=d.useState(""),[C,E]=d.useState(sr),[M,h]=d.useState(()=>wi()),[A,D]=d.useState(""),F=d.useRef(""),H=d.useRef(null),U=d.useRef(null),Y=N=>{H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null),N!==""&&N===F.current?(D(""),H.current=window.requestAnimationFrame(()=>{H.current=null,D(N)})):D(N),F.current=N,U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,F.current="",D("")},au)},J=()=>{H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null),U.current!==null&&(window.clearTimeout(U.current),U.current=null),F.current="",D("")},Z=N=>{q(N),J()},me=N=>{E(N),J()},oe=d.useRef(null),ee=lc(),te=u.data??[],v=Ps(e),y=di(k,i&&l),O=an(k),L=d.useMemo(()=>y.answer?li(te,y.answer.projects):null,[te,y.answer]),B=O!=="",K=d.useMemo(()=>B?L??ci(te,O):te,[te,O,B,L]),X=L===null?"client":"backend",$=d.useMemo(()=>hi(K,C,v),[K,C,v]),je=l&&B&&y.pending,ie=B||!mt(C),z=d.useMemo(()=>Xs(te,b,e),[te,b,e]),se=d.useMemo(()=>Xs($,b,e),[$,b,e]),xe=No(b),fe=g==="board"?se.length:$.length,Ie=!ie||!u.isSuccess?null:g==="board"?n("ui.projects.projects_page.length_of_length_2_in_window",{length:V(se.length,{useGrouping:!1}),length_2:V(z.length,{useGrouping:!1})}):n("ui.projects.projects_page.length_of_length_2_projects",{length:V($.length,{useGrouping:!1}),length_2:te.length}),re=u.isSuccess&&te.length>0,De=re&&ie&&fe===0&&!je,Ye=je&&fe===0&&re,[Wt,it]=d.useState(!1);d.useEffect(()=>{if(!Wt)return;const N=document.querySelector('[data-tour-tag="projects-board-window"]');N&&(N.focus(),it(!1))}),d.useEffect(()=>{if(!i||s)return;const N=W=>{const Q=W.target;if(!Q||Q.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(Q.tagName)||Q.closest('[role="dialog"]'))return;const Ce=W.key==="/"&&!W.metaKey&&!W.ctrlKey&&!W.altKey,le=(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="f";!Ce&&!le||(W.preventDefault(),oe.current?.focus())};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[i,s]);const ct=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const N=ct.current;N!==null&&(N.scrollTop=0)},[s]);const St=ro(g==="timeline"?te.map(N=>N.id):[],i),P=new Map(te.map((N,W)=>[N.id,St[W]])),ce=$.map(N=>({project:N,milestones:P.get(N.id)?.data?.project.milestones??[]})),lt=g==="timeline"?$.filter(N=>P.get(N.id)?.isLoading).length:0,Ne=g==="timeline"?$.filter(N=>P.get(N.id)?.isError).length:0,Ct=()=>{for(const N of St)N.isError&&N.refetch()},Ke=N=>{h(N),ki(N),Y(Ni(N))},On=(N,W)=>{E(Q=>cn(Q,N,W)),J()},Et=()=>{const N=k.trim()!=="",W=!mt(C),Q=M!==null;q(""),E(sr),M!==null&&Ke(null),Y(Si({search:N,filters:W,sort:Q}))},Fs=()=>{x("all"),Js("all"),it(!0)},[Se,qs]=d.useState(null),Vt=d.useRef(!1),Bs=()=>{Vt.current=!1,qs(null)},[Mn,Us]=d.useState([]),In=ye(a.data,"projects_force_done"),Ln=(N,W)=>{const Q=N.id,Ce=ae(W).label;Us(le=>le.includes(Q)?le:[...le,Q]),Wi({move:()=>m.mutateAsync({key:Q,fields:{status:W}}),forceDoneOffered:In,claimQuestion:()=>Vt.current?!1:(Vt.current=!0,!0)}).then(le=>{if(le.kind==="accepted"){ve(n("ui.projects.projects_page.moved_to_label",{label:String(Ce)})),u.refetch().then(()=>ee(Q));return}if(le.kind==="question"){qs({project:N,status:W,refusal:le.refusal});return}de(le.copy,le.refusal?{action:{get label(){return n("ui.projects.projects_page.view_project")},onClick:()=>void r(`/projects/${Q}`)}}:void 0),ee(Q)}).finally(()=>{Us(le=>le.filter(Fn=>Fn!==Q))})};return i?s?t.jsx("div",{ref:ct,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(Fl,{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(Hs,{title:n("ui.projects.projects_page.projects"),icon:Vs,subtitle:n("ui.projects.projects_page.workstreams_you_and_your_agents_track_across_sessions"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.projects_page.refresh_projects"),title:n("ui.projects.projects_page.refresh_projects"),disabled:u.isFetching,onClick:()=>void u.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx($a,{})}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(pt,{}),n("ui.projects.projects_page.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(ru,{value:g,onChange:N=>{S(N),su(N)}}),t.jsx(Ql,{projects:K,query:k,onQueryChange:Z,filters:C,onFiltersChange:me,onClearAll:Et,todayMs:v,resultText:Ie,countRevealClass:g==="board"?"@[47rem]:inline":void 0,disabled:u.isError,searchFieldRef:oe,trailing:g==="board"&&!(u.isSuccess&&u.data.length===0)?t.jsx(Vi,{value:b,onChange:N=>{x(N),Js(N)}}):null})]}),t.jsx(Zl,{filters:C,sort:M,onFiltersChange:me,onSortChange:Ke,onClearAll:Et,hideClearAll:De,searchFieldRef:oe}),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:[u.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:n("ui.projects.projects_page.loading_projects")}),nu.map(N=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(He,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(He,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-40 shrink-0 bg-elevated"})]},N))]}),u.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(ts,{variant:"danger",children:u.error instanceof Error&&u.error.message?u.error.message:n("ui.projects.projects_page.the_projects_could_not_be_read")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>void u.refetch(),children:n("ui.projects.projects_page.try_again")})]}),u.isSuccess&&u.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:n("ui.projects.projects_page.no_projects_yet")}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:n("ui.projects.projects_page.create_one_here_or_ask_an_agent_to_create_one_and_link_this_sessi")}),t.jsxs(G,{variant:"primary",onClick:()=>f(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(pt,{}),n("ui.projects.projects_page.new_project")]})]}),Ye&&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:n("ui.projects.projects_page.searching")})}),re&&De&&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:k.trim()?n("ui.projects.projects_page.no_projects_match_trim",{trim:String(k.trim())}):n("ui.projects.projects_page.no_projects_match")}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:k.trim()?Jo[X]:n("ui.projects.projects_page.try_removing_a_filter_clearing_the_filters_restores_the_list")}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(G,{variant:"secondary",onClick:()=>{Et(),oe.current?.focus()},children:n("ui.projects.projects_page.clear_all")}),g==="board"&&$.length>0&&t.jsx(G,{variant:"secondary",onClick:Fs,children:n("ui.projects.projects_page.show_all_time")})]})]}),re&&!De&&!Ye&&g==="list"&&t.jsx(Hl,{projects:$,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),sort:M,onSortChange:Ke,searchPopulation:K,filters:C,query:k,todayMs:v,onToggleFilter:On,onClearFilters:Et,teamLabelFor:c}),re&&!De&&g==="board"&&se.length>0&&t.jsx(dc,{projects:se,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),onEdit:N=>void r(`/projects/${N.id}`),onDelete:T,onMove:Ln,teamLabelFor:c,movingKeys:Mn}),re&&!De&&!Ye&&g==="board"&&se.length===0&&xe!==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:xe}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:n("ui.projects.projects_page.older_projects_are_hidden_by_the_window")}),t.jsx(G,{variant:"secondary",onClick:Fs,children:n("ui.projects.projects_page.show_all_time")})]}),re&&!De&&!Ye&&g==="timeline"&&t.jsx(Vl,{items:ce,nowMs:e,onOpen:N=>void r(`/projects/${N.project.id}`),pendingDetails:lt,failedDetails:Ne,onRetryDetails:Ct,teamLabelFor:c})]}),t.jsx(vn,{open:w!==null,projectName:w?.name??"",onClose:()=>T(null),onConfirm:async N=>{w&&(await _.mutateAsync({key:w.id,confirmedName:N}),ve(n("ui.projects.projects_page.project_deleted")),T(null))}}),t.jsx(kn,{open:Se!==null,refusal:Se?.refusal??null,projectLabel:Se?ne(Se.project):"",onClose:()=>{Se&&ee(Se.project.id),Bs()},onConfirm:async()=>{if(!Se)return;const{project:N,status:W,refusal:Q}=Se,Ce=await m.mutateAsync({key:N.id,fields:{status:W},forceDone:!0});ve(nn(Ce,Q.count,ae(W).label)),u.refetch().then(()=>ee(N.id))},secondaryLabel:n("ui.projects.projects_page.open_project"),onSecondary:()=>{const N=Se?.project.id;Bs(),N&&r(`/projects/${N}`)}}),t.jsx(Bl,{open:j,onClose:()=>f(!1),onSubmit:async N=>{const W=await p.mutateAsync(N.fields),Q=N.followUp?.title??N.fields.name;if(N.followUp)try{await m.mutateAsync({key:W.id,fields:N.followUp})}catch(Ce){const le=Ce instanceof Error&&Ce.message?Ce.message:"";de(n("ui.projects.projects_page.project_label_was_created_but_the_extra_fields_were_not_saved_val",{label:String(Q),value2:String(yt(le)||n("ui.projects.projects_page.the_server_refused_them"))}));return}ve(n("ui.projects.projects_page.project_label_created",{label:String(Q)}))}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Hs,{title:n("ui.projects.projects_page.projects"),icon:Vs}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(Te,{label:n("ui.projects.projects_page.checking_the_server_s_projects_support")})}):t.jsx(ts,{variant:"warning",children:Sr[o]??Sr.unknown})]})};export{_u as ProjectsPage};
45
+ `).trim()}function wn(e,s,r){const a=e.clipboardData?.getData("text/html");if(!a)return;const o=Xc(a);if(!o)return;e.preventDefault();const i=e.currentTarget,l=i.selectionStart??i.value.length,c=i.selectionEnd??l;r(i.value.slice(0,l)+o+i.value.slice(c)),requestAnimationFrame(()=>{const u=s.current;if(!u)return;const p=l+o.length;u.setSelectionRange(p,p)})}const kn=({open:e,refusal:s,projectLabel:r,onClose:a,onConfirm:o,secondaryLabel:i,onSecondary:l})=>{I();const[c,u]=d.useState(!1),[p,m]=d.useState(null),_=d.useRef(!1),j=d.useRef(null);d.useEffect(()=>{e&&(u(!1),m(null),_.current=!1)},[e]);const f=async()=>{if(!_.current){_.current=!0,u(!0),m(null);try{await o(),a()}catch(S){m({copy:_n(S),gone:fn(S)})}finally{_.current=!1,u(!1)}}},g=s?.names??[];return t.jsx(_t,{open:e,onClose:a,title:n("ui.projects.project_done_anyway_dialog.mark_done_with_open_milestones"),dataTourTag:"project-done-anyway-dialog",maxWidth:"xs",dialogProps:{closeDisabled:c,onEscapeKeyDown:S=>{c&&S.preventDefault()},onInteractOutside:S=>{c&&S.preventDefault()},onOpenAutoFocus:S=>{S.preventDefault(),j.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(Xe,{ref:j,onClick:a,disabled:c,children:n("ui.projects.project_done_anyway_dialog.cancel")}),!p?.gone&&t.jsx(Xe,{onClick:l,disabled:c,children:i}),p?.gone?t.jsx(Dt,{"data-project-force-close":"",onClick:a,children:n("ui.projects.project_done_anyway_dialog.close")}):t.jsxs(Dt,{"data-project-force-done":"","aria-disabled":c,className:"aria-disabled:pointer-events-none aria-disabled:bg-sunken aria-disabled:text-ink-disabled",onClick:()=>void f(),children:[c?t.jsx(Te,{size:"xs"}):t.jsx("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),n("ui.projects.project_done_anyway_dialog.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:r?n("ui.projects.project_done_anyway_dialog.projectlabel_moves_to_done_and_its_milestones_stay_open",{projectLabel:String(r)}):n("ui.projects.project_done_anyway_dialog.the_project_moves_to_done_and_its_milestones_stay_open")}),t.jsx("p",{className:"text-body-sm text-ink break-words",children:s?Vo(s):""}),g.length>Tt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(Er,{summary:n("ui.projects.project_done_anyway_dialog.show_all_length_open_milestones",{length:g.length}),children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:g.map((S,b)=>t.jsx("li",{className:"break-words",children:S},`${b}-${S}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:p?.copy??""})]})})},Nn=({status:e})=>{const s=ae(e);return t.jsxs(ke,{variant:s.variant,children:[lo(e)&&t.jsx(Ss,{"aria-hidden":!0}),s.label]})},Jc="project-key",Qc="project-key";function ge(e,s){return{name:s,begin:n("ui.projects.project_editors.edit_field",{field:String(e)}),accept:n("ui.projects.project_editors.save_field",{field:String(e)}),cancel:n("ui.projects.project_editors.discard_the_field_edit",{field:String(e)}),busy:n("ui.projects.project_editors.saving_the_field",{field:String(e)}),saved:n("ui.projects.project_editors.display_saved",{display:String(s)}),retry:n("ui.projects.project_editors.retry_saving_the_field",{field:String(e)})}}const Ht=({field:e,fieldRef:s,fieldProps:r,editing:a,label:o,bare:i=!1,display:l,editor:c,slot:u,feedback:p,controlsIdle:m="affordance",hug:_=!1,feedbackExtra:j,className:f,controlsClassName:g})=>t.jsxs("div",{ref:s,...r,"data-project-field":e,className:R(!i&&Ms,"min-w-0",o!==void 0&&"flex items-start gap-3",f),children:[o!==void 0&&t.jsx("dt",{className:"w-24 shrink-0 pt-0.5 text-body-sm text-ink-muted",children:o}),t.jsxs("div",{className:R("flex min-w-0 flex-col gap-1",_&&"items-start",o!==void 0&&"flex-1"),children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("div",{className:R("min-w-0",_?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:u.begin,children:a?c:l}),t.jsx(js,{api:u,idle:m,className:R("shrink-0",g)})]}),t.jsx("div",{className:R("min-h-[1lh] text-meta",_&&"max-w-96"),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx(hs,{api:p}),j]})})]})]}),qe=({field:e,value:s,display:r,commitFields:a,validate:o,labels:i,commit:l,placeholder:c,mono:u=!1,ramp:p="text-body-sm",label:m,bare:_=!1,autoBegin:j=!1,maxLength:f,onRetire:g,className:S,controlsClassName:b})=>{const[x,w]=d.useState(j);d.useEffect(()=>{x&&s!==""&&(w(!1),g?.("filled"))},[x,s,g]);const T=wt({value:s,commit:async k=>{await l(a(k))},equals:(k,q)=>k.trim()===q.trim(),validate:o,labels:i,selectAllOnBegin:!0,beginOnMount:j,errorCopy:ot,onSettle:k=>{k==="cancelled"&&(w(!1),g?.("cancelled"))}});return!x&&s===""?null:t.jsx(Ht,{field:e,fieldRef:T.fieldRef,fieldProps:T.fieldProps,editing:T.editing,label:m,bare:_,display:r,slot:T,feedback:T,className:S,controlsClassName:b,editor:t.jsx(ue,{ref:T.editorRef,...T.editorAria,value:T.draft,readOnly:T.phase==="saving",maxLength:f,placeholder:c,"aria-label":i.name,onChange:k=>T.setDraft(k.target.value),spellCheck:!1,autoComplete:"off",className:R("h-8",u?"font-mono text-mono-sm":p)})})},Zc=({project:e,commit:s})=>{I();const r=e.title??"",[a,o]=d.useState(!1),i=d.useRef(null),l=c=>{o(!1),c==="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:R(Ms,"flex min-w-0 flex-col gap-0.5"),children:[r?t.jsx(qe,{field:"title",value:r,display:t.jsx("h1",{"data-project-title":e.name,className:"min-w-0 break-words text-display text-ink",children:r}),commitFields:c=>({title:c.trim()}),validate:c=>ls(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:Pt,placeholder:n("ui.projects.project_editors.a_short_name_for_the_workstream"),ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(qe,{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:c=>({name:c.trim()}),validate:c=>ss(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:Jc,ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!r&&(a?t.jsx(qe,{field:"title",value:"",display:null,commitFields:c=>({title:c.trim()}),validate:c=>ls(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:Pt,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:()=>o(!0),className:R("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:n("ui.projects.project_editors.add_a_title")}))]}),r&&t.jsx(qe,{field:"key",value:e.name,display:t.jsx("span",{className:"font-mono text-mono-sm text-ink-muted",children:e.name}),commitFields:c=>({name:c.trim()}),validate:c=>ss(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:Qc,mono:!0})]})},el=({project:e,commit:s})=>{I();const[r,a]=d.useState(!1),o=nt(),i=ye(o.data,"projects_force_done"),[l,c]=d.useState(null),[u,p]=d.useState(null),m=d.useRef(!1),_=d.useRef(!1),j=d.useRef(null),f=wt({value:e.status,commit:async b=>{const x=m.current;m.current=!1,c(null);try{const w=await s({status:b},x?{forceDone:!0}:void 0);x&&ve(nn(w,l?.count??0,ae(b).label)),j.current?.resolve()}catch(w){throw c(jn(w)),j.current?.reject(w),w}finally{j.current=null}},labels:ge("status",n("ui.projects.project_editors.status")),keyboardCommit:!1,errorCopy:ot,onBegin:()=>a(!0)}),g=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!_.current||f.phase!=="idle"&&f.phase!=="saved")return;_.current=!1;const b=document.querySelector("[data-project-milestones]");b&&(b.scrollIntoView({block:"start"}),b.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const S=()=>new Promise((b,x)=>{if(f.phase!=="error"||f.conflict!==null){x(new Error(""));return}if(!f.dirty){b();return}m.current=!0,j.current={resolve:b,reject:x},f.accept(f.draft,!0)});return t.jsx(Ht,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(Nn,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[g&&t.jsx(G,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>p(l),children:n("ui.projects.project_editors.mark_done_anyway")}),t.jsx(kn,{open:u!==null,refusal:u,projectLabel:ne(e),onClose:()=>p(null),onConfirm:S,secondaryLabel:n("ui.projects.project_editors.review_milestones"),onSecondary:()=>{p(null),_.current=!0,f.cancel()}})]}),editor:t.jsxs(Je,{open:r,onOpenChange:a,value:f.draft,onValueChange:b=>{a(!1),f.accept(b)},children:[t.jsx(Qe,{ref:f.editorRef,...f.editorAria,"aria-label":n("ui.projects.project_editors.status"),"data-project-status":"",className:"h-7 w-fit min-w-36",children:t.jsx(Ze,{})}),t.jsx(et,{children:Yr.map(b=>t.jsx(Oe,{value:b.value,"data-project-status-option":b.value,children:b.label},b.value))})]})})},tl=({project:e,commit:s})=>{I();const[r,a]=d.useState(!1),o=d.useRef(null),i=d.useRef(null),l=wt({value:e.description,commit:async p=>{await s({description:p.trim()})},equals:(p,m)=>p.trim()===m.trim(),validate:p=>pn(p),multiline:!0,labels:ge("description",n("ui.projects.project_editors.description")),errorCopy:ot,editorRef:o,onSettle:p=>{p==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(r||!l.editing)return;const p=setTimeout(()=>o.current?.focus(),0);return()=>clearTimeout(p)},[r,l.editing]);const u=(l.editing?l.draft:l.displayValue).length>tt;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:R(Ms,"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:n("ui.projects.project_editors.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":r===(p==="preview"),onClick:()=>a(p==="preview"),className:R("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",r===(p==="preview")&&"bg-surface text-ink"),children:p==="write"?n("ui.projects.project_editors.write"):n("ui.projects.project_editors.preview")},p))})]}),t.jsx(js,{api:{...l,acceptBlocked:u}})]}),r?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(rt,{className:"text-body-sm",children:l.draft}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_editors.nothing_to_preview_yet")})}):t.jsx(Or,{ref:o,...l.editorAria,"data-project-description":"",value:l.draft,readOnly:l.phase==="saving",rows:8,placeholder:n("ui.projects.project_editors.markdown_headings_lists_code"),"aria-label":l.labels.name,onChange:p=>l.setDraft(p.target.value),onPaste:p=>wn(p,o,m=>l.setDraft(m)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(hs,{api:l}),t.jsxs("p",{className:R("shrink-0 text-meta tabular-nums",u?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",tt]})]})]}):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(rt,{className:"text-body",children:e.description??""})}),t.jsx(js,{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:n("ui.projects.project_editors.add_description")}),t.jsx("div",{className:"min-h-[1lh] text-meta",children:t.jsx(hs,{api:l})})]})})},sl=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>(I(),t.jsx(qe,{field:"owner",value:e.owner??"",label:n("ui.projects.project_editors.owner"),display:t.jsx("span",{className:"text-body-sm text-ink",children:e.owner}),commitFields:o=>({owner:o.trim()}),validate:o=>Mt(o,"owner"),labels:ge("owner",n("ui.projects.project_editors.owner")),commit:s,maxLength:Ot,placeholder:n("ui.projects.examples.owner"),autoBegin:r,onRetire:a})),rl=({project:e,commit:s,label:r=null,autoBegin:a=!1,onRetire:o})=>(I(),t.jsx(qe,{field:"team",value:e.team??"",label:n("ui.projects.project_editors.team"),display:t.jsx("span",{className:"text-body-sm text-ink",children:r??e.team}),commitFields:i=>({team:i.trim()}),validate:i=>Mt(i,"team"),labels:ge("team",n("ui.projects.project_editors.team")),commit:s,maxLength:Ot,placeholder:n("ui.projects.examples.team"),autoBegin:a,onRetire:o})),vr=({project:e,commit:s,which:r,nowMs:a,autoBegin:o=!1,onRetire:i})=>{const l=r==="start"?e.start_date??"":e.target_date??"",c=I(),u=Me(l,c,new Date(a)),p=r==="start"?n("ui.projects.project_editors.start"):n("ui.projects.project_editors.target");return t.jsx(qe,{field:r==="start"?"start-date":"target-date",value:l,label:p,display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),commitFields:m=>r==="start"?{start_date:m}:{target_date:m},validate:m=>{const _=us(m);return _||(r==="start"?ds(m,e.target_date??""):ds(e.start_date??"",m))},labels:ge(n("ui.projects.project_editors.tolowercase_date",{toLowerCase:String(p.toLowerCase())}),p),commit:s,placeholder:"YYYY-MM-DD",autoBegin:o,onRetire:i})},nl=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{I();const o={estimate:e.estimate,unit:e.estimate_unit==="days"?"days":"points"},[i,l]=d.useState(r);d.useEffect(()=>{i&&e.estimate!==null&&(l(!1),a?.("filled"))},[i,e.estimate,a]);const c=wt({value:{number:e.estimate===null?"":String(e.estimate),unit:o.unit},equals:Yi,commit:async p=>{const m=Hi(o,p);m&&await s(m)},validate:p=>mn(p.number),labels:ge("estimate",n("ui.projects.project_editors.estimate")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:ot,onSettle:p=>{p==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const u=Wr(e.estimate,e.estimate_unit)||"—";return t.jsx(Ht,{field:"estimate",fieldRef:c.fieldRef,fieldProps:c.fieldProps,editing:c.editing,label:n("ui.projects.project_editors.estimate"),display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),slot:c,feedback:c,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ue,{ref:c.editorRef,...c.editorAria,"data-project-estimate":"",value:c.draft.number,readOnly:c.phase==="saving",placeholder:"13",inputMode:"decimal","aria-label":c.labels.name,onChange:p=>c.setDraft({...c.draft,number:p.target.value}),className:"h-8 max-w-24"}),t.jsxs(Je,{value:c.draft.unit,onValueChange:p=>c.setDraft({...c.draft,unit:p}),children:[t.jsx(Qe,{"data-project-estimate-unit":"","aria-label":n("ui.projects.project_editors.estimate_unit"),"aria-invalid":c.editorAria["aria-invalid"],className:"h-8 w-fit min-w-28",children:t.jsx(Ze,{})}),t.jsxs(et,{children:[t.jsx(Oe,{value:"points",children:n("ui.projects.project_editors.points")}),t.jsx(Oe,{value:"days",children:n("ui.projects.project_editors.days")})]})]})]}),c.draft.number.trim()===""&&o.estimate!==null&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_editors.clearing_an_estimate_is_not_supported_yet_saving_keeps_its_curren")})]})})},al=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{I();const[o,i]=d.useState(r);d.useEffect(()=>{o&&e.tags.length>0&&(i(!1),a?.("filled"))},[o,e.tags,a]);const l=wt({value:e.tags.join(", "),equals:(u,p)=>Ki(ft(u),p),commit:async u=>{const{tags:p}=ps(u);await s({tags:p})},validate:u=>ps(u).error,labels:ge("tags",n("ui.projects.project_editors.tags")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:ot,onSettle:u=>{u==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!o&&e.tags.length===0)return null;const c=l.editing?ft(l.draft):e.tags;return t.jsx(Ht,{field:"tags",fieldRef:l.fieldRef,fieldProps:l.fieldProps,editing:l.editing,label:n("ui.projects.project_editors.tags"),display:t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:e.tags.map(u=>t.jsx(ke,{variant:"outline",children:u},u))}),slot:l,feedback:l,editor:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(ue,{ref:l.editorRef,...l.editorAria,"data-project-tags":"",value:l.draft,readOnly:l.phase==="saving",placeholder:n("ui.projects.project_editors.q4_payments"),"aria-label":l.labels.name,onChange:u=>l.setDraft(u.target.value),className:"h-8 max-w-72"}),t.jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:c.map(u=>t.jsx(ke,{variant:"outline",children:u},u))})]})})},ol="project-quick-send:no-target",il=[],cl=({links:e,target:s,onTargetChange:r,onSend:a,focusTick:o})=>{I();const i=d.useRef(null),l=Vn(),{frontend:c,refresh:u}=Ka(),[p,m]=d.useState(!1),_=nt(),j=s??ol;d.useEffect(()=>{s&&u(s)},[s,u]),d.useEffect(()=>{o>0&&i.current?.focusInput()},[o]);const f=e.filter(b=>b.exists),S=(f.find(b=>b.session_id===s)??null)?.runtime?.busy===!0;return t.jsxs("div",{"data-tour-tag":"project-quick-send","data-glass-block":"",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:n("ui.projects.project_quick_send.send_to")}),t.jsxs(Je,{value:s??void 0,onValueChange:b=>r(b),children:[t.jsx(Qe,{"aria-label":n("ui.projects.project_quick_send.select_the_session_to_message"),className:"max-w-72",children:t.jsx(Ze,{placeholder:n("ui.projects.project_quick_send.no_session_selected")})}),t.jsx(et,{children:f.map(b=>t.jsx(Oe,{value:b.session_id,children:Kt(b)},b.session_id))})]}),p?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.sending")}):S?t.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.the_session_is_working_this_message_steers_the_running_turn")}):null]}),t.jsx(Xn,{ref:i,conversationId:j,messages:il,isLoading:!1,ownGutter:!0,transcriptless:!0,autoFocus:!1,placeholderOverride:n("ui.projects.project_quick_send.message_the_session_paste_an_image_to_attach_it"),cwd:c?.cwd,cwdReadOnlyReason:n("ui.projects.project_quick_send.quick_send_follows_the_conversation_s_directory"),sessionStatus:c&&s?{frontend:c,costChannels:ye(_.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:n("ui.projects.project_quick_send.choose_a_session_to_send_to")}),blocksInput:!0,get placeholder(){return n("ui.projects.project_quick_send.choose_a_session_to_send_to")}},onSendMessage:async(b,x)=>{if(!s)return!1;m(!0);try{return await a(s,b,S?"steer":"prompt",x)}finally{m(!1),i.current?.focusInput({preventScroll:!0})}}})]})},ll=({links:e,busy:s,onUnlink:r,onLink:a,onQuickSend:o,onStartSession:i})=>{I();const l=Bt(),c=At(x=>x.sessions),[u,p]=d.useState(!1),[m,_]=d.useState(null),[j,f]=d.useState(0),g=m&&e.some(x=>x.session_id===m&&x.exists)?m:$o(e),S=d.useMemo(()=>{const x=new Set(e.map(w=>w.session_id));return c.filter(w=>!x.has(w.session_id)).map(w=>({id:w.session_id,name:w.title||w.session_id,description:w.cwd??void 0}))},[c,e]),b=x=>{At.getState().openSession(x).then(w=>{w&&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:n("ui.projects.project_links.linked_sessions")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:i,"data-tour-tag":"project-start-session",children:[t.jsx(Fa,{}),n("ui.projects.project_links.new_session")]}),t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:()=>p(!0),"data-tour-tag":"project-link-session",children:[t.jsx(qa,{}),n("ui.projects.project_links.link_session")]})]})]}),e.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_links.no_sessions_linked_yet_link_the_conversations_that_are_working_on")}):t.jsx("ul",{"data-glass-block":"",className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(x=>{const w=xo(x),T=bo(x.subagents),k=vo(x.todos),q=x.title||x.session_id,C=x.exists;return t.jsxs("li",{"data-glass-block-row":"",className:R("flex items-center gap-2 rounded-sm px-2 py-2",C&&"hover:bg-row-hover"),children:[t.jsx("button",{type:"button",disabled:!C,onClick:()=>{C&&b(x.session_id)},className:R("flex min-w-0 flex-1 items-center gap-2 text-left",C?"cursor-pointer":"cursor-default opacity-100"),children:t.jsx("span",{"data-glass-block-row-label":"",className:R("min-w-0 truncate text-body-sm",x.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:q})}),x.runtime?.busy===!0&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_links.busy")}),T&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:T}),k&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:k}),t.jsx(ke,{variant:w.variant,children:w.label}),C&&t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.message_title",{title:String(q)}),title:n("ui.projects.project_links.message_title",{title:String(q)}),onClick:()=>{_(x.session_id),f(E=>E+1)},children:t.jsx(Ba,{})}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.unlink_title",{title:String(q)}),onClick:()=>r(x.session_id),children:t.jsx(to,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(cl,{links:e,target:g,onTargetChange:_,onSend:o,focusTick:j}),t.jsx(_t,{open:u,onClose:()=>p(!1),title:n("ui.projects.project_links.link_a_session"),maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Xe,{onClick:()=>p(!1),children:n("ui.projects.project_links.close")}),children:t.jsxs("div",{className:"flex flex-col gap-2 px-1 py-1",children:[t.jsx(pe,{children:n("ui.projects.project_links.session")}),t.jsx(Mr,{showLabel:!1,ariaLabel:n("ui.projects.project_links.search_sessions"),busyLabel:n("ui.projects.project_links.loading_sessions"),placeholder:n("ui.projects.project_links.search_conversations"),options:S,selected:null,onSelect:x=>{p(!1),a(x.id)}}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_links.conversations_already_linked_to_this_project_are_not_listed")})]})})]})},ul=({milestones:e,summary:s,busy:r,onToggle:a,onRemove:o,onAdd:i})=>{const[l,c]=d.useState(""),[u,p]=d.useState(""),m=I(),_=!Kr.test(u.trim()),j=l.trim().length>0&&!_&&!r,f=()=>{j&&(i(l.trim(),u.trim()),c(""),p(""))};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:n("ui.projects.project_milestones.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:n("ui.projects.project_milestones.no_milestones_yet_add_one_below_to_mark_the_dates_this_project_is")}):t.jsx("ul",{"data-glass-block":"",className:"flex flex-col divide-y divide-hairline rounded-md bg-surface",children:e.map(g=>{const S=po(g.status),b=g.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Ir,{checked:b,disabled:r,onCheckedChange:x=>a(g.name,x===!0),"aria-label":b?n("ui.projects.project_milestones.mark_name_not_complete",{name:String(g.name)}):n("ui.projects.project_milestones.mark_name_complete",{name:String(g.name)})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:g.name}),g.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:Me(g.target_date,m)}),t.jsx(ke,{variant:S.variant,children:S.label}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:r,"aria-label":n("ui.projects.project_milestones.remove_name",{name:String(g.name)}),onClick:()=>o(g.name),children:t.jsx(zt,{})})]},g.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(pe,{htmlFor:"project-milestone-name",children:n("ui.projects.project_milestones.new_milestone")}),t.jsx(ue,{id:"project-milestone-name",value:l,onChange:g=>c(g.target.value),placeholder:n("ui.projects.project_milestones.beta_cut"),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),f())}})]}),t.jsxs("div",{className:"flex w-40 flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:"project-milestone-date",children:n("ui.projects.project_milestones.target_date")}),t.jsx(ue,{id:"project-milestone-date",value:u,onChange:g=>p(g.target.value),placeholder:"YYYY-MM-DD","aria-invalid":_}),_&&t.jsx("p",{className:"text-meta text-danger",children:n("ui.projects.project_milestones.dates_are_yyyy_mm_dd_or_empty")})]}),t.jsxs(G,{variant:"secondary",disabled:!j,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(pt,{}),n("ui.projects.project_milestones.add")]})]})]})},dl=[{field:"owner",get label(){return n("ui.projects.project_properties.owner")}},{field:"team",get label(){return n("ui.projects.project_properties.team")}},{field:"start",get label(){return n("ui.projects.project_properties.start_date")}},{field:"target",get label(){return n("ui.projects.project_properties.target_date")}},{field:"estimate",get label(){return n("ui.projects.project_properties.estimate")}},{field:"tags",get label(){return n("ui.projects.project_properties.tags")}}],yr=({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})]}),pl=({project:e,nowMs:s,commit:r,teamLabel:a=null})=>{const o=I(),i=new Date(s),[l,c]=d.useState(null),u=d.useRef(null),p=d.useRef(!1),m={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},_=(E,M)=>{c(h=>h===E?null:h),M==="cancelled"&&!m[E]&&setTimeout(()=>u.current?.focus(),0)},j=dl.filter(({field:E})=>!m[E]&&l!==E),f=Me(e.completed_at,o,i),g=e.updated_at>0?bt(xt(e.updated_at,s)):"",S=e.updated_at>0?Jn(new Date(e.updated_at*1e3),{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},o):"",b=m.owner||l==="owner",x=m.team||l==="team",w=m.start||l==="start",T=m.target||l==="target",k=m.estimate||l==="estimate",q=m.tags||l==="tags",C=b||x||w||T||!!f||k||q||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:n("ui.projects.project_properties.properties")}),j.length>0&&t.jsxs(bs,{children:[t.jsx(vs,{asChild:!0,children:t.jsxs("button",{ref:u,type:"button","data-project-add-field":"",className:R("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(pt,{className:"size-3","aria-hidden":"true"}),n("ui.projects.project_properties.add")]})}),t.jsx(ys,{align:"end",onCloseAutoFocus:E=>{p.current&&(p.current=!1,E.preventDefault())},children:j.map(({field:E,label:M})=>t.jsx(be,{"data-project-add-option":E,onSelect:()=>{p.current=!0,c(E)},children:M},E))})]})]}),C?t.jsxs("dl",{className:"flex flex-col gap-2",children:[b&&t.jsx(sl,{project:e,commit:r,autoBegin:l==="owner",onRetire:E=>_("owner",E)}),x&&t.jsx(rl,{project:e,commit:r,label:a,autoBegin:l==="team",onRetire:E=>_("team",E)}),w&&t.jsx(vr,{project:e,commit:r,which:"start",nowMs:s,autoBegin:l==="start",onRetire:E=>_("start",E)}),T&&t.jsx(vr,{project:e,commit:r,which:"target",nowMs:s,autoBegin:l==="target",onRetire:E=>_("target",E)}),f&&t.jsx(yr,{label:n("ui.projects.project_properties.completed"),children:f}),k&&t.jsx(nl,{project:e,commit:r,autoBegin:l==="estimate",onRetire:E=>_("estimate",E)}),q&&t.jsx(al,{project:e,commit:r,autoBegin:l==="tags",onRetire:E=>_("tags",E)}),e.updated_at>0&&t.jsx(yr,{label:n("ui.projects.project_properties.updated"),children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:S,children:g})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_properties.no_dates_estimate_tags_owner_or_team_yet")})]})},ml=({project:e})=>{I();const s=nt(),r=bn(),{sending:a,cooling:o,cooldownRemainingMs:i}=cc(e.id);if(!ye(s.data,"projects_request_update"))return null;const l=ne(e),c=Zi(e.id);return t.jsxs(t.Fragment,{children:[t.jsx($t,{content:o&&i!==null?It(l,i):n("ui.projects.request_update.ask_the_sessions_linked_to_this_project_to_post_a_progress_update"),children:t.jsxs(G,{variant:"secondary",className:"min-w-37","data-tour-tag":"project-request-update","aria-busy":a?!0:void 0,"aria-disabled":o?!0:void 0,"aria-describedby":o?c:void 0,onClick:()=>r(e),children:[a?t.jsx(Te,{size:"sm"}):o?t.jsx(Ss,{}):t.jsx(Qa,{}),a?n("ui.projects.project_request_update_button.requesting"):o?n("ui.projects.project_request_update_button.requested"):n("ui.projects.project_request_update_button.request_update")]})}),o&&i!==null&&t.jsx("span",{id:c,className:"sr-only",children:It(l,i)})]})},Sn="plain",Cn=e=>`team:${e}`,En=e=>`agent:${e}`;function fl(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function _l(e){return e.kind==="team"?Cn(e.name):e.kind==="agent"?En(e.name):Sn}const wr={kind:"plain"},jl=({open:e,onClose:s,onStart:r,teamsEnabled:a,profilesEnabled:o})=>{I();const[i,l]=d.useState(wr),[c,u]=d.useState(null),[p,m]=d.useState(!1),_=Qn(e&&a),j=Zn(e&&o);d.useEffect(()=>{e&&(l(wr),u(null),m(!1))},[e]);const f=d.useMemo(()=>{const w=[{id:Sn,get name(){return n("ui.projects.project_start_session.nothing_in_particular")},get description(){return n("ui.projects.project_start_session.a_plain_session_assign_a_team_or_agent_later")},get group(){return n("ui.projects.project_start_session.plain")}}];for(const T of _.data??[])w.push({id:Cn(T.name),name:Ys(T),keywords:T.name===Ys(T)?void 0:[T.name],description:n("ui.projects.project_start_session.team_manager_manager",{manager:String(T.manager)}),get group(){return n("ui.projects.project_start_session.teams")}});for(const T of(j.data??[]).filter(k=>k.source!=="builtin"))w.push({id:En(T.name),name:T.name,description:T.description||T.kind,get group(){return n("ui.projects.project_start_session.agents")}});return w},[_.data,j.data]),g=f.find(w=>w.id===_l(i))??f[0],S=!a||!o,b=_.isLoading||j.isLoading,x=async()=>{m(!0),u(null);try{await r(i),s()}catch(w){u(w instanceof Error&&w.message?w.message:n("ui.projects.project_start_session.the_session_could_not_be_started"))}finally{m(!1)}};return t.jsx(_t,{open:e,onClose:s,title:n("ui.projects.project_start_session.start_a_session"),maxWidth:"sm",dataTourTag:"project-start-session-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Xe,{onClick:s,disabled:p,children:n("ui.projects.project_start_session.cancel")}),t.jsxs(Dt,{onClick:()=>void x(),disabled:p,children:[p&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_start_session.start_session")]})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx(Mr,{label:n("ui.projects.project_start_session.work_with"),placeholder:n("ui.projects.project_start_session.search_teams_and_agents"),options:f,selected:g,onSelect:w=>l(fl(w.id)),busy:b,busyLabel:n("ui.projects.project_start_session.loading_teams_and_agents")}),t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_start_session.the_session_starts_now_links_itself_to_this_project_and_opens_wit")}),S&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_start_session.this_server_does_not_offer_the_team_or_agent_catalogues_yet_so_on")}),c&&t.jsx("p",{className:"text-body-sm text-danger",children:c})]})})},hl=({links:e})=>{I();const s=Uo(e),r=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:n("ui.projects.project_todos.to_dos")}),s&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:Zs(s)})]}),r.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_todos.no_to_do_snapshots_from_the_linked_sessions_yet_a_session_publish")}):t.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:r.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:Kt(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Zs(a.todos)})]},a.session_id))})]})},Is=({filePath:e,tooltip:s="File actions",icon:r,"aria-label":a="File actions",onShowInCanvas:o,onPreview:i})=>{I();const l=async()=>{if(e)try{await navigator.clipboard.writeText(e),ve("File path copied to clipboard")}catch(u){console.error("Failed to copy file path: ",u),de("Failed to copy file path")}},c=()=>{e&&window.api.openFile(e)};return t.jsxs(bs,{children:[t.jsx($t,{content:s,children:t.jsx(vs,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon-sm","aria-label":a,onClick:u=>u.stopPropagation(),children:r??t.jsx(Cr,{"aria-hidden":"true"})})})}),t.jsxs(ys,{align:"end",className:"min-w-45",onClick:u=>u.stopPropagation(),children:[i&&t.jsxs(be,{onSelect:i,children:[t.jsx(Ua,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.preview")})]}),o&&t.jsxs(be,{onSelect:o,children:[t.jsx(ea,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.show_in_canvas")})]}),t.jsxs(be,{onSelect:c,children:[t.jsx(ta,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.open_file")})]}),t.jsxs(be,{onSelect:()=>window.api.showItemInFolder(e),children:[t.jsx(sa,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.open_folder")})]}),t.jsxs(be,{onSelect:l,children:[t.jsx(ra,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.copy_file_path")})]})]})]})},gl=/[/\\]/,xl=e=>{if(e.name)return e.name;const s=e.path.split(gl);return s[s.length-1]||e.path},bl="h-[min(90vh,calc(100vh-104px))] w-[min(760px,calc(100vw-104px))] max-w-none gap-0 p-0",Tn=({open:e,attachment:s,onClose:r,restoreFocusTo:a})=>{I(),Ea(e,"project-file-preview");const[o,i]=d.useState({status:"loading"}),l=s?.path??null,c=s?Tr(s.name||s.path):!1;d.useEffect(()=>{if(!e||l===null)return;let p=!0;i({status:"loading"});const m=window.api?.readFile;if(typeof m!="function"){i({status:"unavailable"});return}return(async()=>{try{const _=await m(l);if(!p)return;if(!_.success){console.error("Project file preview failed",_.error),i({status:"error"});return}i({status:"ready",text:_.data})}catch(_){if(!p)return;console.error("Project file preview failed",_),i({status:"error"})}})(),()=>{p=!1}},[e,l]);const u=s?xl(s):"";return t.jsx(Ta,{open:e,onOpenChange:p=>!p&&r(),children:t.jsxs(Ra,{className:bl,onCloseAutoFocus:p=>{const m=a?.current;m&&(p.preventDefault(),m.focus())},children:[t.jsx("div",{className:"shrink-0 border-hairline border-b px-4 py-3 pr-12",children:t.jsx(Da,{className:"truncate text-title",title:l??"",children:u})}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3","data-project-file-preview":"",children:o.status==="loading"?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_updates.preview_loading")}):o.status==="unavailable"?t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_updates.preview_unavailable")}):o.status==="error"?t.jsxs("div",{className:"flex flex-col gap-1 text-body-sm text-ink-muted",children:[t.jsx("p",{children:n("ui.projects.project_updates.preview_failed")}),t.jsx("p",{children:n("ui.projects.project_updates.preview_moved")})]}):c?t.jsx(rt,{children:o.text}):t.jsx("pre",{className:"whitespace-pre-wrap font-mono text-ink text-mono-sm",children:o.text})})]})})};Tn.displayName="ProjectFilePreviewDialog";const vl=/[/\\]/,Re=e=>{if(e.name)return e.name;const s=e.path.split(vl);return s[s.length-1]||n("ui.projects.project_updates.attachment")};function yl(e){const s=e.kind.trim().toLowerCase();if(s==="image"||s==="video"||s==="audio")return s;const r=Rr(e.name||e.path);return r==="image"||r==="video"||r==="audio"?r:"file"}const kt=e=>{const s=Date.parse(e.added_at);return{mimeType:ia(e.name||e.path),sizeBytes:e.bytes,...Number.isFinite(s)?{mtimeMs:s}:{}}},Ae=e=>`${e.path}:${e.added_at}`,Ue="h-[78px] w-[117px]",Ls="pointer-events-none absolute top-1 right-1 z-[2] flex opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",Nt=({kind:e})=>e==="audio"?t.jsx("div",{className:"h-11 w-[242px] max-w-full rounded-sm border border-hairline bg-sunken"}):t.jsx(Be,{boundary:"control",className:Ue}),wl=({attachment:e,onOpen:s})=>{I();const r=Re(e),a=jt(e.path,kt(e));if(a.status==="ready"){const o=n("ui.projects.project_updates.open_name",{name:String(r)});return t.jsx(Dr,{file:e.path,src:a.url,label:r,conversationId:"",size:"thumbnail",press:{onPress:s,label:o,title:o}})}return a.status==="loading"?t.jsx(Be,{boundary:"control",className:Ue,children:t.jsxs("span",{className:"sr-only",children:[n("ui.projects.project_updates.loading"),r]})}):t.jsx(ht,{name:r,compact:!0})},kl=({attachment:e,onOpen:s})=>{const[r,a]=Ut();return t.jsx("div",{ref:r,className:"group relative flex leading-none","data-project-asset-tile":"image",children:a?t.jsx(wl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"image"})})},Nl=({attachment:e,onOpen:s})=>{I();const r=Re(e),a=jt(e.path,kt(e));if(a.status!=="ready")return a.status==="loading"?t.jsx(Nt,{kind:"video"}):t.jsx(ht,{name:r,compact:!0});const o=n("ui.projects.project_updates.play_name",{name:String(r)});return t.jsx(t.Fragment,{children:t.jsx("button",{type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":o,title:o,onClick:s,children:t.jsxs(Be,{boundary:"control",className:R(Ue,"relative"),children:[t.jsx("video",{src:a.url,preload:"metadata",muted:!0,playsInline:!0,className:R("h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]"),"data-project-video-thumb":""}),t.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx(Br,{className:"size-6 text-ink",fill:"currentColor","aria-hidden":"true"})})]})})})},Sl=({attachment:e,onOpen:s})=>{const[r,a]=Ut();return t.jsxs("div",{ref:r,className:"group relative block leading-none","data-project-asset-tile":"video",children:[a?t.jsx(Nl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"video"}),t.jsx("div",{className:Ls,children:t.jsx(Is,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Cl=({attachment:e})=>{I();const s=Re(e),r=jt(e.path,kt(e));return r.status!=="ready"?r.status==="loading"?t.jsx(Nt,{kind:"audio"}):t.jsx(ht,{name:s}):t.jsx("div",{className:"w-[242px] max-w-full rounded-sm border border-hairline bg-surface px-2",children:t.jsx(oa,{ownerId:`project-sound:${e.path}`,src:r.url,label:s,peaks:null,variant:"compact"})})},El=({attachment:e})=>{const[s,r]=Ut();return t.jsxs("div",{ref:s,className:"group relative block leading-none sm:col-span-2","data-project-asset-tile":"audio",children:[r?t.jsx(Cl,{attachment:e}):t.jsx(Nt,{kind:"audio"}),t.jsx("div",{className:Ls,children:t.jsx(Is,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Tl=e=>{const s=e.name||e.path;if(Tr(s))return!0;const r=Rr(s);return r==="text"||r==="code"},Rl=({attachment:e,onPreview:s})=>{I();const r=Re(e),a=qo(e.bytes),o=d.useRef(null),i=Tl(e),l=i?n("ui.projects.project_updates.preview_name",{name:String(r)}):n("ui.projects.project_updates.open_name",{name:String(r)});return t.jsxs("div",{className:"group relative inline-block","data-project-asset-tile":"file",children:[t.jsx("button",{ref:o,type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":l,title:r,onClick:()=>{if(i){s(o.current);return}window.api?.openFile(e.path)},children:t.jsxs(Be,{boundary:"control",className:R(Ue,"flex-col gap-0.5 px-2 py-1 text-center"),children:[t.jsx(na,{path:e.path}),t.jsx("span",{className:"w-full truncate text-meta text-ink",children:r}),a&&t.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:a})]})}),t.jsx("div",{className:Ls,children:t.jsx(Is,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(r)}),onPreview:i?()=>s(o.current):void 0})})]})},Dl=({asset:e,current:s,index:r,count:a,onSelect:o,scrollIntoView:i})=>{I();const[l,c]=Ut(),u=d.useRef(null),p=Re(e.attachment);return d.useEffect(()=>{!s||!i||u.current?.scrollIntoView({block:"nearest",inline:"nearest"})},[s,i]),t.jsx("li",{ref:u,className:R("flex shrink-0 rounded-sm leading-none",s&&"ring-1 ring-ink"),children:t.jsx("div",{ref:l,className:"group relative",children:c?t.jsx(Al,{asset:e,onSelect:o,current:s,index:r,count:a}):t.jsx("button",{type:"button","aria-label":n("ui.projects.project_updates.show_asset_name",{name:String(p),index:String(r+1),count:String(a)}),className:"group/tile inline-block cursor-pointer rounded-sm leading-none",onClick:o,children:t.jsx(Be,{boundary:"control",className:Ue,"data-attachment-reserved":""})})})})},Al=({asset:e,current:s,index:r,count:a,onSelect:o})=>{I();const i=Re(e.attachment),l=jt(e.attachment.path,kt(e.attachment)),c=n("ui.projects.project_updates.show_asset_name",{name:String(i),index:String(r+1),count:String(a)});return e.kind==="image"&&l.status==="ready"?t.jsx(Dr,{file:e.attachment.path,src:l.url,label:i,conversationId:"",size:"thumbnail",press:{onPress:o,label:c,title:c,current:s}}):l.status!=="ready"?l.status==="loading"?t.jsx("button",{type:"button","aria-label":c,className:"group/tile inline-block cursor-pointer rounded-sm leading-none",onClick:o,children:t.jsx(Be,{boundary:"control",className:Ue})}):t.jsx(ht,{name:i,compact:!0}):t.jsx("button",{type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":c,title:c,"aria-current":s?"true":void 0,onClick:o,children:t.jsxs(Be,{boundary:"control",className:R(Ue,"relative"),children:[t.jsx("video",{src:l.url,preload:"metadata",muted:!0,playsInline:!0,className:R("h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]")}),t.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx(Br,{className:"size-4 text-ink",fill:"currentColor","aria-hidden":"true"})})]})})},Pl=({media:e,index:s,onSelect:r})=>(I(),t.jsx("ul",{role:"list","aria-label":n("ui.projects.project_updates.attachments"),"data-project-asset-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((a,o)=>t.jsx(Dl,{asset:a,current:o===s,index:o,count:e.length,onSelect:()=>r(o),scrollIntoView:s===o},Ae(a.attachment)))})),Ol=({media:e,index:s,onIndexChange:r,onClose:a,restoreFocusTo:o})=>{I();const i=e[s],l=Re(i.attachment),c=jt(i.attachment.path,kt(i.attachment)),u=e.length>1?t.jsx(Pl,{media:e,index:s,onSelect:r}):void 0;return t.jsx(aa,{open:!0,onOpenChange:p=>{p||a()},src:c.status==="ready"?c.url:void 0,pending:c.status==="loading",label:l,mediaKind:i.kind,mediaLabel:"asset",restoreFocusTo:o,fallback:t.jsx(ht,{name:l}),group:{index:s,count:e.length,onPrev:()=>r(Ks(s,e.length,-1)),onNext:()=>r(Ks(s,e.length,1)),filmstrip:u}})},Rn=({attachments:e})=>{I();const s=d.useMemo(()=>e.map(j=>({attachment:j,kind:yl(j)})),[e]),r=d.useMemo(()=>s.filter(j=>j.kind==="image"||j.kind==="video"),[s]),[a,o]=d.useState(null),[i,l]=d.useState(null),c=d.useRef(null),u=d.useRef(null),p=a?r.findIndex(j=>Ae(j.attachment)===a):-1,m=j=>{const f=document.activeElement;c.current=f instanceof HTMLElement?f:null,o(Ae(j))},_=(j,f=null)=>{const g=document.activeElement;u.current=f??(g instanceof HTMLElement?g:null),l(j)};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid max-w-[492px] grid-cols-[repeat(auto-fill,117px)] items-start gap-2","data-project-asset-grid":"",children:s.map(({attachment:j,kind:f})=>f==="image"?t.jsx(kl,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="video"?t.jsx(Sl,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="audio"?t.jsx(El,{attachment:j},Ae(j)):t.jsx(Rl,{attachment:j,onPreview:g=>_(j,g)},Ae(j)))}),p>=0&&t.jsx(Ol,{media:r,index:p,onIndexChange:j=>{const f=r[j];f&&o(Ae(f.attachment))},onClose:()=>o(null),restoreFocusTo:c}),t.jsx(Tn,{open:i!==null,attachment:i,onClose:()=>l(null),restoreFocusTo:u})]})};Rn.displayName="ProjectUpdateAssets";const Ml=({update:e,nowMs:s})=>{const r=I(),a=Lo(e,r,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((o,i)=>t.jsxs(d.Fragment,{children:[i>0&&t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:o.text})]},o.key))}),e.text&&t.jsx(rt,{children:e.text}),e.attachments.length>0&&t.jsx(Rn,{attachments:e.attachments})]})},Il=({updates:e,nowMs:s})=>{const r=I(),a=Ao(e.length),o=Fo(e,r,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:n("ui.projects.project_updates.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:n("ui.projects.project_updates.no_updates_yet_progress_reported_by_you_or_by_the_sessions_workin")}):t.jsx("div",{className:"flex flex-col gap-4",children:o.map(i=>t.jsxs("div",{className:"flex flex-col gap-2",children:[i.label&&t.jsx("h3",{className:"text-meta text-ink-muted",children:i.label}),t.jsx("div",{className:"flex flex-col divide-y divide-hairline",children:i.entries.map((l,c)=>t.jsx(Ml,{update:l,nowMs:s},`${l.at}:${l.by}:${c}`))})]},i.key||"ungrouped"))})]})},Ll="project_not_found",Fl=({projectKey:e,nowMs:s})=>{I();const r=Bt(),a=nt(),o=Ar(ye(a.data,"team_catalogue")),i=Ur(e,!0),l=$r(),c=zr(),u=io(),p=co(),m=ao(),_=oo(),[j,f]=d.useState(!1),[g,S]=d.useState(!1),b=l.isPending||c.isPending||u.isPending||p.isPending||m.isPending||_.isPending;if(i.isLoading)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(Te,{label:n("ui.projects.project_detail.loading_project")})});if(i.isError||!i.data){const h=i.error instanceof qt&&(i.error.code===Ll||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(ts,{variant:"danger",className:"w-full",children:h?n("ui.projects.project_detail.this_project_could_not_be_found_it_may_have_been_deleted"):i.error instanceof Error&&i.error.message?i.error.message:n("ui.projects.project_detail.the_project_could_not_be_read")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",onClick:()=>void i.refetch(),children:n("ui.projects.project_detail.try_again")}),t.jsxs(G,{variant:"secondary",onClick:()=>void r("/projects"),children:[t.jsx(Ws,{}),n("ui.projects.project_detail.all_projects")]})]})]})}const{project:x,links:w}=i.data,T=ne(x),k=(h,A)=>l.mutateAsync({key:x.id,fields:h,...A?.forceDone===!0?{forceDone:!0}:{}}),q=x.team?o(x.team):null,C=Bo(x.milestones.filter(h=>h.completed_at!==null).length,x.milestones.length),E=async(h,A,D,F)=>{const H=At.getState(),U=la(null,h,H.drafts);if(!U)return!1;try{const{images:Y,unreadable:J,overflow:Z}=await ua(F,A),me=da(J);if(me)return de(me),!1;const oe=pa(Z);if(oe)return de(oe),!1;const ee=ma(A,Y);if(ee)return de(ee),!1;if(await fa(U,{text:A,attachments:F,images:Y,mode:D,cwd:H.cwd},h)===null)return de(n("ui.projects.project_detail.that_session_already_has_a_message_going_out_try_again_in_a_momen")),!1;const v=w.find(y=>y.session_id===h);return ve(n("ui.projects.project_detail.sent_to_value1",{value1:String(v?Kt(v):h)})),!0}catch(Y){return de(Y instanceof Error&&Y.message?Y.message:n("ui.projects.project_detail.the_message_was_not_sent")),!1}},M=async h=>{const A=At.getState(),D=h.kind==="plain"?void 0:{kind:h.kind,name:h.name},F=await A.createSession(A.cwd||"~",D);if(!F)throw new Error(A.error??n("ui.projects.project_detail.the_session_could_not_be_started"));_a.getState().setCurrentInput(F,zo(x));let H=null;try{await m.mutateAsync({key:x.id,sessionId:F})}catch(U){H=U instanceof Error&&U.message?U.message:n("ui.projects.project_detail.the_link_was_refused")}if(H)de(n("ui.projects.project_detail.session_started_but_linking_it_failed_linkfailure",{linkFailure:String(H)}));else{const U=D?n("ui.projects.project_detail.with_value1",{value1:String(Go(D))}):"";ve(n("ui.projects.project_detail.session_started_withtarget_and_linked_to_displayname",{withTarget:String(U),displayName:String(T)}))}await Fr(r,F)};return t.jsx(wc,{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 r("/projects"),className:"flex w-fit items-center gap-1.5 text-body-sm text-ink-muted hover:text-ink",children:[t.jsx(Ws,{className:"size-4"}),n("ui.projects.project_detail.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(Zc,{project:x,commit:k}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(el,{project:x,commit:k}),x.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ml,{project:x}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(ca,{}),n("ui.projects.project_detail.delete")]})]})]})]}),t.jsx(tl,{project:x,commit:k}),t.jsx(pl,{project:x,nowMs:s,commit:k,teamLabel:q}),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:n("ui.projects.project_detail.progress")}),t.jsx(rt,{className:"text-body",children:x.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:_o(x,s)})]}),t.jsx(ul,{milestones:x.milestones,summary:C,busy:b,onToggle:(h,A)=>{u.mutateAsync({key:x.id,name:h,completed:A}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_updated"))})},onRemove:h=>{p.mutateAsync({key:x.id,name:h}).catch(A=>{de(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_milestone_was_not_removed"))})},onAdd:(h,A)=>{u.mutateAsync({key:x.id,name:h,targetDate:A}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_added"))})}}),t.jsx(ll,{projectKey:x.id,links:w,busy:b,onStartSession:()=>S(!0),onQuickSend:E,onLink:h=>{m.mutateAsync({key:x.id,sessionId:h}).catch(A=>{de(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_session_was_not_linked"))})},onUnlink:h=>{_.mutateAsync({key:x.id,sessionId:h}).catch(A=>{de(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_session_was_not_unlinked"))})}}),t.jsx(hl,{links:w}),t.jsx(Il,{updates:x.updates,nowMs:s}),t.jsx(vn,{open:j,projectName:x.name,onClose:()=>f(!1),onConfirm:async h=>{await c.mutateAsync({key:x.id,confirmedName:h}),ve(n("ui.projects.project_detail.project_deleted")),r("/projects")}}),t.jsx(jl,{open:g,onClose:()=>S(!1),onStart:M,teamsEnabled:ye(a.data,"team_catalogue"),profilesEnabled:ye(a.data,"profile_catalogue")})]})})},ql="payments-migration",kr={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},Bl=({open:e,onClose:s,onSubmit:r})=>{I();const[a,o]=d.useState(kr),[i,l]=d.useState({}),[c,u]=d.useState(null),p=d.useRef(null),[m,_]=d.useState(!1),[j,f]=d.useState(!1),[g,S]=d.useState(!1),b=d.useId(),x=d.useRef(null);d.useEffect(()=>{e&&(o({...kr,description:hr}),l({}),u(null),_(!1),f(!1),S(!1))},[e]),d.useEffect(()=>{c&&p.current?.scrollIntoView({block:"nearest"})},[c]);const w=(h,A)=>{o(D=>({...D,[h]:A}))},T=j?a.name:Ac(a.title),k=h=>wn(h,x,A=>w("description",A)),q=(h,A)=>{const D={},F=ss(A);F&&(D.name=F);const H=pn(h.description);H&&(D.description=H);const U=ps(h.tags).error;U&&(D.tags=U);const Y=us(h.startDate);Y&&(D.startDate=Y);const J=us(h.targetDate);if(J)D.targetDate=J;else if(!Y){const ee=ds(h.startDate,h.targetDate);ee&&(D.targetDate=ee)}if(h.estimate.trim()){const ee=mn(h.estimate);ee&&(D.estimate=ee)}const Z=ls(h.title);Z&&(D.title=Z);const me=Mt(h.owner,"owner");me&&(D.owner=me);const oe=Mt(h.team,"team");return oe&&(D.team=oe),D},C=async()=>{const h=T.trim(),A=q(a,h);if(l(A),Object.keys(A).length>0)return;_(!0),u(null);const D=ft(a.tags);try{const F={};a.title.trim()&&(F.title=a.title.trim()),a.owner.trim()&&(F.owner=a.owner.trim()),a.team.trim()&&(F.team=a.team.trim()),a.startDate&&(F.start_date=a.startDate),a.targetDate&&(F.target_date=a.targetDate),a.estimate&&(F.estimate=Number(a.estimate),F.estimate_unit=a.estimateUnit),await r({fields:{name:h,...a.description.trim()&&a.description.trim()!==hr?{description:a.description.trim()}:{},status:a.status,...D.length>0?{tags:D}:{}},...Object.keys(F).length>0?{followUp:F}:{}}),s()}catch(F){const H=F instanceof Error&&F.message?F.message:"";u(yt(H)||n("ui.projects.project_form_dialog.the_project_was_not_saved"))}finally{_(!1)}},E=n("ui.projects.project_form_dialog.new_project"),M=a.description.length>tt;return t.jsx(_t,{open:e,onClose:s,title:E,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:m,onEscapeKeyDown:h=>{m&&h.preventDefault()},onInteractOutside:h=>{m&&h.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Xe,{onClick:s,disabled:m,children:n("ui.projects.project_form_dialog.cancel")}),t.jsxs(Dt,{"data-project-submit":"",onClick:()=>void C(),disabled:m,children:[m&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_form_dialog.create_project")]})]}),children:t.jsxs("form",{className:"flex flex-col gap-6 px-1 py-1",onSubmit:h=>{h.preventDefault(),C()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-title`,children:n("ui.projects.project_form_dialog.title")}),t.jsx(ue,{id:`${b}-title`,"data-project-title":"",value:a.title,onChange:h=>w("title",h.target.value),placeholder:n("ui.projects.project_form_dialog.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(pe,{htmlFor:`${b}-key`,className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.key")}),t.jsx(ue,{id:`${b}-key`,"data-project-key":"",value:T,onChange:h=>{f(!0),w("name",h.target.value)},placeholder:ql,"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:j?n("ui.projects.project_form_dialog.letters_digits_dot_underscore_or_dash_no_spaces"):n("ui.projects.project_form_dialog.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(pe,{htmlFor:`${b}-description`,children:n("ui.projects.project_form_dialog.description")}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:n("ui.projects.project_form_dialog.description_mode")}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:["write","preview"].map(h=>t.jsx("button",{type:"button","data-project-description-mode":h,"aria-pressed":g===(h==="preview"),onClick:()=>S(h==="preview"),className:R("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",g===(h==="preview")&&"bg-surface text-ink"),children:h==="write"?n("ui.projects.project_form_dialog.write"):n("ui.projects.project_form_dialog.preview")},h))})]})]}),g?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(rt,{className:"text-body-sm",children:a.description}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_form_dialog.nothing_to_preview_yet")})}):t.jsx(Or,{ref:x,id:`${b}-description`,"data-project-description":"",value:a.description,onChange:h=>w("description",h.target.value),onPaste:k,rows:8,placeholder:n("ui.projects.project_form_dialog.markdown_headings_lists_code"),"aria-invalid":M||!!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:R("text-meta tabular-nums",M?"text-danger":"text-ink-muted"),children:[a.description.length,"/",tt]})]})]}),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(pe,{children:n("ui.projects.project_form_dialog.status")}),t.jsxs(Je,{value:a.status,onValueChange:h=>w("status",h),children:[t.jsx(Qe,{"aria-label":n("ui.projects.project_form_dialog.status"),children:t.jsx(Ze,{})}),t.jsx(et,{children:Yr.map(h=>t.jsx(Oe,{value:h.value,children:h.label},h.value))})]}),a.status==="done"&&t.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.moving_a_project_to_done_stamps_today_as_its_completion_date")})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${b}-owner`,children:n("ui.projects.project_form_dialog.owner")}),t.jsx(ue,{id:`${b}-owner`,"data-project-owner":"",value:a.owner,onChange:h=>w("owner",h.target.value),placeholder:n("ui.projects.examples.owner"),"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(pe,{htmlFor:`${b}-team`,children:n("ui.projects.project_form_dialog.team")}),t.jsx(ue,{id:`${b}-team`,value:a.team,onChange:h=>w("team",h.target.value),placeholder:n("ui.projects.examples.team"),"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(pe,{htmlFor:`${b}-target`,children:n("ui.projects.project_form_dialog.target_date")}),t.jsx(ue,{id:`${b}-target`,"data-project-target":"",value:a.targetDate,onChange:h=>w("targetDate",h.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(pe,{htmlFor:`${b}-start`,children:n("ui.projects.project_form_dialog.start_date")}),t.jsx(ue,{id:`${b}-start`,value:a.startDate,onChange:h=>w("startDate",h.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(pe,{htmlFor:`${b}-estimate`,children:n("ui.projects.project_form_dialog.estimate")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ue,{id:`${b}-estimate`,value:a.estimate,onChange:h=>w("estimate",h.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(Je,{value:a.estimateUnit,onValueChange:h=>w("estimateUnit",h),children:[t.jsx(Qe,{"aria-label":n("ui.projects.project_form_dialog.estimate_unit"),className:"max-w-32",children:t.jsx(Ze,{})}),t.jsxs(et,{children:[t.jsx(Oe,{value:"points",children:n("ui.projects.project_form_dialog.points")}),t.jsx(Oe,{value:"days",children:n("ui.projects.project_form_dialog.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(pe,{htmlFor:`${b}-tags`,children:n("ui.projects.project_form_dialog.tags")}),t.jsx(ue,{id:`${b}-tags`,value:a.tags,onChange:h=>w("tags",h.target.value),placeholder:n("ui.projects.project_form_dialog.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:n("ui.projects.project_form_dialog.comma_separated_up_to_8_lowercase_letters_digits_underscore_or_da")})]})]}),c&&t.jsx("p",{ref:p,className:"text-body-sm text-danger",children:c})]})})},Dn=({children:e})=>{const s=d.useRef(null),[r,a]=d.useState(!1),o=()=>{const i=s.current;i&&a(i.scrollTop+i.clientHeight<i.scrollHeight-1)};return d.useEffect(o),t.jsx("div",{ref:s,onScroll:o,className:R("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",r&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},Ul=({label:e,count:s,selected:r,onToggle:a})=>{const o=d.useId();return t.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1 hover:bg-sunken",children:[t.jsx(Ir,{id:o,checked:r,onCheckedChange:()=>a()}),t.jsx(pe,{htmlFor:o,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})]})},$l=({column:e,spec:s,onChange:r})=>{I();const a=d.useId(),o=s!==null&&s.key===e,i=o?s.direction:Xt(e),l=i==="asc"?"desc":"asc",c=()=>r({key:e,direction:o?l:Xt(e)}),u=s===null?"default":o?"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:n("ui.projects.project_filters_panel.sort_by_sortcolumnlabel_column",{sortColumnLabel_column:String(st(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:u==="default",onChange:()=>r(null),className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:R("min-w-0 flex-1 truncate",u==="default"?"text-ink":"text-ink-muted"),children:n("ui.projects.project_sort.default_as_listed")})]}),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:u==="sorted",onChange:c,onClick:()=>{u==="sorted"&&c()},onKeyDown:p=>{u==="sorted"&&(p.key!==" "&&p.key!=="Enter"||(p.preventDefault(),c()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:R("min-w-0 flex-1 truncate",u==="sorted"?"text-ink":"text-ink-muted"),children:n("ui.projects.project_filters_panel.sort_by_sortcolumnlabel_column_value2",{sortColumnLabel_column:String(st(e)),value2:String(Ds(e,o?i:Xt(e)))})})]})]})},zl=({facet:e,options:s,onToggle:r})=>(I(),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:dt[e]}),s.map(a=>t.jsx(Ul,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>r(e,a.value)},`${e}:${a.value??"none"}`))]})),An=({projects:e,state:s,query:r,todayMs:a,onToggle:o,onClearAll:i,scope:l,sort:c})=>{I();const u=l===void 0?bi(e,s,a):l===null?[]:[dn(l,e,s,a)],p=!mt(s)||r.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:n("ui.projects.project_filters_panel.filters")}),p&&t.jsx(G,{variant:"link",size:"sm",onClick:i,children:n("ui.projects.project_filters_panel.clear_all")})]}),c&&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:n("ui.projects.project_filters_panel.sort_by_key",{key:String(st(c.key))})}),t.jsx($l,{column:c.key,spec:c.spec,onChange:c.onChange})]}),u.map(m=>t.jsx(zl,{facet:m.facet,options:m.options,onToggle:o},m.facet))]})},Gl=({team:e,count:s,headingId:r,className:a,...o})=>(I(),t.jsxs("div",{...o,"data-glass-well":"",className:R("flex h-8 cursor-default items-center gap-2 bg-surface px-3 text-meta",a),children:[t.jsx("h3",{id:r,className:"truncate text-ink",children:e??n("ui.projects.project_model.no_team")}),t.jsx("span",{className:"shrink-0 text-ink-muted","aria-label":ho(s),children:s})]})),Ee=[{key:"name",get label(){return n("ui.projects.project_list.project")},className:"min-w-0 flex-1",sort:"name",facet:null},{key:"status",get label(){return n("ui.projects.project_list.status")},className:"w-20 shrink-0",sort:"status",facet:"status"},{key:"target",get label(){return n("ui.projects.project_list.target")},className:"hidden w-32 shrink-0 @[40rem]:block",sort:"target",facet:"target"},{key:"estimate",get label(){return n("ui.projects.project_list.estimate")},className:"hidden w-16 shrink-0 @[40rem]:block",sort:"estimate",facet:"estimate"},{key:"milestones",get label(){return n("ui.projects.project_list.milestones")},className:"hidden w-20 shrink-0 @[34rem]:block",sort:"milestones",facet:"milestones"},{key:"live",get label(){return n("ui.projects.project_list.live")},className:"hidden w-14 shrink-0 @[34rem]:block",sort:"live",facet:"live"},{key:"progress",get label(){return n("ui.projects.project_list.progress")},className:"w-40 shrink-0",sort:"progress",facet:"progress"}];function Yl(e,s){const r=xt(e.progress_updated_at,s);return r?bt(r):n("ui.projects.project_list.not_reported")}const Kl=({direction:e})=>e==="asc"?t.jsx(qr,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Pr,{size:10,className:"shrink-0","aria-hidden":"true"}),Hl=({projects:e,nowMs:s,onOpen:r,sort:a,onSortChange:o,searchPopulation:i,filters:l,query:c,todayMs:u,onToggleFilter:p,onClearFilters:m,teamLabelFor:_=j=>j})=>{const j=I(),f=a?Ti(e,a):e,g=Es(f,vt),S=d.useId(),b=C=>`${S}-team-${C}`,[x,w]=d.useState(0),T=d.useRef([]),k=(C,E)=>{const M=Ee.length;for(let h=1;h<=M;h+=1){const A=(C+E*h+M*M)%M,D=T.current[A];if(D&&D.offsetParent!==null){w(A),D.focus();return}}},q=C=>E=>{E.key!=="ArrowLeft"&&E.key!=="ArrowRight"||(E.preventDefault(),k(C,E.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":n("ui.projects.project_list.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:Ee.map((C,E)=>{const M=a!==null&&a.key===C.sort;return t.jsx("th",{scope:"col","aria-sort":M?a.direction==="desc"?"descending":"ascending":"none",className:R(C.className,"p-0 text-left font-normal"),children:t.jsxs(ws,{children:[t.jsx(ks,{asChild:!0,children:t.jsxs("button",{type:"button",ref:h=>{T.current[E]=h},tabIndex:E===x?0:-1,"data-project-column":C.key,onFocus:()=>w(E),onKeyDown:q(E),className:R("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",M?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:C.label}),M?t.jsx(Kl,{direction:a.direction}):t.jsx(ja,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(Ns,{align:"start","aria-label":n("ui.projects.project_list.label_column",{label:String(C.label)}),className:"w-72 p-0",children:t.jsx(Dn,{children:t.jsx(An,{projects:i,state:l,query:c,todayMs:u,onToggle:p,onClearAll:m,scope:C.facet,sort:{key:C.sort,spec:a,onChange:o}})})})]})},C.key)})})})}),t.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:g.map((C,E)=>t.jsxs("li",{children:[t.jsx(Gl,{team:C.team==null?null:_(C.team),count:C.items.length,headingId:b(E),className:"sticky top-0 z-10","data-project-team":C.team??""}),t.jsx("ul",{"aria-labelledby":b(E),className:"divide-y divide-hairline",children:C.items.map(M=>{const h=new Map(Xr(M,j).map(F=>[F.key,F.text])),A=Vr(M.milestones_completed,M.milestones_total),D=Cs(M.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>r(M),"data-project-name":M.name,className:R("flex w-full items-center gap-3 px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","hover:bg-row-hover"),children:[t.jsx("span",{className:R(Ee[0].className,"truncate text-body-sm text-ink"),children:ne(M)}),t.jsx("span",{className:Ee[1].className,children:t.jsx(Nn,{status:M.status})}),t.jsx("span",{className:R(Ee[2].className,"truncate text-meta text-ink-muted"),children:h.get("target")??h.get("completed")??""}),t.jsx("span",{className:R(Ee[3].className,"truncate text-meta text-ink-muted"),children:h.get("estimate")??""}),t.jsx("span",{className:R(Ee[4].className,"truncate text-meta text-ink-muted"),children:A}),t.jsx("span",{className:R(Ee[5].className,"truncate text-meta text-ink-muted"),children:D}),t.jsxs("span",{className:R(Ee[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:Yl(M,s)}),M.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]})},M.id)})})]},C.team??""))})]})},Ft=224,Nr=36,Wl={get day(){return n("ui.projects.project_timeline.days")},get week(){return n("ui.projects.project_timeline.weeks")},get month(){return n("ui.projects.project_timeline.months")},get quarter(){return n("ui.projects.project_timeline.quarters")}},Vl=({items:e,nowMs:s,onOpen:r,pendingDetails:a,failedDetails:o,onRetryDetails:i,teamLabelFor:l=c=>c})=>{I();const[c,u]=d.useState(null),[p,m]=d.useState(0),_=d.useRef(null),j=Ps(s),f=d.useMemo(()=>Ai(e,j),[e,j]),g=d.useMemo(()=>Pi(e),[e]),S=d.useMemo(()=>Es(g.dated,C=>vt(C.project)),[g]);d.useLayoutEffect(()=>{const C=_.current;if(!C)return;const E=()=>m(C.clientWidth);if(E(),typeof ResizeObserver>"u")return;const M=new ResizeObserver(E);return M.observe(C),()=>M.disconnect()},[]);const b=Math.max(p-Ft-24,160),x=f?Ri(or(f.startMs,f.endMs),b):"month",w=c??x,T=C=>{const E=Pe.indexOf(w),M=Pe[E-C];M&&u(M)},k=As[w],q=f?or(f.startMs,f.endMs)*k:0;return t.jsxs("div",{ref:_,className:"flex min-h-0 flex-1 flex-col","data-testid":"project-timeline",children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-9 py-2",children:[t.jsx("span",{className:"truncate text-meta text-ink-muted","data-timeline-note":!0,children:o>0?n("ui.projects.timeline.read_failed",{count:o}):n("ui.projects.project_timeline.length_dated_length_2_without_dates_value3",{length:V(g.dated.length,{useGrouping:!1}),length_2:V(g.undated.length,{useGrouping:!1}),value3:String(a>0?n("ui.projects.project_timeline.loading_milestones_for_pendingdetails",{pendingDetails:V(a,{useGrouping:!1})}):"")})}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[o>0&&t.jsx(G,{variant:"secondary",size:"sm",onClick:i,children:n("ui.projects.project_timeline.try_again")}),t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.project_timeline.zoom_in"),title:n("ui.projects.project_timeline.zoom_in_finer"),disabled:!f||w===Pe[0],onClick:()=>T(1),children:t.jsx(pt,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Wl[w]}),t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.project_timeline.zoom_out"),title:n("ui.projects.project_timeline.zoom_out_coarser"),disabled:!f||w===Pe[Pe.length-1],onClick:()=>T(-1),children:t.jsx(Aa,{})})]})]}),f&&g.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(Xl,{startMs:f.startMs,endMs:f.endMs,tier:w,pxPerDay:k,trackPx:q}),S.map(C=>t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-20 flex items-stretch bg-canvas","data-project-team":C.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:Ft},children:[t.jsx("span",{className:"truncate text-ink",children:C.team==null?n("ui.projects.project_model.no_team"):l(C.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:C.items.length})]})}),C.items.map(E=>t.jsx(Jl,{item:E,spanStart:f.startMs,pxPerDay:k,trackPx:q,today:j,onOpen:()=>r(E)},E.project.id))]},C.team??""))]})}):null,g.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(Er,{defaultOpen:g.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(Wa,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Oi(g.undated.length)})]}),children:[g.dated.length===0&&t.jsx("p",{className:"pb-1 text-meta text-ink-muted",children:n("ui.projects.project_timeline.set_a_start_date_a_target_date_or_a_milestone_date_and_it_will_ap")}),t.jsx("ul",{className:"flex max-h-24 flex-wrap gap-x-3 gap-y-1 overflow-y-auto",children:g.undated.map(C=>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:()=>r(C),children:ne(C.project)})},C.project.id))})]})})]})},Xl=({startMs:e,endMs:s,tier:r,pxPerDay:a,trackPx:o})=>{const i=zi(e,s,r);return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx("span",{className:"sticky left-0 z-10 shrink-0 bg-canvas",style:{width:Ft}}),t.jsx("span",{className:"relative block h-6",style:{width:o},children:i.map(l=>t.jsxs("span",{className:"absolute top-0 h-full",style:{left:Fe(e,l.dayMs)*a},children:[t.jsx("span",{className:R("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))})]})},Jl=({item:e,spanStart:s,pxPerDay:r,trackPx:a,today:o,onOpen:i})=>{const{project:l}=e,c=Mi(e),u=Ii(e),p=m=>new Date(m).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-row-hover",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:Ft,height:Nr},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:ne(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:Nr},children:[c&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:Fe(s,c.fromMs)*r,width:(Fe(c.fromMs,c.toMs)+1)*r},title:`${Me(p(c.fromMs))} → ${Me(p(c.toMs))}`}),u.map(m=>t.jsx("span",{"data-milestone":m.status,className:R("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",m.status==="completed"&&"bg-success",m.status==="overdue"&&"bg-warning",m.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:Fe(s,m.dayMs)*r},title:`${m.name} · ${m.status} · ${Me(p(m.dayMs))}`},`${m.name}-${m.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:Fe(s,o)*r},"aria-hidden":"true"})]})]})},Ql=({projects:e,query:s,onQueryChange:r,filters:a,onFiltersChange:o,onClearAll:i,todayMs:l,resultText:c,countRevealClass:u="@[37rem]:inline",trailing:p,disabled:m=!1,searchFieldRef:_})=>{I();const[j,f]=d.useState(!1),g=d.useRef(!1),S=ji(a),b=Lr(c??"",300),x=s.trim()!==""||!mt(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(ha,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),t.jsx(ue,{ref:_,inputSize:"sm",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>{w.key==="Escape"&&(s?r(""):w.currentTarget.blur())},placeholder:n("ui.projects.projects_toolbar.search_projects"),"aria-label":n("ui.projects.projects_toolbar.search_projects"),autoComplete:"off",spellCheck:!1,className:"pl-9"}),s?t.jsx(G,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>ga(_.current,r),"aria-label":n("ui.projects.projects_toolbar.clear_search"),children:t.jsx(zt,{"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(xa,{shortcut:"/"})})]}),t.jsxs(ws,{open:j,onOpenChange:f,children:[t.jsx(ks,{asChild:!0,children:t.jsxs(G,{variant:"secondary",size:"sm",disabled:m,"data-project-filters-button":"",children:[t.jsx(Xa,{size:14,"aria-hidden":"true"}),n("ui.projects.projects_toolbar.filters"),S>0&&t.jsx(ke,{variant:"neutral",children:S})]})}),t.jsx(Ns,{align:"end","aria-label":n("ui.projects.projects_toolbar.filters"),className:"w-80 p-0",onCloseAutoFocus:w=>{g.current&&(g.current=!1,w.preventDefault())},children:t.jsx(Dn,{children:t.jsx(An,{projects:e,state:a,query:s,todayMs:l,onToggle:(w,T)=>o(cn(a,w,T)),onClearAll:()=>{i(),g.current=!0,f(!1),_.current?.focus()}})})})]}),x&&c!==null&&t.jsx("span",{className:R("hidden whitespace-nowrap text-meta text-ink-dim",u),"data-project-count":"",children:c}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:b}),p]})},Zl=({filters:e,sort:s,onFiltersChange:r,onSortChange:a,onClearAll:o,hideClearAll:i=!1,searchFieldRef:l})=>{I();const[c,u]=d.useState(null);d.useEffect(()=>{if(!c)return;let _=null;c.kind==="search"?_=l.current:(_=document.querySelector(`[data-project-chip="${c.index}"]`),_||(_=document.querySelector("[data-project-chip]")),_||(_=document.querySelector("[data-project-filters-button]"))),_&&(_.focus(),u(null))});const p=[];for(const _ of at){const j=e[_];if(j.length===0)continue;const f=j.map(b=>on(_,b)),g=f[0],S=f.length>1?n("ui.projects.projects_toolbar.facet_labels_facet_first_length_1",{FACET_LABELS_facet:String(dt[_]),first:String(g),length___1:V(f.length-1,{useGrouping:!1})}):n("ui.projects.projects_toolbar.facet_labels_facet_first",{FACET_LABELS_facet:String(dt[_]),first:String(g)});p.push({kind:"facet",facet:_,label:S,ariaLabel:n("ui.projects.projects_toolbar.remove_filter_facet_labels_facet_join",{FACET_LABELS_facet:String(dt[_]),join:String(f.join(", "))}),clear:()=>r({...e,[_]:[]})})}if(s&&p.push({kind:"sort",spec:s,label:n("ui.projects.projects_toolbar.sort_key",{key:String(st(s.key))}),ariaLabel:n("ui.projects.projects_toolbar.remove_sort_key_direction",{key:String(st(s.key)),direction:String(Ds(s.key,s.direction))}),clear:()=>a(null)}),p.length===0)return null;const m=(_,j)=>{j.clear();const f=p.length-1;u(f===0?{kind:"chip",index:0}:{kind:"chip",index:Math.min(_,f-1)})};return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map((_,j)=>t.jsx(ke,{asChild:!0,variant:"neutral",className:"gap-1 pr-1 text-ink",children:t.jsxs("button",{type:"button",className:"group","data-project-chip":j,"aria-label":_.ariaLabel,onClick:()=>m(j,_),children:[_.kind==="sort"&&(_.spec.direction==="asc"?t.jsx(qr,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Pr,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:_.label}),t.jsx(zt,{className:R("text-ink-dim transition-colors duration-fast ease-out-quart","group-hover:text-danger"),"aria-hidden":"true"})]})},_.kind==="facet"?_.facet:"sort")),!i&&t.jsx(G,{variant:"link",size:"sm",onClick:()=>{o(),u({kind:"search"})},children:n("ui.projects.projects_toolbar.clear_all")})]})},Pn="projects-view",eu=[{value:"list",get label(){return n("ui.projects.projects_view_switcher.list")}},{value:"board",get label(){return n("ui.projects.projects_view_switcher.board")}},{value:"timeline",get label(){return n("ui.projects.projects_view_switcher.timeline")}}];function tu(){try{const e=localStorage.getItem(Pn);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function su(e){try{localStorage.setItem(Pn,e)}catch{}}const ru=({value:e,onChange:s})=>(I(),t.jsx(Pa,{value:e,onValueChange:r=>s(r),children:t.jsx(Oa,{"aria-label":n("ui.projects.projects_view_switcher.project_view"),"data-tour-tag":"projects-view-switcher",children:eu.map(r=>t.jsx(Ma,{value:r.value,children:r.label},r.value))})})),nu=["r1","r2","r3","r4","r5","r6"],au=4e3,Sr={get unpaired(){return n("ui.projects.projects_page.this_app_is_not_paired_with_the_local_operator_server_so_projects")},get"below-version"(){return n("ui.projects.projects_page.the_local_operator_server_is_older_than_this_app_expects_so_proje")},get unknown(){return n("ui.projects.projects_page.the_server_s_capabilities_could_not_be_read_so_projects_are_unava")}},_u=({nowMs:e=Date.now()})=>{I();const{projectId:s}=ba(),r=Bt(),a=nt(),o=va(a.data,"projects",1),i=o==="enabled",l=ye(a.data,"projects",Qo),c=Ar(ye(a.data,"team_catalogue")),u=so(i),p=no(),m=$r(),_=zr(),[j,f]=d.useState(!1),[g,S]=d.useState(()=>tu()),[b,x]=d.useState(()=>So()),[w,T]=d.useState(null),[k,q]=d.useState(""),[C,E]=d.useState(sr),[M,h]=d.useState(()=>wi()),[A,D]=d.useState(""),F=d.useRef(""),H=d.useRef(null),U=d.useRef(null),Y=N=>{H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null),N!==""&&N===F.current?(D(""),H.current=window.requestAnimationFrame(()=>{H.current=null,D(N)})):D(N),F.current=N,U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{U.current=null,F.current="",D("")},au)},J=()=>{H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null),U.current!==null&&(window.clearTimeout(U.current),U.current=null),F.current="",D("")},Z=N=>{q(N),J()},me=N=>{E(N),J()},oe=d.useRef(null),ee=lc(),te=u.data??[],v=Ps(e),y=di(k,i&&l),O=an(k),L=d.useMemo(()=>y.answer?li(te,y.answer.projects):null,[te,y.answer]),B=O!=="",K=d.useMemo(()=>B?L??ci(te,O):te,[te,O,B,L]),X=L===null?"client":"backend",$=d.useMemo(()=>hi(K,C,v),[K,C,v]),je=l&&B&&y.pending,ie=B||!mt(C),z=d.useMemo(()=>Xs(te,b,e),[te,b,e]),se=d.useMemo(()=>Xs($,b,e),[$,b,e]),xe=No(b),fe=g==="board"?se.length:$.length,Ie=!ie||!u.isSuccess?null:g==="board"?n("ui.projects.projects_page.length_of_length_2_in_window",{length:V(se.length,{useGrouping:!1}),length_2:V(z.length,{useGrouping:!1})}):n("ui.projects.projects_page.length_of_length_2_projects",{length:V($.length,{useGrouping:!1}),length_2:te.length}),re=u.isSuccess&&te.length>0,De=re&&ie&&fe===0&&!je,Ye=je&&fe===0&&re,[Wt,it]=d.useState(!1);d.useEffect(()=>{if(!Wt)return;const N=document.querySelector('[data-tour-tag="projects-board-window"]');N&&(N.focus(),it(!1))}),d.useEffect(()=>{if(!i||s)return;const N=W=>{const Q=W.target;if(!Q||Q.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(Q.tagName)||Q.closest('[role="dialog"]'))return;const Ce=W.key==="/"&&!W.metaKey&&!W.ctrlKey&&!W.altKey,le=(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="f";!Ce&&!le||(W.preventDefault(),oe.current?.focus())};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[i,s]);const ct=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const N=ct.current;N!==null&&(N.scrollTop=0)},[s]);const St=ro(g==="timeline"?te.map(N=>N.id):[],i),P=new Map(te.map((N,W)=>[N.id,St[W]])),ce=$.map(N=>({project:N,milestones:P.get(N.id)?.data?.project.milestones??[]})),lt=g==="timeline"?$.filter(N=>P.get(N.id)?.isLoading).length:0,Ne=g==="timeline"?$.filter(N=>P.get(N.id)?.isError).length:0,Ct=()=>{for(const N of St)N.isError&&N.refetch()},Ke=N=>{h(N),ki(N),Y(Ni(N))},On=(N,W)=>{E(Q=>cn(Q,N,W)),J()},Et=()=>{const N=k.trim()!=="",W=!mt(C),Q=M!==null;q(""),E(sr),M!==null&&Ke(null),Y(Si({search:N,filters:W,sort:Q}))},Fs=()=>{x("all"),Js("all"),it(!0)},[Se,qs]=d.useState(null),Vt=d.useRef(!1),Bs=()=>{Vt.current=!1,qs(null)},[Mn,Us]=d.useState([]),In=ye(a.data,"projects_force_done"),Ln=(N,W)=>{const Q=N.id,Ce=ae(W).label;Us(le=>le.includes(Q)?le:[...le,Q]),Wi({move:()=>m.mutateAsync({key:Q,fields:{status:W}}),forceDoneOffered:In,claimQuestion:()=>Vt.current?!1:(Vt.current=!0,!0)}).then(le=>{if(le.kind==="accepted"){ve(n("ui.projects.projects_page.moved_to_label",{label:String(Ce)})),u.refetch().then(()=>ee(Q));return}if(le.kind==="question"){qs({project:N,status:W,refusal:le.refusal});return}de(le.copy,le.refusal?{action:{get label(){return n("ui.projects.projects_page.view_project")},onClick:()=>void r(`/projects/${Q}`)}}:void 0),ee(Q)}).finally(()=>{Us(le=>le.filter(Fn=>Fn!==Q))})};return i?s?t.jsx("div",{ref:ct,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(Fl,{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(Hs,{title:n("ui.projects.projects_page.projects"),icon:Vs,subtitle:n("ui.projects.projects_page.workstreams_you_and_your_agents_track_across_sessions"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"secondary",size:"icon","aria-label":n("ui.projects.projects_page.refresh_projects"),title:n("ui.projects.projects_page.refresh_projects"),disabled:u.isFetching,onClick:()=>void u.refetch(),"data-tour-tag":"refresh-projects-button",children:t.jsx($a,{})}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(pt,{}),n("ui.projects.projects_page.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(ru,{value:g,onChange:N=>{S(N),su(N)}}),t.jsx(Ql,{projects:K,query:k,onQueryChange:Z,filters:C,onFiltersChange:me,onClearAll:Et,todayMs:v,resultText:Ie,countRevealClass:g==="board"?"@[47rem]:inline":void 0,disabled:u.isError,searchFieldRef:oe,trailing:g==="board"&&!(u.isSuccess&&u.data.length===0)?t.jsx(Vi,{value:b,onChange:N=>{x(N),Js(N)}}):null})]}),t.jsx(Zl,{filters:C,sort:M,onFiltersChange:me,onSortChange:Ke,onClearAll:Et,hideClearAll:De,searchFieldRef:oe}),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:[u.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:n("ui.projects.projects_page.loading_projects")}),nu.map(N=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(He,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(He,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(He,{className:"h-4 w-40 shrink-0 bg-elevated"})]},N))]}),u.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(ts,{variant:"danger",children:u.error instanceof Error&&u.error.message?u.error.message:n("ui.projects.projects_page.the_projects_could_not_be_read")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>void u.refetch(),children:n("ui.projects.projects_page.try_again")})]}),u.isSuccess&&u.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:n("ui.projects.projects_page.no_projects_yet")}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:n("ui.projects.projects_page.create_one_here_or_ask_an_agent_to_create_one_and_link_this_sessi")}),t.jsxs(G,{variant:"primary",onClick:()=>f(!0),"data-tour-tag":"create-project-empty-button",children:[t.jsx(pt,{}),n("ui.projects.projects_page.new_project")]})]}),Ye&&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:n("ui.projects.projects_page.searching")})}),re&&De&&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:k.trim()?n("ui.projects.projects_page.no_projects_match_trim",{trim:String(k.trim())}):n("ui.projects.projects_page.no_projects_match")}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:k.trim()?Jo[X]:n("ui.projects.projects_page.try_removing_a_filter_clearing_the_filters_restores_the_list")}),t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(G,{variant:"secondary",onClick:()=>{Et(),oe.current?.focus()},children:n("ui.projects.projects_page.clear_all")}),g==="board"&&$.length>0&&t.jsx(G,{variant:"secondary",onClick:Fs,children:n("ui.projects.projects_page.show_all_time")})]})]}),re&&!De&&!Ye&&g==="list"&&t.jsx(Hl,{projects:$,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),sort:M,onSortChange:Ke,searchPopulation:K,filters:C,query:k,todayMs:v,onToggleFilter:On,onClearFilters:Et,teamLabelFor:c}),re&&!De&&g==="board"&&se.length>0&&t.jsx(dc,{projects:se,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),onEdit:N=>void r(`/projects/${N.id}`),onDelete:T,onMove:Ln,teamLabelFor:c,movingKeys:Mn}),re&&!De&&!Ye&&g==="board"&&se.length===0&&xe!==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:xe}),t.jsx("p",{className:"max-w-140 text-center text-body-sm text-ink-muted",children:n("ui.projects.projects_page.older_projects_are_hidden_by_the_window")}),t.jsx(G,{variant:"secondary",onClick:Fs,children:n("ui.projects.projects_page.show_all_time")})]}),re&&!De&&!Ye&&g==="timeline"&&t.jsx(Vl,{items:ce,nowMs:e,onOpen:N=>void r(`/projects/${N.project.id}`),pendingDetails:lt,failedDetails:Ne,onRetryDetails:Ct,teamLabelFor:c})]}),t.jsx(vn,{open:w!==null,projectName:w?.name??"",onClose:()=>T(null),onConfirm:async N=>{w&&(await _.mutateAsync({key:w.id,confirmedName:N}),ve(n("ui.projects.projects_page.project_deleted")),T(null))}}),t.jsx(kn,{open:Se!==null,refusal:Se?.refusal??null,projectLabel:Se?ne(Se.project):"",onClose:()=>{Se&&ee(Se.project.id),Bs()},onConfirm:async()=>{if(!Se)return;const{project:N,status:W,refusal:Q}=Se,Ce=await m.mutateAsync({key:N.id,fields:{status:W},forceDone:!0});ve(nn(Ce,Q.count,ae(W).label)),u.refetch().then(()=>ee(N.id))},secondaryLabel:n("ui.projects.projects_page.open_project"),onSecondary:()=>{const N=Se?.project.id;Bs(),N&&r(`/projects/${N}`)}}),t.jsx(Bl,{open:j,onClose:()=>f(!1),onSubmit:async N=>{const W=await p.mutateAsync(N.fields),Q=N.followUp?.title??N.fields.name;if(N.followUp)try{await m.mutateAsync({key:W.id,fields:N.followUp})}catch(Ce){const le=Ce instanceof Error&&Ce.message?Ce.message:"";de(n("ui.projects.projects_page.project_label_was_created_but_the_extra_fields_were_not_saved_val",{label:String(Q),value2:String(yt(le)||n("ui.projects.projects_page.the_server_refused_them"))}));return}ve(n("ui.projects.projects_page.project_label_created",{label:String(Q)}))}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Hs,{title:n("ui.projects.projects_page.projects"),icon:Vs}),a.isLoading?t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(Te,{label:n("ui.projects.projects_page.checking_the_server_s_projects_support")})}):t.jsx(ts,{variant:"warning",children:Sr[o]??Sr.unknown})]})};export{_u as ProjectsPage};
@@ -0,0 +1 @@
1
+ import{V as y,W as w,X as f,Y as T,Z as v,_ as $,$ as A}from"./conversation-input-sync-bgD4kyw3.js";import{p as d,P as R,a as L,b as I,c as N,d as P}from"./ui-preferences-store-C91RrpgH.js";import{l as S,a as E}from"./index-jVCAPb0a.js";const p={malware_or_exploitation:"Instructions to build or spread malware, or to attack systems you do not own, cannot be published.",credential_theft:"Instructions to obtain someone else's credentials or tokens cannot be published.",fraud_or_deception:"Instructions to deceive or defraud people cannot be published.",harassment_or_hate:"Instructions to harass, threaten or target people cannot be published.",sexual_content_minors:"This agent cannot be published. If you believe this is a mistake, contact support.",sexual_content:"Explicit sexual content cannot be published.",violence_or_weapons:"Instructions to build weapons or to injure people cannot be published.",drugs_or_controlled_substances:"Instructions to make or traffic illegal drugs cannot be published.",self_harm:"This agent cannot be published. If you believe this is a mistake, contact support.",mass_surveillance_or_privacy_abuse:"Instructions to surveil or profile people without their consent cannot be published.",evasion_or_abuse_tooling:"Instructions to evade or defeat safety and anti-abuse systems cannot be published.",prompt_injection:"This instruction set tries to instruct the reviewer rather than describe an agent, so it cannot be published.",unclear_dual_use:"We could not tell whether this is aimed at your own systems or someone else's. Add a sentence stating the scope and target, then publish again.",other_harmful:"This agent was rejected because its instructions would cause harm."},O=e=>{const n=e.trim();return n.length>12&&/\s/.test(n)&&!/^(not found|bad request|unauthorized|error|internal server error)\.?$/i.test(n)};function z(e){const n=e?.categories?.[0];return n&&v(n)?p[n]:p.other_harmful}function k(e,n){const t=n?.rule?` ${n.rule}`:"";switch(n?.field){case"name":return{body:`Name${t||" is not acceptable"}.`,field:"name"};case"instructions":return{body:t?`The instruction body${t}.`:`The instruction body must be between 1 and ${R} characters.`,field:"instructions"};case"description":return{body:`Description${t}.`,field:"description"};case"tools":return{body:`Tools${t}.`,field:"tools"};case"when_to_use":return{body:`When to use${t}.`,field:"when_to_use"};case"categories":return{body:`Categories${t}.`,field:"categories"};case"tags":return{body:`Tags${t}.`,field:"tags"};default:return{body:e,field:null}}}function H(e,n){const t=n.surface==="pull",a=t?"Nothing was pulled.":"Nothing was published.",o=t?"pull again":"publish again",s=n.name.trim()||(t?"this team":"this agent");switch(e.code){case"name_taken":return e.details?.owned_by_caller===!0?{variant:"danger",headline:"You already published this agent",body:`You published "${s}" already. Update that listing instead of publishing a second one.`,note:null,actions:e.details?.existing_agent_id||n.hubAgentId?["update-listing","focus-name"]:["focus-name"]}:{variant:"danger",headline:"That name is taken",body:`"${s}" is already published on the hub by another account. Agent names are unique across the hub.`,note:null,actions:["focus-name"]};case"name_claim_in_flight":return{variant:"warning",headline:"That name is being published right now",body:`Someone is publishing an agent called "${s}" at this moment. It is not claimed — try again in a moment.`,note:null,actions:["retry"]};case"name_reserved_builtin":{const i=e.details?.builtin_name,u=i?d(i)===d(s):!1;return{variant:"danger",headline:"That name is reserved",body:i&&!u?`"${s}" is reserved by the built-in agent "${i}". Built-in names cannot be published to the hub.`:`"${i??s}" is the name of a built-in agent. Built-in names cannot be published to the hub.`,note:null,actions:["focus-name","install-builtin"]}}case"moderation_rejected":return{variant:"danger",headline:"This agent was not accepted",body:e.details?.reason?.trim()||e.message,note:z(e.details),actions:["edit-instructions"]};case"moderation_unavailable":return{variant:"warning",headline:"Review is temporarily unavailable",body:"We could not review this agent just now. Nothing was published. Try again in a minute.",note:null,actions:["retry"]};case"invalid_instruction_set":{const{body:i,field:u}=k(e.message,e.details);return{variant:"danger",headline:"The agent document is not valid",body:i,note:null,actions:u==="name"?["focus-name"]:u==="instructions"?["edit-instructions"]:["edit-agent"]}}case"payload_too_large":{const i=e.details?.limit_bytes;return{variant:"danger",headline:"This agent is too large to publish",body:i?`The instruction set is larger than ${Math.round(i/1024)} KiB. Shorten the instructions.`:"The instruction set is larger than the hub accepts. Shorten the instructions.",note:null,actions:["edit-instructions"]}}case"not_owner":return{variant:"danger",headline:"You cannot update this listing",body:"This listing belongs to another account.",note:null,actions:["publish-as-new"]};case"agent_not_found":return{variant:"danger",headline:"That listing no longer exists",body:"It may have been delisted.",note:null,actions:["publish-as-new","refresh-hub"]};case"hub_unauthorized":return{variant:"danger",headline:"The hub refused this machine's sign-in",body:`${a} Sign in to Radient again to replace the credential the hub refused, then ${o}.`,note:null,actions:["sign-in"]};case"hub_unavailable":return{variant:"warning",headline:t?"The pull did not go through":"The publication did not go through",body:O(e.message)?e.message:`${a} Try again in a moment, or update the backend if the hub has moved.`,note:null,actions:["retry"]};case"local_failure":return{variant:"warning",headline:t?"The team could not be pulled from this machine":"The agent could not be published from this machine",body:e.message,note:null,actions:["retry"]};case"team_plan_required":return{variant:"warning",headline:"That organization needs an active Team plan",body:t?"Reading an organization's teams is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then pull again.":"Sharing agents inside an organization is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then publish again.",note:null,actions:["retry"]};case"not_a_member":return{variant:"danger",headline:"You are not a member of that organization",body:`${a} Ask an owner of the organization to invite you, then ${o}.`,note:null,actions:[]};case"insufficient_role":{const i=e.details?.required;return{variant:"danger",headline:"Your organization role does not allow this",body:i?`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} the ${i} role. Ask an owner of the organization to change your role, then ${o}.`:`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} a higher role than yours. Ask an owner of the organization to change your role, then ${o}.`,note:null,actions:[]}}case"team_not_found":return{variant:"danger",headline:"That team is no longer published",body:"It may have been delisted since this page was loaded.",note:null,actions:["refresh-hub"]};default:return{variant:"danger",headline:"The agent could not be published",body:e.message,note:null,actions:["retry"]}}}const C=[/^(?:Download agent from Radient failed: )?(?:Error downloading agent from Radient: )?\s*/,/^Failed to download agent(?: [^\s]+)? from Radient Agent Hub(?: due to a requests error)?:\s*/,/^[A-Za-z_][\w.]*\([^)]*\):\s*/],U=/^(\d{3})\b/,B=new Set([404,410]),q=["read timed out","connection timed out","connection refused","connection aborted","connection reset","connectionerror","connecttimeout","remote end closed connection","max retries exceeded","temporary failure in name resolution","name or service not known","no route to host"],x=e=>{const n=e.toLowerCase();return q.some(t=>n.includes(t))||T(e)},D=(e,n)=>{const t=n.trim()?`"${n.trim()}"`:"That agent";if(w(e))switch(e.code){case"agent_not_found":return`${t} is no longer on the hub, so nothing was downloaded.`;case"hub_unavailable":return`The hub did not complete the download, so ${t} was not downloaded.`;default:return`${t} was not downloaded: ${e.message}`}const a=C.reduce((s,i)=>s.replace(i,""),f(e,"").trim()).trim();if(!a)return`${t} could not be downloaded.`;const o=Number(U.exec(a)?.[1]??Number.NaN);return B.has(o)?`${t} is no longer on the hub, so nothing was downloaded.`:x(a)||o===408?`The hub could not be reached, so ${t} was not downloaded.`:o===429?`The hub is busy, so ${t} was not downloaded. Try again in a moment.`:o===401||o===403?`The hub refused this machine's sign-in, so ${t} was not downloaded.`:o>=500?`The hub could not complete the download, so ${t} was not downloaded. Try again in a moment.`:o>=400?`The hub refused the download, so ${t} is not here.`:`${t} was not downloaded: ${a}`},F="The action did not complete.",G=(e,n,t)=>e==="download"?D(n,t):y(F,n),X={"focus-name":"Choose another name","update-listing":"Update the existing listing","install-builtin":"Install the built-in instead",retry:"Try again","edit-instructions":"Edit the instructions","edit-agent":"Edit the agent","publish-as-new":"Publish as a new listing","sign-in":"Sign in again","refresh-hub":"Refresh the hub"},j="download_count",g={all:["public-agents"],list:e=>[...g.all,"list",{page:e.page,perPage:e.perPage,categories:e.categories?.join(",")??void 0,name:e.name??void 0,description:e.description??void 0,sort:e.sort,order:e.order}]},h={all:["org-agents"],list:(e,n)=>[...h.all,"list",e,{page:n.page,perPage:n.perPage,categories:n.categories?.join(",")??void 0,name:n.name??void 0,description:n.description??void 0,sort:n.sort,order:n.order}]},K=e=>e&&e[0]===h.all[0]?String(e[2]??""):null,Z=e=>e.invalidateQueries({queryKey:g.all}),V=(e,n)=>e.invalidateQueries({queryKey:n?[...h.all,"list",n]:h.all}),J=({page:e=1,perPage:n=20,enabled:t=!0,categories:a,name:o,description:s,sort:i=j,order:u="desc",tenantId:c}={})=>{const b={page:e,perPage:n,categories:a,name:o,description:s,sort:i,order:u},_=c?h.list(c,b):g.list(b),l=$({queryKey:_,queryFn:async()=>{const r={};return a&&a.length>0&&(r.categories=a.join(",")),o&&(r.name=o),s&&(r.description=s),r.sort=i,r.order=u,c?await S(c,e,n,r):await E(e,n,r)},select:r=>r.result,enabled:t,retry:A,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1,placeholderData:(r,m)=>K(m?.queryKey)===(c??null)?r:void 0});return{...l,agents:l.data?.records,isRefreshing:l.isFetching&&l.data!==void 0,pagination:l.data?{page:l.data.page,perPage:l.data.per_page,totalPages:l.data.total_pages,totalRecords:l.data.total_records}:void 0}},M={name:"Name",description:"Description",instructions:"The instruction body",tools:"Tools"};function ee(e){const n=[],t=(a,o)=>{o&&n.push({field:a,message:`${M[a]} ${o}.`})};return t("name",L(e.name)),t("description",I(e.description)),e.instructions!==null&&t("instructions",N(e.instructions)),t("tools",P(e.tools??[])),n}function ne(e,n){const t=d(e);return n.some(a=>d(a)===t)}function te(e){for(const n of e??[]){const t=n.indexOf(":");if(t<0||n.slice(0,t).trim().toLowerCase()!=="tools")continue;const a=n.slice(t+1).split(",").map(o=>o.trim()).filter(Boolean);return a.length>0?a:null}return null}function ae(e,n){const t=d(e);return n.find(a=>d(a)===t)??null}export{X as P,G as a,g as b,V as c,ne as d,ee as e,Z as i,ae as l,H as p,te as t,J as u};