local-operator-ui 0.42.0 → 0.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +552 -20
- package/out/preload/index.js +1 -1
- package/out/renderer/assets/{_basePickBy-KfApUmWE.js → _basePickBy-BA9uepHv.js} +1 -1
- package/out/renderer/assets/{_baseUniq-DXd1h_x3.js → _baseUniq-CVACH15m.js} +1 -1
- package/out/renderer/assets/{agent-details-page-D-oKoyjm.js → agent-details-page-xNTNJ7kP.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-CMbCN_Bg.js → agent-hub-page-B-zE3Ln0.js} +2 -2
- package/out/renderer/assets/{agents-page-COpZu9CS.js → agents-page-BeZQ1S7f.js} +3 -3
- package/out/renderer/assets/approvalsOverlay-BBr6f98F.css +1 -0
- package/out/renderer/assets/approvalsOverlay-BmSmF8Ga.js +1 -0
- package/out/renderer/assets/{arc-Dim07OWx.js → arc-DYIy54Kn.js} +1 -1
- package/out/renderer/assets/architectureDiagram-IEHRJDOE-CmfaKw-J.js +36 -0
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-BcLFfkMT.js → blockDiagram-JOT3LUYC-bQf90tJr.js} +2 -2
- package/out/renderer/assets/{book-open-C2DZijqP.js → book-open-iGajLTwQ.js} +1 -1
- package/out/renderer/assets/browser-page-B63Z8oE2.js +1 -0
- package/out/renderer/assets/browser-webauthn-prompt-DX5l4JNA.js +1 -0
- package/out/renderer/assets/{building-2-DfFTqKaJ.js → building-2-bjja6JTC.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-Dm38eTOl.js → c4Diagram-VJAJSXHY-BxIFIYVW.js} +2 -2
- package/out/renderer/assets/channel-Blax8LQd.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-94enK1_-.js → chunk-4BMEZGHF-C2LQ_mlD.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-YiigwCRa.js → chunk-A2AXSNBT-BKH53MbC.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-Bo9PQDfg.js → chunk-AEK57VVT-CuB5dlAL.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-vwOZoeTn.js → chunk-D6G4REZN-CECeg3Wn.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-BY9NQkOq.js → chunk-RZ5BOZE2-D-zkJWYc.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-D31wKKrQ.js → chunk-XZIHB7SX-DstteBuH.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DA1IQG_V.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DA1IQG_V.js +1 -0
- package/out/renderer/assets/clone-mVVuLCMS.js +1 -0
- package/out/renderer/assets/{console-mirror-ClsQ7RUr.js → console-mirror-gqAdwBWl.js} +13 -13
- package/out/renderer/assets/consoleCapture-BQQVRcXT.js +1 -0
- package/out/renderer/assets/{conversation-input-sync-CxT2etWK.js → conversation-input-sync-grry80zS.js} +234 -234
- package/out/renderer/assets/dagre-OKDRZEBW-D6RBxeJd.js +4 -0
- package/out/renderer/assets/diagram-SSKATNLV--xUREIPn.js +43 -0
- package/out/renderer/assets/diagram-VNBRO52H-BYjZ86BM.js +24 -0
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-B17XYgVW.js → erDiagram-Q7BY3M3F-CmajcoOO.js} +2 -2
- package/out/renderer/assets/error-boundary-DfTTKe65.js +126 -0
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-BuuUG-g9.js → flowDiagram-4HSFHLVR-CtQab7ap.js} +2 -2
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-D8R9R-AO.js → ganttDiagram-APWFNJXF-CuKez3d0.js} +2 -2
- package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-D9QOaWwN.js +65 -0
- package/out/renderer/assets/{graph-nV36Izm2.js → graph-Ccifoj7G.js} +1 -1
- package/out/renderer/assets/{hash-0qLX32ng.js → hash-EZ0d40pW.js} +1 -1
- package/out/renderer/assets/{heart-DFAcW-lm.js → heart-Bo3ZudoI.js} +1 -1
- package/out/renderer/assets/index-ByZv232u.css +1 -0
- package/out/renderer/assets/index-CLJ4-1jd.js +1 -0
- package/out/renderer/assets/index-DXk6NfLu.js +55 -0
- package/out/renderer/assets/index-Dw4hyitu.js +7 -0
- package/out/renderer/assets/index-LBzSehKd.js +830 -0
- package/out/renderer/assets/infoDiagram-PH2N3AL5-DrTRSok5.js +2 -0
- package/out/renderer/assets/installer-B7DhTrnG.js +1 -0
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BwwXu0up.js → journeyDiagram-U35MCT3I-YTjOSo-b.js} +2 -2
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CDbDK3QO.js → kanban-definition-NDS4AKOZ-C1UmNEaT.js} +4 -4
- package/out/renderer/assets/{layout-B7RIhnQw.js → layout-CWPZ7noV.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-DFGXD5LW.js → legacy-agents-page-ikCownYN.js} +2 -2
- package/out/renderer/assets/library-page-DBSSkZvn.js +157 -0
- package/out/renderer/assets/{mermaid.core-DcMJPeY9.js → mermaid.core-B_nZt27J.js} +5 -5
- package/out/renderer/assets/mesh-page-CgjL4HIw.js +1 -0
- package/out/renderer/assets/messages-Bswe4yCX.js +3 -0
- package/out/renderer/assets/mindmap-definition-ALO5MXBD-D-Y3n0RT.js +95 -0
- package/out/renderer/assets/mini-BdCfujvn.js +1 -0
- package/out/renderer/assets/{notebook-pen-ClukfLau.js → notebook-pen-BvZPJ7Yv.js} +1 -1
- package/out/renderer/assets/org-access-C1u_2VVY.js +1 -0
- package/out/renderer/assets/{org-surface-gate-B66nUFl-.js → org-surface-gate-CyIC6H59.js} +1 -1
- package/out/renderer/assets/{page-header-C8bsR5wI.js → page-header-C9IFgiIB.js} +1 -1
- package/out/renderer/assets/{path-utils-DbnynqGJ.js → path-utils-DC6z9Ymz.js} +17 -17
- package/out/renderer/assets/pieDiagram-IB7DONF6-BJ2PZoWa.js +30 -0
- package/out/renderer/assets/{projects-page-4Cv9HMNh.js → projects-page-CwwrR-j7.js} +2 -2
- package/out/renderer/assets/{publication-validation-BlKeNjlY.js → publication-validation-DAffiuLy.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DFsFogdr.js → quadrantDiagram-7GDLP6J5-Dpr0N86G.js} +2 -2
- package/out/renderer/assets/{radar-MK3ICKWK-YGPF88zl.js → radar-MK3ICKWK-CwLLK6fK.js} +1 -1
- package/out/renderer/assets/radient-auth-buttons-DN7K_uGZ.js +1 -0
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-x2D5VXdu.js → requirementDiagram-KVF5MWMF-LI2fP6nJ.js} +2 -2
- package/out/renderer/assets/sankeyDiagram-QLVOVGJD-uUOWgFO1.js +10 -0
- package/out/renderer/assets/{schedules-page-CLrwsPcv.js → schedules-page-Cf1PQGDR.js} +2 -2
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BUX2Yk2J.js → sequenceDiagram-X6HHIX6F-DperbqVG.js} +2 -2
- package/out/renderer/assets/{settings-page-BAVKJQXi.js → settings-page-CrnST8YF.js} +3 -3
- package/out/renderer/assets/smartart-qEAWtDlk.js +1 -0
- package/out/renderer/assets/stateDiagram-DGXRK772-RvRbNkSX.js +1 -0
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-fK1yLl-v.js +1 -0
- package/out/renderer/assets/{team-bridge-page-DU_d4Yfc.js → team-bridge-page-BgcLwc5M.js} +2 -2
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-Doja7siy.js → timeline-definition-BDJGKUSR-CeQ3AsWj.js} +2 -2
- package/out/renderer/assets/{use-download-agent-mutation-CH4V_o78.js → use-download-agent-mutation-C_zDZ6-1.js} +2 -2
- package/out/renderer/assets/{use-session-snapshot-7A4rQnOH.js → use-session-snapshot-BMDB4uZ0.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-D2e6wZz8.js → xychartDiagram-VJFVF3MP-C6-d6maF.js} +5 -5
- package/out/renderer/browser-approvals-overlay.html +40 -0
- package/out/renderer/console-capture.html +6 -5
- package/out/renderer/index.html +8 -7
- package/out/renderer/installer.html +5 -4
- package/out/renderer/mini.html +8 -7
- package/package.json +6 -4
- package/out/renderer/assets/architectureDiagram-IEHRJDOE-BdwEpGi5.js +0 -36
- package/out/renderer/assets/browser-page-DzwNid1n.js +0 -1
- package/out/renderer/assets/browser-webauthn-prompt-C4aaSeT0.js +0 -1
- package/out/renderer/assets/channel-CefUnWw7.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BKByQj4B.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BKByQj4B.js +0 -1
- package/out/renderer/assets/clone-DpeVXG90.js +0 -1
- package/out/renderer/assets/consoleCapture-DHR2J1Z2.js +0 -1
- package/out/renderer/assets/dagre-OKDRZEBW-DV8UoEV8.js +0 -4
- package/out/renderer/assets/diagram-SSKATNLV-KF8nQEWd.js +0 -43
- package/out/renderer/assets/diagram-VNBRO52H-P7VEv-Kl.js +0 -24
- package/out/renderer/assets/error-boundary-DBgLhXDJ.js +0 -126
- package/out/renderer/assets/gitGraphDiagram-7IBYFJ6S-fr4ArrNz.js +0 -65
- package/out/renderer/assets/index-BKg4FYjW.js +0 -7
- package/out/renderer/assets/index-BlshO0D3.css +0 -1
- package/out/renderer/assets/index-BmixXvR4.js +0 -1
- package/out/renderer/assets/index-D6Di-Q2H.js +0 -57
- package/out/renderer/assets/index-DQKtrmMo.js +0 -830
- package/out/renderer/assets/infoDiagram-PH2N3AL5-DmrijSS0.js +0 -2
- package/out/renderer/assets/installer-4TSvERLS.js +0 -1
- package/out/renderer/assets/library-page-DPid0cmw.js +0 -157
- package/out/renderer/assets/mesh-page-CIV9irJF.js +0 -1
- package/out/renderer/assets/mindmap-definition-ALO5MXBD-aLvI45Tt.js +0 -95
- package/out/renderer/assets/mini-leTyoKhc.js +0 -1
- package/out/renderer/assets/org-access-BmjQJdOO.js +0 -1
- package/out/renderer/assets/pieDiagram-IB7DONF6-DvzUPikw.js +0 -30
- package/out/renderer/assets/radient-auth-buttons-syGP58Ed.js +0 -1
- package/out/renderer/assets/sankeyDiagram-QLVOVGJD-DA4pKMXD.js +0 -10
- package/out/renderer/assets/smartart-ipuU9VIr.js +0 -1
- package/out/renderer/assets/stateDiagram-DGXRK772-BsVvaiaW.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BvVuptXT.js +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{p as B}from"./chunk-4BMEZGHF-C2LQ_mlD.js";import{_ as p,g as U,s as j,a as q,b as H,t as K,q as Q,l as F,c as Z,F as J,K as X,Q as Y,e as tt,z as et,H as at}from"./mermaid.core-B_nZt27J.js";import{p as rt}from"./radar-MK3ICKWK-CwLLK6fK.js";import{d as P}from"./arc-DYIy54Kn.js";import{a as y,t as z,U as nt,V as it}from"./conversation-input-sync-grry80zS.js";import"./index-DXk6NfLu.js";import"./_baseUniq-CVACH15m.js";import"./_basePickBy-BA9uepHv.js";import"./clone-mVVuLCMS.js";import"./path-utils-DC6z9Ymz.js";import"./messages-Bswe4yCX.js";import"./error-boundary-DfTTKe65.js";function st(t,a){return a<t?-1:a>t?1:a>=t?0:NaN}function ot(t){return t}function lt(){var t=ot,a=st,m=null,s=y(0),u=y(z),x=y(0);function i(e){var r,l=(e=nt(e)).length,d,A,h=0,c=new Array(l),n=new Array(l),v=+s.apply(this,arguments),w=Math.min(z,Math.max(-z,u.apply(this,arguments)-v)),f,T=Math.min(Math.abs(w)/l,x.apply(this,arguments)),$=T*(w<0?-1:1),g;for(r=0;r<l;++r)(g=n[c[r]=r]=+t(e[r],r,e))>0&&(h+=g);for(a!=null?c.sort(function(S,C){return a(n[S],n[C])}):m!=null&&c.sort(function(S,C){return m(e[S],e[C])}),r=0,A=h?(w-l*$)/h:0;r<l;++r,v=f)d=c[r],g=n[d],f=v+(g>0?g*A:0)+$,n[d]={data:e[d],index:r,value:g,startAngle:v,endAngle:f,padAngle:T};return n}return i.value=function(e){return arguments.length?(t=typeof e=="function"?e:y(+e),i):t},i.sortValues=function(e){return arguments.length?(a=e,m=null,i):a},i.sort=function(e){return arguments.length?(m=e,a=null,i):m},i.startAngle=function(e){return arguments.length?(s=typeof e=="function"?e:y(+e),i):s},i.endAngle=function(e){return arguments.length?(u=typeof e=="function"?e:y(+e),i):u},i.padAngle=function(e){return arguments.length?(x=typeof e=="function"?e:y(+e),i):x},i}var ct=at.pie,G={sections:new Map,showData:!1},b=G.sections,W=G.showData,pt=structuredClone(ct),ut=p(()=>structuredClone(pt),"getConfig"),dt=p(()=>{b=new Map,W=G.showData,et()},"clear"),gt=p(({label:t,value:a})=>{b.has(t)||(b.set(t,a),F.debug(`added new section: ${t}, with value: ${a}`))},"addSection"),ft=p(()=>b,"getSections"),mt=p(t=>{W=t},"setShowData"),ht=p(()=>W,"getShowData"),R={getConfig:ut,clear:dt,setDiagramTitle:Q,getDiagramTitle:K,setAccTitle:H,getAccTitle:q,setAccDescription:j,getAccDescription:U,addSection:gt,getSections:ft,setShowData:mt,getShowData:ht},vt=p((t,a)=>{B(t,a),a.setShowData(t.showData),t.sections.map(a.addSection)},"populateDb"),St={parse:p(async t=>{const a=await rt("pie",t);F.debug(a),vt(a,R)},"parse")},yt=p(t=>`
|
|
2
|
+
.pieCircle{
|
|
3
|
+
stroke: ${t.pieStrokeColor};
|
|
4
|
+
stroke-width : ${t.pieStrokeWidth};
|
|
5
|
+
opacity : ${t.pieOpacity};
|
|
6
|
+
}
|
|
7
|
+
.pieOuterCircle{
|
|
8
|
+
stroke: ${t.pieOuterStrokeColor};
|
|
9
|
+
stroke-width: ${t.pieOuterStrokeWidth};
|
|
10
|
+
fill: none;
|
|
11
|
+
}
|
|
12
|
+
.pieTitleText {
|
|
13
|
+
text-anchor: middle;
|
|
14
|
+
font-size: ${t.pieTitleTextSize};
|
|
15
|
+
fill: ${t.pieTitleTextColor};
|
|
16
|
+
font-family: ${t.fontFamily};
|
|
17
|
+
}
|
|
18
|
+
.slice {
|
|
19
|
+
font-family: ${t.fontFamily};
|
|
20
|
+
fill: ${t.pieSectionTextColor};
|
|
21
|
+
font-size:${t.pieSectionTextSize};
|
|
22
|
+
// fill: white;
|
|
23
|
+
}
|
|
24
|
+
.legend text {
|
|
25
|
+
fill: ${t.pieLegendTextColor};
|
|
26
|
+
font-family: ${t.fontFamily};
|
|
27
|
+
font-size: ${t.pieLegendTextSize};
|
|
28
|
+
}
|
|
29
|
+
`,"getStyles"),xt=yt,At=p(t=>{const a=[...t.entries()].map(s=>({label:s[0],value:s[1]})).sort((s,u)=>u.value-s.value);return lt().value(s=>s.value)(a)},"createPieArcs"),wt=p((t,a,m,s)=>{F.debug(`rendering pie chart
|
|
30
|
+
`+t);const u=s.db,x=Z(),i=J(u.getConfig(),x.pie),e=40,r=18,l=4,d=450,A=d,h=X(a),c=h.append("g");c.attr("transform","translate("+A/2+","+d/2+")");const{themeVariables:n}=x;let[v]=Y(n.pieOuterStrokeWidth);v??=2;const w=i.textPosition,f=Math.min(A,d)/2-e,T=P().innerRadius(0).outerRadius(f),$=P().innerRadius(f*w).outerRadius(f*w);c.append("circle").attr("cx",0).attr("cy",0).attr("r",f+v/2).attr("class","pieOuterCircle");const g=u.getSections(),S=At(g),C=[n.pie1,n.pie2,n.pie3,n.pie4,n.pie5,n.pie6,n.pie7,n.pie8,n.pie9,n.pie10,n.pie11,n.pie12],D=it(C);c.selectAll("mySlices").data(S).enter().append("path").attr("d",T).attr("fill",o=>D(o.data.label)).attr("class","pieCircle");let N=0;g.forEach(o=>{N+=o}),c.selectAll("mySlices").data(S).enter().append("text").text(o=>(o.data.value/N*100).toFixed(0)+"%").attr("transform",o=>"translate("+$.centroid(o)+")").style("text-anchor","middle").attr("class","slice"),c.append("text").text(u.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText");const M=c.selectAll(".legend").data(D.domain()).enter().append("g").attr("class","legend").attr("transform",(o,k)=>{const E=r+l,L=E*D.domain().length/2,_=12*r,V=k*E-L;return"translate("+_+","+V+")"});M.append("rect").attr("width",r).attr("height",r).style("fill",D).style("stroke",D),M.data(S).append("text").attr("x",r+l).attr("y",r-l).text(o=>{const{label:k,value:E}=o.data;return u.getShowData()?`${k} [${E}]`:k});const I=Math.max(...M.selectAll("text").nodes().map(o=>o?.getBoundingClientRect().width??0)),O=A+e+r+l+I;h.attr("viewBox",`0 0 ${O} ${d}`),tt(h,d,O,i.useMaxWidth)},"draw"),Ct={draw:wt},Ot={parser:St,db:R,renderer:Ct,styles:xt};export{Ot as diagram};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{j as t,c as R,r as d,u as qn}from"./index-DXk6NfLu.js";import{t as n,b as $e}from"./messages-Bswe4yCX.js";import{aq as ze,bU as V,bi as Rt,bj as Bn,bV as $s,bW as zs,bX as Gs,bn as Un,ar as ve,bY as $n,aA as Cr,S as _t,av as Xe,bZ as zn,bA as Gn,bf as Yn,bg as Hn,bh as Kn,ax as Er,aw as Dt,aZ as Wn,ag as Vn,b5 as Xn,b9 as Jn,b8 as Qn,b7 as Ys,bS as Zn,bC as ea,bz as ta,bB as sa,T as le,b_ as Tr,b$ as Rr,bI as qt,c0 as Be,c1 as ra,c2 as jt,bM as na,bN as Hs,c3 as ht,c4 as Dr,bJ as aa,c5 as oa,c6 as Ar,as as ia,a7 as ca,a8 as la,a9 as ua,aa as da,ab as pa,c7 as ma,c8 as Or,bd as fa,c9 as _a,af as ja}from"./conversation-input-sync-grry80zS.js";import{h as gs,d as _e,a7 as ha,r as xs,u as ga,a9 as xa,aa as ba,ab as Je,ac as va,D as Bt,a as nt,c as ye,A as Ut,ad as ts,q as At,s as ya,o as wa,t as ka,y as Na,B as Sa,L as Ca}from"./path-utils-DC6z9Ymz.js";import{c as gt,u as I,F as Qe,l as $t,G as Ze,H as et,J as tt,K as Pe,B as G,q as bs,r as vs,S as Te,s as ys,w as be,a9 as Ea,aa as Ta,ab as Ra,$ as Da,a0 as Aa,v as Oa,z as ke,a5 as ws,af as ks,a7 as Ns,I as ue,X as zt,g as Ss,T as Pr,L as pe,N as Mr,C as Lr,D as Pa,a as Ma,d as La,A as ss,O as Ia,Y as Fa,Z as qa,_ as Ba,k as Ke}from"./error-boundary-DfTTKe65.js";import{P as Ks}from"./page-header-C9IFgiIB.js";import{cx as Ua,ce as Ir,cy as $a,cz as za,cm as Ga,b_ as Ya,aL as pt,cA as Ha,A as Ws,bj as Fr,cB as Vs,cw as Ka}from"./index-LBzSehKd.js";import{o as qr}from"./console-mirror-gqAdwBWl.js";import{u as Wa}from"./use-session-snapshot-BMDB4uZ0.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,f as $e,j as t,c as R,r as d,u as qn}from"./index-D6Di-Q2H.js";imp
|
|
|
42
42
|
`);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(Xc,`
|
|
43
43
|
`).replace(Jc,`
|
|
44
44
|
|
|
45
|
-
`).trim()}function wn(e,s,r){const a=e.clipboardData?.getData("text/html");if(!a)return;const o=Qc(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?Jo(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:[po(e)&&t.jsx(Ss,{"aria-hidden":!0}),s.label]})},Zc="project-key",el="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 Kt=({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(Kt,{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)})})},tl=({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:Ot,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=>ts(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:Zc,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:Ot,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=>ts(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:el,mono:!0})]})},sl=({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(Kt,{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(Qe,{open:r,onOpenChange:a,value:f.draft,onValueChange:b=>{a(!1),f.accept(b)},children:[t.jsx(Ze,{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(et,{})}),t.jsx(tt,{children:Yr.map(b=>t.jsx(Pe,{value:b.value,"data-project-status-option":b.value,children:b.label},b.value))})]})})},rl=({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>Je;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(Pr,{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,"/",Je]})]})]}):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})})]})})},nl=({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:Pt,placeholder:n("ui.projects.examples.owner"),autoBegin:r,onRetire:a})),al=({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:Pt,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})},ol=({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:Ki,commit:async p=>{const m=Vi(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(Kt,{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(Qe,{value:c.draft.unit,onValueChange:p=>c.setDraft({...c.draft,unit:p}),children:[t.jsx(Ze,{"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(et,{})}),t.jsxs(tt,{children:[t.jsx(Pe,{value:"points",children:n("ui.projects.project_editors.points")}),t.jsx(Pe,{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")})]})})},il=({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)=>Wi(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(Kt,{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))})]})})},cl="project-quick-send:no-target",ll=[],ul=({links:e,target:s,onTargetChange:r,onSend:a,focusTick:o})=>{I();const i=d.useRef(null),l=Wn(),{frontend:c,refresh:u}=Wa(),[p,m]=d.useState(!1),_=nt(),j=s??cl;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(Qe,{value:s??void 0,onValueChange:b=>r(b),children:[t.jsx(Ze,{"aria-label":n("ui.projects.project_quick_send.select_the_session_to_message"),className:"max-w-72",children:t.jsx(et,{placeholder:n("ui.projects.project_quick_send.no_session_selected")})}),t.jsx(tt,{children:f.map(b=>t.jsx(Pe,{value:b.session_id,children:Ht(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(Vn,{ref:i,conversationId:j,messages:ll,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})}}})]})},dl=({links:e,busy:s,onUnlink:r,onLink:a,onQuickSend:o,onStartSession:i})=>{I();const l=Ut(),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:Go(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(za,{}),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(Ga,{}),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=vo(x),T=yo(x.subagents),k=wo(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(Ya,{})}),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(ro,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(ul,{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")})]})})]})},pl=({milestones:e,summary:s,busy:r,onToggle:a,onRemove:o,onAdd:i})=>{const[l,c]=d.useState(""),[u,p]=d.useState(""),m=I(),_=!Hr.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=fo(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(Lr,{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")]})]})]})},ml=[{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})]}),fl=({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=ml.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?Xn(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(nl,{project:e,commit:r,autoBegin:l==="owner",onRetire:E=>_("owner",E)}),x&&t.jsx(al,{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(ol,{project:e,commit:r,autoBegin:l==="estimate",onRetire:E=>_("estimate",E)}),q&&t.jsx(il,{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")})]})},_l=({project:e})=>{I();const s=nt(),r=bn(),{sending:a,cooling:o,cooldownRemainingMs:i}=uc(e.id);if(!ye(s.data,"projects_request_update"))return null;const l=ne(e),c=tc(e.id);return t.jsxs(t.Fragment,{children:[t.jsx($t,{content:o&&i!==null?Lt(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(eo,{}),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:Lt(l,i)})]})},Sn="plain",Cn=e=>`team:${e}`,En=e=>`agent:${e}`;function jl(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function hl(e){return e.kind==="team"?Cn(e.name):e.kind==="agent"?En(e.name):Sn}const wr={kind:"plain"},gl=({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),_=Jn(e&&a),j=Qn(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===hl(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(jl(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})]})})},xl=({links:e})=>{I();const s=zo(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:Ht(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Zs(a.todos)})]},a.session_id))})]})},Ls=({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),le("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(Ha,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.preview")})]}),o&&t.jsxs(be,{onSelect:o,children:[t.jsx(Zn,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.show_in_canvas")})]}),t.jsxs(be,{onSelect:c,children:[t.jsx(ea,{"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(ta,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.open_folder")})]}),t.jsxs(be,{onSelect:l,children:[t.jsx(sa,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.copy_file_path")})]})]})]})},bl=/[/\\]/,vl=e=>{if(e.name)return e.name;const s=e.path.split(bl);return s[s.length-1]||e.path},yl="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(),qn(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?vl(s):"";return t.jsx(Pa,{open:e,onOpenChange:p=>!p&&r(),children:t.jsxs(Ma,{className:yl,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(La,{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 wl=/[/\\]/,Re=e=>{if(e.name)return e.name;const s=e.path.split(wl);return s[s.length-1]||n("ui.projects.project_updates.attachment")};function kl(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:oa(e.name||e.path),sizeBytes:e.bytes,...Number.isFinite(s)?{mtimeMs:s}:{}}},Ae=e=>`${e.path}:${e.added_at}`,Ue="h-[78px] w-[117px]",Is="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}),Nl=({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})},Sl=({attachment:e,onOpen:s})=>{const[r,a]=qt();return t.jsx("div",{ref:r,className:"group relative flex leading-none","data-project-asset-tile":"image",children:a?t.jsx(Nl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"image"})})},Cl=({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"})})]})})})},El=({attachment:e,onOpen:s})=>{const[r,a]=qt();return t.jsxs("div",{ref:r,className:"group relative block leading-none","data-project-asset-tile":"video",children:[a?t.jsx(Cl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"video"}),t.jsx("div",{className:Is,children:t.jsx(Ls,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Tl=({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(aa,{ownerId:`project-sound:${e.path}`,src:r.url,label:s,peaks:null,variant:"compact"})})},Rl=({attachment:e})=>{const[s,r]=qt();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(Tl,{attachment:e}):t.jsx(Nt,{kind:"audio"}),t.jsx("div",{className:Is,children:t.jsx(Ls,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Dl=e=>{const s=e.name||e.path;if(Tr(s))return!0;const r=Rr(s);return r==="text"||r==="code"},Al=({attachment:e,onPreview:s})=>{I();const r=Re(e),a=Uo(e.bytes),o=d.useRef(null),i=Dl(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(ra,{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:Is,children:t.jsx(Ls,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(r)}),onPreview:i?()=>s(o.current):void 0})})]})},Ol=({asset:e,current:s,index:r,count:a,onSelect:o,scrollIntoView:i})=>{I();const[l,c]=qt(),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(Pl,{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":""})})})})},Pl=({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"})})]})})},Ml=({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(Ol,{asset:a,current:o===s,index:o,count:e.length,onSelect:()=>r(o),scrollIntoView:s===o},Ae(a.attachment)))})),Ll=({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(Ml,{media:e,index:s,onSelect:r}):void 0;return t.jsx(na,{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(Hs(s,e.length,-1)),onNext:()=>r(Hs(s,e.length,1)),filmstrip:u}})},Rn=({attachments:e})=>{I();const s=d.useMemo(()=>e.map(j=>({attachment:j,kind:kl(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(Sl,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="video"?t.jsx(El,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="audio"?t.jsx(Rl,{attachment:j},Ae(j)):t.jsx(Al,{attachment:j,onPreview:g=>_(j,g)},Ae(j)))}),p>=0&&t.jsx(Ll,{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 Il=({update:e,nowMs:s})=>{const r=I(),a=qo(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})]})},Fl=({updates:e,nowMs:s})=>{const r=I(),a=Po(e.length),o=Bo(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(Il,{update:l,nowMs:s},`${l.at}:${l.by}:${c}`))})]},i.key||"ungrouped"))})]})},ql="project_not_found",Bl=({projectKey:e,nowMs:s})=>{I();const r=Ut(),a=nt(),o=Ar(ye(a.data,"team_catalogue")),i=Ur(e,!0),l=$r(),c=zr(),u=lo(),p=uo(),m=io(),_=co(),[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 Bt&&(i.error.code===ql||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(ss,{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=$o(x.milestones.filter(h=>h.completed_at!==null).length,x.milestones.length),E=async(h,A,D,F)=>{const Y=At.getState(),U=ya(null,h,Y.drafts);if(!U)return!1;try{const{images:H,files:X,failures:ee,overflow:fe,fileOverflow:de}=await ca(F,A,{remoteOwned:wa(Y.sessions,Y.placementFacts,h)}),te=la(ee);if(te)return le(te),!1;const Z=ua(fe);if(Z)return le(Z),!1;const v=da(de);if(v)return le(v),!1;const y=pa(A,H);if(y)return le(y),!1;if(await ka(U,{text:A,attachments:F,images:H,mode:D,cwd:Y.cwd,...X.length?{files:X}:{}},h)===null)return le(n("ui.projects.project_detail.that_session_already_has_a_message_going_out_try_again_in_a_momen")),!1;const L=w.find(B=>B.session_id===h);return ve(n("ui.projects.project_detail.sent_to_value1",{value1:String(L?Ht(L):h)})),!0}catch(H){return le(H instanceof Error&&H.message?H.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"));Na.getState().setCurrentInput(F,Yo(x));let Y=null;try{await m.mutateAsync({key:x.id,sessionId:F})}catch(U){Y=U instanceof Error&&U.message?U.message:n("ui.projects.project_detail.the_link_was_refused")}if(Y)le(n("ui.projects.project_detail.session_started_but_linking_it_failed_linkfailure",{linkFailure:String(Y)}));else{const U=D?n("ui.projects.project_detail.with_value1",{value1:String(Ho(D))}):"";ve(n("ui.projects.project_detail.session_started_withtarget_and_linked_to_displayname",{withTarget:String(U),displayName:String(T)}))}await qr(r,F)};return t.jsx(Nc,{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(tl,{project:x,commit:k}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(sl,{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(_l,{project:x}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(ia,{}),n("ui.projects.project_detail.delete")]})]})]})]}),t.jsx(rl,{project:x,commit:k}),t.jsx(fl,{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:ho(x,s)})]}),t.jsx(pl,{milestones:x.milestones,summary:C,busy:b,onToggle:(h,A)=>{u.mutateAsync({key:x.id,name:h,completed:A}).catch(D=>{le(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=>{le(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=>{le(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_added"))})}}),t.jsx(dl,{projectKey:x.id,links:w,busy:b,onStartSession:()=>S(!0),onQuickSend:E,onLink:h=>{m.mutateAsync({key:x.id,sessionId:h}).catch(A=>{le(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=>{le(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_session_was_not_unlinked"))})}}),t.jsx(xl,{links:w}),t.jsx(Fl,{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(gl,{open:g,onClose:()=>S(!1),onStart:M,teamsEnabled:ye(a.data,"team_catalogue"),profilesEnabled:ye(a.data,"profile_catalogue")})]})})},Ul="payments-migration",kr={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},$l=({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:Pc(a.title),k=h=>wn(h,x,A=>w("description",A)),q=(h,A)=>{const D={},F=ts(A);F&&(D.name=F);const Y=pn(h.description);Y&&(D.description=Y);const U=ps(h.tags).error;U&&(D.tags=U);const H=us(h.startDate);H&&(D.startDate=H);const X=us(h.targetDate);if(X)D.targetDate=X;else if(!H){const te=ds(h.startDate,h.targetDate);te&&(D.targetDate=te)}if(h.estimate.trim()){const te=mn(h.estimate);te&&(D.estimate=te)}const ee=ls(h.title);ee&&(D.title=ee);const fe=Mt(h.owner,"owner");fe&&(D.owner=fe);const de=Mt(h.team,"team");return de&&(D.team=de),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 Y=F instanceof Error&&F.message?F.message:"";u(yt(Y)||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>Je;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:Ul,"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(Pr,{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,"/",Je]})]})]}),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(Qe,{value:a.status,onValueChange:h=>w("status",h),children:[t.jsx(Ze,{"aria-label":n("ui.projects.project_form_dialog.status"),children:t.jsx(et,{})}),t.jsx(tt,{children:Yr.map(h=>t.jsx(Pe,{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(Qe,{value:a.estimateUnit,onValueChange:h=>w("estimateUnit",h),children:[t.jsx(Ze,{"aria-label":n("ui.projects.project_form_dialog.estimate_unit"),className:"max-w-32",children:t.jsx(et,{})}),t.jsxs(tt,{children:[t.jsx(Pe,{value:"points",children:n("ui.projects.project_form_dialog.points")}),t.jsx(Pe,{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})},zl=({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(Lr,{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})]})},Gl=({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)))})})]})]})},Yl=({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(zl,{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?yi(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(Gl,{column:c.key,spec:c.spec,onChange:c.onChange})]}),u.map(m=>t.jsx(Yl,{facet:m.facet,options:m.options,onToggle:o},m.facet))]})},Hl=({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":xo(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 Kl(e,s){const r=xt(e.progress_updated_at,s);return r?bt(r):n("ui.projects.project_list.not_reported")}const Wl=({direction:e})=>e==="asc"?t.jsx(Fr,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Or,{size:10,className:"shrink-0","aria-hidden":"true"}),Vl=({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?Di(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(Wl,{direction:a.direction}):t.jsx(ma,{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(Hl,{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:Kl(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,Xl={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")}},Jl=({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=Os(s),f=d.useMemo(()=>Pi(e,j),[e,j]),g=d.useMemo(()=>Mi(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?Ai(or(f.startMs,f.endMs),b):"month",w=c??x,T=C=>{const E=Oe.indexOf(w),M=Oe[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===Oe[0],onClick:()=>T(1),children:t.jsx(pt,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Xl[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===Oe[Oe.length-1],onClick:()=>T(-1),children:t.jsx(Ia,{})})]})]}),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(Ql,{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(Zl,{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(Xa,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Li(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))})]})})]})},Ql=({startMs:e,endMs:s,tier:r,pxPerDay:a,trackPx:o})=>{const i=Yi(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))})]})},Zl=({item:e,spanStart:s,pxPerDay:r,trackPx:a,today:o,onOpen:i})=>{const{project:l}=e,c=Ii(e),u=Fi(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"})]})]})},eu=({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=gi(a),b=Ir(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(fa,{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:()=>_a(_.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(ja,{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(Qa,{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]})},tu=({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(Fr,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Or,{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")})]})},On="projects-view",su=[{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 ru(){try{const e=localStorage.getItem(On);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function nu(e){try{localStorage.setItem(On,e)}catch{}}const au=({value:e,onChange:s})=>(I(),t.jsx(Fa,{value:e,onValueChange:r=>s(r),children:t.jsx(qa,{"aria-label":n("ui.projects.projects_view_switcher.project_view"),"data-tour-tag":"projects-view-switcher",children:su.map(r=>t.jsx(Ba,{value:r.value,children:r.label},r.value))})})),ou=["r1","r2","r3","r4","r5","r6"],iu=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")}},ju=({nowMs:e=Date.now()})=>{I();const{projectId:s}=Sa(),r=Ut(),a=nt(),o=Ca(a.data,"projects",1),i=o==="enabled",l=ye(a.data,"projects",ei),c=Ar(ye(a.data,"team_catalogue")),u=no(i),p=oo(),m=$r(),_=zr(),[j,f]=d.useState(!1),[g,S]=d.useState(()=>ru()),[b,x]=d.useState(()=>Eo()),[w,T]=d.useState(null),[k,q]=d.useState(""),[C,E]=d.useState(sr),[M,h]=d.useState(()=>Ni()),[A,D]=d.useState(""),F=d.useRef(""),Y=d.useRef(null),U=d.useRef(null),H=N=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),N!==""&&N===F.current?(D(""),Y.current=window.requestAnimationFrame(()=>{Y.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("")},iu)},X=()=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),U.current!==null&&(window.clearTimeout(U.current),U.current=null),F.current="",D("")},ee=N=>{q(N),X()},fe=N=>{E(N),X()},de=d.useRef(null),te=dc(),Z=u.data??[],v=Os(e),y=mi(k,i&&l),O=an(k),L=d.useMemo(()=>y.answer?di(Z,y.answer.projects):null,[Z,y.answer]),B=O!=="",K=d.useMemo(()=>B?L??ui(Z,O):Z,[Z,O,B,L]),J=L===null?"client":"backend",$=d.useMemo(()=>xi(K,C,v),[K,C,v]),je=l&&B&&y.pending,oe=B||!mt(C),z=d.useMemo(()=>Xs(Z,b,e),[Z,b,e]),se=d.useMemo(()=>Xs($,b,e),[$,b,e]),xe=Co(b),me=g==="board"?se.length:$.length,Le=!oe||!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:Z.length}),re=u.isSuccess&&Z.length>0,De=re&&oe&&me===0&&!je,Ye=je&&me===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,ce=(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="f";!Ce&&!ce||(W.preventDefault(),de.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=ao(g==="timeline"?Z.map(N=>N.id):[],i),P=new Map(Z.map((N,W)=>[N.id,St[W]])),ie=$.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()},He=N=>{h(N),Si(N),H(Ci(N))},Pn=(N,W)=>{E(Q=>cn(Q,N,W)),X()},Et=()=>{const N=k.trim()!=="",W=!mt(C),Q=M!==null;q(""),E(sr),M!==null&&He(null),H(Ei({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([]),Ln=ye(a.data,"projects_force_done"),In=(N,W)=>{const Q=N.id,Ce=ae(W).label;Us(ce=>ce.includes(Q)?ce:[...ce,Q]),Xi({move:()=>m.mutateAsync({key:Q,fields:{status:W}}),forceDoneOffered:Ln,claimQuestion:()=>Vt.current?!1:(Vt.current=!0,!0)}).then(ce=>{if(ce.kind==="accepted"){ve(n("ui.projects.projects_page.moved_to_label",{label:String(Ce)})),u.refetch().then(()=>te(Q));return}if(ce.kind==="question"){qs({project:N,status:W,refusal:ce.refusal});return}le(ce.copy,ce.refusal?{action:{get label(){return n("ui.projects.projects_page.view_project")},onClick:()=>void r(`/projects/${Q}`)}}:void 0),te(Q)}).finally(()=>{Us(ce=>ce.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(Bl,{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(Ks,{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(Ka,{})}),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(au,{value:g,onChange:N=>{S(N),nu(N)}}),t.jsx(eu,{projects:K,query:k,onQueryChange:ee,filters:C,onFiltersChange:fe,onClearAll:Et,todayMs:v,resultText:Le,countRevealClass:g==="board"?"@[47rem]:inline":void 0,disabled:u.isError,searchFieldRef:de,trailing:g==="board"&&!(u.isSuccess&&u.data.length===0)?t.jsx(Ji,{value:b,onChange:N=>{x(N),Js(N)}}):null})]}),t.jsx(tu,{filters:C,sort:M,onFiltersChange:fe,onSortChange:He,onClearAll:Et,hideClearAll:De,searchFieldRef:de}),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")}),ou.map(N=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(Ke,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Ke,{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(ss,{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()?Zo[J]: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(),de.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(Vl,{projects:$,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),sort:M,onSortChange:He,searchPopulation:K,filters:C,query:k,todayMs:v,onToggleFilter:Pn,onClearFilters:Et,teamLabelFor:c}),re&&!De&&g==="board"&&se.length>0&&t.jsx(mc,{projects:se,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),onEdit:N=>void r(`/projects/${N.id}`),onDelete:T,onMove:In,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(Jl,{items:ie,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&&te(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(()=>te(N.id))},secondaryLabel:n("ui.projects.projects_page.open_project"),onSecondary:()=>{const N=Se?.project.id;Bs(),N&&r(`/projects/${N}`)}}),t.jsx($l,{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 ce=Ce instanceof Error&&Ce.message?Ce.message:"";le(n("ui.projects.projects_page.project_label_was_created_but_the_extra_fields_were_not_saved_val",{label:String(Q),value2:String(yt(ce)||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(Ks,{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(ss,{variant:"warning",children:Sr[o]??Sr.unknown})]})};export{ju as ProjectsPage};
|
|
45
|
+
`).trim()}function wn(e,s,r){const a=e.clipboardData?.getData("text/html");if(!a)return;const o=Qc(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?Jo(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:[po(e)&&t.jsx(Ss,{"aria-hidden":!0}),s.label]})},Zc="project-key",el="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 Kt=({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(Kt,{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)})})},tl=({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:Ot,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=>ts(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:Zc,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:Ot,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=>ts(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:ir,placeholder:el,mono:!0})]})},sl=({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(Kt,{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(Qe,{open:r,onOpenChange:a,value:f.draft,onValueChange:b=>{a(!1),f.accept(b)},children:[t.jsx(Ze,{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(et,{})}),t.jsx(tt,{children:Yr.map(b=>t.jsx(Pe,{value:b.value,"data-project-status-option":b.value,children:b.label},b.value))})]})})},rl=({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>Je;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(Pr,{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,"/",Je]})]})]}):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})})]})})},nl=({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:Pt,placeholder:n("ui.projects.examples.owner"),autoBegin:r,onRetire:a})),al=({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:Pt,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})},ol=({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:Ki,commit:async p=>{const m=Vi(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(Kt,{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(Qe,{value:c.draft.unit,onValueChange:p=>c.setDraft({...c.draft,unit:p}),children:[t.jsx(Ze,{"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(et,{})}),t.jsxs(tt,{children:[t.jsx(Pe,{value:"points",children:n("ui.projects.project_editors.points")}),t.jsx(Pe,{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")})]})})},il=({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)=>Wi(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(Kt,{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))})]})})},cl="project-quick-send:no-target",ll=[],ul=({links:e,target:s,onTargetChange:r,onSend:a,focusTick:o})=>{I();const i=d.useRef(null),l=Wn(),{frontend:c,refresh:u}=Wa(),[p,m]=d.useState(!1),_=nt(),j=s??cl;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(Qe,{value:s??void 0,onValueChange:b=>r(b),children:[t.jsx(Ze,{"aria-label":n("ui.projects.project_quick_send.select_the_session_to_message"),className:"max-w-72",children:t.jsx(et,{placeholder:n("ui.projects.project_quick_send.no_session_selected")})}),t.jsx(tt,{children:f.map(b=>t.jsx(Pe,{value:b.session_id,children:Ht(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(Vn,{ref:i,conversationId:j,messages:ll,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})}}})]})},dl=({links:e,busy:s,onUnlink:r,onLink:a,onQuickSend:o,onStartSession:i})=>{I();const l=Ut(),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:Go(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(za,{}),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(Ga,{}),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=vo(x),T=yo(x.subagents),k=wo(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(Ya,{})}),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(ro,{})})]},x.session_id)})}),e.some(x=>x.exists)&&t.jsx(ul,{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")})]})})]})},pl=({milestones:e,summary:s,busy:r,onToggle:a,onRemove:o,onAdd:i})=>{const[l,c]=d.useState(""),[u,p]=d.useState(""),m=I(),_=!Hr.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=fo(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(Lr,{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")]})]})]})},ml=[{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})]}),fl=({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=ml.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?Xn(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(nl,{project:e,commit:r,autoBegin:l==="owner",onRetire:E=>_("owner",E)}),x&&t.jsx(al,{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(ol,{project:e,commit:r,autoBegin:l==="estimate",onRetire:E=>_("estimate",E)}),q&&t.jsx(il,{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")})]})},_l=({project:e})=>{I();const s=nt(),r=bn(),{sending:a,cooling:o,cooldownRemainingMs:i}=uc(e.id);if(!ye(s.data,"projects_request_update"))return null;const l=ne(e),c=tc(e.id);return t.jsxs(t.Fragment,{children:[t.jsx($t,{content:o&&i!==null?Lt(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(eo,{}),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:Lt(l,i)})]})},Sn="plain",Cn=e=>`team:${e}`,En=e=>`agent:${e}`;function jl(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function hl(e){return e.kind==="team"?Cn(e.name):e.kind==="agent"?En(e.name):Sn}const wr={kind:"plain"},gl=({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),_=Jn(e&&a),j=Qn(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===hl(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(jl(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})]})})},xl=({links:e})=>{I();const s=zo(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:Ht(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Zs(a.todos)})]},a.session_id))})]})},Ls=({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),le("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(Ha,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.preview")})]}),o&&t.jsxs(be,{onSelect:o,children:[t.jsx(Zn,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.show_in_canvas")})]}),t.jsxs(be,{onSelect:c,children:[t.jsx(ea,{"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(ta,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.open_folder")})]}),t.jsxs(be,{onSelect:l,children:[t.jsx(sa,{"aria-hidden":"true"}),t.jsx("span",{children:n("ui.common.file_actions.copy_file_path")})]})]})]})},bl=/[/\\]/,vl=e=>{if(e.name)return e.name;const s=e.path.split(bl);return s[s.length-1]||e.path},yl="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(),qn(e,"dialog","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?vl(s):"";return t.jsx(Pa,{open:e,onOpenChange:p=>!p&&r(),children:t.jsxs(Ma,{className:yl,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(La,{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 wl=/[/\\]/,Re=e=>{if(e.name)return e.name;const s=e.path.split(wl);return s[s.length-1]||n("ui.projects.project_updates.attachment")};function kl(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:oa(e.name||e.path),sizeBytes:e.bytes,...Number.isFinite(s)?{mtimeMs:s}:{}}},Ae=e=>`${e.path}:${e.added_at}`,Ue="h-[78px] w-[117px]",Is="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}),Nl=({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})},Sl=({attachment:e,onOpen:s})=>{const[r,a]=qt();return t.jsx("div",{ref:r,className:"group relative flex leading-none","data-project-asset-tile":"image",children:a?t.jsx(Nl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"image"})})},Cl=({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"})})]})})})},El=({attachment:e,onOpen:s})=>{const[r,a]=qt();return t.jsxs("div",{ref:r,className:"group relative block leading-none","data-project-asset-tile":"video",children:[a?t.jsx(Cl,{attachment:e,onOpen:s}):t.jsx(Nt,{kind:"video"}),t.jsx("div",{className:Is,children:t.jsx(Ls,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Tl=({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(aa,{ownerId:`project-sound:${e.path}`,src:r.url,label:s,peaks:null,variant:"compact"})})},Rl=({attachment:e})=>{const[s,r]=qt();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(Tl,{attachment:e}):t.jsx(Nt,{kind:"audio"}),t.jsx("div",{className:Is,children:t.jsx(Ls,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(Re(e))})})})]})},Dl=e=>{const s=e.name||e.path;if(Tr(s))return!0;const r=Rr(s);return r==="text"||r==="code"},Al=({attachment:e,onPreview:s})=>{I();const r=Re(e),a=Uo(e.bytes),o=d.useRef(null),i=Dl(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(ra,{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:Is,children:t.jsx(Ls,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(r)}),onPreview:i?()=>s(o.current):void 0})})]})},Ol=({asset:e,current:s,index:r,count:a,onSelect:o,scrollIntoView:i})=>{I();const[l,c]=qt(),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(Pl,{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":""})})})})},Pl=({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"})})]})})},Ml=({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(Ol,{asset:a,current:o===s,index:o,count:e.length,onSelect:()=>r(o),scrollIntoView:s===o},Ae(a.attachment)))})),Ll=({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(Ml,{media:e,index:s,onSelect:r}):void 0;return t.jsx(na,{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(Hs(s,e.length,-1)),onNext:()=>r(Hs(s,e.length,1)),filmstrip:u}})},Rn=({attachments:e})=>{I();const s=d.useMemo(()=>e.map(j=>({attachment:j,kind:kl(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(Sl,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="video"?t.jsx(El,{attachment:j,onOpen:()=>m(j)},Ae(j)):f==="audio"?t.jsx(Rl,{attachment:j},Ae(j)):t.jsx(Al,{attachment:j,onPreview:g=>_(j,g)},Ae(j)))}),p>=0&&t.jsx(Ll,{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 Il=({update:e,nowMs:s})=>{const r=I(),a=qo(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})]})},Fl=({updates:e,nowMs:s})=>{const r=I(),a=Po(e.length),o=Bo(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(Il,{update:l,nowMs:s},`${l.at}:${l.by}:${c}`))})]},i.key||"ungrouped"))})]})},ql="project_not_found",Bl=({projectKey:e,nowMs:s})=>{I();const r=Ut(),a=nt(),o=Ar(ye(a.data,"team_catalogue")),i=Ur(e,!0),l=$r(),c=zr(),u=lo(),p=uo(),m=io(),_=co(),[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 Bt&&(i.error.code===ql||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(ss,{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=$o(x.milestones.filter(h=>h.completed_at!==null).length,x.milestones.length),E=async(h,A,D,F)=>{const Y=At.getState(),U=ya(null,h,Y.drafts);if(!U)return!1;try{const{images:H,files:X,failures:ee,overflow:fe,fileOverflow:de}=await ca(F,A,{remoteOwned:wa(Y.sessions,Y.placementFacts,h)}),te=la(ee);if(te)return le(te),!1;const Z=ua(fe);if(Z)return le(Z),!1;const v=da(de);if(v)return le(v),!1;const y=pa(A,H);if(y)return le(y),!1;if(await ka(U,{text:A,attachments:F,images:H,mode:D,cwd:Y.cwd,...X.length?{files:X}:{}},h)===null)return le(n("ui.projects.project_detail.that_session_already_has_a_message_going_out_try_again_in_a_momen")),!1;const L=w.find(B=>B.session_id===h);return ve(n("ui.projects.project_detail.sent_to_value1",{value1:String(L?Ht(L):h)})),!0}catch(H){return le(H instanceof Error&&H.message?H.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"));Na.getState().setCurrentInput(F,Yo(x));let Y=null;try{await m.mutateAsync({key:x.id,sessionId:F})}catch(U){Y=U instanceof Error&&U.message?U.message:n("ui.projects.project_detail.the_link_was_refused")}if(Y)le(n("ui.projects.project_detail.session_started_but_linking_it_failed_linkfailure",{linkFailure:String(Y)}));else{const U=D?n("ui.projects.project_detail.with_value1",{value1:String(Ho(D))}):"";ve(n("ui.projects.project_detail.session_started_withtarget_and_linked_to_displayname",{withTarget:String(U),displayName:String(T)}))}await qr(r,F)};return t.jsx(Nc,{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(tl,{project:x,commit:k}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(sl,{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(_l,{project:x}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"project-delete",children:[t.jsx(ia,{}),n("ui.projects.project_detail.delete")]})]})]})]}),t.jsx(rl,{project:x,commit:k}),t.jsx(fl,{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:ho(x,s)})]}),t.jsx(pl,{milestones:x.milestones,summary:C,busy:b,onToggle:(h,A)=>{u.mutateAsync({key:x.id,name:h,completed:A}).catch(D=>{le(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=>{le(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=>{le(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_added"))})}}),t.jsx(dl,{projectKey:x.id,links:w,busy:b,onStartSession:()=>S(!0),onQuickSend:E,onLink:h=>{m.mutateAsync({key:x.id,sessionId:h}).catch(A=>{le(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=>{le(A instanceof Error&&A.message?A.message:n("ui.projects.project_detail.the_session_was_not_unlinked"))})}}),t.jsx(xl,{links:w}),t.jsx(Fl,{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(gl,{open:g,onClose:()=>S(!1),onStart:M,teamsEnabled:ye(a.data,"team_catalogue"),profilesEnabled:ye(a.data,"profile_catalogue")})]})})},Ul="payments-migration",kr={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},$l=({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:Pc(a.title),k=h=>wn(h,x,A=>w("description",A)),q=(h,A)=>{const D={},F=ts(A);F&&(D.name=F);const Y=pn(h.description);Y&&(D.description=Y);const U=ps(h.tags).error;U&&(D.tags=U);const H=us(h.startDate);H&&(D.startDate=H);const X=us(h.targetDate);if(X)D.targetDate=X;else if(!H){const te=ds(h.startDate,h.targetDate);te&&(D.targetDate=te)}if(h.estimate.trim()){const te=mn(h.estimate);te&&(D.estimate=te)}const ee=ls(h.title);ee&&(D.title=ee);const fe=Mt(h.owner,"owner");fe&&(D.owner=fe);const de=Mt(h.team,"team");return de&&(D.team=de),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 Y=F instanceof Error&&F.message?F.message:"";u(yt(Y)||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>Je;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:Ul,"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(Pr,{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,"/",Je]})]})]}),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(Qe,{value:a.status,onValueChange:h=>w("status",h),children:[t.jsx(Ze,{"aria-label":n("ui.projects.project_form_dialog.status"),children:t.jsx(et,{})}),t.jsx(tt,{children:Yr.map(h=>t.jsx(Pe,{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(Qe,{value:a.estimateUnit,onValueChange:h=>w("estimateUnit",h),children:[t.jsx(Ze,{"aria-label":n("ui.projects.project_form_dialog.estimate_unit"),className:"max-w-32",children:t.jsx(et,{})}),t.jsxs(tt,{children:[t.jsx(Pe,{value:"points",children:n("ui.projects.project_form_dialog.points")}),t.jsx(Pe,{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})},zl=({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(Lr,{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})]})},Gl=({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)))})})]})]})},Yl=({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(zl,{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?yi(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(Gl,{column:c.key,spec:c.spec,onChange:c.onChange})]}),u.map(m=>t.jsx(Yl,{facet:m.facet,options:m.options,onToggle:o},m.facet))]})},Hl=({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":xo(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 Kl(e,s){const r=xt(e.progress_updated_at,s);return r?bt(r):n("ui.projects.project_list.not_reported")}const Wl=({direction:e})=>e==="asc"?t.jsx(Fr,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Or,{size:10,className:"shrink-0","aria-hidden":"true"}),Vl=({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?Di(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(Wl,{direction:a.direction}):t.jsx(ma,{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(Hl,{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:Kl(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,Xl={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")}},Jl=({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=Os(s),f=d.useMemo(()=>Pi(e,j),[e,j]),g=d.useMemo(()=>Mi(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?Ai(or(f.startMs,f.endMs),b):"month",w=c??x,T=C=>{const E=Oe.indexOf(w),M=Oe[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===Oe[0],onClick:()=>T(1),children:t.jsx(pt,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Xl[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===Oe[Oe.length-1],onClick:()=>T(-1),children:t.jsx(Ia,{})})]})]}),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(Ql,{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(Zl,{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(Xa,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Li(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))})]})})]})},Ql=({startMs:e,endMs:s,tier:r,pxPerDay:a,trackPx:o})=>{const i=Yi(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))})]})},Zl=({item:e,spanStart:s,pxPerDay:r,trackPx:a,today:o,onOpen:i})=>{const{project:l}=e,c=Ii(e),u=Fi(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"})]})]})},eu=({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=gi(a),b=Ir(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(fa,{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:()=>_a(_.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(ja,{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(Qa,{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]})},tu=({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(Fr,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Or,{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")})]})},On="projects-view",su=[{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 ru(){try{const e=localStorage.getItem(On);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function nu(e){try{localStorage.setItem(On,e)}catch{}}const au=({value:e,onChange:s})=>(I(),t.jsx(Fa,{value:e,onValueChange:r=>s(r),children:t.jsx(qa,{"aria-label":n("ui.projects.projects_view_switcher.project_view"),"data-tour-tag":"projects-view-switcher",children:su.map(r=>t.jsx(Ba,{value:r.value,children:r.label},r.value))})})),ou=["r1","r2","r3","r4","r5","r6"],iu=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")}},hu=({nowMs:e=Date.now()})=>{I();const{projectId:s}=Sa(),r=Ut(),a=nt(),o=Ca(a.data,"projects",1),i=o==="enabled",l=ye(a.data,"projects",ei),c=Ar(ye(a.data,"team_catalogue")),u=no(i),p=oo(),m=$r(),_=zr(),[j,f]=d.useState(!1),[g,S]=d.useState(()=>ru()),[b,x]=d.useState(()=>Eo()),[w,T]=d.useState(null),[k,q]=d.useState(""),[C,E]=d.useState(sr),[M,h]=d.useState(()=>Ni()),[A,D]=d.useState(""),F=d.useRef(""),Y=d.useRef(null),U=d.useRef(null),H=N=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),N!==""&&N===F.current?(D(""),Y.current=window.requestAnimationFrame(()=>{Y.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("")},iu)},X=()=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),U.current!==null&&(window.clearTimeout(U.current),U.current=null),F.current="",D("")},ee=N=>{q(N),X()},fe=N=>{E(N),X()},de=d.useRef(null),te=dc(),Z=u.data??[],v=Os(e),y=mi(k,i&&l),O=an(k),L=d.useMemo(()=>y.answer?di(Z,y.answer.projects):null,[Z,y.answer]),B=O!=="",K=d.useMemo(()=>B?L??ui(Z,O):Z,[Z,O,B,L]),J=L===null?"client":"backend",$=d.useMemo(()=>xi(K,C,v),[K,C,v]),je=l&&B&&y.pending,oe=B||!mt(C),z=d.useMemo(()=>Xs(Z,b,e),[Z,b,e]),se=d.useMemo(()=>Xs($,b,e),[$,b,e]),xe=Co(b),me=g==="board"?se.length:$.length,Le=!oe||!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:Z.length}),re=u.isSuccess&&Z.length>0,De=re&&oe&&me===0&&!je,Ye=je&&me===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,ce=(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="f";!Ce&&!ce||(W.preventDefault(),de.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=ao(g==="timeline"?Z.map(N=>N.id):[],i),P=new Map(Z.map((N,W)=>[N.id,St[W]])),ie=$.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()},He=N=>{h(N),Si(N),H(Ci(N))},Pn=(N,W)=>{E(Q=>cn(Q,N,W)),X()},Et=()=>{const N=k.trim()!=="",W=!mt(C),Q=M!==null;q(""),E(sr),M!==null&&He(null),H(Ei({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([]),Ln=ye(a.data,"projects_force_done"),In=(N,W)=>{const Q=N.id,Ce=ae(W).label;Us(ce=>ce.includes(Q)?ce:[...ce,Q]),Xi({move:()=>m.mutateAsync({key:Q,fields:{status:W}}),forceDoneOffered:Ln,claimQuestion:()=>Vt.current?!1:(Vt.current=!0,!0)}).then(ce=>{if(ce.kind==="accepted"){ve(n("ui.projects.projects_page.moved_to_label",{label:String(Ce)})),u.refetch().then(()=>te(Q));return}if(ce.kind==="question"){qs({project:N,status:W,refusal:ce.refusal});return}le(ce.copy,ce.refusal?{action:{get label(){return n("ui.projects.projects_page.view_project")},onClick:()=>void r(`/projects/${Q}`)}}:void 0),te(Q)}).finally(()=>{Us(ce=>ce.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(Bl,{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(Ks,{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(Ka,{})}),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(au,{value:g,onChange:N=>{S(N),nu(N)}}),t.jsx(eu,{projects:K,query:k,onQueryChange:ee,filters:C,onFiltersChange:fe,onClearAll:Et,todayMs:v,resultText:Le,countRevealClass:g==="board"?"@[47rem]:inline":void 0,disabled:u.isError,searchFieldRef:de,trailing:g==="board"&&!(u.isSuccess&&u.data.length===0)?t.jsx(Ji,{value:b,onChange:N=>{x(N),Js(N)}}):null})]}),t.jsx(tu,{filters:C,sort:M,onFiltersChange:fe,onSortChange:He,onClearAll:Et,hideClearAll:De,searchFieldRef:de}),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")}),ou.map(N=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(Ke,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(Ke,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(Ke,{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(ss,{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()?Zo[J]: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(),de.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(Vl,{projects:$,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),sort:M,onSortChange:He,searchPopulation:K,filters:C,query:k,todayMs:v,onToggleFilter:Pn,onClearFilters:Et,teamLabelFor:c}),re&&!De&&g==="board"&&se.length>0&&t.jsx(mc,{projects:se,nowMs:e,onOpen:N=>void r(`/projects/${N.id}`),onEdit:N=>void r(`/projects/${N.id}`),onDelete:T,onMove:In,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(Jl,{items:ie,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&&te(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(()=>te(N.id))},secondaryLabel:n("ui.projects.projects_page.open_project"),onSecondary:()=>{const N=Se?.project.id;Bs(),N&&r(`/projects/${N}`)}}),t.jsx($l,{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 ce=Ce instanceof Error&&Ce.message?Ce.message:"";le(n("ui.projects.projects_page.project_label_was_created_but_the_extra_fields_were_not_saved_val",{label:String(Q),value2:String(yt(ce)||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(Ks,{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(ss,{variant:"warning",children:Sr[o]??Sr.unknown})]})};export{hu as ProjectsPage};
|