local-operator-ui 0.36.4 → 0.36.6
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 +3915 -150
- package/out/preload/index.js +120 -0
- package/out/renderer/assets/{_basePickBy-DQ6BzkJm.js → _basePickBy-B0B_HryP.js} +1 -1
- package/out/renderer/assets/{_baseUniq-D4Pzw8OZ.js → _baseUniq-BC6WfZEZ.js} +1 -1
- package/out/renderer/assets/{agent-details-page-vUtr6XRL.js → agent-details-page-CIKeI8ax.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-DLfJB8ns.js → agent-hub-page-NKE7fJK1.js} +2 -7
- package/out/renderer/assets/agents-page-BIRTx9kB.js +7 -0
- package/out/renderer/assets/{arc-BvXLfjiv.js → arc-DyL52bz_.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DGO7ixLg.js → architectureDiagram-IEHRJDOE-OQsI3Nan.js} +1 -1
- package/out/renderer/assets/{arrow-up-D8Tgt51O.js → arrow-up-BpuHf_sB.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-Bpj3zFYQ.js → blockDiagram-JOT3LUYC-CS1fz58m.js} +1 -1
- package/out/renderer/assets/{book-open-DeWHPw1t.js → book-open-BiI_r4jM.js} +1 -1
- package/out/renderer/assets/browser-page-CvUjgYjV.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-CLrsocAn.js → browser-webauthn-prompt-ja8N1ehh.js} +1 -1
- package/out/renderer/assets/building-2-Dar5h3t0.js +6 -0
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-tA5p19nS.js → c4Diagram-VJAJSXHY-C6RZIvJP.js} +1 -1
- package/out/renderer/assets/channel-Ca9itbEI.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CAtpoCnM.js → chunk-4BMEZGHF-Cpn-cLXo.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-CYHy7Mvk.js → chunk-A2AXSNBT-S8Vffyme.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-B2bXanTe.js → chunk-AEK57VVT-K1GcoFUy.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-DfhdrNKB.js → chunk-D6G4REZN-CyqTe7_6.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-BNdcLGHR.js → chunk-RZ5BOZE2-QWUc1JND.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-Caa_mRlB.js → chunk-XZIHB7SX-v3MFY8Qn.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BDSTmyjZ.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BDSTmyjZ.js +1 -0
- package/out/renderer/assets/clone-OIhREtCX.js +1 -0
- package/out/renderer/assets/{console-mirror-BnHVC7eO.js → console-mirror-BfM9Le8Y.js} +1 -1
- package/out/renderer/assets/{consoleCapture-BxykZlLx.js → consoleCapture-mqMk3W7y.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-CJiOSzCX.js → conversation-input-sync-BD8ZrQRq.js} +292 -262
- package/out/renderer/assets/{dagre-OKDRZEBW-pq4RiyaY.js → dagre-OKDRZEBW-D1-V7-Tj.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DnlzCGD2.js → diagram-SSKATNLV-D7jQdHV1.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DbJ2RTVe.js → diagram-VNBRO52H-DB_YZ9C8.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-C56WVcbc.js → erDiagram-Q7BY3M3F-Blv-3W3v.js} +1 -1
- package/out/renderer/assets/{error-boundary-Tv9TlaZ8.js → error-boundary-Bpk2r3Ma.js} +2 -2
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CL1GRaaq.js → flowDiagram-4HSFHLVR-BTShSZPF.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CES2U6dP.js → ganttDiagram-APWFNJXF-_SXfULy-.js} +4 -4
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-CRyPEqXz.js → gitGraphDiagram-7IBYFJ6S-9E7LTj7S.js} +1 -1
- package/out/renderer/assets/{graph-Dtsej9jG.js → graph-BhaFec28.js} +1 -1
- package/out/renderer/assets/hash-CrDnkZ9w.js +6 -0
- package/out/renderer/assets/index-BgwxrPpP.css +1 -0
- package/out/renderer/assets/index-BuM037wD.js +824 -0
- package/out/renderer/assets/index-ByYW6G08.js +57 -0
- package/out/renderer/assets/{index-BsV4LVu3.js → index-ClCIwVJj.js} +1 -1
- package/out/renderer/assets/{index-DAoplO_Z.js → index-Shz25Z8Y.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-BwRaN2ZH.js → infoDiagram-PH2N3AL5-CCsEuNFb.js} +1 -1
- package/out/renderer/assets/{installer-DjflOef5.js → installer-CJRb2tgb.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-CwrSuzth.js → journeyDiagram-U35MCT3I-LXUs-hfi.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CjW130n-.js → kanban-definition-NDS4AKOZ-GLYV-Ku1.js} +1 -1
- package/out/renderer/assets/{layout-DnBx2qbk.js → layout-erSNWSH-.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-BiAHAYWZ.js → legacy-agents-page-CtFhdgCi.js} +7 -7
- package/out/renderer/assets/library-page-C6-aUarQ.js +157 -0
- package/out/renderer/assets/{mermaid.core-BHqZ2SZO.js → mermaid.core-BGROKqtx.js} +5 -5
- package/out/renderer/assets/mesh-page-CzSDWDfu.js +1 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Ca2VY79V.js → mindmap-definition-ALO5MXBD-C1KlK3C5.js} +1 -1
- package/out/renderer/assets/{mini-Dd3N58po.js → mini-Dnf6EgXd.js} +1 -1
- package/out/renderer/assets/{notebook-pen-CcH01r1l.js → notebook-pen-CTurnI5u.js} +1 -1
- package/out/renderer/assets/{org-access-WIuI99P6.js → org-access-DTXfQgW5.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-BsP8aWCi.js → org-surface-gate-CDaexKo1.js} +1 -1
- package/out/renderer/assets/{page-header-ggruiR-O.js → page-header-Does21Km.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-C7lP9J7V.js → pieDiagram-IB7DONF6-DaaMC8-4.js} +1 -1
- package/out/renderer/assets/{projects-page-BIRVv4yi.js → projects-page-Bw0c4vc_.js} +6 -6
- package/out/renderer/assets/publication-validation-MxGQJEQj.js +1 -0
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CPMEK8EO.js → quadrantDiagram-7GDLP6J5-BVFqf3uw.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-sbfBaJo0.js → radar-MK3ICKWK-BbBjm1y3.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-C0ljZy4O.js → radient-auth-buttons-BeDvFHK7.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-S2rhrmTH.js → requirementDiagram-KVF5MWMF-luASPwgm.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-sNpc3Wfn.js → sankeyDiagram-QLVOVGJD-DJ-Xk1mH.js} +1 -1
- package/out/renderer/assets/{schedules-page-DbZSRb3g.js → schedules-page-D7XfeTME.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-Cv-47OeQ.js → sequenceDiagram-X6HHIX6F-C9vBEHGW.js} +1 -1
- package/out/renderer/assets/{settings-page-DH9sXfEW.js → settings-page-BubJ0gmV.js} +8 -8
- package/out/renderer/assets/smartart-DCxfy3Tv.js +1 -0
- package/out/renderer/assets/{stateDiagram-DGXRK772-DIBWf8qm.js → stateDiagram-DGXRK772-DCbA594R.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-P9yjg6o0.js +1 -0
- package/out/renderer/assets/{tags-input-chips-B4_gHGYO.js → tags-input-chips-BSg2kzIn.js} +1 -1
- package/out/renderer/assets/team-bridge-page-DshgiIxJ.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-CE8q2f33.js → timeline-definition-BDJGKUSR-AlhVX480.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-CAt3Nng3.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-LdjExo2g.js → use-download-agent-mutation-DmirSifx.js} +4 -4
- package/out/renderer/assets/{use-memberships-query-DcD9UeVY.js → use-memberships-query-fzcoT-92.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-Cqye2iDz.js → use-session-snapshot-DQQ3D8W6.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DlbgdRgT.js → xychartDiagram-VJFVF3MP-djayCUFZ.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +2 -2
- package/out/renderer/assets/agents-page-B-PHMFxF.js +0 -7
- package/out/renderer/assets/browser-page-DAQis2Rt.js +0 -1
- package/out/renderer/assets/channel-CG3c-hsB.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BGWu-T14.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BGWu-T14.js +0 -1
- package/out/renderer/assets/clone-UwOnPjS7.js +0 -1
- package/out/renderer/assets/index-D0l2JJ6w.js +0 -829
- package/out/renderer/assets/index-hX_aZwq0.js +0 -57
- package/out/renderer/assets/index-vPvXCaIy.css +0 -1
- package/out/renderer/assets/library-page-BGmng_P-.js +0 -162
- package/out/renderer/assets/mesh-page-1yPLxWRO.js +0 -1
- package/out/renderer/assets/publication-validation-C73bqNja.js +0 -1
- package/out/renderer/assets/smartart-C2eRO4WK.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DBPLNjJl.js +0 -1
- package/out/renderer/assets/ui-preferences-store-C6eXGzFs.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d,t as n,d as Fe,j as t,c as M}from"./index-
|
|
1
|
+
import{r as d,t as n,d as Fe,j as t,c as M}from"./index-ByYW6G08.js";import{cp as Tn,cq as Yt,cr as Rn,c1 as xr,u as br,cs as Dn,ct as An,cu as On,cv as Pn,cw as Mn,cx as Ln,cy as As,cz as Os,cA as In,cB as Fn,C as us,aN as qe,d as _e,c6 as qn,D as ds,cC as V,cD as yt,cE as Un,Z as Rt,cF as Ps,cG as Ms,cH as Ls,bR as Bn,aO as be,cI as $n,a as Ze,c as ye,b4 as yr,aQ as Dt,a6 as dt,aU as Ye,cJ as zn,c9 as Gn,cl as Hn,cK as Yn,cm as Kn,aW as vr,aV as vt,bv as Wn,aE as Vn,au as kt,bE as Qn,bK as Xn,bJ as Jn,bH as Is,co as Zn,cb as kr,c8 as ea,ca as ta,a7 as de,cL as sa,cM as ra,cN as na,cO as aa,cP as oa,cQ as wr,aP as ia,at as ca,ao as la,ap as ua,ar as da,as as pa,av as ma,aB as fa,cR as _a,cS as Nr,bN as ja,cT as ha,aD as ga,aR as xa,b5 as ba}from"./conversation-input-sync-BD8ZrQRq.js";import{c as At,u as F,K as Ke,y as Ot,M as We,N as Ve,O as Qe,P as Ae,a as G,h as ps,i as ms,S as Te,k as fs,q as Ee,a9 as ya,aa as va,ab as ka,m as wa,n as Na,p as Sa,B as ke,a5 as _s,af as js,a7 as hs,I as ue,X as Pt,s as gs,T as Sr,L as pe,R as Cr,C as Er,A as Kt,U as Ca,a0 as Ea,a1 as Ta,a2 as Ra,x as ze}from"./error-boundary-Bpk2r3Ma.js";import{P as Fs}from"./page-header-Does21Km.js";import{bj as Tr,bD as Da,br as Rr,bE as Aa,bs as Oa,b3 as Pa,a as it,E as qs,bF as Us,bC as Ma}from"./index-BuM037wD.js";import{h as La,j as Ia,k as Xe,l as Fa,m as Wt}from"./ui-preferences-store-CAt3Nng3.js";import{u as qa}from"./use-session-snapshot-DQQ3D8W6.js";import{A as Dr}from"./arrow-up-BpuHf_sB.js";import"./console-mirror-BfM9Le8Y.js";function Bs(e,s){return e.filter(r=>!s.includes(r))}function Ua(e,s,r){const a=e.slice(0);return a[s]=r,a}var Ba=class extends Tn{#r;#e;#n;#a;#t;#s;#o;#i;#c=[];constructor(e,s,r){super(),this.#r=e,this.#a=r,this.#n=[],this.#t=[],this.#e=[],this.setQueries(s)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(s=>{this.#p(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,s){this.#n=e,this.#a=s,Yt.batch(()=>{const r=this.#t,a=this.#d(this.#n);this.#c=a,a.forEach(c=>c.observer.setOptions(c.defaultedQueryOptions));const o=a.map(c=>c.observer),i=o.map(c=>c.getCurrentResult()),l=o.some((c,u)=>c!==r[u]);r.length===o.length&&!l||(this.#t=o,this.#e=i,this.hasListeners()&&(Bs(r,o).forEach(c=>{c.destroy()}),Bs(o,r).forEach(c=>{c.subscribe(u=>{this.#p(c,u)})}),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,s){const r=this.#d(e),a=r.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions));return[a,o=>this.#u(o??a,s),()=>this.#l(a,r)]}#l(e,s){return s.map((r,a)=>{const o=e[a];return r.defaultedQueryOptions.notifyOnChangeProps?o:r.observer.trackResult(o,i=>{s.forEach(l=>{l.observer.trackProp(i)})})})}#u(e,s){return s?((!this.#s||this.#e!==this.#i||s!==this.#o)&&(this.#o=s,this.#i=this.#e,this.#s=Rn(this.#s,s(e))),this.#s):e}#d(e){const s=new Map(this.#t.map(a=>[a.options.queryHash,a])),r=[];return e.forEach(a=>{const o=this.#r.defaultQueryOptions(a),i=s.get(o.queryHash);i?r.push({defaultedQueryOptions:o,observer:i}):r.push({defaultedQueryOptions:o,observer:new xr(this.#r,o)})}),r}#p(e,s){const r=this.#t.indexOf(e);r!==-1&&(this.#e=Ua(this.#e,r,s),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,s=this.#l(this.#e,this.#c),r=this.#u(s,this.#a?.combine);e!==r&&Yt.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function $a({queries:e,...s},r){const a=br(r),o=Dn(),i=An(),l=d.useMemo(()=>e.map(w=>{const g=a.defaultQueryOptions(w);return g._optimisticResults=o?"isRestoring":"optimistic",g}),[e,a,o]);l.forEach(w=>{On(w),Pn(w,i)}),Mn(i);const[c]=d.useState(()=>new Ba(a,l,s)),[u,m,p]=c.getOptimisticResult(l,s.combine),_=!o&&s.subscribed!==!1;d.useSyncExternalStore(d.useCallback(w=>_?c.subscribe(Yt.batchCalls(w)):Ln,[c,_]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),d.useEffect(()=>{c.setQueries(l,s)},[l,s,c]);const f=u.some((w,g)=>As(l[g],w))?u.flatMap((w,g)=>{const h=l[g];if(h){const v=new xr(a,h);if(As(h,w))return Os(h,v,i);In(w,o)&&Os(h,v,i)}return[]}):[];if(f.length>0)throw Promise.all(f);const x=u.find((w,g)=>{const h=l[g];return h&&Fn({result:w,errorResetBoundary:i,throwOnError:h.throwOnError,query:a.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(x?.error)throw x.error;return m(p())}/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,7 +8,7 @@ import{r as d,t as n,d as Fe,j as t,c as M}from"./index-hX_aZwq0.js";import{cg a
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const Ha=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Ya=At("list-filter",Ha);/**
|
|
12
12
|
* @license lucide-react v0.507.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
@@ -18,12 +18,12 @@ import{r as d,t as n,d as Fe,j as t,c as M}from"./index-hX_aZwq0.js";import{cg a
|
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Va=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],Qa=At("unlink",Va),Mt={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Xa(e){return us({queryKey:Mt.list,enabled:e,queryFn:()=>_e({op:"projects.list"}).then(s=>s.projects),retry:ds,staleTime:1e4})}function Ja(e,s){return $a({queries:e.map(r=>({queryKey:Mt.detail(r),enabled:s&&!!r,queryFn:()=>_e({op:"projects.get",key:r}),retry:ds,staleTime:1e4}))})}function Ar(e,s){return us({queryKey:Mt.detail(e??""),enabled:s&&!!e,queryFn:()=>_e({op:"projects.get",key:e??""}),retry:ds,staleTime:1e4})}function Ue(){const e=br();return()=>{e.invalidateQueries({queryKey:Mt.list})}}function Za(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.create",name:s.name,...s.description!==void 0?{description:s.description}:{},...s.status!==void 0?{status:s.status}:{},...s.tags!==void 0?{tags:s.tags}:{}}),onSuccess:()=>e()})}function Or(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.update",key:s.key,fields:s.fields,...s.forceDone===!0?{force_done:!0}:{}}),retry:qn,onSuccess:()=>e()})}function Pr(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function eo(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function to(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function so(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.milestone",key:s.key,name:s.name,...s.targetDate!==void 0?{targetDate:s.targetDate}:{},...s.completed!==void 0?{completed:s.completed}:{}}),onSuccess:()=>e()})}function ro(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const Mr={planning:{get label(){return n("ui.projects.project_model.planning")},variant:"info"},active:{get label(){return n("ui.projects.project_model.active")},variant:"accent"},qa:{get label(){return n("ui.projects.project_model.qa")},variant:"attention"},validation:{get label(){return n("ui.projects.project_model.validation")},variant:"warning"},done:{get label(){return n("ui.projects.project_model.done")},variant:"success"},paused:{get label(){return n("ui.projects.project_model.paused")},variant:"neutral"},archived:{get label(){return n("ui.projects.project_model.archived")},variant:"outline"}},Ge=Object.keys(Mr);function ae(e){return Mr[e]??{label:e||n("ui.projects.project_model.unknown"),variant:"neutral"}}const Lr=["planning","active","qa","validation","done","paused","archived"].map(e=>({value:e,label:ae(e).label}));function no(e){return e==="done"}const ao={completed:{get label(){return n("ui.projects.project_model.completed")},variant:"success"},overdue:{get label(){return n("ui.projects.project_model.overdue")},variant:"warning"},upcoming:{get label(){return n("ui.projects.project_model.upcoming")},variant:"neutral"}};function oo(e){return ao[e]??{label:String(e),variant:"neutral"}}Fe["ui.projects.project_model.stale"];const io=/^(\d{4})-(\d{2})-(\d{2})$/;function Oe(e,s,r=new Date){if(!e)return"";const a=io.exec(e);if(!a)return e;const o=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(o.getTime()))return e;const i=yt(o,{month:"short",day:"numeric"},s);return o.getFullYear()===r.getFullYear()?i:yt(o,{month:"short",day:"numeric",year:"numeric"},s)}function pt(e,s){if(e==null)return"";const r=Math.max(0,Math.floor(s/1e3-e));return r<60?n("ui.projects.project_model.just_now"):r<3600?`${V(Math.floor(r/60),{useGrouping:!1})}m`:r<86400?`${V(Math.floor(r/3600),{useGrouping:!1})}h`:`${V(Math.floor(r/86400),{useGrouping:!1})}d`}function mt(e){return e===n("ui.projects.project_model.just_now")?n("ui.projects.project_model.just_now"):n("ui.projects.project_model.age_ago",{age:String(e)})}function co(e){return e?n("ui.projects.project_model.reported_progressagephrase_age",{progressAgePhrase_age:String(mt(e))}):n("ui.projects.project_model.no_progress")}const Ir=/^$|^\d{4}-\d{2}-\d{2}$/;function Fr(e){return e?e==="operator"?n("ui.projects.project_model.the_operator"):n("ui.projects.project_model.session_reportedby",{reportedBy:String(e)}):""}function lo(e,s){if(!e.progress)return n("ui.projects.project_model.not_reported_yet");const r=pt(e.progress_updated_at,s),a=Fr(e.progress_reported_by),o=[r?n("ui.projects.project_model.reported_progressagephrase_age",{progressAgePhrase_age:String(mt(r))}):"reported"];return a&&o.push(n("ui.projects.project_model.by_reporter",{reporter:String(a)})),o.join(" ")}function qr(e,s){if(e==null)return"";const r=V(e,{useGrouping:!1,maximumFractionDigits:20});return s==="points"?n("ui.projects.project_model.value_pt",{value:String(r)}):s==="days"?n("ui.projects.project_model.value_d",{value:String(r)}):r}function Ur(e,s){return s<=0?"":n("ui.projects.project_model.completed_total",{completed:V(e,{useGrouping:!1}),total:V(s,{useGrouping:!1})})}function xs(e){return e<=0?"":n("ui.projects.project_model.live_live",{live:e})}function uo(e){return e<=0?"":n("ui.projects.count.session",{count:e})}function po(e){return n("ui.projects.count.project",{count:e})}function mo(e){const s=uo(e.sessions);if(!s)return"";const r=xs(e.live_sessions);return r?n("ui.projects.project_model.count_live",{count:String(s),live:String(r)}):s}function fo(e){if(!e.exists)return{get label(){return n("ui.projects.project_model.missing")},variant:"outline"};if(e.archived)return{get label(){return n("ui.projects.project_model.archived")},variant:"neutral"};switch(e.runtime?.state){case"live":return{get label(){return n("ui.projects.project_model.live")},variant:"success"};case"wedged":return{get label(){return n("ui.projects.project_model.wedged")},variant:"warning"};case"stale":return{get label(){return n("ui.projects.project_model.stale")},variant:"warning"};case"stopped":return{get label(){return n("ui.projects.project_model.stopped")},variant:"neutral"};default:return{label:String(e.runtime?.state??n("ui.projects.project_model.unknown")),variant:"neutral"}}}function _o(e){return e?e.running>0?n("ui.projects.count.subagent_running",{count:e.running}):n("ui.projects.count.subagent",{count:e.settled}):""}function jo(e){return e?n("ui.projects.count.todo",{count:e.total}):""}function Br(e,s){const r=[],a=Oe(e.completed_at??e.target_date,s);a&&r.push({key:e.completed_at?"completed":"target",text:e.completed_at?n("ui.projects.project_model.completed_day",{day:String(a)}):n("ui.projects.project_model.due_day",{day:String(a)})});const o=qr(e.estimate,e.estimate_unit);o&&r.push({key:"estimate",text:o});const i=Ur(e.milestones_completed,e.milestones_total);i&&r.push({key:"milestones",text:n("ui.projects.project_model.milestones_milestones",{milestones:String(i)})});const l=xs(e.live_sessions);return l&&r.push({key:"live",text:l}),r}const Ye=864e5,ho=/^(\d{4})-(\d{2})-(\d{2})$/;function ve(e){if(!e)return null;const s=ho.exec(e);if(!s)return null;const r=Number(s[1]),a=Number(s[2]),o=Number(s[3]),i=Date.UTC(r,a-1,o),l=new Date(i);return l.getUTCFullYear()!==r||l.getUTCMonth()!==a-1||l.getUTCDate()!==o?null:i}const Vt=["planning","active","qa","validation","done"],Qt=["paused","archived"],Lt=[{value:"24h",get label(){return n("ui.projects.project_model.last_24_hours")},get phrase(){return n("ui.projects.project_model.the_last_24_hours")},seconds:86400},{value:"7d",get label(){return n("ui.projects.project_model.last_7_days")},get phrase(){return n("ui.projects.project_model.the_last_7_days")},seconds:604800},{value:"30d",get label(){return n("ui.projects.project_model.last_30_days")},get phrase(){return n("ui.projects.project_model.the_last_30_days")},seconds:2592e3},{value:"90d",get label(){return n("ui.projects.project_model.last_90_days")},get phrase(){return n("ui.projects.project_model.the_last_90_days")},seconds:7776e3},{value:"all",get label(){return n("ui.projects.project_model.all_time")},phrase:null,seconds:null}],$r="7d",go=Lt.find(e=>e.value===$r);function zr(e){return Lt.find(s=>s.value===e)??go}function xo(e){return Lt.some(s=>s.value===e)}function $s(e,s,r){const a=zr(s);return a.seconds===null?e:e.filter(o=>r/1e3-o.updated_at<=a.seconds)}function bo(e){const s=zr(e);return s.seconds===null?null:n("ui.projects.project_model.nothing_changed_in_phrase",{phrase:String(s.phrase)})}const Gr="projects-board-window";function yo(){try{const e=localStorage.getItem(Gr);if(e!==null&&xo(e))return e}catch{}return $r}function zs(e){try{localStorage.setItem(Gr,e)}catch{}}const Yr="projects-board-column-order";let Xt=null;function vo(){if(Xt)return[...Xt];try{const e=localStorage.getItem(Yr);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const r=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];r.includes(a)||r.push(a)}return r}catch{return[]}}function ko(e){Xt=[...e];try{localStorage.setItem(Yr,JSON.stringify(e))}catch{}}function wo(e,s,r){const a=e.filter(i=>i!==s),o=Math.max(0,Math.min(r,a.length));return a.splice(o,0,s),a}function No(e,s=[]){const r=new Map;for(const c of e){const u=r.get(c.status)??[];u.push(c),r.set(c.status,u)}const a=Vt.map(c=>({status:c,projects:r.get(c)??[]}));for(const c of Qt){const u=r.get(c)??[];u.length>0&&a.push({status:c,projects:u})}for(const[c,u]of r)!Qt.includes(c)&&!Vt.includes(c)&&a.push({status:c,projects:u});if(s.length===0)return a;const o=new Map(s.map((c,u)=>[c,u])),i=a.filter(c=>o.has(c.status));i.sort((c,u)=>(o.get(c.status)??0)-(o.get(u.status)??0));const l=a.filter(c=>!o.has(c.status));return[...i,...l]}function Hr(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const r=ve(e.target_date);return r===null?!1:r<s}function ne(e){return e.title||e.name}Fe["ui.projects.project_model.no_team"];function ft(e){const s=e.team?.trim();if(s)return s;const r=e.owner?.trim();return r||null}function bs(e,s){const r=new Map,a=[];for(const i of e){const l=s(i);if(l===null){a.push(i);continue}const c=r.get(l);c?c.push(i):r.set(l,[i])}const o=[...r.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return a.length>0&&o.push({team:null,items:a}),o}function It(e){return e.title||e.session_id}function So(e){return[...e].reverse()}function Co(e){return e<=0?"":n("ui.projects.count.update",{count:e})}const Gs=e=>String(e).padStart(2,"0");function Jt(e){return`${e.getFullYear()}-${Gs(e.getMonth()+1)}-${Gs(e.getDate())}`}function Eo(e){const s=Date.parse(e);return Number.isNaN(s)?"":Jt(new Date(s))}function To(e,s,r=new Date){if(!e)return"";if(e===Jt(r))return n("ui.projects.project_model.today");const a=new Date(r.getFullYear(),r.getMonth(),r.getDate()-1);return e===Jt(a)?n("ui.projects.project_model.yesterday"):Oe(e,s,r)}function Ro(e,s){const r=Date.parse(e);return Number.isNaN(r)?"":Un(new Date(r),{hour:"numeric",minute:"2-digit"},s)}function Do(e,s){const r=Date.parse(e);return Number.isNaN(r)?"":mt(pt(r/1e3,s))}function Ao(e,s,r=Date.now()){const a=[],o=Fr(e.by);o&&a.push({key:"author",text:o});const i=Ro(e.at,s);i&&a.push({key:"time",text:i});const l=Do(e.at,r);return l&&a.push({key:"age",text:l}),a}function Oo(e,s,r=new Date){const a=[];for(const o of So(e)){const i=Eo(o.at),l=a[a.length-1];if(l&&l.key===i){l.entries.push(o);continue}a.push({key:i,label:To(i,s,r),entries:[o]})}return a}function Po(e){return!Number.isFinite(e)||e<0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function Mo(e,s){return s<=0?"":`${e} of ${s} complete`}function Lo(e){let s=0,r=0,a=!1;for(const o of e)o.todos&&(a=!0,s+=o.todos.open,r+=o.todos.total);return a?{open:s,total:r}:null}function Ys(e){return`${e.open} open of ${e.total}`}function Io(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Fo(e){const s=ne(e),r=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${r}`,"Review the project details and continue or complete the work."].join(`
|
|
22
|
-
`)}function qo(e){return e?e.kind==="team"?n("ui.projects.project_model.team_name",{name:String(e.name)}):n("ui.projects.project_model.agent_name",{name:String(e.name)}):""}const Uo=/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"/g;function Kr(e){const s=[];for(const r of e.matchAll(Uo))s.push((r[1]??r[2]??"").replace(/\\(.)/g,"$1"));return s}const bt=3;function ys(e){if(e.length<=bt+1)return e.length<=1?e.join(""):n("ui.projects.project_model.join_and_length_1",{join:String(e.slice(0,-1).join(", ")),length___1:String(e[e.length-1])});const s=e.length-bt;return n("ui.projects.project_model.join_and_hidden_more",{join:String(e.slice(0,bt).join(", ")),hidden:V(s,{useGrouping:!1})})}function vs(e){return n("ui.projects.count.milestones_are",{count:e})}const Hs="complete them, or pass force_done=true to close with them open",Bo="complete or remove the incomplete milestones, then mark it done",Wr=/^cannot set status 'done': (\d+) milestones? still incomplete \((.+)\) — /;function _t(e){const s=e.match(Wr);if(s){const r=Number(s[1]),a=Kr(s[2]),o=a.length>0?ys(a):s[2];return n("ui.projects.project_model.this_can_t_be_marked_done_yet_milestonesare_count_still_incomplet",{milestonesAre_count:String(vs(r)),clause:String(o)})}return e.includes(Hs)?e.replace(Hs,Bo):e}const $o="project_done_incomplete";function zo(e){const s=e.message.match(Wr),r=e.code===$o;if(!r&&!s)return null;const a=typeof e.detail=="object"&&e.detail!==null&&Array.isArray(e.detail.incomplete)?e.detail.incomplete.filter(l=>typeof l=="string"):null,o=a&&a.length>0?a:s?Kr(s[2]):[];return{count:o.length>0?o.length:s?Number(s[1]):0,names:o,coded:r,message:e.message}}function Go(e){if(e.count>0){const s=ys(e.names);return n("ui.projects.project_model.count_still_open_clause_clause",{count:String(vs(e.count)),clause________clause:String(s?n("ui.projects.project_model.clause",{clause:String(s)}):"")})}return _t(e.message)||n("ui.projects.project_model.some_milestones_are_still_open")}function Yo(e){return e.count>0&&e.names.length>0?n("ui.projects.project_model.this_can_t_be_marked_done_yet_count_still_incomplete_names_comple",{count:String(vs(e.count)),names:String(ys(e.names))}):_t(e.message)||n("ui.projects.project_model.milestones_are_still_open_on_this_project_complete_or_remove_them")}function Vr(e,s,r){if(!e||e.forced_done!==!0)return n("ui.projects.project_model.moved_to_statuslabel",{statusLabel:String(r)});const a=typeof e.milestones_total=="number"&&typeof e.milestones_completed=="number"?e.milestones_total-e.milestones_completed:s,o=a>0?a:s;return n("ui.projects.count.moved_open",{status:r,open:o})}Fe["ui.projects.project_model.the_project_was_not_moved_try_again_or_open_it_to_change_its_stat"];function Qr(e){return e.trim().slice(0,La)}const Ho={get client(){return n("ui.projects.project_search.searches_names_descriptions_tags_owners_and_teams_update_text_is")},get backend(){return n("ui.projects.project_search.searches_names_descriptions_tags_owners_teams_and_update_text_cle")}},Ko=2,Wo=4,Vo=3,Qo=2,Xo=1,Jo=3,Me={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},Zo=/[^\p{L}\p{N}]+/u,ei=/\s+/;function Ks(e,s){const r=s.trim().toLowerCase();if(!r)return 0;if(r===e)return Wo;if(r.startsWith(e))return Vo;const a=r.split(Zo).filter(Boolean),o=e.split(ei).filter(Boolean);if(o.length>0&&o.every(l=>a.some(c=>c.startsWith(l))))return Qo;const i=o.join("");return i.length>=Jo&&ti(i,r)?Xo:0}function ti(e,s){let r=0;for(const a of e){if(r=s.indexOf(a,r),r<0)return!1;r+=1}return!0}function si(e,s){const r=s.trim().toLowerCase();if(!r)return 0;const a=[[e.title,Me.title],[e.name,Me.name],[e.description,Me.description],[e.owner,Me.attribution],[e.team,Me.attribution],[e.status,Me.status]];let o=0;for(const[i,l]of a){if(!i)continue;const c=Ks(r,i)*l;c>o&&(o=c)}for(const i of e.tags){const l=Ks(r,i)*Me.tags;l>o&&(o=l)}return o}function ri(e,s){const r=s.trim();if(!r)return e;const a=[];for(const o of e){const i=si(o,r);i>0&&a.push({project:o,score:i})}return a.sort((o,i)=>{if(o.score!==i.score)return i.score-o.score;if(o.project.updated_at!==i.project.updated_at)return i.project.updated_at-o.project.updated_at;const l=ne(o.project).localeCompare(ne(i.project),void 0,{sensitivity:"base"});if(l!==0)return l;const c=o.project.name.localeCompare(i.project.name,void 0,{sensitivity:"base"});return c!==0?c:o.project.id<i.project.id?-1:o.project.id>i.project.id?1:0}),a.map(o=>o.project)}function ni(e,s){if(s.length===0)return[];const r=new Map(e.map(o=>[o.id,o])),a=[];for(const o of s){const i=r.get(o.id);i!==void 0&&a.push(i)}return a}const ai=180;function oi(e,s){const r=Qr(e),a=Tr(r,ai),o=us({queryKey:["desktop","projects","search",a],enabled:s&&a.length>0,queryFn:()=>_e({op:"projects.search",q:a,limit:Ia}),retry:!1,staleTime:3e4}),i=a===r,l=i&&o.data&&o.data.query===r?o.data:null,c=i&&r.length>0&&!l&&o.isError;return{answer:l,pending:s&&r.length>0&&!l&&!c}}const et=["status","team","owner","tags","progress","target","estimate","milestones","live"],Ws={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},ot={get status(){return n("ui.projects.project_filters.status")},get team(){return n("ui.projects.project_filters.team")},get owner(){return n("ui.projects.project_filters.owner")},get tags(){return n("ui.projects.project_filters.tags")},get progress(){return n("ui.projects.project_filters.progress")},get target(){return n("ui.projects.project_filters.target_date")},get estimate(){return n("ui.projects.project_filters.estimate")},get milestones(){return n("ui.projects.project_filters.milestones")},get live(){return n("ui.projects.project_filters.live_sessions")}},ii=new Set(["status","progress","target","estimate","milestones","live"]),ci={progress:["stale","up-to-date","not-reported"],target:["none","overdue","within-7","within-30"],estimate:["none","points","days"],milestones:["none","incomplete","complete"],live:["has-live","no-live"]},li={get stale(){return n("ui.projects.project_filters.stale")},get"up-to-date"(){return n("ui.projects.project_filters.up_to_date")},get"not-reported"(){return n("ui.projects.project_filters.not_reported")},get none(){return n("ui.projects.project_filters.no_target_date")},get overdue(){return n("ui.projects.project_filters.overdue")},get"within-7"(){return n("ui.projects.project_filters.due_within_7_days")},get"within-30"(){return n("ui.projects.project_filters.due_within_30_days")},get points(){return n("ui.projects.project_filters.points")},get days(){return n("ui.projects.project_filters.days")},get incomplete(){return n("ui.projects.project_filters.incomplete")},get complete(){return n("ui.projects.project_filters.complete")},get"has-live"(){return n("ui.projects.project_filters.has_live_sessions")},get"no-live"(){return n("ui.projects.project_filters.no_live_sessions")}};function Xr(e,s){switch(e){case"status":return ae(s).label;case"team":return s===null?n("ui.projects.project_filters.no_team"):s;case"owner":return s===null?n("ui.projects.project_filters.no_owner"):s;case"tags":return s??"";case"estimate":if(s==="none")return n("ui.projects.project_filters.no_estimate");break;case"milestones":if(s==="none")return n("ui.projects.project_filters.none_set");break;case"target":if(s==="none")return n("ui.projects.project_filters.no_target_date");break}return li[s]??s??""}function ui(e,s){return e[s].length>0}function ct(e){return et.every(s=>!ui(e,s))}function di(e){return et.reduce((s,r)=>s+e[r].length,0)}function Jr(e,s,r){const a=e[s],o=a.includes(r)?a.filter(i=>i!==r):[...a,r];return{...e,[s]:o}}function Zr(e,s,r,a){switch(e){case"status":return s.status===r;case"team":return ft(s)===r;case"owner":return(s.owner?.trim()||null)===r;case"tags":return s.tags.includes(r??"");case"progress":return r==="stale"?s.progress_stale===!0:r==="up-to-date"?s.progress_stale===!1:s.progress_updated_at===null;case"target":{if(r==="none")return ve(s.target_date)===null;if(r==="overdue")return Hr(s,a);const o=ve(s.target_date);if(o===null)return!1;const i=(o-a)/Ye;return r==="within-7"?i>=0&&i<=7:i>=0&&i<=30}case"estimate":return r==="none"?s.estimate===null:s.estimate===null?!1:r==="points"?s.estimate_unit==="points":s.estimate_unit==="days";case"milestones":return r==="none"?s.milestones_total===0:s.milestones_total===0?!1:r==="complete"?s.milestones_completed>=s.milestones_total:s.milestones_completed<s.milestones_total;case"live":return r==="has-live"?s.live_sessions>0:s.live_sessions===0}}function en(e,s,r,a){const o=e[s];return o.length===0?!0:o.some(i=>Zr(s,r,i,a))}function pi(e,s,r){return ct(s)?e:e.filter(a=>et.every(o=>en(s,o,a,r)))}function mi(e,s,r,a){return s.filter(o=>et.every(i=>i===e||en(r,i,o,a)))}function fi(e,s,r){const a=r[e];switch(e){case"status":{const i=[...new Set(s.map(c=>c.status))].filter(c=>!Ge.includes(c)).sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"})),l=a.filter(c=>typeof c=="string"&&!Ge.includes(c)&&!i.includes(c));return[...Ge,...i,...l]}case"team":{const o=new Set;let i=!1;for(const c of s){const u=ft(c);u===null?i=!0:o.add(u)}for(const c of a)c===null?i=!0:o.add(c);const l=[...o].sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"owner":{const o=new Set;let i=!1;for(const c of s){const u=c.owner?.trim();u?o.add(u):i=!0}for(const c of a)c===null?i=!0:o.add(c);const l=[...o].sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"tags":{const o=new Set;for(const i of s)for(const l of i.tags)o.add(l);for(const i of a)o.add(i??"");return[...o].sort((i,l)=>i.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return ci[e]}}function tn(e,s,r,a){const o=mi(e,s,r,a),i=ii.has(e),l=[];for(const c of fi(e,o,r)){const u=r[e].includes(c),m=o.reduce((p,_)=>p+(Zr(e,_,c,a)?1:0),0);!i&&m===0&&!u||l.push({value:c,label:Xr(e,c),count:m,selected:u})}return{facet:e,label:ot[e],options:l}}function _i(e,s,r){return et.map(a=>tn(a,e,s,r))}const Zt="projects-sort";Fe["ui.projects.project_sort.default_as_listed"];function ji(e){return hi.includes(e)}const hi=["name","status","target","estimate","milestones","live","progress"];function gi(){try{const e=localStorage.getItem(Zt);if(e===null)return null;const[s,r,...a]=e.split(":");if(a.length>0)return null;if(s&&ji(s)&&(r==="asc"||r==="desc"))return{key:s,direction:r}}catch{}return null}function xi(e){try{e===null?localStorage.removeItem(Zt):localStorage.setItem(Zt,`${e.key}:${e.direction}`)}catch{}}function Je(e){switch(e){case"name":return n("ui.projects.project_sort.project");case"status":return n("ui.projects.project_sort.status");case"target":return n("ui.projects.project_sort.target");case"estimate":return n("ui.projects.project_sort.estimate");case"milestones":return n("ui.projects.project_sort.milestones");case"live":return n("ui.projects.project_sort.live");case"progress":return n("ui.projects.project_sort.progress")}}function Bt(e){return e==="target"||e==="progress"?"desc":"asc"}function ks(e,s){const r=s==="desc";switch(e){case"name":return r?n("ui.projects.project_sort.z_to_a"):n("ui.projects.project_sort.a_to_z");case"status":return r?n("ui.projects.project_sort.archived_first"):n("ui.projects.project_sort.planning_first");case"target":return r?n("ui.projects.project_sort.latest_first"):n("ui.projects.project_sort.soonest_first");case"estimate":return r?n("ui.projects.project_sort.days_first"):n("ui.projects.project_sort.points_first");case"milestones":return r?n("ui.projects.project_sort.most_complete_first"):n("ui.projects.project_sort.least_complete_first");case"live":return r?n("ui.projects.project_sort.most_first"):n("ui.projects.project_sort.fewest_first");case"progress":return r?n("ui.projects.project_sort.most_recent_first"):n("ui.projects.project_sort.most_stale_first")}}function bi(e){return e===null?n("ui.projects.project_sort.sort_cleared"):n("ui.projects.project_sort.sorted_by_key_direction",{key:String(Je(e.key)),direction:String(ks(e.key,e.direction))})}function yi(e){const s=[e.search?"search":null,e.filters?"filters":null,e.sort?"sort":null].filter(a=>a!==null);if(s.length===0)return"";const r=s.length===1?n("ui.projects.project_sort.parts_0_cleared",{parts_0:String(s[0])}):n("ui.projects.project_sort.join_and_length_1_cleared",{join:String(s.slice(0,-1).join(", ")),length___1:String(s[s.length-1])});return r.charAt(0).toUpperCase()+r.slice(1)}function Vs(e,s){switch(e){case"name":return 0;case"status":return Ge.includes(s.status)?0:1;case"target":return es(s)===null?1:0;case"estimate":return s.estimate===null?1:0;case"milestones":return s.milestones_total===0?1:0;case"live":return 0;case"progress":return s.progress_updated_at===null?1:0}}function es(e){return ve(e.completed_at??e.target_date)}function Qs(e){return e==="points"?0:e==="days"?1:2}function vi(e,s,r){switch(e){case"name":return ne(s).localeCompare(ne(r),void 0,{sensitivity:"base"});case"status":return Ge.indexOf(s.status)-Ge.indexOf(r.status);case"target":{const a=es(s)??0,o=es(r)??0;return a-o}case"estimate":{const a=Qs(s.estimate_unit)-Qs(r.estimate_unit);return a!==0?a:(s.estimate??0)-(r.estimate??0)}case"milestones":return s.milestones_completed*r.milestones_total-r.milestones_completed*s.milestones_total;case"live":return s.live_sessions-r.live_sessions;case"progress":return(s.progress_updated_at??0)-(r.progress_updated_at??0)}}function Xs(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const r=ne(e).localeCompare(ne(s),void 0,{sensitivity:"base"});if(r!==0)return r;const a=e.name.localeCompare(s.name,void 0,{sensitivity:"base"});return a!==0?a:e.id<s.id?-1:e.id>s.id?1:0}function ki(e,s,r){const a=Vs(r.key,e),o=Vs(r.key,s);if(a!==o)return a-o;if(a===1)return Xs(e,s);const i=vi(r.key,e,s);return i!==0?r.direction==="desc"?-i:i:Xs(e,s)}function wi(e,s){return[...e].sort((r,a)=>ki(r,a,s))}const De=["day","week","month","quarter"],ws={day:24,week:9,month:3,quarter:1};function Ns(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function Le(e,s){return Math.round((s-e)/Ye)}function Js(e,s){return Le(e,s)+1}function Ni(e,s){for(const r of De)if(e*ws[r]<=s)return r;return De[De.length-1]}function Si(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(r=>!!r.target_date)}function Ci(e,s){const r=[s];for(const a of e){for(const o of[a.project.start_date,a.project.target_date,a.project.completed_at]){const i=ve(o);i!==null&&r.push(i)}for(const o of a.milestones){const i=ve(o.target_date);i!==null&&r.push(i)}}return r.length===1?null:{startMs:Math.min(...r),endMs:Math.max(...r)}}function Ei(e){const s=[],r=[];for(const a of e)(Si(a)?s:r).push(a);return{dated:s,undated:r}}function Ti(e){return n("ui.projects.count.undated",{count:e})}function Ri(e){const{project:s}=e,r=ve(s.start_date),a=ve(s.target_date),o=ve(s.completed_at),i=s.status==="done"&&o!==null?o:a,l=r??i,c=i??r;return l===null||c===null?null:{fromMs:Math.min(l,c),toMs:Math.max(l,c)}}function Di(e){const s=[];for(const r of e.milestones){const a=ve(r.target_date);a!==null&&s.push({name:r.name,dayMs:a,status:r.status})}return s}const $t=e=>yt(new Date(e),{month:"short",timeZone:"UTC"});function he(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function Ai(e){const{year:s,month:r}=he(e);return Date.UTC(s,r-1,1)}function Oi(e){const{year:s,month:r}=he(e);return r===12?Date.UTC(s+1,0,1):Date.UTC(s,r,1)}function Pi(e){const{year:s,month:r}=he(e);return Date.UTC(s,Math.floor((r-1)/3)*3,1)}function Mi(e){const{year:s,month:r}=he(e),a=Math.floor((r-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function Li(e){const{weekday:s}=he(e);return e-(s+6)%7*Ye}const Ii=26;function Fi(e,s,r){const a=[],o=(p,_,b)=>{p<e||p>s||a.push({dayMs:p,label:_,major:b})};if(r==="day"){let p=!1;for(let _=e;_<=s;_+=Ye){const{day:b}=he(_);b===1?(o(_,$t(_),!0),p=!0):p?(o(_,"",!1),p=!1):o(_,V(b,{useGrouping:!1}),!1)}return a}if(r==="week"){for(let p=Li(e);p<=s;p+=7*Ye){if(p<e)continue;const{day:_,month:b}=he(p);he(p-7*Ye).month!==b?o(p,yt(new Date(p),{month:"short",day:"numeric",timeZone:"UTC"}),!0):o(p,V(_,{useGrouping:!1}),!1)}return a}const i=r==="month"?Ai:Pi,l=r==="month"?Oi:Mi,c=p=>{const{year:_,month:b}=he(p);if(r==="month")return b===1&&_!==he(e).year?`${$t(p)} '${V(_%100,{minimumIntegerDigits:2,useGrouping:!1})}`:$t(p);const f=Math.floor((b-1)/3)+1;return f===1&&_!==he(e).year?`Q1 '${String(_%100).padStart(2,"0")}`:`Q${f}`};o(e,c(i(e)),!0);const u=Math.ceil(Ii/ws[r]);let m=e;for(let p=l(i(e));p<=s;p=l(p))Le(m,p)<u||(o(p,c(p),!0),m=p);return a}function lt(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}const wt=80,Nt=80,Zs=64,er=8;function ts(e){return e.trim().length>wt?n("ui.projects.project_edit_model.titles_are_at_most_value1_characters",{value1:wt}):null}function sn(e){return e.length>Xe?n("ui.projects.project_edit_model.keep_the_description_within_value1_characters",{value1:Xe}):null}function St(e,s){return e.trim().length>Nt?n("ui.projects.project_edit_model.teams_are_at_most_value2_characters",{teams:String(s==="owner"?n("ui.projects.project_edit_model.owners"):n("ui.projects.project_edit_model.teams")),value2:Nt}):null}function ss(e){return Ir.test(e)?null:n("ui.projects.project_edit_model.dates_are_yyyy_mm_dd_or_empty")}function rs(e,s){return e&&s&&s<e?n("ui.projects.project_edit_model.the_target_date_is_before_the_start_date"):null}function rn(e){const s=e.trim();if(s==="")return null;const r=Number(s);return!Number.isFinite(r)||!(r>0)||r>1e3?n("ui.projects.project_edit_model.estimates_are_greater_than_0_and_at_most_1000"):null}function ns(e){const s=lt(e);if(s.length>er)return{tags:s,error:n("ui.projects.project_edit_model.up_to_project_tags_max_tags",{PROJECT_TAGS_MAX:er})};for(const r of s){const a=Fa(r);if(a)return{tags:s,error:a}}return{tags:s,error:null}}const qi="project_name_exists";function tr(e){return e.code===qi?n("ui.projects.project_edit_model.a_project_with_this_key_already_exists"):_t(e.message)||n("ui.projects.project_edit_model.the_project_was_not_saved")}function Ui(e,s){if(e.unit!==s.unit)return!1;const r=e.number.trim(),a=s.number.trim();return a===""?!0:r===""?!1:Number(r)===Number(a)}function Bi(e,s){const r=lt(s);return r.length!==e.length?!1:r.every((a,o)=>a===e[o])}function $i(e,s){const r={},a=s.number.trim();if(a!==""){const o=Number(a);(e.estimate===null||e.estimate!==o)&&(r.estimate=o)}return s.unit!==e.unit&&(r.estimate_unit=s.unit),Object.keys(r).length>0?r:null}function tt(e){return e instanceof Rt?tr({code:e.code,message:e.message}):tr({message:e instanceof Error?e.message:""})}function nn(e){return e instanceof Rt&&(e.code==="project_not_found"||e.status===404)}function an(e){return!(e instanceof Error)||!e.message?n("ui.projects.project_model.the_project_was_not_moved_try_again_or_open_it_to_change_its_stat"):nn(e)?n("ui.projects.project_refusals.this_project_could_not_be_found_it_may_have_been_deleted"):tt(e)}function on(e){if(!(e instanceof Error))return null;const s=e instanceof Rt?e:null;return zo({code:s?.code??null,message:e.message,detail:s?.detail})}async function zi(e){try{return await e.move(),{kind:"accepted"}}catch(s){const r=on(s);return r?.coded&&e.forceDoneOffered&&e.claimQuestion()?{kind:"question",refusal:r}:{kind:"spoken",copy:r?Yo(r):an(s),refusal:r}}}Fe["ui.projects.board_window_select.shows_projects_last_updated_within_this_window_older_ones_are_hid"];const Gi=({value:e,onChange:s})=>(F(),t.jsxs(Ke,{value:e,onValueChange:r=>s(r),children:[t.jsx(Ot,{content:e==="all"?null:n("ui.projects.board_window_select.shows_projects_last_updated_within_this_window_older_ones_are_hid"),side:"bottom",disableHoverableContent:!0,children:t.jsx(We,{"aria-label":n("ui.projects.board_window_select.projects_updated_within"),className:M("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(Ve,{})})}),t.jsx(Qe,{children:Lt.map(r=>t.jsx(Ae,{value:r.value,children:r.label},r.value))})]})),as=6e4,os=6e3;Fe["ui.projects.request_update.requesting_updates"];const Yi=400;Fe["ui.projects.request_update.ask_the_sessions_linked_to_this_project_to_post_a_progress_update"];const Hi="linked but not yet in use — it becomes a recipient after the first message",sr=e=>`project-request-update-${e}`,Ki=e=>`project-request-cooldown-${e}`,Wi=e=>`project-request-update-cooldown-${e}`,zt=e=>e.length===1?e[0]:e.length===2?n("ui.projects.request_update.names_0_and_names_1",{names_0:String(e[0]),names_1:String(e[1])}):n("ui.projects.request_update.names_0_names_1_and_length_2_more",{names_0:String(e[0]),names_1:String(e[1]),length___2:V(e.length-2,{useGrouping:!1})}),rr=(e,s)=>e.sessions.filter(r=>r.outcome===s).map(r=>It({session_id:r.session_id,title:r.title})),Vi=e=>e.outcome==="failed"&&e.detail===Hi;function Ct(e,s){const r=Math.max(1,Math.ceil(s/1e3)),a=Math.max(0,Math.ceil(as/1e3)-r);return n("ui.projects.request_update.update_already_requested_ago_s_ago_on_display_try_again_in_left_s",{ago:V(a,{useGrouping:!1}),display:String(e),left:V(r,{useGrouping:!1})})}function Qi(e){const s=ne({title:e.project.title,name:e.project.key}),{delivered:r,unconfirmed:a,failed:o,total:i}=e.counts;if(e.state==="empty")return{variant:"info",title:n("ui.projects.request_update.no_linked_sessions_to_ask_link_a_session_to_display_first",{display:String(s)}),duration:os};if(e.state==="cooldown")return{variant:"info",title:Ct(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:os};if(e.state!=="sent")return null;const l=rr(e,"failed"),c=rr(e,"unconfirmed");if(r>=1&&o===0&&a===0)return{variant:"success",title:n("ui.projects.request_update.delivered",{delivered:r,display:s})};if(r>=1){let u=n("ui.projects.request_update.requested_updates_from_delivered_of_total_sessions_on_display",{delivered:V(r,{useGrouping:!1}),total:i,display:String(s)});return o>0&&(u+=n("ui.projects.request_update.value1_could_not_be_reached",{value1:String(zt(l))})),a>0&&(u+=n("ui.projects.request_update.delivery_to_value1_could_not_be_confirmed",{value1:String(zt(c))})),{variant:"warning",title:u,duration:Number.POSITIVE_INFINITY}}if(o===0)return{variant:"warning",title:n("ui.projects.request_update.could_not_confirm_delivery_on_display_the_requests_may_still_reac",{display:String(s)}),duration:Number.POSITIVE_INFINITY};if(a===0){const u=e.sessions.every(Vi);let m;return u?m=n("ui.projects.request_update.never_started",{total:i}):m=n("ui.projects.request_update.could_not_reach_any_of_the_total_linked_sessions_on_display",{total:i,display:String(s)}),{variant:"error",title:m,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:n("ui.projects.request_update.could_not_reach_failed_of_the_total_linked_sessions_on_display_de",{failed:V(o,{useGrouping:!1}),total:i,display:String(s),value4:String(zt(c))}),duration:Number.POSITIVE_INFINITY}}const at=new Map,Ss=new Set,Gt=new Map,is=new Set;let cn=0;const Et=()=>{cn+=1;for(const e of is)e()},Xi=e=>(is.add(e),()=>{is.delete(e)}),nr=()=>cn,ln=e=>Ss.has(e),un=e=>at.get(e);function Ji(e){Ss.add(e),Et()}function Zi(e){Ss.delete(e),Et()}function ar(e,s,r){const a=Date.now();if(r<=a)return;const o=at.get(e);if(o&&o.untilMs>=r)return;at.set(e,{startedMs:s,untilMs:r});const i=Gt.get(e);i&&clearTimeout(i);const l=setTimeout(()=>{Gt.delete(e);const c=at.get(e);c&&c.untilMs<=Date.now()&&(at.delete(e),Et())},r-a);l.unref?.(),Gt.set(e,l),Et()}const ec=e=>/[.!?…]$/.test(e)?e:`${e}.`;function tc(e,s){const r=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;ar(e,r-(as-a),r+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&ar(e,r,r+as)}async function sc(e){const s=e.id;if(ln(s)){Ps(n("ui.projects.request_update.requesting_updates"),{id:sr(s)});return}const r=Date.now(),a=un(s);if(a&&a.untilMs>r){Ms(Ct(ne(e),a.untilMs-r),{id:Ki(s),duration:os});return}Ji(s);const o=sr(s);let i=!1;const l=setTimeout(()=>{i=!0,Ps(n("ui.projects.request_update.requesting_updates"),{id:o})},Yi);try{const c=await _e({op:"projects.request_update",key:s});tc(s,c);const u=Qi(c);if(u){const m={id:o,...u.duration!==void 0?{duration:u.duration}:{}};switch(u.variant){case"success":be(u.title,m);break;case"warning":Bn(u.title,m);break;case"error":Ls(u.title,m);break;default:Ms(u.title,m)}}else i&&$n(o)}catch(c){const u=c instanceof Error&&c.message.trim()!==""?c.message.trim():null;Ls(u?n("ui.projects.use_request_update.could_not_request_updates_endedsentence_message",{endedSentence_message:String(ec(u))}):n("ui.projects.use_request_update.the_request_could_not_be_confirmed"),{id:o,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),Zi(s)}}function dn(){return d.useCallback(e=>{sc(e)},[])}function rc(e){d.useSyncExternalStore(Xi,nr,nr);const s=ln(e),r=un(e),a=r!==void 0?r.untilMs-Date.now():0,o=a>0;return{sending:s,cooling:o,cooldownRemainingMs:o?a:null}}const or={get active(){return n("ui.projects.project_board.in_flight")},get paused(){return n("ui.projects.project_board.on_hold")},get done(){return n("ui.projects.project_board.finished")}};function nc(){const[e,s]=d.useState(null);return d.useEffect(()=>{if(!e)return;const r=document.querySelector(`[data-project-menu="${e}"]`);r&&(r.focus(),s(null))}),d.useCallback(r=>s(r),[])}const ac=4,ir="board-column-move-hint",oc=({projects:e,nowMs:s,onOpen:r,onEdit:a,onDelete:o,onMove:i,movingKeys:l=[],teamLabelFor:c=u=>u})=>{F();const[u,m]=d.useState(vo),p=No(e,u),_=bs(e,ft),[b,f]=d.useState(null),[x,w]=d.useState(""),g=d.useRef(null),h=d.useRef(null),v=d.useRef(null);d.useEffect(()=>{const y=g.current,k=h.current;if(!y||!k)return;const O=k.firstElementChild;let L=-1;const U=()=>{const z=k.offsetWidth-k.clientWidth;z!==L&&(L=z,y.style.paddingRight=z>0?`${z}px`:"")};let H=-1;const Q=()=>{const z=k.scrollLeft;Math.abs(y.scrollLeft-z)>.5&&(y.scrollLeft=z),H=z},$=()=>{Math.abs(y.scrollLeft-H)<=.5||(Math.abs(k.scrollLeft-y.scrollLeft)>.5&&(k.scrollLeft=y.scrollLeft),H=y.scrollLeft)},je=z=>{const se=z.deltaMode===1?16:z.deltaMode===2?k.clientWidth:1,xe=z.deltaMode===1?16:z.deltaMode===2?k.clientHeight:1;Math.abs(z.deltaX)>Math.abs(z.deltaY)?k.scrollLeft+=z.deltaX*se:k.scrollTop+=z.deltaY*xe,z.preventDefault()};U(),Q(),y.addEventListener("wheel",je,{passive:!1}),y.addEventListener("scroll",$,{passive:!0}),k.addEventListener("scroll",Q,{passive:!0});const ie=new ResizeObserver(()=>{U(),Q()});return ie.observe(k),O&&ie.observe(O),window.addEventListener("resize",U),()=>{y.removeEventListener("wheel",je),y.removeEventListener("scroll",$),k.removeEventListener("scroll",Q),ie.disconnect(),window.removeEventListener("resize",U)}},[]);const T=d.useRef(null),N=d.useRef(null),q=d.useRef(null),C=new Set(l),E=(y,k)=>{const O=wo(p.map(L=>L.status),y,k);m(O),ko(O),w(n("ui.projects.project_board.moved_label_column_to_position_indexof_status_1_of_length",{label:String(ae(y).label),indexOf_status____1:String(O.indexOf(y)+1),length:V(O.length,{useGrouping:!1})}))},P=(y,k)=>{const O=g.current;if(!O)return 0;let L=0;const U=O.querySelectorAll("[data-board-column]");for(const H of U){if(H.dataset.boardColumn===k)continue;const Q=H.getBoundingClientRect();y>(Q.left+Q.right)/2&&(L+=1)}return L},j=(y,k)=>{const O=p.filter(H=>H.status!==y),L=O[k-1]?.status,U=O[k]?.status;return L&&U?n("ui.projects.project_board.between_label_and_label_2",{label:String(ae(L).label),label_2:String(ae(U).label)}):U?n("ui.projects.project_board.before_label",{label:String(ae(U).label)}):L?n("ui.projects.project_board.after_label",{label:String(ae(L).label)}):n("ui.projects.project_board.in_place")},D=(y,k)=>{const O=P(y,k.status);O!==k.over&&(k.over=O,f({status:k.status,over:O}),w(n("ui.projects.project_board.moving_label_column_it_will_drop_status_over",{label:String(ae(k.status).label),status__over:String(j(k.status,O))})))},R=()=>{N.current!==null&&(cancelAnimationFrame(N.current),N.current=null)},I=32,K=12,B=()=>{N.current=null;const y=q.current,k=h.current,O=T.current;if(!y?.armed||!k||O===null)return;const L=k.getBoundingClientRect(),U=k.scrollWidth-k.clientWidth;let H=0;if(O-L.left<I&&k.scrollLeft>0?H=-1:L.right-O<I&&k.scrollLeft<U&&(H=1),H!==0){const Q=k.scrollLeft;if(k.scrollLeft=Q+H*K,k.scrollLeft!==Q){const $=g.current;$&&($.scrollLeft=k.scrollLeft),D(O,y)}}else D(O,y);ee(y.status,y.over),N.current=requestAnimationFrame(B)};d.useEffect(()=>()=>{N.current!==null&&cancelAnimationFrame(N.current)},[]);const Y=(y,k)=>{if(y.button===0){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}q.current={pointerId:y.pointerId,status:k,startX:y.clientX,startY:y.clientY,armed:!1,over:p.findIndex(O=>O.status===k)},T.current=y.clientX}},X=y=>{const k=q.current;if(!(!k||y.pointerId!==k.pointerId)){if(T.current=y.clientX,!k.armed){if(Math.hypot(y.clientX-k.startX,y.clientY-k.startY)<ac)return;k.armed=!0,f({status:k.status,over:k.over}),w(n("ui.projects.project_board.moving_label_column",{label:String(ae(k.status).label)})),N.current===null&&(N.current=requestAnimationFrame(B))}D(y.clientX,k)}},Z=y=>{const k=q.current;if(q.current=null,R(),f(null),!k?.armed)return;if(!y){w(n("ui.projects.project_board.move_cancelled"));return}const O=p.findIndex(L=>L.status===k.status);if(k.over===O){w("");return}E(k.status,k.over)},me=y=>{const k=q.current;!k||y.pointerId!==k.pointerId||Z(!0)},oe=()=>{Z(!1)};d.useEffect(()=>{if(!b)return;const y=k=>{k.key==="Escape"&&Z(!1)};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[b!==null]);const ee=d.useCallback((y,k)=>{const O=g.current,L=h.current,U=v.current;if(!O||!L||!U)return;const H=L.getBoundingClientRect(),Q=[];for(const re of O.querySelectorAll("[data-board-column]"))re.dataset.boardColumn!==y&&Q.push(re.getBoundingClientRect());const $=6,je=k>=Q.length?(Q[Q.length-1]?.right??H.left)+$:(Q[k]?.left??H.right)-$,ie=L.scrollLeft,z=2,se=je-H.left+ie,xe=ie+1,fe=ie+L.clientWidth-z-1,Pe=Math.round(Math.min(Math.max(se,xe),Math.max(xe,fe)));U.style.left=`${Pe}px`},[]);d.useLayoutEffect(()=>{b&&ee(b.status,b.over)},[b,ee]);const te=(y,k)=>{if(y.key==="Enter"||y.key===" "){y.preventDefault(),w(n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column"));return}if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const O=p.map(H=>H.status),L=O.indexOf(k),U=y.key==="ArrowLeft"?L-1:L+1;if(U<0||U>=O.length){w(n("ui.projects.project_board.label_column_is_already_the_last_column",{label:String(ae(k).label),the_last_column:String(U<0?n("ui.projects.project_board.the_first_column"):n("ui.projects.project_board.the_last_column"))}));return}E(k,U)};return t.jsxs("div",{className:M("[container-type:size] flex min-h-0 flex-1 flex-col",b&&"cursor-grabbing select-none"),"data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:x}),t.jsx("span",{id:ir,className:"sr-only",children:n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column")}),t.jsx("div",{ref:g,"data-board-header-viewport":"",className:"h-11 shrink-0 overflow-hidden",children:t.jsx("div",{"data-board-column-row":"",className:"flex h-11 w-max gap-3 px-6",children:p.map(y=>{const k=ae(y.status);return t.jsxs("header",{"data-board-column":y.status,"data-board-column-handle":y.status,onPointerDown:O=>Y(O,y.status),onPointerMove:X,onPointerUp:me,onPointerCancel:oe,className:M("flex h-11 w-64 shrink-0 cursor-grab items-center justify-between gap-2 rounded-t-md bg-sunken px-3 active:cursor-grabbing",b?.status===y.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(G,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":y.status,"aria-label":n("ui.projects.project_board.move_label_column",{label:String(k.label)}),"aria-describedby":ir,title:n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column"),className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:O=>te(O,y.status),children:t.jsx(Da,{"aria-hidden":"true"})}),t.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[t.jsx("span",{className:"truncate text-body-sm font-medium text-ink",children:k.label}),or[y.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:or[y.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:y.projects.length})]},y.status)})})}),t.jsxs("div",{ref:h,"data-board-strip":"",className:"relative min-h-0 flex-1 overflow-auto px-6 pb-9",children:[b&&t.jsx("div",{ref:v,"aria-hidden":"true","data-board-drop-indicator":"",className:"pointer-events-none absolute top-3 bottom-3 w-0.5 rounded-full bg-accent"}),t.jsx("div",{className:"flex w-max flex-col",children:_.map(y=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":y.team??"",className:"sticky top-0 z-20 flex h-8 items-center bg-canvas px-3 text-meta",children:t.jsxs("span",{className:"sticky left-3 flex min-w-0 max-w-[calc(100cqw-2.25rem)] items-center gap-2",children:[t.jsx("span",{className:"truncate text-ink",children:y.team==null?n("ui.projects.project_model.no_team"):c(y.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:y.items.length})]})}),t.jsx("div",{"data-glass-lane":"",className:"flex gap-3 rounded-md bg-sunken py-2",children:p.map(k=>{const O=y.items.filter(L=>L.status===k.status);return t.jsx("div",{"data-board-cell":k.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:O.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:O.map(L=>t.jsx("li",{children:t.jsx(ic,{project:L,nowMs:s,busy:C.has(L.id),onOpen:()=>r(L),onEdit:()=>a(L),onDelete:()=>o(L),onMove:U=>i(L,U)})},L.id))})},k.status)})})]},y.team??""))})]})]})},ic=({project:e,nowMs:s,busy:r,onOpen:a,onEdit:o,onDelete:i,onMove:l})=>{const c=F(),u=Br(e,c),m=Ze(),p=dn(),_=ye(m.data,"projects_request_update"),b=ne(e),f=d.useRef(null),[x,w]=d.useState(!1);d.useEffect(()=>{const N=f.current;if(!N)return;const q=()=>{N.isConnected&&w(N.scrollWidth-N.clientWidth>.5)},C=requestAnimationFrame(q),E=new ResizeObserver(q);return E.observe(N),document.fonts?.ready.then(q).catch(()=>{}),()=>{cancelAnimationFrame(C),E.disconnect()}},[b,x]);const g=Hr(e,Ns(s)),h=pt(e.progress_updated_at,s),v=()=>{const N=window.getSelection();N&&!N.isCollapsed||a()},T=N=>{N.key!=="Enter"&&N.key!==" "||N.target===N.currentTarget&&(N.preventDefault(),a())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":n("ui.projects.project_board.open_displayname",{displayName:String(b)}),onClick:v,onKeyDown:T,"data-glass-block":"",className:M("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",g&&"border border-warning-border"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx(Ot,{content:x?b:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:f,"data-project-title":e.name,tabIndex:x?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:b})}),e.title&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.name}),e.description&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.description})]}),t.jsxs(ps,{children:[t.jsx(ms,{"data-project-menu":e.id,"aria-label":n("ui.projects.project_board.actions_for_displayname",{displayName:String(b)}),disabled:r,onClick:N=>N.stopPropagation(),className:M("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:r?t.jsx(Te,{size:"xs"}):t.jsx(yr,{className:"size-4"})}),t.jsxs(fs,{align:"end",onClick:N=>N.stopPropagation(),children:[t.jsx(Ee,{onSelect:a,children:n("ui.projects.project_board.open")}),t.jsxs(ya,{children:[t.jsx(va,{children:n("ui.projects.project_board.set_status")}),t.jsx(ka,{children:t.jsx(wa,{value:e.status,onValueChange:l,children:[...Vt,...Qt].map(N=>t.jsx(Na,{value:N,children:ae(N).label},N))})})]}),_&&t.jsx(Ee,{onSelect:()=>p(e),children:n("ui.projects.project_board.request_update")}),t.jsx(Sa,{}),t.jsx(Ee,{onSelect:o,children:n("ui.projects.project_board.edit")}),t.jsx(Ee,{onSelect:i,children:n("ui.projects.project_board.delete")})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[u.filter(N=>N.key!=="live").map(N=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:N.text},N.key)),g&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_board.overdue")})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-meta text-ink-muted",children:co(h)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!h)&&t.jsx("span",{"aria-label":n("ui.projects.project_model.stale"),title:n("ui.projects.project_model.stale"),className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(cc,{project:e})]})]})]})},cc=({project:e})=>{F();const[s,r]=d.useState(!1),a=Dt(),o=Ar(e.id,s),i=o.data?.links??[],l=mo(e),c=ne(e);return t.jsxs(_s,{open:s,onOpenChange:r,children:[t.jsx(js,{"data-project-sessions":e.id,"aria-label":n("ui.projects.project_board.sessions_linked_to_displayname",{displayName:String(c)}),onClick:u=>u.stopPropagation(),className:M("rounded-sm px-1 text-meta whitespace-nowrap",e.live_sessions>0?"text-success hover:bg-sunken":"text-ink-muted hover:bg-sunken"),children:l}),t.jsx(hs,{align:"end",className:"w-64 p-2 outline-none",onClick:u=>u.stopPropagation(),children:o.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:n("ui.projects.project_board.loading_linked_sessions")}):o.isError?t.jsxs("div",{className:"flex flex-col items-start gap-1.5 px-1 py-2",children:[t.jsx("p",{className:"text-meta text-ink-muted",children:o.error instanceof Error&&o.error.message?o.error.message:n("ui.projects.project_board.the_linked_sessions_could_not_be_read")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>void o.refetch(),children:n("ui.projects.project_board.try_again")})]}):i.length===0?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:n("ui.projects.project_board.no_sessions_linked_yet")}):t.jsx("ul",{className:"flex flex-col",children:i.map(u=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!u.exists,onClick:()=>{u.exists&&(r(!1),Rr(a,u.session_id))},className:M("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",u.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:u.title||u.session_id})})},u.session_id))})})]})},pn=({open:e,projectName:s,onClose:r,onConfirm:a})=>{F();const[o,i]=d.useState(""),[l,c]=d.useState(null),[u,m]=d.useState(!1),p=d.useId();d.useEffect(()=>{e&&(i(""),c(null),m(!1))},[e]);const _=o.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,b=async()=>{m(!0),c(null);try{await a(o.trim()),r()}catch(f){c(f instanceof Error&&f.message?f.message:n("ui.projects.project_delete_dialog.the_project_was_not_deleted"))}finally{m(!1)}};return t.jsx(dt,{open:e,onClose:r,title:n("ui.projects.project_delete_dialog.delete_this_project"),dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(He,{onClick:r,disabled:u,children:n("ui.projects.project_delete_dialog.cancel")}),t.jsxs(zn,{onClick:()=>void b(),disabled:!_||u,children:[u&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_delete_dialog.delete_project")]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink",children:n("ui.projects.project_delete_dialog.this_deletes_the_project_and_its_milestones_the_sessions_linked_t")}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[n("ui.projects.project_delete_dialog.type")," ",t.jsx("span",{className:"font-mono text-mono-sm text-ink",children:s})," ",n("ui.projects.project_delete_dialog.to_confirm")]}),t.jsx(ue,{id:`${p}-confirm`,value:o,onChange:f=>i(f.target.value),placeholder:s,"aria-label":n("ui.projects.project_delete_dialog.type_the_project_name_to_confirm"),"aria-invalid":o.length>0&&!_,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})};function lc(e){return e==="editing"||e==="saving"||e==="error"}function uc(e,s,r=Object.is){return!r(e,s)}function dc(e,s){if(e.key==="Escape")return e.defaultPrevented===!0?null:"revert";if(e.key!=="Enter"||!s.keyboardCommit)return null;const r=e.metaKey===!0||e.ctrlKey===!0;return s.multiline?r?"accept":null:s.onEditor?"accept":null}function pc(e,s){return e==="saving"||e==="error"?!0:e==="editing"&&s}function mc(e){const{phase:s,base:r,draft:a,fresh:o,equals:i}=e;return s==="saving"||s==="saved"||i(r,o)?"none":s==="idle"||i(r,a)||i(o,a)?"adopt":"conflict"}function cr(e,s,r=Object.is){return!r(e,s)}const Cs="group/inline-edit",Yt="inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-xs text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",fc="relative before:absolute before:-inset-1.5 before:content-['']",_c="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-left-1.5 before:right-0 before:content-['']",jc="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-right-1.5 before:left-0 before:content-['']",cs=({api:e,idle:s="affordance",className:r})=>{const{phase:a,labels:o}=e,i=a==="editing"||a==="saving"||a==="error",l=pc(a,e.dirty),c=e.acceptBlocked===!0;return t.jsx("span",{"data-inline-edit-slot":a,className:M("inline-flex shrink-0 items-center gap-0.5",r),children:l?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","data-inline-edit-control":"cancel","aria-label":a==="saving"?o.busy:o.cancel,title:a==="saving"?o.busy:o.cancel,"aria-disabled":a==="saving"||void 0,onMouseDown:u=>u.preventDefault(),onClick:u=>{u.detail>1||a!=="saving"&&e.cancel()},className:M(Yt,_c,a==="saving"&&"cursor-default text-ink-disabled"),children:t.jsx(Pt,{className:"size-3","aria-hidden":"true"})}),a==="saving"?t.jsx("span",{"data-inline-edit-control":"busy",className:"inline-flex size-5 shrink-0 items-center justify-center",children:t.jsx(Te,{size:"xs"})}):t.jsx("button",{type:"button","data-inline-edit-control":"accept","aria-label":a==="error"?o.retry??o.accept:o.accept,title:a==="error"?o.retry??o.accept:o.accept,"aria-disabled":c||void 0,onMouseDown:u=>u.preventDefault(),onClick:u=>{u.detail>1||c||e.accept()},className:M(Yt,jc,c&&"cursor-default text-ink-disabled"),children:t.jsx(gs,{className:"size-3","aria-hidden":"true"})})]}):i?null:s==="affordance"?t.jsx("button",{ref:e.slotRef,type:"button","data-inline-edit-control":"begin","aria-label":o.begin,title:o.begin,onClick:u=>{u.detail>1||e.begin()},className:M(Yt,fc,"opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","focus-visible:opacity-100"),children:t.jsx(Gn,{className:"size-3","aria-hidden":"true"})}):null})},ls=({api:e,className:s})=>{F();const{phase:r,error:a,conflict:o}=e;return r==="saved"?t.jsx("p",{"data-inline-edit-feedback":"saved",className:M("text-meta text-success",s),children:e.labels.saved}):!a&&!o?null:t.jsxs("div",{id:e.feedbackId,"data-inline-edit-feedback":a&&o?"error+conflict":a?"error":"conflict",role:"alert",className:M("flex flex-wrap items-center gap-x-3 gap-y-1",s),children:[a&&t.jsx("p",{className:"text-meta text-danger",children:a}),a&&o===null&&t.jsx("button",{type:"button","data-inline-edit-control":"retry",onClick:()=>e.accept(),className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.actions.retry")}),o!==null&&t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-warning",children:n("ui.common.editing.conflict")}),t.jsx("button",{type:"button","data-inline-edit-control":"keep-mine",onClick:e.keepMine,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.editing.keep_mine")}),t.jsx("button",{type:"button","data-inline-edit-control":"use-theirs",onClick:e.useTheirs,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.editing.use_theirs")})]})]})},mn=d.createContext(null),hc=50,gc=({children:e})=>{const[s,r]=d.useState(""),a=d.useMemo(()=>({current:o=>{r(""),window.setTimeout(()=>r(o),hc)}}),[]);return t.jsxs(mn.Provider,{value:a,children:[e,t.jsx("span",{"data-inline-edit-announcement":"","aria-live":"polite",className:"sr-only",children:s})]})},xc=1200;function bc(e){return e instanceof Error&&e.message?e.message:"The change was not saved."}function jt(e){const{value:s,multiline:r=!1,keyboardCommit:a=!0,selectAllOnBegin:o=!1,beginOnMount:i=!1,savedDwellMs:l=xc,labels:c}=e,u=d.useRef(e.equals??Object.is);u.current=e.equals??Object.is;const m=d.useRef(e.commit);m.current=e.commit;const p=d.useRef(e.validate);p.current=e.validate;const _=d.useRef(e.errorCopy);_.current=e.errorCopy;const b=d.useRef(e.onSettle);b.current=e.onSettle;const f=d.useRef(e.onBegin);f.current=e.onBegin;const x=d.useRef(c);x.current=c;const[w,g]=d.useState(i?"editing":"idle"),[h,v]=d.useState(s),[T,N]=d.useState(s),[q,C]=d.useState(null),[E,P]=d.useState(null),j=d.useRef(w),D=d.useRef(h),R=d.useRef(T),I=d.useRef(q),K=d.useRef(s);K.current=s;const B=d.useCallback(A=>{j.current=A,g(A)},[]),Y=d.useCallback(A=>{D.current=A,v(A)},[]),X=d.useCallback(A=>{R.current=A,N(A)},[]),Z=d.useCallback(A=>{I.current=A,C(A)},[]),me=d.useRef(null),oe=d.useRef(null),ee=d.useRef(null),te=e.editorRef??ee,y=d.useRef(te);y.current=te;const k=`${d.useId()}-inline-edit`,O=d.useContext(mn),L=d.useRef(null),U=L.current,Q=U!==null&&(e.equals??Object.is)(s,U.previous)&&!(e.equals??Object.is)(s,U.saved)&&U!==null?U.saved:s,$=d.useRef(Q);$.current=Q,d.useEffect(()=>{const A=L.current;if(A===null)return;const ce=u.current;(ce(s,A.saved)||!ce(s,A.previous))&&(L.current=null)},[s]);const je=d.useRef(i);d.useEffect(()=>{if(w!=="editing"||!je.current)return;je.current=!1;const A=y.current.current;A&&(A.focus(),o&&(A instanceof HTMLInputElement||A instanceof HTMLTextAreaElement)&&A.select())},[w,o]);const ie=d.useRef(!1);d.useEffect(()=>{ie.current&&(w!=="idle"&&w!=="saved"||(ie.current=!1,oe.current?.focus()))});const z=d.useRef(null),se=d.useCallback(()=>{z.current!==null&&(clearTimeout(z.current),z.current=null)},[]);d.useEffect(()=>()=>se(),[se]);const xe=d.useRef(w);d.useEffect(()=>{const A=xe.current;if(xe.current=w,A==="saving"&&w==="saved"){b.current?.("saved");return}(A==="editing"||A==="error")&&w==="idle"&&b.current?.("cancelled")},[w]),d.useEffect(()=>{const A=mc({phase:j.current,base:R.current,draft:D.current,fresh:$.current,equals:u.current});A==="adopt"?(u.current(R.current,$.current)||X($.current),u.current($.current,D.current)||Y($.current)):A==="conflict"&&(I.current===null||!u.current(I.current,$.current))&&Z($.current)},[s,w,X,Y,Z]);const fe=d.useCallback(A=>{Z(null),P(null),Y(R.current),B("idle"),A&&(ie.current=!0)},[Z,Y,B]),Pe=d.useCallback(()=>{j.current!=="saving"&&(j.current==="idle"||j.current==="saved"||(se(),fe(!0)))},[se,fe]),re=d.useCallback((A,ce=!0)=>{const nt=j.current;if(nt==="saving"||nt==="saved"||I.current!==null)return;const we=A!==void 0?A:D.current;if(!cr(R.current,we,u.current)){fe(ce&&nt!=="idle");return}const gt=p.current?.(we)??null;if(gt!==null){B("error"),P(gt);return}Y(we),P(null),B("saving"),m.current(we).then(()=>{j.current==="saving"&&(L.current={saved:we,previous:R.current},X(we),Y(we),ce&&(ie.current=!0),B("saved"),se(),z.current=setTimeout(()=>{z.current=null,j.current==="saved"&&B("idle")},l),O?.current?.(x.current.saved))},$e=>{j.current==="saving"&&(B("error"),P(_.current?_.current($e):bc($e)))})},[O,se,fe,l,X,Y,B]),Re=d.useCallback(()=>{j.current==="editing"||j.current==="saving"||(se(),je.current=!0,Y($.current),X($.current),Z(null),P(null),B("editing"),f.current?.())},[se,X,Z,Y,B]),Be=d.useCallback(()=>{const A=I.current;A!==null&&(Z(null),X(A),re())},[re,X,Z]),qt=d.useCallback(()=>{const A=I.current;A!==null&&(X(A),fe(!0))},[fe,X]),st=d.useCallback(A=>{const ce=dc(A,{multiline:r,keyboardCommit:a,onEditor:A.target===y.current.current});if(ce==="revert"){A.preventDefault(),Pe();return}ce==="accept"&&(A.preventDefault(),re())},[re,Pe,a,r]),rt=d.useCallback(A=>{if(j.current!=="editing")return;const ce=A.relatedTarget;if(!(ce!==null&&me.current?.contains(ce))&&!(ce instanceof Element&&ce.closest("[data-radix-popper-content-wrapper]")!==null)&&I.current===null){if(!cr(R.current,D.current,u.current)){fe(!1);return}re(void 0,!1)}},[re,fe]),ht=w==="saved"?h:Q;return{phase:w,dirty:uc(T,h,u.current),conflict:q,error:E,draft:h,setDraft:Y,displayValue:ht,editing:lc(w),begin:Re,accept:re,cancel:Pe,keepMine:Be,useTheirs:qt,handleKeyDown:st,handleBlur:rt,fieldProps:{onKeyDown:st,onBlur:rt,"aria-busy":w==="saving"?!0:void 0},editorAria:{"aria-invalid":E!==null?!0:void 0,"aria-describedby":E!==null||q!==null?k:void 0},fieldRef:me,editorRef:te,slotRef:oe,feedbackId:k,labels:c}}const yc=/^(https?:|mailto:)/i,vc={a:({href:e,children:s})=>typeof e=="string"&&yc.test(e)?t.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:s}):t.jsx("span",{className:"font-mono text-mono-sm",children:s}),table:Hn},ut=d.memo(({children:e,className:s})=>t.jsx("div",{className:M("lo-markdown",s),children:t.jsx(Yn,{remarkPlugins:[Kn],components:vc,children:e})})),lr=`## Summary
|
|
21
|
+
*/const Va=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],Qa=At("unlink",Va),Mt={list:["desktop","projects"],detail:e=>["desktop","projects",e]};function Xa(e){return us({queryKey:Mt.list,enabled:e,queryFn:()=>_e({op:"projects.list"}).then(s=>s.projects),retry:ds,staleTime:1e4})}function Ja(e,s){return $a({queries:e.map(r=>({queryKey:Mt.detail(r),enabled:s&&!!r,queryFn:()=>_e({op:"projects.get",key:r}),retry:ds,staleTime:1e4}))})}function Ar(e,s){return us({queryKey:Mt.detail(e??""),enabled:s&&!!e,queryFn:()=>_e({op:"projects.get",key:e??""}),retry:ds,staleTime:1e4})}function Ue(){const e=br();return()=>{e.invalidateQueries({queryKey:Mt.list})}}function Za(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.create",name:s.name,...s.description!==void 0?{description:s.description}:{},...s.status!==void 0?{status:s.status}:{},...s.tags!==void 0?{tags:s.tags}:{}}),onSuccess:()=>e()})}function Or(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.update",key:s.key,fields:s.fields,...s.forceDone===!0?{force_done:!0}:{}}),retry:qn,onSuccess:()=>e()})}function Pr(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.delete",key:s.key,confirmed_name:s.confirmedName}),onSuccess:()=>e()})}function eo(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.link",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function to(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.unlink",key:s.key,sessionId:s.sessionId}),onSuccess:()=>e()})}function so(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.milestone",key:s.key,name:s.name,...s.targetDate!==void 0?{targetDate:s.targetDate}:{},...s.completed!==void 0?{completed:s.completed}:{}}),onSuccess:()=>e()})}function ro(){const e=Ue();return qe({mutationFn:s=>_e({op:"projects.milestone.remove",key:s.key,name:s.name}),onSuccess:()=>e()})}const Mr={planning:{get label(){return n("ui.projects.project_model.planning")},variant:"info"},active:{get label(){return n("ui.projects.project_model.active")},variant:"accent"},qa:{get label(){return n("ui.projects.project_model.qa")},variant:"attention"},validation:{get label(){return n("ui.projects.project_model.validation")},variant:"warning"},done:{get label(){return n("ui.projects.project_model.done")},variant:"success"},paused:{get label(){return n("ui.projects.project_model.paused")},variant:"neutral"},archived:{get label(){return n("ui.projects.project_model.archived")},variant:"outline"}},Ge=Object.keys(Mr);function ae(e){return Mr[e]??{label:e||n("ui.projects.project_model.unknown"),variant:"neutral"}}const Lr=["planning","active","qa","validation","done","paused","archived"].map(e=>({value:e,label:ae(e).label}));function no(e){return e==="done"}const ao={completed:{get label(){return n("ui.projects.project_model.completed")},variant:"success"},overdue:{get label(){return n("ui.projects.project_model.overdue")},variant:"warning"},upcoming:{get label(){return n("ui.projects.project_model.upcoming")},variant:"neutral"}};function oo(e){return ao[e]??{label:String(e),variant:"neutral"}}Fe["ui.projects.project_model.stale"];const io=/^(\d{4})-(\d{2})-(\d{2})$/;function Oe(e,s,r=new Date){if(!e)return"";const a=io.exec(e);if(!a)return e;const o=new Date(Number(a[1]),Number(a[2])-1,Number(a[3]));if(Number.isNaN(o.getTime()))return e;const i=yt(o,{month:"short",day:"numeric"},s);return o.getFullYear()===r.getFullYear()?i:yt(o,{month:"short",day:"numeric",year:"numeric"},s)}function pt(e,s){if(e==null)return"";const r=Math.max(0,Math.floor(s/1e3-e));return r<60?n("ui.projects.project_model.just_now"):r<3600?`${V(Math.floor(r/60),{useGrouping:!1})}m`:r<86400?`${V(Math.floor(r/3600),{useGrouping:!1})}h`:`${V(Math.floor(r/86400),{useGrouping:!1})}d`}function mt(e){return e===n("ui.projects.project_model.just_now")?n("ui.projects.project_model.just_now"):n("ui.projects.project_model.age_ago",{age:String(e)})}function co(e){return e?n("ui.projects.project_model.reported_progressagephrase_age",{progressAgePhrase_age:String(mt(e))}):n("ui.projects.project_model.no_progress")}const Ir=/^$|^\d{4}-\d{2}-\d{2}$/;function Fr(e){return e?e==="operator"?n("ui.projects.project_model.the_operator"):n("ui.projects.project_model.session_reportedby",{reportedBy:String(e)}):""}function lo(e,s){if(!e.progress)return n("ui.projects.project_model.not_reported_yet");const r=pt(e.progress_updated_at,s),a=Fr(e.progress_reported_by),o=[r?n("ui.projects.project_model.reported_progressagephrase_age",{progressAgePhrase_age:String(mt(r))}):"reported"];return a&&o.push(n("ui.projects.project_model.by_reporter",{reporter:String(a)})),o.join(" ")}function qr(e,s){if(e==null)return"";const r=V(e,{useGrouping:!1,maximumFractionDigits:20});return s==="points"?n("ui.projects.project_model.value_pt",{value:String(r)}):s==="days"?n("ui.projects.project_model.value_d",{value:String(r)}):r}function Ur(e,s){return s<=0?"":n("ui.projects.project_model.completed_total",{completed:V(e,{useGrouping:!1}),total:V(s,{useGrouping:!1})})}function xs(e){return e<=0?"":n("ui.projects.project_model.live_live",{live:e})}function uo(e){return e<=0?"":n("ui.projects.count.session",{count:e})}function po(e){return n("ui.projects.count.project",{count:e})}function mo(e){const s=uo(e.sessions);if(!s)return"";const r=xs(e.live_sessions);return r?n("ui.projects.project_model.count_live",{count:String(s),live:String(r)}):s}function fo(e){if(!e.exists)return{get label(){return n("ui.projects.project_model.missing")},variant:"outline"};if(e.archived)return{get label(){return n("ui.projects.project_model.archived")},variant:"neutral"};switch(e.runtime?.state){case"live":return{get label(){return n("ui.projects.project_model.live")},variant:"success"};case"wedged":return{get label(){return n("ui.projects.project_model.wedged")},variant:"warning"};case"stale":return{get label(){return n("ui.projects.project_model.stale")},variant:"warning"};case"stopped":return{get label(){return n("ui.projects.project_model.stopped")},variant:"neutral"};default:return{label:String(e.runtime?.state??n("ui.projects.project_model.unknown")),variant:"neutral"}}}function _o(e){return e?e.running>0?n("ui.projects.count.subagent_running",{count:e.running}):n("ui.projects.count.subagent",{count:e.settled}):""}function jo(e){return e?n("ui.projects.count.todo",{count:e.total}):""}function Br(e,s){const r=[],a=Oe(e.completed_at??e.target_date,s);a&&r.push({key:e.completed_at?"completed":"target",text:e.completed_at?n("ui.projects.project_model.completed_day",{day:String(a)}):n("ui.projects.project_model.due_day",{day:String(a)})});const o=qr(e.estimate,e.estimate_unit);o&&r.push({key:"estimate",text:o});const i=Ur(e.milestones_completed,e.milestones_total);i&&r.push({key:"milestones",text:n("ui.projects.project_model.milestones_milestones",{milestones:String(i)})});const l=xs(e.live_sessions);return l&&r.push({key:"live",text:l}),r}const He=864e5,ho=/^(\d{4})-(\d{2})-(\d{2})$/;function ve(e){if(!e)return null;const s=ho.exec(e);if(!s)return null;const r=Number(s[1]),a=Number(s[2]),o=Number(s[3]),i=Date.UTC(r,a-1,o),l=new Date(i);return l.getUTCFullYear()!==r||l.getUTCMonth()!==a-1||l.getUTCDate()!==o?null:i}const Vt=["planning","active","qa","validation","done"],Qt=["paused","archived"],Lt=[{value:"24h",get label(){return n("ui.projects.project_model.last_24_hours")},get phrase(){return n("ui.projects.project_model.the_last_24_hours")},seconds:86400},{value:"7d",get label(){return n("ui.projects.project_model.last_7_days")},get phrase(){return n("ui.projects.project_model.the_last_7_days")},seconds:604800},{value:"30d",get label(){return n("ui.projects.project_model.last_30_days")},get phrase(){return n("ui.projects.project_model.the_last_30_days")},seconds:2592e3},{value:"90d",get label(){return n("ui.projects.project_model.last_90_days")},get phrase(){return n("ui.projects.project_model.the_last_90_days")},seconds:7776e3},{value:"all",get label(){return n("ui.projects.project_model.all_time")},phrase:null,seconds:null}],$r="7d",go=Lt.find(e=>e.value===$r);function zr(e){return Lt.find(s=>s.value===e)??go}function xo(e){return Lt.some(s=>s.value===e)}function $s(e,s,r){const a=zr(s);return a.seconds===null?e:e.filter(o=>r/1e3-o.updated_at<=a.seconds)}function bo(e){const s=zr(e);return s.seconds===null?null:n("ui.projects.project_model.nothing_changed_in_phrase",{phrase:String(s.phrase)})}const Gr="projects-board-window";function yo(){try{const e=localStorage.getItem(Gr);if(e!==null&&xo(e))return e}catch{}return $r}function zs(e){try{localStorage.setItem(Gr,e)}catch{}}const Hr="projects-board-column-order";let Xt=null;function vo(){if(Xt)return[...Xt];try{const e=localStorage.getItem(Hr);if(!e)return[];const s=JSON.parse(e);if(!Array.isArray(s))return[];const r=[];for(const a of s){if(typeof a!="string"||a.length===0)return[];r.includes(a)||r.push(a)}return r}catch{return[]}}function ko(e){Xt=[...e];try{localStorage.setItem(Hr,JSON.stringify(e))}catch{}}function wo(e,s,r){const a=e.filter(i=>i!==s),o=Math.max(0,Math.min(r,a.length));return a.splice(o,0,s),a}function No(e,s=[]){const r=new Map;for(const c of e){const u=r.get(c.status)??[];u.push(c),r.set(c.status,u)}const a=Vt.map(c=>({status:c,projects:r.get(c)??[]}));for(const c of Qt){const u=r.get(c)??[];u.length>0&&a.push({status:c,projects:u})}for(const[c,u]of r)!Qt.includes(c)&&!Vt.includes(c)&&a.push({status:c,projects:u});if(s.length===0)return a;const o=new Map(s.map((c,u)=>[c,u])),i=a.filter(c=>o.has(c.status));i.sort((c,u)=>(o.get(c.status)??0)-(o.get(u.status)??0));const l=a.filter(c=>!o.has(c.status));return[...i,...l]}function Yr(e,s){if(e.status==="done"||e.status==="archived"||e.completed_at)return!1;const r=ve(e.target_date);return r===null?!1:r<s}function ne(e){return e.title||e.name}Fe["ui.projects.project_model.no_team"];function ft(e){const s=e.team?.trim();if(s)return s;const r=e.owner?.trim();return r||null}function bs(e,s){const r=new Map,a=[];for(const i of e){const l=s(i);if(l===null){a.push(i);continue}const c=r.get(l);c?c.push(i):r.set(l,[i])}const o=[...r.entries()].sort(([i],[l])=>i.localeCompare(l,void 0,{sensitivity:"base"})).map(([i,l])=>({team:i,items:l}));return a.length>0&&o.push({team:null,items:a}),o}function It(e){return e.title||e.session_id}function So(e){return[...e].reverse()}function Co(e){return e<=0?"":n("ui.projects.count.update",{count:e})}const Gs=e=>String(e).padStart(2,"0");function Jt(e){return`${e.getFullYear()}-${Gs(e.getMonth()+1)}-${Gs(e.getDate())}`}function Eo(e){const s=Date.parse(e);return Number.isNaN(s)?"":Jt(new Date(s))}function To(e,s,r=new Date){if(!e)return"";if(e===Jt(r))return n("ui.projects.project_model.today");const a=new Date(r.getFullYear(),r.getMonth(),r.getDate()-1);return e===Jt(a)?n("ui.projects.project_model.yesterday"):Oe(e,s,r)}function Ro(e,s){const r=Date.parse(e);return Number.isNaN(r)?"":Un(new Date(r),{hour:"numeric",minute:"2-digit"},s)}function Do(e,s){const r=Date.parse(e);return Number.isNaN(r)?"":mt(pt(r/1e3,s))}function Ao(e,s,r=Date.now()){const a=[],o=Fr(e.by);o&&a.push({key:"author",text:o});const i=Ro(e.at,s);i&&a.push({key:"time",text:i});const l=Do(e.at,r);return l&&a.push({key:"age",text:l}),a}function Oo(e,s,r=new Date){const a=[];for(const o of So(e)){const i=Eo(o.at),l=a[a.length-1];if(l&&l.key===i){l.entries.push(o);continue}a.push({key:i,label:To(i,s,r),entries:[o]})}return a}function Po(e){return!Number.isFinite(e)||e<0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function Mo(e,s){return s<=0?"":`${e} of ${s} complete`}function Lo(e){let s=0,r=0,a=!1;for(const o of e)o.todos&&(a=!0,s+=o.todos.open,r+=o.todos.total);return a?{open:s,total:r}:null}function Hs(e){return`${e.open} open of ${e.total}`}function Io(e){const s=e.filter(a=>a.exists);return(s.find(a=>a.runtime?.state==="live")??s[0])?.session_id??null}function Fo(e){const s=ne(e),r=e.progress.trim()||"not reported yet";return[`Continue work on project "${s}" (${e.name}).`,`Latest progress: ${r}`,"Review the project details and continue or complete the work."].join(`
|
|
22
|
+
`)}function qo(e){return e?e.kind==="team"?n("ui.projects.project_model.team_name",{name:String(e.name)}):n("ui.projects.project_model.agent_name",{name:String(e.name)}):""}const Uo=/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"/g;function Kr(e){const s=[];for(const r of e.matchAll(Uo))s.push((r[1]??r[2]??"").replace(/\\(.)/g,"$1"));return s}const bt=3;function ys(e){if(e.length<=bt+1)return e.length<=1?e.join(""):n("ui.projects.project_model.join_and_length_1",{join:String(e.slice(0,-1).join(", ")),length___1:String(e[e.length-1])});const s=e.length-bt;return n("ui.projects.project_model.join_and_hidden_more",{join:String(e.slice(0,bt).join(", ")),hidden:V(s,{useGrouping:!1})})}function vs(e){return n("ui.projects.count.milestones_are",{count:e})}const Ys="complete them, or pass force_done=true to close with them open",Bo="complete or remove the incomplete milestones, then mark it done",Wr=/^cannot set status 'done': (\d+) milestones? still incomplete \((.+)\) — /;function _t(e){const s=e.match(Wr);if(s){const r=Number(s[1]),a=Kr(s[2]),o=a.length>0?ys(a):s[2];return n("ui.projects.project_model.this_can_t_be_marked_done_yet_milestonesare_count_still_incomplet",{milestonesAre_count:String(vs(r)),clause:String(o)})}return e.includes(Ys)?e.replace(Ys,Bo):e}const $o="project_done_incomplete";function zo(e){const s=e.message.match(Wr),r=e.code===$o;if(!r&&!s)return null;const a=typeof e.detail=="object"&&e.detail!==null&&Array.isArray(e.detail.incomplete)?e.detail.incomplete.filter(l=>typeof l=="string"):null,o=a&&a.length>0?a:s?Kr(s[2]):[];return{count:o.length>0?o.length:s?Number(s[1]):0,names:o,coded:r,message:e.message}}function Go(e){if(e.count>0){const s=ys(e.names);return n("ui.projects.project_model.count_still_open_clause_clause",{count:String(vs(e.count)),clause________clause:String(s?n("ui.projects.project_model.clause",{clause:String(s)}):"")})}return _t(e.message)||n("ui.projects.project_model.some_milestones_are_still_open")}function Ho(e){return e.count>0&&e.names.length>0?n("ui.projects.project_model.this_can_t_be_marked_done_yet_count_still_incomplete_names_comple",{count:String(vs(e.count)),names:String(ys(e.names))}):_t(e.message)||n("ui.projects.project_model.milestones_are_still_open_on_this_project_complete_or_remove_them")}function Vr(e,s,r){if(!e||e.forced_done!==!0)return n("ui.projects.project_model.moved_to_statuslabel",{statusLabel:String(r)});const a=typeof e.milestones_total=="number"&&typeof e.milestones_completed=="number"?e.milestones_total-e.milestones_completed:s,o=a>0?a:s;return n("ui.projects.count.moved_open",{status:r,open:o})}Fe["ui.projects.project_model.the_project_was_not_moved_try_again_or_open_it_to_change_its_stat"];function Qr(e){return e.trim().slice(0,La)}const Yo={get client(){return n("ui.projects.project_search.searches_names_descriptions_tags_owners_and_teams_update_text_is")},get backend(){return n("ui.projects.project_search.searches_names_descriptions_tags_owners_teams_and_update_text_cle")}},Ko=2,Wo=4,Vo=3,Qo=2,Xo=1,Jo=3,Me={title:3,name:2.5,description:2,tags:1.5,attribution:1.5,status:1},Zo=/[^\p{L}\p{N}]+/u,ei=/\s+/;function Ks(e,s){const r=s.trim().toLowerCase();if(!r)return 0;if(r===e)return Wo;if(r.startsWith(e))return Vo;const a=r.split(Zo).filter(Boolean),o=e.split(ei).filter(Boolean);if(o.length>0&&o.every(l=>a.some(c=>c.startsWith(l))))return Qo;const i=o.join("");return i.length>=Jo&&ti(i,r)?Xo:0}function ti(e,s){let r=0;for(const a of e){if(r=s.indexOf(a,r),r<0)return!1;r+=1}return!0}function si(e,s){const r=s.trim().toLowerCase();if(!r)return 0;const a=[[e.title,Me.title],[e.name,Me.name],[e.description,Me.description],[e.owner,Me.attribution],[e.team,Me.attribution],[e.status,Me.status]];let o=0;for(const[i,l]of a){if(!i)continue;const c=Ks(r,i)*l;c>o&&(o=c)}for(const i of e.tags){const l=Ks(r,i)*Me.tags;l>o&&(o=l)}return o}function ri(e,s){const r=s.trim();if(!r)return e;const a=[];for(const o of e){const i=si(o,r);i>0&&a.push({project:o,score:i})}return a.sort((o,i)=>{if(o.score!==i.score)return i.score-o.score;if(o.project.updated_at!==i.project.updated_at)return i.project.updated_at-o.project.updated_at;const l=ne(o.project).localeCompare(ne(i.project),void 0,{sensitivity:"base"});if(l!==0)return l;const c=o.project.name.localeCompare(i.project.name,void 0,{sensitivity:"base"});return c!==0?c:o.project.id<i.project.id?-1:o.project.id>i.project.id?1:0}),a.map(o=>o.project)}function ni(e,s){if(s.length===0)return[];const r=new Map(e.map(o=>[o.id,o])),a=[];for(const o of s){const i=r.get(o.id);i!==void 0&&a.push(i)}return a}const ai=180;function oi(e,s){const r=Qr(e),a=Tr(r,ai),o=us({queryKey:["desktop","projects","search",a],enabled:s&&a.length>0,queryFn:()=>_e({op:"projects.search",q:a,limit:Ia}),retry:!1,staleTime:3e4}),i=a===r,l=i&&o.data&&o.data.query===r?o.data:null,c=i&&r.length>0&&!l&&o.isError;return{answer:l,pending:s&&r.length>0&&!l&&!c}}const et=["status","team","owner","tags","progress","target","estimate","milestones","live"],Ws={status:[],team:[],owner:[],tags:[],progress:[],target:[],estimate:[],milestones:[],live:[]},ot={get status(){return n("ui.projects.project_filters.status")},get team(){return n("ui.projects.project_filters.team")},get owner(){return n("ui.projects.project_filters.owner")},get tags(){return n("ui.projects.project_filters.tags")},get progress(){return n("ui.projects.project_filters.progress")},get target(){return n("ui.projects.project_filters.target_date")},get estimate(){return n("ui.projects.project_filters.estimate")},get milestones(){return n("ui.projects.project_filters.milestones")},get live(){return n("ui.projects.project_filters.live_sessions")}},ii=new Set(["status","progress","target","estimate","milestones","live"]),ci={progress:["stale","up-to-date","not-reported"],target:["none","overdue","within-7","within-30"],estimate:["none","points","days"],milestones:["none","incomplete","complete"],live:["has-live","no-live"]},li={get stale(){return n("ui.projects.project_filters.stale")},get"up-to-date"(){return n("ui.projects.project_filters.up_to_date")},get"not-reported"(){return n("ui.projects.project_filters.not_reported")},get none(){return n("ui.projects.project_filters.no_target_date")},get overdue(){return n("ui.projects.project_filters.overdue")},get"within-7"(){return n("ui.projects.project_filters.due_within_7_days")},get"within-30"(){return n("ui.projects.project_filters.due_within_30_days")},get points(){return n("ui.projects.project_filters.points")},get days(){return n("ui.projects.project_filters.days")},get incomplete(){return n("ui.projects.project_filters.incomplete")},get complete(){return n("ui.projects.project_filters.complete")},get"has-live"(){return n("ui.projects.project_filters.has_live_sessions")},get"no-live"(){return n("ui.projects.project_filters.no_live_sessions")}};function Xr(e,s){switch(e){case"status":return ae(s).label;case"team":return s===null?n("ui.projects.project_filters.no_team"):s;case"owner":return s===null?n("ui.projects.project_filters.no_owner"):s;case"tags":return s??"";case"estimate":if(s==="none")return n("ui.projects.project_filters.no_estimate");break;case"milestones":if(s==="none")return n("ui.projects.project_filters.none_set");break;case"target":if(s==="none")return n("ui.projects.project_filters.no_target_date");break}return li[s]??s??""}function ui(e,s){return e[s].length>0}function ct(e){return et.every(s=>!ui(e,s))}function di(e){return et.reduce((s,r)=>s+e[r].length,0)}function Jr(e,s,r){const a=e[s],o=a.includes(r)?a.filter(i=>i!==r):[...a,r];return{...e,[s]:o}}function Zr(e,s,r,a){switch(e){case"status":return s.status===r;case"team":return ft(s)===r;case"owner":return(s.owner?.trim()||null)===r;case"tags":return s.tags.includes(r??"");case"progress":return r==="stale"?s.progress_stale===!0:r==="up-to-date"?s.progress_stale===!1:s.progress_updated_at===null;case"target":{if(r==="none")return ve(s.target_date)===null;if(r==="overdue")return Yr(s,a);const o=ve(s.target_date);if(o===null)return!1;const i=(o-a)/He;return r==="within-7"?i>=0&&i<=7:i>=0&&i<=30}case"estimate":return r==="none"?s.estimate===null:s.estimate===null?!1:r==="points"?s.estimate_unit==="points":s.estimate_unit==="days";case"milestones":return r==="none"?s.milestones_total===0:s.milestones_total===0?!1:r==="complete"?s.milestones_completed>=s.milestones_total:s.milestones_completed<s.milestones_total;case"live":return r==="has-live"?s.live_sessions>0:s.live_sessions===0}}function en(e,s,r,a){const o=e[s];return o.length===0?!0:o.some(i=>Zr(s,r,i,a))}function pi(e,s,r){return ct(s)?e:e.filter(a=>et.every(o=>en(s,o,a,r)))}function mi(e,s,r,a){return s.filter(o=>et.every(i=>i===e||en(r,i,o,a)))}function fi(e,s,r){const a=r[e];switch(e){case"status":{const i=[...new Set(s.map(c=>c.status))].filter(c=>!Ge.includes(c)).sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"})),l=a.filter(c=>typeof c=="string"&&!Ge.includes(c)&&!i.includes(c));return[...Ge,...i,...l]}case"team":{const o=new Set;let i=!1;for(const c of s){const u=ft(c);u===null?i=!0:o.add(u)}for(const c of a)c===null?i=!0:o.add(c);const l=[...o].sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"owner":{const o=new Set;let i=!1;for(const c of s){const u=c.owner?.trim();u?o.add(u):i=!0}for(const c of a)c===null?i=!0:o.add(c);const l=[...o].sort((c,u)=>c.localeCompare(u,void 0,{sensitivity:"base"}));return i?[...l,null]:l}case"tags":{const o=new Set;for(const i of s)for(const l of i.tags)o.add(l);for(const i of a)o.add(i??"");return[...o].sort((i,l)=>i.localeCompare(l,void 0,{sensitivity:"base"}))}case"progress":case"target":case"estimate":case"milestones":case"live":return ci[e]}}function tn(e,s,r,a){const o=mi(e,s,r,a),i=ii.has(e),l=[];for(const c of fi(e,o,r)){const u=r[e].includes(c),m=o.reduce((p,_)=>p+(Zr(e,_,c,a)?1:0),0);!i&&m===0&&!u||l.push({value:c,label:Xr(e,c),count:m,selected:u})}return{facet:e,label:ot[e],options:l}}function _i(e,s,r){return et.map(a=>tn(a,e,s,r))}const Zt="projects-sort";Fe["ui.projects.project_sort.default_as_listed"];function ji(e){return hi.includes(e)}const hi=["name","status","target","estimate","milestones","live","progress"];function gi(){try{const e=localStorage.getItem(Zt);if(e===null)return null;const[s,r,...a]=e.split(":");if(a.length>0)return null;if(s&&ji(s)&&(r==="asc"||r==="desc"))return{key:s,direction:r}}catch{}return null}function xi(e){try{e===null?localStorage.removeItem(Zt):localStorage.setItem(Zt,`${e.key}:${e.direction}`)}catch{}}function Je(e){switch(e){case"name":return n("ui.projects.project_sort.project");case"status":return n("ui.projects.project_sort.status");case"target":return n("ui.projects.project_sort.target");case"estimate":return n("ui.projects.project_sort.estimate");case"milestones":return n("ui.projects.project_sort.milestones");case"live":return n("ui.projects.project_sort.live");case"progress":return n("ui.projects.project_sort.progress")}}function Bt(e){return e==="target"||e==="progress"?"desc":"asc"}function ks(e,s){const r=s==="desc";switch(e){case"name":return r?n("ui.projects.project_sort.z_to_a"):n("ui.projects.project_sort.a_to_z");case"status":return r?n("ui.projects.project_sort.archived_first"):n("ui.projects.project_sort.planning_first");case"target":return r?n("ui.projects.project_sort.latest_first"):n("ui.projects.project_sort.soonest_first");case"estimate":return r?n("ui.projects.project_sort.days_first"):n("ui.projects.project_sort.points_first");case"milestones":return r?n("ui.projects.project_sort.most_complete_first"):n("ui.projects.project_sort.least_complete_first");case"live":return r?n("ui.projects.project_sort.most_first"):n("ui.projects.project_sort.fewest_first");case"progress":return r?n("ui.projects.project_sort.most_recent_first"):n("ui.projects.project_sort.most_stale_first")}}function bi(e){return e===null?n("ui.projects.project_sort.sort_cleared"):n("ui.projects.project_sort.sorted_by_key_direction",{key:String(Je(e.key)),direction:String(ks(e.key,e.direction))})}function yi(e){const s=[e.search?"search":null,e.filters?"filters":null,e.sort?"sort":null].filter(a=>a!==null);if(s.length===0)return"";const r=s.length===1?n("ui.projects.project_sort.parts_0_cleared",{parts_0:String(s[0])}):n("ui.projects.project_sort.join_and_length_1_cleared",{join:String(s.slice(0,-1).join(", ")),length___1:String(s[s.length-1])});return r.charAt(0).toUpperCase()+r.slice(1)}function Vs(e,s){switch(e){case"name":return 0;case"status":return Ge.includes(s.status)?0:1;case"target":return es(s)===null?1:0;case"estimate":return s.estimate===null?1:0;case"milestones":return s.milestones_total===0?1:0;case"live":return 0;case"progress":return s.progress_updated_at===null?1:0}}function es(e){return ve(e.completed_at??e.target_date)}function Qs(e){return e==="points"?0:e==="days"?1:2}function vi(e,s,r){switch(e){case"name":return ne(s).localeCompare(ne(r),void 0,{sensitivity:"base"});case"status":return Ge.indexOf(s.status)-Ge.indexOf(r.status);case"target":{const a=es(s)??0,o=es(r)??0;return a-o}case"estimate":{const a=Qs(s.estimate_unit)-Qs(r.estimate_unit);return a!==0?a:(s.estimate??0)-(r.estimate??0)}case"milestones":return s.milestones_completed*r.milestones_total-r.milestones_completed*s.milestones_total;case"live":return s.live_sessions-r.live_sessions;case"progress":return(s.progress_updated_at??0)-(r.progress_updated_at??0)}}function Xs(e,s){if(e.updated_at!==s.updated_at)return s.updated_at-e.updated_at;const r=ne(e).localeCompare(ne(s),void 0,{sensitivity:"base"});if(r!==0)return r;const a=e.name.localeCompare(s.name,void 0,{sensitivity:"base"});return a!==0?a:e.id<s.id?-1:e.id>s.id?1:0}function ki(e,s,r){const a=Vs(r.key,e),o=Vs(r.key,s);if(a!==o)return a-o;if(a===1)return Xs(e,s);const i=vi(r.key,e,s);return i!==0?r.direction==="desc"?-i:i:Xs(e,s)}function wi(e,s){return[...e].sort((r,a)=>ki(r,a,s))}const De=["day","week","month","quarter"],ws={day:24,week:9,month:3,quarter:1};function Ns(e){const s=new Date(e);return Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())}function Le(e,s){return Math.round((s-e)/He)}function Js(e,s){return Le(e,s)+1}function Ni(e,s){for(const r of De)if(e*ws[r]<=s)return r;return De[De.length-1]}function Si(e){const{project:s}=e;return s.start_date||s.target_date||s.completed_at?!0:e.milestones.some(r=>!!r.target_date)}function Ci(e,s){const r=[s];for(const a of e){for(const o of[a.project.start_date,a.project.target_date,a.project.completed_at]){const i=ve(o);i!==null&&r.push(i)}for(const o of a.milestones){const i=ve(o.target_date);i!==null&&r.push(i)}}return r.length===1?null:{startMs:Math.min(...r),endMs:Math.max(...r)}}function Ei(e){const s=[],r=[];for(const a of e)(Si(a)?s:r).push(a);return{dated:s,undated:r}}function Ti(e){return n("ui.projects.count.undated",{count:e})}function Ri(e){const{project:s}=e,r=ve(s.start_date),a=ve(s.target_date),o=ve(s.completed_at),i=s.status==="done"&&o!==null?o:a,l=r??i,c=i??r;return l===null||c===null?null:{fromMs:Math.min(l,c),toMs:Math.max(l,c)}}function Di(e){const s=[];for(const r of e.milestones){const a=ve(r.target_date);a!==null&&s.push({name:r.name,dayMs:a,status:r.status})}return s}const $t=e=>yt(new Date(e),{month:"short",timeZone:"UTC"});function he(e){const s=new Date(e);return{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),weekday:s.getUTCDay()}}function Ai(e){const{year:s,month:r}=he(e);return Date.UTC(s,r-1,1)}function Oi(e){const{year:s,month:r}=he(e);return r===12?Date.UTC(s+1,0,1):Date.UTC(s,r,1)}function Pi(e){const{year:s,month:r}=he(e);return Date.UTC(s,Math.floor((r-1)/3)*3,1)}function Mi(e){const{year:s,month:r}=he(e),a=Math.floor((r-1)/3);return a===3?Date.UTC(s+1,0,1):Date.UTC(s,a*3+3,1)}function Li(e){const{weekday:s}=he(e);return e-(s+6)%7*He}const Ii=26;function Fi(e,s,r){const a=[],o=(p,_,b)=>{p<e||p>s||a.push({dayMs:p,label:_,major:b})};if(r==="day"){let p=!1;for(let _=e;_<=s;_+=He){const{day:b}=he(_);b===1?(o(_,$t(_),!0),p=!0):p?(o(_,"",!1),p=!1):o(_,V(b,{useGrouping:!1}),!1)}return a}if(r==="week"){for(let p=Li(e);p<=s;p+=7*He){if(p<e)continue;const{day:_,month:b}=he(p);he(p-7*He).month!==b?o(p,yt(new Date(p),{month:"short",day:"numeric",timeZone:"UTC"}),!0):o(p,V(_,{useGrouping:!1}),!1)}return a}const i=r==="month"?Ai:Pi,l=r==="month"?Oi:Mi,c=p=>{const{year:_,month:b}=he(p);if(r==="month")return b===1&&_!==he(e).year?`${$t(p)} '${V(_%100,{minimumIntegerDigits:2,useGrouping:!1})}`:$t(p);const f=Math.floor((b-1)/3)+1;return f===1&&_!==he(e).year?`Q1 '${String(_%100).padStart(2,"0")}`:`Q${f}`};o(e,c(i(e)),!0);const u=Math.ceil(Ii/ws[r]);let m=e;for(let p=l(i(e));p<=s;p=l(p))Le(m,p)<u||(o(p,c(p),!0),m=p);return a}function lt(e){return e.split(",").map(s=>s.trim()).filter(s=>s.length>0)}const wt=80,Nt=80,Zs=64,er=8;function ts(e){return e.trim().length>wt?n("ui.projects.project_edit_model.titles_are_at_most_value1_characters",{value1:wt}):null}function sn(e){return e.length>Xe?n("ui.projects.project_edit_model.keep_the_description_within_value1_characters",{value1:Xe}):null}function St(e,s){return e.trim().length>Nt?n("ui.projects.project_edit_model.teams_are_at_most_value2_characters",{teams:String(s==="owner"?n("ui.projects.project_edit_model.owners"):n("ui.projects.project_edit_model.teams")),value2:Nt}):null}function ss(e){return Ir.test(e)?null:n("ui.projects.project_edit_model.dates_are_yyyy_mm_dd_or_empty")}function rs(e,s){return e&&s&&s<e?n("ui.projects.project_edit_model.the_target_date_is_before_the_start_date"):null}function rn(e){const s=e.trim();if(s==="")return null;const r=Number(s);return!Number.isFinite(r)||!(r>0)||r>1e3?n("ui.projects.project_edit_model.estimates_are_greater_than_0_and_at_most_1000"):null}function ns(e){const s=lt(e);if(s.length>er)return{tags:s,error:n("ui.projects.project_edit_model.up_to_project_tags_max_tags",{PROJECT_TAGS_MAX:er})};for(const r of s){const a=Fa(r);if(a)return{tags:s,error:a}}return{tags:s,error:null}}const qi="project_name_exists";function tr(e){return e.code===qi?n("ui.projects.project_edit_model.a_project_with_this_key_already_exists"):_t(e.message)||n("ui.projects.project_edit_model.the_project_was_not_saved")}function Ui(e,s){if(e.unit!==s.unit)return!1;const r=e.number.trim(),a=s.number.trim();return a===""?!0:r===""?!1:Number(r)===Number(a)}function Bi(e,s){const r=lt(s);return r.length!==e.length?!1:r.every((a,o)=>a===e[o])}function $i(e,s){const r={},a=s.number.trim();if(a!==""){const o=Number(a);(e.estimate===null||e.estimate!==o)&&(r.estimate=o)}return s.unit!==e.unit&&(r.estimate_unit=s.unit),Object.keys(r).length>0?r:null}function tt(e){return e instanceof Rt?tr({code:e.code,message:e.message}):tr({message:e instanceof Error?e.message:""})}function nn(e){return e instanceof Rt&&(e.code==="project_not_found"||e.status===404)}function an(e){return!(e instanceof Error)||!e.message?n("ui.projects.project_model.the_project_was_not_moved_try_again_or_open_it_to_change_its_stat"):nn(e)?n("ui.projects.project_refusals.this_project_could_not_be_found_it_may_have_been_deleted"):tt(e)}function on(e){if(!(e instanceof Error))return null;const s=e instanceof Rt?e:null;return zo({code:s?.code??null,message:e.message,detail:s?.detail})}async function zi(e){try{return await e.move(),{kind:"accepted"}}catch(s){const r=on(s);return r?.coded&&e.forceDoneOffered&&e.claimQuestion()?{kind:"question",refusal:r}:{kind:"spoken",copy:r?Ho(r):an(s),refusal:r}}}Fe["ui.projects.board_window_select.shows_projects_last_updated_within_this_window_older_ones_are_hid"];const Gi=({value:e,onChange:s})=>(F(),t.jsxs(Ke,{value:e,onValueChange:r=>s(r),children:[t.jsx(Ot,{content:e==="all"?null:n("ui.projects.board_window_select.shows_projects_last_updated_within_this_window_older_ones_are_hid"),side:"bottom",disableHoverableContent:!0,children:t.jsx(We,{"aria-label":n("ui.projects.board_window_select.projects_updated_within"),className:M("w-36 shrink-0"),"data-tour-tag":"projects-board-window",children:t.jsx(Ve,{})})}),t.jsx(Qe,{children:Lt.map(r=>t.jsx(Ae,{value:r.value,children:r.label},r.value))})]})),as=6e4,os=6e3;Fe["ui.projects.request_update.requesting_updates"];const Hi=400;Fe["ui.projects.request_update.ask_the_sessions_linked_to_this_project_to_post_a_progress_update"];const Yi="linked but not yet in use — it becomes a recipient after the first message",sr=e=>`project-request-update-${e}`,Ki=e=>`project-request-cooldown-${e}`,Wi=e=>`project-request-update-cooldown-${e}`,zt=e=>e.length===1?e[0]:e.length===2?n("ui.projects.request_update.names_0_and_names_1",{names_0:String(e[0]),names_1:String(e[1])}):n("ui.projects.request_update.names_0_names_1_and_length_2_more",{names_0:String(e[0]),names_1:String(e[1]),length___2:V(e.length-2,{useGrouping:!1})}),rr=(e,s)=>e.sessions.filter(r=>r.outcome===s).map(r=>It({session_id:r.session_id,title:r.title})),Vi=e=>e.outcome==="failed"&&e.detail===Yi;function Ct(e,s){const r=Math.max(1,Math.ceil(s/1e3)),a=Math.max(0,Math.ceil(as/1e3)-r);return n("ui.projects.request_update.update_already_requested_ago_s_ago_on_display_try_again_in_left_s",{ago:V(a,{useGrouping:!1}),display:String(e),left:V(r,{useGrouping:!1})})}function Qi(e){const s=ne({title:e.project.title,name:e.project.key}),{delivered:r,unconfirmed:a,failed:o,total:i}=e.counts;if(e.state==="empty")return{variant:"info",title:n("ui.projects.request_update.no_linked_sessions_to_ask_link_a_session_to_display_first",{display:String(s)}),duration:os};if(e.state==="cooldown")return{variant:"info",title:Ct(s,Math.max(0,e.cooldown_remaining_s??0)*1e3),duration:os};if(e.state!=="sent")return null;const l=rr(e,"failed"),c=rr(e,"unconfirmed");if(r>=1&&o===0&&a===0)return{variant:"success",title:n("ui.projects.request_update.delivered",{delivered:r,display:s})};if(r>=1){let u=n("ui.projects.request_update.requested_updates_from_delivered_of_total_sessions_on_display",{delivered:V(r,{useGrouping:!1}),total:i,display:String(s)});return o>0&&(u+=n("ui.projects.request_update.value1_could_not_be_reached",{value1:String(zt(l))})),a>0&&(u+=n("ui.projects.request_update.delivery_to_value1_could_not_be_confirmed",{value1:String(zt(c))})),{variant:"warning",title:u,duration:Number.POSITIVE_INFINITY}}if(o===0)return{variant:"warning",title:n("ui.projects.request_update.could_not_confirm_delivery_on_display_the_requests_may_still_reac",{display:String(s)}),duration:Number.POSITIVE_INFINITY};if(a===0){const u=e.sessions.every(Vi);let m;return u?m=n("ui.projects.request_update.never_started",{total:i}):m=n("ui.projects.request_update.could_not_reach_any_of_the_total_linked_sessions_on_display",{total:i,display:String(s)}),{variant:"error",title:m,duration:Number.POSITIVE_INFINITY}}return{variant:"warning",title:n("ui.projects.request_update.could_not_reach_failed_of_the_total_linked_sessions_on_display_de",{failed:V(o,{useGrouping:!1}),total:i,display:String(s),value4:String(zt(c))}),duration:Number.POSITIVE_INFINITY}}const at=new Map,Ss=new Set,Gt=new Map,is=new Set;let cn=0;const Et=()=>{cn+=1;for(const e of is)e()},Xi=e=>(is.add(e),()=>{is.delete(e)}),nr=()=>cn,ln=e=>Ss.has(e),un=e=>at.get(e);function Ji(e){Ss.add(e),Et()}function Zi(e){Ss.delete(e),Et()}function ar(e,s,r){const a=Date.now();if(r<=a)return;const o=at.get(e);if(o&&o.untilMs>=r)return;at.set(e,{startedMs:s,untilMs:r});const i=Gt.get(e);i&&clearTimeout(i);const l=setTimeout(()=>{Gt.delete(e);const c=at.get(e);c&&c.untilMs<=Date.now()&&(at.delete(e),Et())},r-a);l.unref?.(),Gt.set(e,l),Et()}const ec=e=>/[.!?…]$/.test(e)?e:`${e}.`;function tc(e,s){const r=Date.now();if(s.state==="cooldown"){const a=Math.max(0,s.cooldown_remaining_s??0)*1e3;ar(e,r-(as-a),r+a);return}s.state==="sent"&&(s.counts.delivered>=1||s.counts.unconfirmed>=1)&&ar(e,r,r+as)}async function sc(e){const s=e.id;if(ln(s)){Ps(n("ui.projects.request_update.requesting_updates"),{id:sr(s)});return}const r=Date.now(),a=un(s);if(a&&a.untilMs>r){Ms(Ct(ne(e),a.untilMs-r),{id:Ki(s),duration:os});return}Ji(s);const o=sr(s);let i=!1;const l=setTimeout(()=>{i=!0,Ps(n("ui.projects.request_update.requesting_updates"),{id:o})},Hi);try{const c=await _e({op:"projects.request_update",key:s});tc(s,c);const u=Qi(c);if(u){const m={id:o,...u.duration!==void 0?{duration:u.duration}:{}};switch(u.variant){case"success":be(u.title,m);break;case"warning":Bn(u.title,m);break;case"error":Ls(u.title,m);break;default:Ms(u.title,m)}}else i&&$n(o)}catch(c){const u=c instanceof Error&&c.message.trim()!==""?c.message.trim():null;Ls(u?n("ui.projects.use_request_update.could_not_request_updates_endedsentence_message",{endedSentence_message:String(ec(u))}):n("ui.projects.use_request_update.the_request_could_not_be_confirmed"),{id:o,duration:Number.POSITIVE_INFINITY})}finally{clearTimeout(l),Zi(s)}}function dn(){return d.useCallback(e=>{sc(e)},[])}function rc(e){d.useSyncExternalStore(Xi,nr,nr);const s=ln(e),r=un(e),a=r!==void 0?r.untilMs-Date.now():0,o=a>0;return{sending:s,cooling:o,cooldownRemainingMs:o?a:null}}const or={get active(){return n("ui.projects.project_board.in_flight")},get paused(){return n("ui.projects.project_board.on_hold")},get done(){return n("ui.projects.project_board.finished")}};function nc(){const[e,s]=d.useState(null);return d.useEffect(()=>{if(!e)return;const r=document.querySelector(`[data-project-menu="${e}"]`);r&&(r.focus(),s(null))}),d.useCallback(r=>s(r),[])}const ac=4,ir="board-column-move-hint",oc=({projects:e,nowMs:s,onOpen:r,onEdit:a,onDelete:o,onMove:i,movingKeys:l=[],teamLabelFor:c=u=>u})=>{F();const[u,m]=d.useState(vo),p=No(e,u),_=bs(e,ft),[b,f]=d.useState(null),[x,w]=d.useState(""),g=d.useRef(null),h=d.useRef(null),v=d.useRef(null);d.useEffect(()=>{const y=g.current,k=h.current;if(!y||!k)return;const O=k.firstElementChild;let L=-1;const U=()=>{const z=k.offsetWidth-k.clientWidth;z!==L&&(L=z,y.style.paddingRight=z>0?`${z}px`:"")};let Y=-1;const Q=()=>{const z=k.scrollLeft;Math.abs(y.scrollLeft-z)>.5&&(y.scrollLeft=z),Y=z},$=()=>{Math.abs(y.scrollLeft-Y)<=.5||(Math.abs(k.scrollLeft-y.scrollLeft)>.5&&(k.scrollLeft=y.scrollLeft),Y=y.scrollLeft)},je=z=>{const se=z.deltaMode===1?16:z.deltaMode===2?k.clientWidth:1,xe=z.deltaMode===1?16:z.deltaMode===2?k.clientHeight:1;Math.abs(z.deltaX)>Math.abs(z.deltaY)?k.scrollLeft+=z.deltaX*se:k.scrollTop+=z.deltaY*xe,z.preventDefault()};U(),Q(),y.addEventListener("wheel",je,{passive:!1}),y.addEventListener("scroll",$,{passive:!0}),k.addEventListener("scroll",Q,{passive:!0});const ie=new ResizeObserver(()=>{U(),Q()});return ie.observe(k),O&&ie.observe(O),window.addEventListener("resize",U),()=>{y.removeEventListener("wheel",je),y.removeEventListener("scroll",$),k.removeEventListener("scroll",Q),ie.disconnect(),window.removeEventListener("resize",U)}},[]);const T=d.useRef(null),N=d.useRef(null),q=d.useRef(null),C=new Set(l),E=(y,k)=>{const O=wo(p.map(L=>L.status),y,k);m(O),ko(O),w(n("ui.projects.project_board.moved_label_column_to_position_indexof_status_1_of_length",{label:String(ae(y).label),indexOf_status____1:String(O.indexOf(y)+1),length:V(O.length,{useGrouping:!1})}))},P=(y,k)=>{const O=g.current;if(!O)return 0;let L=0;const U=O.querySelectorAll("[data-board-column]");for(const Y of U){if(Y.dataset.boardColumn===k)continue;const Q=Y.getBoundingClientRect();y>(Q.left+Q.right)/2&&(L+=1)}return L},j=(y,k)=>{const O=p.filter(Y=>Y.status!==y),L=O[k-1]?.status,U=O[k]?.status;return L&&U?n("ui.projects.project_board.between_label_and_label_2",{label:String(ae(L).label),label_2:String(ae(U).label)}):U?n("ui.projects.project_board.before_label",{label:String(ae(U).label)}):L?n("ui.projects.project_board.after_label",{label:String(ae(L).label)}):n("ui.projects.project_board.in_place")},D=(y,k)=>{const O=P(y,k.status);O!==k.over&&(k.over=O,f({status:k.status,over:O}),w(n("ui.projects.project_board.moving_label_column_it_will_drop_status_over",{label:String(ae(k.status).label),status__over:String(j(k.status,O))})))},R=()=>{N.current!==null&&(cancelAnimationFrame(N.current),N.current=null)},I=32,K=12,B=()=>{N.current=null;const y=q.current,k=h.current,O=T.current;if(!y?.armed||!k||O===null)return;const L=k.getBoundingClientRect(),U=k.scrollWidth-k.clientWidth;let Y=0;if(O-L.left<I&&k.scrollLeft>0?Y=-1:L.right-O<I&&k.scrollLeft<U&&(Y=1),Y!==0){const Q=k.scrollLeft;if(k.scrollLeft=Q+Y*K,k.scrollLeft!==Q){const $=g.current;$&&($.scrollLeft=k.scrollLeft),D(O,y)}}else D(O,y);ee(y.status,y.over),N.current=requestAnimationFrame(B)};d.useEffect(()=>()=>{N.current!==null&&cancelAnimationFrame(N.current)},[]);const H=(y,k)=>{if(y.button===0){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}q.current={pointerId:y.pointerId,status:k,startX:y.clientX,startY:y.clientY,armed:!1,over:p.findIndex(O=>O.status===k)},T.current=y.clientX}},X=y=>{const k=q.current;if(!(!k||y.pointerId!==k.pointerId)){if(T.current=y.clientX,!k.armed){if(Math.hypot(y.clientX-k.startX,y.clientY-k.startY)<ac)return;k.armed=!0,f({status:k.status,over:k.over}),w(n("ui.projects.project_board.moving_label_column",{label:String(ae(k.status).label)})),N.current===null&&(N.current=requestAnimationFrame(B))}D(y.clientX,k)}},Z=y=>{const k=q.current;if(q.current=null,R(),f(null),!k?.armed)return;if(!y){w(n("ui.projects.project_board.move_cancelled"));return}const O=p.findIndex(L=>L.status===k.status);if(k.over===O){w("");return}E(k.status,k.over)},me=y=>{const k=q.current;!k||y.pointerId!==k.pointerId||Z(!0)},oe=()=>{Z(!1)};d.useEffect(()=>{if(!b)return;const y=k=>{k.key==="Escape"&&Z(!1)};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[b!==null]);const ee=d.useCallback((y,k)=>{const O=g.current,L=h.current,U=v.current;if(!O||!L||!U)return;const Y=L.getBoundingClientRect(),Q=[];for(const re of O.querySelectorAll("[data-board-column]"))re.dataset.boardColumn!==y&&Q.push(re.getBoundingClientRect());const $=6,je=k>=Q.length?(Q[Q.length-1]?.right??Y.left)+$:(Q[k]?.left??Y.right)-$,ie=L.scrollLeft,z=2,se=je-Y.left+ie,xe=ie+1,fe=ie+L.clientWidth-z-1,Pe=Math.round(Math.min(Math.max(se,xe),Math.max(xe,fe)));U.style.left=`${Pe}px`},[]);d.useLayoutEffect(()=>{b&&ee(b.status,b.over)},[b,ee]);const te=(y,k)=>{if(y.key==="Enter"||y.key===" "){y.preventDefault(),w(n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column"));return}if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const O=p.map(Y=>Y.status),L=O.indexOf(k),U=y.key==="ArrowLeft"?L-1:L+1;if(U<0||U>=O.length){w(n("ui.projects.project_board.label_column_is_already_the_last_column",{label:String(ae(k).label),the_last_column:String(U<0?n("ui.projects.project_board.the_first_column"):n("ui.projects.project_board.the_last_column"))}));return}E(k,U)};return t.jsxs("div",{className:M("[container-type:size] flex min-h-0 flex-1 flex-col",b&&"cursor-grabbing select-none"),"data-testid":"project-board",children:[t.jsx("output",{"aria-live":"polite",className:"sr-only","data-board-column-announcement":"",children:x}),t.jsx("span",{id:ir,className:"sr-only",children:n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column")}),t.jsx("div",{ref:g,"data-board-header-viewport":"",className:"h-11 shrink-0 overflow-hidden",children:t.jsx("div",{"data-board-column-row":"",className:"flex h-11 w-max gap-3 px-6",children:p.map(y=>{const k=ae(y.status);return t.jsxs("header",{"data-board-column":y.status,"data-board-column-handle":y.status,onPointerDown:O=>H(O,y.status),onPointerMove:X,onPointerUp:me,onPointerCancel:oe,className:M("flex h-11 w-64 shrink-0 cursor-grab items-center justify-between gap-2 rounded-t-md bg-sunken px-3 active:cursor-grabbing",b?.status===y.status&&"opacity-85"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[t.jsx(G,{type:"button",variant:"ghost",size:"icon-sm","data-board-column-grip":y.status,"aria-label":n("ui.projects.project_board.move_label_column",{label:String(k.label)}),"aria-describedby":ir,title:n("ui.projects.project_board.drag_the_header_or_press_the_arrow_keys_to_move_this_column"),className:"-ml-1.5 cursor-grab text-ink-muted active:cursor-grabbing",onKeyDown:O=>te(O,y.status),children:t.jsx(Da,{"aria-hidden":"true"})}),t.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[t.jsx("span",{className:"truncate text-body-sm font-medium text-ink",children:k.label}),or[y.status]&&t.jsx("span",{className:"truncate text-meta text-ink-muted",children:or[y.status]})]})]}),t.jsx("span",{className:"text-meta text-ink-muted",children:y.projects.length})]},y.status)})})}),t.jsxs("div",{ref:h,"data-board-strip":"",className:"relative min-h-0 flex-1 overflow-auto px-6 pb-9",children:[b&&t.jsx("div",{ref:v,"aria-hidden":"true","data-board-drop-indicator":"",className:"pointer-events-none absolute top-3 bottom-3 w-0.5 rounded-full bg-accent"}),t.jsx("div",{className:"flex w-max flex-col",children:_.map(y=>t.jsxs("section",{className:"flex flex-col",children:[t.jsx("div",{"data-board-team":y.team??"",className:"sticky top-0 z-20 flex h-8 items-center bg-canvas px-3 text-meta",children:t.jsxs("span",{className:"sticky left-3 flex min-w-0 max-w-[calc(100cqw-2.25rem)] items-center gap-2",children:[t.jsx("span",{className:"truncate text-ink",children:y.team==null?n("ui.projects.project_model.no_team"):c(y.team)}),t.jsx("span",{className:"shrink-0 text-ink-muted",children:y.items.length})]})}),t.jsx("div",{"data-glass-lane":"",className:"flex gap-3 rounded-md bg-sunken py-2",children:p.map(k=>{const O=y.items.filter(L=>L.status===k.status);return t.jsx("div",{"data-board-cell":k.status,className:"flex max-h-[calc(100cqh-92px)] w-64 shrink-0 flex-col gap-2 overflow-y-auto px-2",children:O.length>0&&t.jsx("ul",{className:"flex flex-col gap-2",children:O.map(L=>t.jsx("li",{children:t.jsx(ic,{project:L,nowMs:s,busy:C.has(L.id),onOpen:()=>r(L),onEdit:()=>a(L),onDelete:()=>o(L),onMove:U=>i(L,U)})},L.id))})},k.status)})})]},y.team??""))})]})]})},ic=({project:e,nowMs:s,busy:r,onOpen:a,onEdit:o,onDelete:i,onMove:l})=>{const c=F(),u=Br(e,c),m=Ze(),p=dn(),_=ye(m.data,"projects_request_update"),b=ne(e),f=d.useRef(null),[x,w]=d.useState(!1);d.useEffect(()=>{const N=f.current;if(!N)return;const q=()=>{N.isConnected&&w(N.scrollWidth-N.clientWidth>.5)},C=requestAnimationFrame(q),E=new ResizeObserver(q);return E.observe(N),document.fonts?.ready.then(q).catch(()=>{}),()=>{cancelAnimationFrame(C),E.disconnect()}},[b,x]);const g=Yr(e,Ns(s)),h=pt(e.progress_updated_at,s),v=()=>{const N=window.getSelection();N&&!N.isCollapsed||a()},T=N=>{N.key!=="Enter"&&N.key!==" "||N.target===N.currentTarget&&(N.preventDefault(),a())};return t.jsxs("div",{"data-project-name":e.name,role:"button",tabIndex:0,"aria-label":n("ui.projects.project_board.open_displayname",{displayName:String(b)}),onClick:v,onKeyDown:T,"data-glass-block":"",className:M("group/card flex flex-col gap-2 rounded-sm bg-surface p-3","transition-colors duration-fast ease-out-quart hover:bg-elevated",g&&"border border-warning-border"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx(Ot,{content:x?b:null,side:"top",disableHoverableContent:!0,children:t.jsx("span",{ref:f,"data-project-title":e.name,tabIndex:x?0:void 0,className:"block truncate text-body-sm font-medium text-ink",children:b})}),e.title&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.name}),e.description&&t.jsx("span",{className:"mt-0.5 block truncate text-meta text-ink-muted",children:e.description})]}),t.jsxs(ps,{children:[t.jsx(ms,{"data-project-menu":e.id,"aria-label":n("ui.projects.project_board.actions_for_displayname",{displayName:String(b)}),disabled:r,onClick:N=>N.stopPropagation(),className:M("shrink-0 rounded-sm p-1 text-ink-muted whitespace-nowrap","hover:bg-sunken hover:text-ink"),children:r?t.jsx(Te,{size:"xs"}):t.jsx(yr,{className:"size-4"})}),t.jsxs(fs,{align:"end",onClick:N=>N.stopPropagation(),children:[t.jsx(Ee,{onSelect:a,children:n("ui.projects.project_board.open")}),t.jsxs(ya,{children:[t.jsx(va,{children:n("ui.projects.project_board.set_status")}),t.jsx(ka,{children:t.jsx(wa,{value:e.status,onValueChange:l,children:[...Vt,...Qt].map(N=>t.jsx(Na,{value:N,children:ae(N).label},N))})})]}),_&&t.jsx(Ee,{onSelect:()=>p(e),children:n("ui.projects.project_board.request_update")}),t.jsx(Sa,{}),t.jsx(Ee,{onSelect:o,children:n("ui.projects.project_board.edit")}),t.jsx(Ee,{onSelect:i,children:n("ui.projects.project_board.delete")})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[u.filter(N=>N.key!=="live").map(N=>t.jsx("span",{className:"rounded-sm bg-sunken px-1.5 py-0.5 text-meta text-ink-muted",children:N.text},N.key)),g&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_board.overdue")})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-meta text-ink-muted",children:co(h)}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[(e.progress_stale||!h)&&t.jsx("span",{"aria-label":n("ui.projects.project_model.stale"),title:n("ui.projects.project_model.stale"),className:"size-1.5 rounded-full bg-warning"}),e.sessions>0&&t.jsx(cc,{project:e})]})]})]})},cc=({project:e})=>{F();const[s,r]=d.useState(!1),a=Dt(),o=Ar(e.id,s),i=o.data?.links??[],l=mo(e),c=ne(e);return t.jsxs(_s,{open:s,onOpenChange:r,children:[t.jsx(js,{"data-project-sessions":e.id,"aria-label":n("ui.projects.project_board.sessions_linked_to_displayname",{displayName:String(c)}),onClick:u=>u.stopPropagation(),className:M("rounded-sm px-1 text-meta whitespace-nowrap",e.live_sessions>0?"text-success hover:bg-sunken":"text-ink-muted hover:bg-sunken"),children:l}),t.jsx(hs,{align:"end",className:"w-64 p-2 outline-none",onClick:u=>u.stopPropagation(),children:o.isLoading?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:n("ui.projects.project_board.loading_linked_sessions")}):o.isError?t.jsxs("div",{className:"flex flex-col items-start gap-1.5 px-1 py-2",children:[t.jsx("p",{className:"text-meta text-ink-muted",children:o.error instanceof Error&&o.error.message?o.error.message:n("ui.projects.project_board.the_linked_sessions_could_not_be_read")}),t.jsx(G,{variant:"secondary",size:"sm",onClick:()=>void o.refetch(),children:n("ui.projects.project_board.try_again")})]}):i.length===0?t.jsx("p",{className:"px-1 py-2 text-meta text-ink-muted",children:n("ui.projects.project_board.no_sessions_linked_yet")}):t.jsx("ul",{className:"flex flex-col",children:i.map(u=>t.jsx("li",{children:t.jsx("button",{type:"button",disabled:!u.exists,onClick:()=>{u.exists&&(r(!1),Rr(a,u.session_id))},className:M("flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-meta",u.exists?"text-ink hover:bg-elevated":"text-ink-disabled"),children:t.jsx("span",{className:"truncate",children:u.title||u.session_id})})},u.session_id))})})]})},pn=({open:e,projectName:s,onClose:r,onConfirm:a})=>{F();const[o,i]=d.useState(""),[l,c]=d.useState(null),[u,m]=d.useState(!1),p=d.useId();d.useEffect(()=>{e&&(i(""),c(null),m(!1))},[e]);const _=o.trim().toLowerCase()===s.trim().toLowerCase()&&s.trim().length>0,b=async()=>{m(!0),c(null);try{await a(o.trim()),r()}catch(f){c(f instanceof Error&&f.message?f.message:n("ui.projects.project_delete_dialog.the_project_was_not_deleted"))}finally{m(!1)}};return t.jsx(dt,{open:e,onClose:r,title:n("ui.projects.project_delete_dialog.delete_this_project"),dataTourTag:"project-delete-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Ye,{onClick:r,disabled:u,children:n("ui.projects.project_delete_dialog.cancel")}),t.jsxs(zn,{onClick:()=>void b(),disabled:!_||u,children:[u&&t.jsx(Te,{size:"xs"}),n("ui.projects.project_delete_dialog.delete_project")]})]}),children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("p",{className:"text-body-sm text-ink",children:n("ui.projects.project_delete_dialog.this_deletes_the_project_and_its_milestones_the_sessions_linked_t")}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[n("ui.projects.project_delete_dialog.type")," ",t.jsx("span",{className:"font-mono text-mono-sm text-ink",children:s})," ",n("ui.projects.project_delete_dialog.to_confirm")]}),t.jsx(ue,{id:`${p}-confirm`,value:o,onChange:f=>i(f.target.value),placeholder:s,"aria-label":n("ui.projects.project_delete_dialog.type_the_project_name_to_confirm"),"aria-invalid":o.length>0&&!_,autoFocus:!0}),l&&t.jsx("p",{className:"text-body-sm text-danger",children:l})]})})};function lc(e){return e==="editing"||e==="saving"||e==="error"}function uc(e,s,r=Object.is){return!r(e,s)}function dc(e,s){if(e.key==="Escape")return e.defaultPrevented===!0?null:"revert";if(e.key!=="Enter"||!s.keyboardCommit)return null;const r=e.metaKey===!0||e.ctrlKey===!0;return s.multiline?r?"accept":null:s.onEditor?"accept":null}function pc(e,s){return e==="saving"||e==="error"?!0:e==="editing"&&s}function mc(e){const{phase:s,base:r,draft:a,fresh:o,equals:i}=e;return s==="saving"||s==="saved"||i(r,o)?"none":s==="idle"||i(r,a)||i(o,a)?"adopt":"conflict"}function cr(e,s,r=Object.is){return!r(e,s)}const Cs="group/inline-edit",Ht="inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-xs text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",fc="relative before:absolute before:-inset-1.5 before:content-['']",_c="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-left-1.5 before:right-0 before:content-['']",jc="relative before:absolute before:-top-1.5 before:-bottom-1.5 before:-right-1.5 before:left-0 before:content-['']",cs=({api:e,idle:s="affordance",className:r})=>{const{phase:a,labels:o}=e,i=a==="editing"||a==="saving"||a==="error",l=pc(a,e.dirty),c=e.acceptBlocked===!0;return t.jsx("span",{"data-inline-edit-slot":a,className:M("inline-flex shrink-0 items-center gap-0.5",r),children:l?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button","data-inline-edit-control":"cancel","aria-label":a==="saving"?o.busy:o.cancel,title:a==="saving"?o.busy:o.cancel,"aria-disabled":a==="saving"||void 0,onMouseDown:u=>u.preventDefault(),onClick:u=>{u.detail>1||a!=="saving"&&e.cancel()},className:M(Ht,_c,a==="saving"&&"cursor-default text-ink-disabled"),children:t.jsx(Pt,{className:"size-3","aria-hidden":"true"})}),a==="saving"?t.jsx("span",{"data-inline-edit-control":"busy",className:"inline-flex size-5 shrink-0 items-center justify-center",children:t.jsx(Te,{size:"xs"})}):t.jsx("button",{type:"button","data-inline-edit-control":"accept","aria-label":a==="error"?o.retry??o.accept:o.accept,title:a==="error"?o.retry??o.accept:o.accept,"aria-disabled":c||void 0,onMouseDown:u=>u.preventDefault(),onClick:u=>{u.detail>1||c||e.accept()},className:M(Ht,jc,c&&"cursor-default text-ink-disabled"),children:t.jsx(gs,{className:"size-3","aria-hidden":"true"})})]}):i?null:s==="affordance"?t.jsx("button",{ref:e.slotRef,type:"button","data-inline-edit-control":"begin","aria-label":o.begin,title:o.begin,onClick:u=>{u.detail>1||e.begin()},className:M(Ht,fc,"opacity-0 transition-opacity duration-base ease-out-quart","group-hover/inline-edit:opacity-100 group-hover/inline-edit:duration-fast","group-focus-within/inline-edit:opacity-100 group-focus-within/inline-edit:duration-fast","focus-visible:opacity-100"),children:t.jsx(Gn,{className:"size-3","aria-hidden":"true"})}):null})},ls=({api:e,className:s})=>{F();const{phase:r,error:a,conflict:o}=e;return r==="saved"?t.jsx("p",{"data-inline-edit-feedback":"saved",className:M("text-meta text-success",s),children:e.labels.saved}):!a&&!o?null:t.jsxs("div",{id:e.feedbackId,"data-inline-edit-feedback":a&&o?"error+conflict":a?"error":"conflict",role:"alert",className:M("flex flex-wrap items-center gap-x-3 gap-y-1",s),children:[a&&t.jsx("p",{className:"text-meta text-danger",children:a}),a&&o===null&&t.jsx("button",{type:"button","data-inline-edit-control":"retry",onClick:()=>e.accept(),className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.actions.retry")}),o!==null&&t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-meta text-warning",children:n("ui.common.editing.conflict")}),t.jsx("button",{type:"button","data-inline-edit-control":"keep-mine",onClick:e.keepMine,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.editing.keep_mine")}),t.jsx("button",{type:"button","data-inline-edit-control":"use-theirs",onClick:e.useTheirs,className:"cursor-pointer text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink",children:n("ui.common.editing.use_theirs")})]})]})},mn=d.createContext(null),hc=50,gc=({children:e})=>{const[s,r]=d.useState(""),a=d.useMemo(()=>({current:o=>{r(""),window.setTimeout(()=>r(o),hc)}}),[]);return t.jsxs(mn.Provider,{value:a,children:[e,t.jsx("span",{"data-inline-edit-announcement":"","aria-live":"polite",className:"sr-only",children:s})]})},xc=1200;function bc(e){return e instanceof Error&&e.message?e.message:"The change was not saved."}function jt(e){const{value:s,multiline:r=!1,keyboardCommit:a=!0,selectAllOnBegin:o=!1,beginOnMount:i=!1,savedDwellMs:l=xc,labels:c}=e,u=d.useRef(e.equals??Object.is);u.current=e.equals??Object.is;const m=d.useRef(e.commit);m.current=e.commit;const p=d.useRef(e.validate);p.current=e.validate;const _=d.useRef(e.errorCopy);_.current=e.errorCopy;const b=d.useRef(e.onSettle);b.current=e.onSettle;const f=d.useRef(e.onBegin);f.current=e.onBegin;const x=d.useRef(c);x.current=c;const[w,g]=d.useState(i?"editing":"idle"),[h,v]=d.useState(s),[T,N]=d.useState(s),[q,C]=d.useState(null),[E,P]=d.useState(null),j=d.useRef(w),D=d.useRef(h),R=d.useRef(T),I=d.useRef(q),K=d.useRef(s);K.current=s;const B=d.useCallback(A=>{j.current=A,g(A)},[]),H=d.useCallback(A=>{D.current=A,v(A)},[]),X=d.useCallback(A=>{R.current=A,N(A)},[]),Z=d.useCallback(A=>{I.current=A,C(A)},[]),me=d.useRef(null),oe=d.useRef(null),ee=d.useRef(null),te=e.editorRef??ee,y=d.useRef(te);y.current=te;const k=`${d.useId()}-inline-edit`,O=d.useContext(mn),L=d.useRef(null),U=L.current,Q=U!==null&&(e.equals??Object.is)(s,U.previous)&&!(e.equals??Object.is)(s,U.saved)&&U!==null?U.saved:s,$=d.useRef(Q);$.current=Q,d.useEffect(()=>{const A=L.current;if(A===null)return;const ce=u.current;(ce(s,A.saved)||!ce(s,A.previous))&&(L.current=null)},[s]);const je=d.useRef(i);d.useEffect(()=>{if(w!=="editing"||!je.current)return;je.current=!1;const A=y.current.current;A&&(A.focus(),o&&(A instanceof HTMLInputElement||A instanceof HTMLTextAreaElement)&&A.select())},[w,o]);const ie=d.useRef(!1);d.useEffect(()=>{ie.current&&(w!=="idle"&&w!=="saved"||(ie.current=!1,oe.current?.focus()))});const z=d.useRef(null),se=d.useCallback(()=>{z.current!==null&&(clearTimeout(z.current),z.current=null)},[]);d.useEffect(()=>()=>se(),[se]);const xe=d.useRef(w);d.useEffect(()=>{const A=xe.current;if(xe.current=w,A==="saving"&&w==="saved"){b.current?.("saved");return}(A==="editing"||A==="error")&&w==="idle"&&b.current?.("cancelled")},[w]),d.useEffect(()=>{const A=mc({phase:j.current,base:R.current,draft:D.current,fresh:$.current,equals:u.current});A==="adopt"?(u.current(R.current,$.current)||X($.current),u.current($.current,D.current)||H($.current)):A==="conflict"&&(I.current===null||!u.current(I.current,$.current))&&Z($.current)},[s,w,X,H,Z]);const fe=d.useCallback(A=>{Z(null),P(null),H(R.current),B("idle"),A&&(ie.current=!0)},[Z,H,B]),Pe=d.useCallback(()=>{j.current!=="saving"&&(j.current==="idle"||j.current==="saved"||(se(),fe(!0)))},[se,fe]),re=d.useCallback((A,ce=!0)=>{const nt=j.current;if(nt==="saving"||nt==="saved"||I.current!==null)return;const we=A!==void 0?A:D.current;if(!cr(R.current,we,u.current)){fe(ce&&nt!=="idle");return}const gt=p.current?.(we)??null;if(gt!==null){B("error"),P(gt);return}H(we),P(null),B("saving"),m.current(we).then(()=>{j.current==="saving"&&(L.current={saved:we,previous:R.current},X(we),H(we),ce&&(ie.current=!0),B("saved"),se(),z.current=setTimeout(()=>{z.current=null,j.current==="saved"&&B("idle")},l),O?.current?.(x.current.saved))},$e=>{j.current==="saving"&&(B("error"),P(_.current?_.current($e):bc($e)))})},[O,se,fe,l,X,H,B]),Re=d.useCallback(()=>{j.current==="editing"||j.current==="saving"||(se(),je.current=!0,H($.current),X($.current),Z(null),P(null),B("editing"),f.current?.())},[se,X,Z,H,B]),Be=d.useCallback(()=>{const A=I.current;A!==null&&(Z(null),X(A),re())},[re,X,Z]),qt=d.useCallback(()=>{const A=I.current;A!==null&&(X(A),fe(!0))},[fe,X]),st=d.useCallback(A=>{const ce=dc(A,{multiline:r,keyboardCommit:a,onEditor:A.target===y.current.current});if(ce==="revert"){A.preventDefault(),Pe();return}ce==="accept"&&(A.preventDefault(),re())},[re,Pe,a,r]),rt=d.useCallback(A=>{if(j.current!=="editing")return;const ce=A.relatedTarget;if(!(ce!==null&&me.current?.contains(ce))&&!(ce instanceof Element&&ce.closest("[data-radix-popper-content-wrapper]")!==null)&&I.current===null){if(!cr(R.current,D.current,u.current)){fe(!1);return}re(void 0,!1)}},[re,fe]),ht=w==="saved"?h:Q;return{phase:w,dirty:uc(T,h,u.current),conflict:q,error:E,draft:h,setDraft:H,displayValue:ht,editing:lc(w),begin:Re,accept:re,cancel:Pe,keepMine:Be,useTheirs:qt,handleKeyDown:st,handleBlur:rt,fieldProps:{onKeyDown:st,onBlur:rt,"aria-busy":w==="saving"?!0:void 0},editorAria:{"aria-invalid":E!==null?!0:void 0,"aria-describedby":E!==null||q!==null?k:void 0},fieldRef:me,editorRef:te,slotRef:oe,feedbackId:k,labels:c}}const yc=/^(https?:|mailto:)/i,vc={a:({href:e,children:s})=>typeof e=="string"&&yc.test(e)?t.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:s}):t.jsx("span",{className:"font-mono text-mono-sm",children:s}),table:Yn},ut=d.memo(({children:e,className:s})=>t.jsx("div",{className:M("lo-markdown",s),children:t.jsx(Hn,{remarkPlugins:[Kn],components:vc,children:e})})),lr=`## Summary
|
|
23
23
|
|
|
24
24
|
## Goals
|
|
25
25
|
|
|
26
|
-
## Notes`,kc=new RegExp("\\p{Mn}","gu"),wc=/[^a-z0-9._-]+/g,Nc=/[._-]{2,}/g,Sc=/^[^a-z0-9]+/,ur=/[^a-z0-9]+$/;function Cc(e){return e.normalize("NFKD").replace(kc,"").toLowerCase().replace(wc,"-").replace(Nc,"-").replace(Sc,"").replace(ur,"").slice(0,64).replace(ur,"")}const Ec=/&#x([0-9a-f]+);/gi,Tc=/&#(\d+);/g,Rc=/ /g,Dc=/</g,Ac=/>/g,Oc=/"/g,Pc=/'|'/g,Mc=/&/g,dr=e=>e.replace(Ec,(s,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(Tc,(s,r)=>String.fromCodePoint(Number.parseInt(r,10))).replace(Rc," ").replace(Dc,"<").replace(Ac,">").replace(Oc,'"').replace(Pc,"'").replace(Mc,"&"),Lc=/<[^>]*>|[^<]+/g,Ic=/^<\//,Fc=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,qc=/\s+/g,pr=/class="[^"]*language-([\w+-]+)/,Uc=/href="([^"]*)"/,Bc=/src="([^"]*)"/,$c=/alt="([^"]*)"/,zc=/[ \t]+\n/g,Gc=/\n{3,}/g;function
|
|
26
|
+
## Notes`,kc=new RegExp("\\p{Mn}","gu"),wc=/[^a-z0-9._-]+/g,Nc=/[._-]{2,}/g,Sc=/^[^a-z0-9]+/,ur=/[^a-z0-9]+$/;function Cc(e){return e.normalize("NFKD").replace(kc,"").toLowerCase().replace(wc,"-").replace(Nc,"-").replace(Sc,"").replace(ur,"").slice(0,64).replace(ur,"")}const Ec=/&#x([0-9a-f]+);/gi,Tc=/&#(\d+);/g,Rc=/ /g,Dc=/</g,Ac=/>/g,Oc=/"/g,Pc=/'|'/g,Mc=/&/g,dr=e=>e.replace(Ec,(s,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(Tc,(s,r)=>String.fromCodePoint(Number.parseInt(r,10))).replace(Rc," ").replace(Dc,"<").replace(Ac,">").replace(Oc,'"').replace(Pc,"'").replace(Mc,"&"),Lc=/<[^>]*>|[^<]+/g,Ic=/^<\//,Fc=/^<\/?\s*([a-zA-Z][a-zA-Z0-9]*)/,qc=/\s+/g,pr=/class="[^"]*language-([\w+-]+)/,Uc=/href="([^"]*)"/,Bc=/src="([^"]*)"/,$c=/alt="([^"]*)"/,zc=/[ \t]+\n/g,Gc=/\n{3,}/g;function Hc(e){const s=[],r=(...m)=>{for(let p=s.length-1;p>=0;p--)if(m.includes(s[p].tag)){const[_]=s.splice(p,1);return _}},a=[],o=()=>s.some(m=>m.tag==="pre"),i=()=>s.filter(m=>m.tag==="blockquote").length;let l=!0;const c=m=>{m&&(i()>0&&l&&!o()&&a.push("> ".repeat(i())),a.push(m),l=m.endsWith(`
|
|
27
27
|
`))},u=e.match(Lc)??[];for(let m=0;m<u.length;m++){const p=u[m];if(!p.startsWith("<")){c(o()?dr(p):dr(p).replace(qc," "));continue}const _=Ic.test(p),b=(p.match(Fc)?.[1]??"").toLowerCase();if(_){switch(b){case"p":case"div":c(`
|
|
28
28
|
|
|
29
29
|
`);break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":r(b),c(`
|
|
@@ -37,4 +37,4 @@ import{r as d,t as n,d as Fe,j as t,c as M}from"./index-hX_aZwq0.js";import{cg a
|
|
|
37
37
|
`);break;case"blockquote":s.push({tag:"blockquote"});break}}return a.join("").replace(zc,`
|
|
38
38
|
`).replace(Gc,`
|
|
39
39
|
|
|
40
|
-
`).trim()}function fn(e,s,r){const a=e.clipboardData?.getData("text/html");if(!a)return;const o=Yc(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 m=l+o.length;u.setSelectionRange(m,m)})}const _n=({open:e,refusal:s,projectLabel:r,onClose:a,onConfirm:o,secondaryLabel:i,onSecondary:l})=>{F();const[c,u]=d.useState(!1),[m,p]=d.useState(null),_=d.useRef(!1),b=d.useRef(null);d.useEffect(()=>{e&&(u(!1),p(null),_.current=!1)},[e]);const f=async()=>{if(!_.current){_.current=!0,u(!0),p(null);try{await o(),a()}catch(w){p({copy:an(w),gone:nn(w)})}finally{_.current=!1,u(!1)}}},x=s?.names??[];return t.jsx(dt,{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:w=>{c&&w.preventDefault()},onInteractOutside:w=>{c&&w.preventDefault()},onOpenAutoFocus:w=>{w.preventDefault(),b.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(He,{ref:b,onClick:a,disabled:c,children:n("ui.projects.project_done_anyway_dialog.cancel")}),!m?.gone&&t.jsx(He,{onClick:l,disabled:c,children:i}),m?.gone?t.jsx(vt,{"data-project-force-close":"",onClick:a,children:n("ui.projects.project_done_anyway_dialog.close")}):t.jsxs(vt,{"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?Go(s):""}),x.length>bt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(vr,{summary:n("ui.projects.project_done_anyway_dialog.show_all_length_open_milestones",{length:x.length}),children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:x.map((w,g)=>t.jsx("li",{className:"break-words",children:w},`${g}-${w}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:m?.copy??""})]})})},jn=({status:e})=>{const s=ae(e);return t.jsxs(ke,{variant:s.variant,children:[no(e)&&t.jsx(gs,{"aria-hidden":!0}),s.label]})},Hc="project-key",Kc="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 Ft=({field:e,fieldRef:s,fieldProps:r,editing:a,label:o,bare:i=!1,display:l,editor:c,slot:u,feedback:m,controlsIdle:p="affordance",hug:_=!1,feedbackExtra:b,className:f,controlsClassName:x})=>t.jsxs("div",{ref:s,...r,"data-project-field":e,className:M(!i&&Cs,"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:M("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:M("min-w-0",_?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:u.begin,children:a?c:l}),t.jsx(cs,{api:u,idle:p,className:M("shrink-0",x)})]}),t.jsx("div",{className:M("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(ls,{api:m}),b]})})]})]}),Ie=({field:e,value:s,display:r,commitFields:a,validate:o,labels:i,commit:l,placeholder:c,mono:u=!1,ramp:m="text-body-sm",label:p,bare:_=!1,autoBegin:b=!1,maxLength:f,onRetire:x,className:w,controlsClassName:g})=>{const[h,v]=d.useState(b);d.useEffect(()=>{h&&s!==""&&(v(!1),x?.("filled"))},[h,s,x]);const T=jt({value:s,commit:async N=>{await l(a(N))},equals:(N,q)=>N.trim()===q.trim(),validate:o,labels:i,selectAllOnBegin:!0,beginOnMount:b,errorCopy:tt,onSettle:N=>{N==="cancelled"&&(v(!1),x?.("cancelled"))}});return!h&&s===""?null:t.jsx(Ft,{field:e,fieldRef:T.fieldRef,fieldProps:T.fieldProps,editing:T.editing,label:p,bare:_,display:r,slot:T,feedback:T,className:w,controlsClassName:g,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:N=>T.setDraft(N.target.value),spellCheck:!1,autoComplete:"off",className:M("h-8",u?"font-mono text-mono-sm":m)})})},Wc=({project:e,commit:s})=>{F();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:M(Cs,"flex min-w-0 flex-col gap-0.5"),children:[r?t.jsx(Ie,{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=>ts(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:wt,placeholder:n("ui.projects.project_editors.a_short_name_for_the_workstream"),ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(Ie,{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=>Wt(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:Zs,placeholder:Hc,ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!r&&(a?t.jsx(Ie,{field:"title",value:"",display:null,commitFields:c=>({title:c.trim()}),validate:c=>ts(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:wt,placeholder:e.name,ramp:"text-body-sm",bare:!0,autoBegin:!0,onRetire:l}):t.jsx("button",{ref:i,type:"button","data-project-add-title":"",onClick:()=>o(!0),className:M("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(Ie,{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=>Wt(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:Zs,placeholder:Kc,mono:!0})]})},Vc=({project:e,commit:s})=>{F();const[r,a]=d.useState(!1),o=Ze(),i=ye(o.data,"projects_force_done"),[l,c]=d.useState(null),[u,m]=d.useState(null),p=d.useRef(!1),_=d.useRef(!1),b=d.useRef(null),f=jt({value:e.status,commit:async g=>{const h=p.current;p.current=!1,c(null);try{const v=await s({status:g},h?{forceDone:!0}:void 0);h&&be(Vr(v,l?.count??0,ae(g).label)),b.current?.resolve()}catch(v){throw c(on(v)),b.current?.reject(v),v}finally{b.current=null}},labels:ge("status",n("ui.projects.project_editors.status")),keyboardCommit:!1,errorCopy:tt,onBegin:()=>a(!0)}),x=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!_.current||f.phase!=="idle"&&f.phase!=="saved")return;_.current=!1;const g=document.querySelector("[data-project-milestones]");g&&(g.scrollIntoView({block:"start"}),g.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const w=()=>new Promise((g,h)=>{if(f.phase!=="error"||f.conflict!==null){h(new Error(""));return}if(!f.dirty){g();return}p.current=!0,b.current={resolve:g,reject:h},f.accept(f.draft,!0)});return t.jsx(Ft,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(jn,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[x&&t.jsx(G,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>m(l),children:n("ui.projects.project_editors.mark_done_anyway")}),t.jsx(_n,{open:u!==null,refusal:u,projectLabel:ne(e),onClose:()=>m(null),onConfirm:w,secondaryLabel:n("ui.projects.project_editors.review_milestones"),onSecondary:()=>{m(null),_.current=!0,f.cancel()}})]}),editor:t.jsxs(Ke,{open:r,onOpenChange:a,value:f.draft,onValueChange:g=>{a(!1),f.accept(g)},children:[t.jsx(We,{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(Ve,{})}),t.jsx(Qe,{children:Lr.map(g=>t.jsx(Ae,{value:g.value,"data-project-status-option":g.value,children:g.label},g.value))})]})})},Qc=({project:e,commit:s})=>{F();const[r,a]=d.useState(!1),o=d.useRef(null),i=d.useRef(null),l=jt({value:e.description,commit:async m=>{await s({description:m.trim()})},equals:(m,p)=>m.trim()===p.trim(),validate:m=>sn(m),multiline:!0,labels:ge("description",n("ui.projects.project_editors.description")),errorCopy:tt,editorRef:o,onSettle:m=>{m==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(r||!l.editing)return;const m=setTimeout(()=>o.current?.focus(),0);return()=>clearTimeout(m)},[r,l.editing]);const u=(l.editing?l.draft:l.displayValue).length>Xe;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:M(Cs,"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(m=>t.jsx("button",{type:"button","data-project-description-mode":m,"aria-pressed":r===(m==="preview"),onClick:()=>a(m==="preview"),className:M("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",r===(m==="preview")&&"bg-surface text-ink"),children:m==="write"?n("ui.projects.project_editors.write"):n("ui.projects.project_editors.preview")},m))})]}),t.jsx(cs,{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(ut,{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(Sr,{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:m=>l.setDraft(m.target.value),onPaste:m=>fn(m,o,p=>l.setDraft(p)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(ls,{api:l}),t.jsxs("p",{className:M("shrink-0 text-meta tabular-nums",u?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",Xe]})]})]}):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(ut,{className:"text-body",children:e.description??""})}),t.jsx(cs,{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(ls,{api:l})})]})})},Xc=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>(F(),t.jsx(Ie,{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=>St(o,"owner"),labels:ge("owner",n("ui.projects.project_editors.owner")),commit:s,maxLength:Nt,placeholder:n("ui.projects.examples.owner"),autoBegin:r,onRetire:a})),Jc=({project:e,commit:s,label:r=null,autoBegin:a=!1,onRetire:o})=>(F(),t.jsx(Ie,{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=>St(i,"team"),labels:ge("team",n("ui.projects.project_editors.team")),commit:s,maxLength:Nt,placeholder:n("ui.projects.examples.team"),autoBegin:a,onRetire:o})),mr=({project:e,commit:s,which:r,nowMs:a,autoBegin:o=!1,onRetire:i})=>{const l=r==="start"?e.start_date??"":e.target_date??"",c=F(),u=Oe(l,c,new Date(a)),m=r==="start"?n("ui.projects.project_editors.start"):n("ui.projects.project_editors.target");return t.jsx(Ie,{field:r==="start"?"start-date":"target-date",value:l,label:m,display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),commitFields:p=>r==="start"?{start_date:p}:{target_date:p},validate:p=>{const _=ss(p);return _||(r==="start"?rs(p,e.target_date??""):rs(e.start_date??"",p))},labels:ge(n("ui.projects.project_editors.tolowercase_date",{toLowerCase:String(m.toLowerCase())}),m),commit:s,placeholder:"YYYY-MM-DD",autoBegin:o,onRetire:i})},Zc=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{F();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=jt({value:{number:e.estimate===null?"":String(e.estimate),unit:o.unit},equals:Ui,commit:async m=>{const p=$i(o,m);p&&await s(p)},validate:m=>rn(m.number),labels:ge("estimate",n("ui.projects.project_editors.estimate")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:tt,onSettle:m=>{m==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const u=qr(e.estimate,e.estimate_unit)||"—";return t.jsx(Ft,{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:m=>c.setDraft({...c.draft,number:m.target.value}),className:"h-8 max-w-24"}),t.jsxs(Ke,{value:c.draft.unit,onValueChange:m=>c.setDraft({...c.draft,unit:m}),children:[t.jsx(We,{"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(Ve,{})}),t.jsxs(Qe,{children:[t.jsx(Ae,{value:"points",children:n("ui.projects.project_editors.points")}),t.jsx(Ae,{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")})]})})},el=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{F();const[o,i]=d.useState(r);d.useEffect(()=>{o&&e.tags.length>0&&(i(!1),a?.("filled"))},[o,e.tags,a]);const l=jt({value:e.tags.join(", "),equals:(u,m)=>Bi(lt(u),m),commit:async u=>{const{tags:m}=ns(u);await s({tags:m})},validate:u=>ns(u).error,labels:ge("tags",n("ui.projects.project_editors.tags")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:tt,onSettle:u=>{u==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!o&&e.tags.length===0)return null;const c=l.editing?lt(l.draft):e.tags;return t.jsx(Ft,{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))})]})})},tl="project-quick-send:no-target",sl=[],rl=({links:e,target:s,onTargetChange:r,onSend:a,focusTick:o})=>{F();const i=d.useRef(null),l=Wn(),{frontend:c,refresh:u}=qa(),[m,p]=d.useState(!1),_=Ze(),b=s??tl;d.useEffect(()=>{s&&u(s)},[s,u]),d.useEffect(()=>{o>0&&i.current?.focusInput()},[o]);const f=e.filter(g=>g.exists),w=(f.find(g=>g.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(Ke,{value:s??void 0,onValueChange:g=>r(g),children:[t.jsx(We,{"aria-label":n("ui.projects.project_quick_send.select_the_session_to_message"),className:"max-w-72",children:t.jsx(Ve,{placeholder:n("ui.projects.project_quick_send.no_session_selected")})}),t.jsx(Qe,{children:f.map(g=>t.jsx(Ae,{value:g.session_id,children:It(g)},g.session_id))})]}),m?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.sending")}):w?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:b,messages:sl,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(g,h)=>{if(!s)return!1;p(!0);try{return await a(s,g,w?"steer":"prompt",h)}finally{p(!1),i.current?.focusInput({preventScroll:!0})}}})]})},nl=({links:e,busy:s,onUnlink:r,onLink:a,onQuickSend:o,onStartSession:i})=>{F();const l=Dt(),c=kt(h=>h.sessions),[u,m]=d.useState(!1),[p,_]=d.useState(null),[b,f]=d.useState(0),x=p&&e.some(h=>h.session_id===p&&h.exists)?p:Io(e),w=d.useMemo(()=>{const h=new Set(e.map(v=>v.session_id));return c.filter(v=>!h.has(v.session_id)).map(v=>({id:v.session_id,name:v.title||v.session_id,description:v.cwd??void 0}))},[c,e]),g=h=>{kt.getState().openSession(h).then(v=>{v&&l(`/chat/${h}`)})};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(Aa,{}),n("ui.projects.project_links.new_session")]}),t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx(Oa,{}),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(h=>{const v=fo(h),T=_o(h.subagents),N=jo(h.todos),q=h.title||h.session_id,C=h.exists;return t.jsxs("li",{"data-glass-block-row":"",className:M("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&&g(h.session_id)},className:M("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:M("min-w-0 truncate text-body-sm",h.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:q})}),h.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}),N&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:N}),t.jsx(ke,{variant:v.variant,children:v.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:()=>{_(h.session_id),f(E=>E+1)},children:t.jsx(Pa,{})}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.unlink_title",{title:String(q)}),onClick:()=>r(h.session_id),children:t.jsx(Qa,{})})]},h.session_id)})}),e.some(h=>h.exists)&&t.jsx(rl,{links:e,target:x,onTargetChange:_,onSend:o,focusTick:b}),t.jsx(dt,{open:u,onClose:()=>m(!1),title:n("ui.projects.project_links.link_a_session"),maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(He,{onClick:()=>m(!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(Cr,{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:w,selected:null,onSelect:h=>{m(!1),a(h.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")})]})})]})},al=({milestones:e,summary:s,busy:r,onToggle:a,onRemove:o,onAdd:i})=>{const[l,c]=d.useState(""),[u,m]=d.useState(""),p=F(),_=!Ir.test(u.trim()),b=l.trim().length>0&&!_&&!r,f=()=>{b&&(i(l.trim(),u.trim()),c(""),m(""))};return t.jsxs("section",{"data-project-milestones":"",className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",tabIndex:-1,"data-project-milestones-heading":"",children: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(x=>{const w=oo(x.status),g=x.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Er,{checked:g,disabled:r,onCheckedChange:h=>a(x.name,h===!0),"aria-label":g?n("ui.projects.project_milestones.mark_name_not_complete",{name:String(x.name)}):n("ui.projects.project_milestones.mark_name_complete",{name:String(x.name)})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:x.name}),x.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:Oe(x.target_date,p)}),t.jsx(ke,{variant:w.variant,children:w.label}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:r,"aria-label":n("ui.projects.project_milestones.remove_name",{name:String(x.name)}),onClick:()=>o(x.name),children:t.jsx(Pt,{})})]},x.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:x=>c(x.target.value),placeholder:n("ui.projects.project_milestones.beta_cut"),onKeyDown:x=>{x.key==="Enter"&&(x.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:x=>m(x.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:!b,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(it,{}),n("ui.projects.project_milestones.add")]})]})]})},ol=[{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")}}],fr=({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})]}),il=({project:e,nowMs:s,commit:r,teamLabel:a=null})=>{const o=F(),i=new Date(s),[l,c]=d.useState(null),u=d.useRef(null),m=d.useRef(!1),p={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,P)=>{c(j=>j===E?null:j),P==="cancelled"&&!p[E]&&setTimeout(()=>u.current?.focus(),0)},b=ol.filter(({field:E})=>!p[E]&&l!==E),f=Oe(e.completed_at,o,i),x=e.updated_at>0?mt(pt(e.updated_at,s)):"",w=e.updated_at>0?Qn(new Date(e.updated_at*1e3),{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},o):"",g=p.owner||l==="owner",h=p.team||l==="team",v=p.start||l==="start",T=p.target||l==="target",N=p.estimate||l==="estimate",q=p.tags||l==="tags",C=g||h||v||T||!!f||N||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")}),b.length>0&&t.jsxs(ps,{children:[t.jsx(ms,{asChild:!0,children:t.jsxs("button",{ref:u,type:"button","data-project-add-field":"",className:M("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(it,{className:"size-3","aria-hidden":"true"}),n("ui.projects.project_properties.add")]})}),t.jsx(fs,{align:"end",onCloseAutoFocus:E=>{m.current&&(m.current=!1,E.preventDefault())},children:b.map(({field:E,label:P})=>t.jsx(Ee,{"data-project-add-option":E,onSelect:()=>{m.current=!0,c(E)},children:P},E))})]})]}),C?t.jsxs("dl",{className:"flex flex-col gap-2",children:[g&&t.jsx(Xc,{project:e,commit:r,autoBegin:l==="owner",onRetire:E=>_("owner",E)}),h&&t.jsx(Jc,{project:e,commit:r,label:a,autoBegin:l==="team",onRetire:E=>_("team",E)}),v&&t.jsx(mr,{project:e,commit:r,which:"start",nowMs:s,autoBegin:l==="start",onRetire:E=>_("start",E)}),T&&t.jsx(mr,{project:e,commit:r,which:"target",nowMs:s,autoBegin:l==="target",onRetire:E=>_("target",E)}),f&&t.jsx(fr,{label:n("ui.projects.project_properties.completed"),children:f}),N&&t.jsx(Zc,{project:e,commit:r,autoBegin:l==="estimate",onRetire:E=>_("estimate",E)}),q&&t.jsx(el,{project:e,commit:r,autoBegin:l==="tags",onRetire:E=>_("tags",E)}),e.updated_at>0&&t.jsx(fr,{label:n("ui.projects.project_properties.updated"),children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:w,children:x})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_properties.no_dates_estimate_tags_owner_or_team_yet")})]})},cl=({project:e})=>{F();const s=Ze(),r=dn(),{sending:a,cooling:o,cooldownRemainingMs:i}=rc(e.id);if(!ye(s.data,"projects_request_update"))return null;const l=ne(e),c=Wi(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(Ot,{content:o&&i!==null?Ct(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(gs,{}):t.jsx(Wa,{}),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:Ct(l,i)})]})},hn="plain",gn=e=>`team:${e}`,xn=e=>`agent:${e}`;function ll(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function ul(e){return e.kind==="team"?gn(e.name):e.kind==="agent"?xn(e.name):hn}const _r={kind:"plain"},dl=({open:e,onClose:s,onStart:r,teamsEnabled:a,profilesEnabled:o})=>{F();const[i,l]=d.useState(_r),[c,u]=d.useState(null),[m,p]=d.useState(!1),_=Xn(e&&a),b=Jn(e&&o);d.useEffect(()=>{e&&(l(_r),u(null),p(!1))},[e]);const f=d.useMemo(()=>{const v=[{id:hn,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??[])v.push({id:gn(T.name),name:Is(T),keywords:T.name===Is(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(b.data??[]).filter(N=>N.source!=="builtin"))v.push({id:xn(T.name),name:T.name,description:T.description||T.kind,get group(){return n("ui.projects.project_start_session.agents")}});return v},[_.data,b.data]),x=f.find(v=>v.id===ul(i))??f[0],w=!a||!o,g=_.isLoading||b.isLoading,h=async()=>{p(!0),u(null);try{await r(i),s()}catch(v){u(v instanceof Error&&v.message?v.message:n("ui.projects.project_start_session.the_session_could_not_be_started"))}finally{p(!1)}};return t.jsx(dt,{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(He,{onClick:s,disabled:m,children:n("ui.projects.project_start_session.cancel")}),t.jsxs(vt,{onClick:()=>void h(),disabled:m,children:[m&&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(Cr,{label:n("ui.projects.project_start_session.work_with"),placeholder:n("ui.projects.project_start_session.search_teams_and_agents"),options:f,selected:x,onSelect:v=>l(ll(v.id)),busy:g,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")}),w&&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})]})})},pl=({links:e})=>{F();const s=Lo(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:Ys(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:It(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Ys(a.todos)})]},a.session_id))})]})},ml=({filePath:e,tooltip:s="File actions",icon:r,"aria-label":a="File actions",onShowInCanvas:o})=>{const i=async()=>{if(e)try{await navigator.clipboard.writeText(e),be("File path copied to clipboard")}catch(c){console.error("Failed to copy file path: ",c),de("Failed to copy file path")}},l=()=>{e&&window.api.openFile(e)};return t.jsxs(ps,{children:[t.jsx(Ot,{content:s,children:t.jsx(ms,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon-sm","aria-label":a,onClick:c=>c.stopPropagation(),children:r??t.jsx(yr,{"aria-hidden":"true"})})})}),t.jsxs(fs,{align:"end",className:"min-w-45",onClick:c=>c.stopPropagation(),children:[o&&t.jsxs(Ee,{onSelect:o,children:[t.jsx(Zn,{"aria-hidden":"true"}),t.jsx("span",{children:"Show in canvas"})]}),t.jsxs(Ee,{onSelect:l,children:[t.jsx(kr,{"aria-hidden":"true"}),t.jsx("span",{children:"Open file"})]}),t.jsxs(Ee,{onSelect:()=>window.api.showItemInFolder(e),children:[t.jsx(ea,{"aria-hidden":"true"}),t.jsx("span",{children:"Open folder"})]}),t.jsxs(Ee,{onSelect:i,children:[t.jsx(ta,{"aria-hidden":"true"}),t.jsx("span",{children:"Copy file path"})]})]})]})},fl=/[/\\]/;function bn(e){if(e.name)return e.name;const s=e.path.split(fl);return s[s.length-1]||n("ui.projects.project_updates.attachment")}const _l=({attachment:e})=>{F();const s=bn(e),r=Po(e.bytes);return t.jsxs("div",{className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-surface px-3 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2.5 text-left",onClick:()=>{window.api?.openFile(e.path)},title:n("ui.projects.project_updates.open_name",{name:String(s)}),children:[t.jsx(kr,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),r&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:r}),t.jsx(ml,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(s)})})]})},jl=({attachment:e})=>{F();const s=bn(e),r=sa(e.path,{mimeType:ra(e.name||e.path),sizeBytes:e.bytes});return r.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(na,{file:e.path,src:r.url,label:s,conversationId:""})}):r.status==="loading"?t.jsx(aa,{children:t.jsxs("span",{className:"sr-only",children:[n("ui.projects.project_updates.loading"),s]})}):t.jsx(oa,{name:s})},hl=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(jl,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(_l,{attachment:s},`${s.path}:${s.added_at}`))}),gl=({update:e,nowMs:s})=>{const r=F(),a=Ao(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(ut,{children:e.text}),e.attachments.length>0&&t.jsx(hl,{attachments:e.attachments})]})},xl=({updates:e,nowMs:s})=>{const r=F(),a=Co(e.length),o=Oo(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(gl,{update:l,nowMs:s},`${l.at}:${l.by}:${c}`))})]},i.key||"ungrouped"))})]})},bl="project_not_found",yl=({projectKey:e,nowMs:s})=>{F();const r=Dt(),a=Ze(),o=wr(ye(a.data,"team_catalogue")),i=Ar(e,!0),l=Or(),c=Pr(),u=so(),m=ro(),p=eo(),_=to(),[b,f]=d.useState(!1),[x,w]=d.useState(!1),g=l.isPending||c.isPending||u.isPending||m.isPending||p.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 j=i.error instanceof Rt&&(i.error.code===bl||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(Kt,{variant:"danger",className:"w-full",children:j?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(qs,{}),n("ui.projects.project_detail.all_projects")]})]})]})}const{project:h,links:v}=i.data,T=ne(h),N=(j,D)=>l.mutateAsync({key:h.id,fields:j,...D?.forceDone===!0?{forceDone:!0}:{}}),q=h.team?o(h.team):null,C=Mo(h.milestones.filter(j=>j.completed_at!==null).length,h.milestones.length),E=async(j,D,R,I)=>{const K=kt.getState(),B=ca(null,j,K.drafts);if(!B)return!1;try{const{images:Y,unreadable:X,overflow:Z}=await la(I,D),me=ua(X);if(me)return de(me),!1;const oe=da(Z);if(oe)return de(oe),!1;const ee=pa(D,Y);if(ee)return de(ee),!1;if(await ma(B,{text:D,attachments:I,images:Y,mode:R,cwd:K.cwd},j)===null)return de(n("ui.projects.project_detail.that_session_already_has_a_message_going_out_try_again_in_a_momen")),!1;const y=v.find(k=>k.session_id===j);return be(n("ui.projects.project_detail.sent_to_value1",{value1:String(y?It(y):j)})),!0}catch(Y){return de(Y instanceof Error&&Y.message?Y.message:n("ui.projects.project_detail.the_message_was_not_sent")),!1}},P=async j=>{const D=kt.getState(),R=j.kind==="plain"?void 0:{kind:j.kind,name:j.name},I=await D.createSession(D.cwd||"~",R);if(!I)throw new Error(D.error??n("ui.projects.project_detail.the_session_could_not_be_started"));fa.getState().setCurrentInput(I,Fo(h));let K=null;try{await p.mutateAsync({key:h.id,sessionId:I})}catch(B){K=B instanceof Error&&B.message?B.message:n("ui.projects.project_detail.the_link_was_refused")}if(K)de(n("ui.projects.project_detail.session_started_but_linking_it_failed_linkfailure",{linkFailure:String(K)}));else{const B=R?n("ui.projects.project_detail.with_value1",{value1:String(qo(R))}):"";be(n("ui.projects.project_detail.session_started_withtarget_and_linked_to_displayname",{withTarget:String(B),displayName:String(T)}))}await Rr(r,I)};return t.jsx(gc,{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(qs,{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(Wc,{project:h,commit:N}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(Vc,{project:h,commit:N}),h.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(cl,{project:h}),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(Qc,{project:h,commit:N}),t.jsx(il,{project:h,nowMs:s,commit:N,teamLabel:q}),h.updates.length===0&&h.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(ut,{className:"text-body",children:h.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:lo(h,s)})]}),t.jsx(al,{milestones:h.milestones,summary:C,busy:g,onToggle:(j,D)=>{u.mutateAsync({key:h.id,name:j,completed:D}).catch(R=>{de(R instanceof Error&&R.message?R.message:n("ui.projects.project_detail.the_milestone_was_not_updated"))})},onRemove:j=>{m.mutateAsync({key:h.id,name:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_removed"))})},onAdd:(j,D)=>{u.mutateAsync({key:h.id,name:j,targetDate:D}).catch(R=>{de(R instanceof Error&&R.message?R.message:n("ui.projects.project_detail.the_milestone_was_not_added"))})}}),t.jsx(nl,{projectKey:h.id,links:v,busy:g,onStartSession:()=>w(!0),onQuickSend:E,onLink:j=>{p.mutateAsync({key:h.id,sessionId:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_session_was_not_linked"))})},onUnlink:j=>{_.mutateAsync({key:h.id,sessionId:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_session_was_not_unlinked"))})}}),t.jsx(pl,{links:v}),t.jsx(xl,{updates:h.updates,nowMs:s}),t.jsx(pn,{open:b,projectName:h.name,onClose:()=>f(!1),onConfirm:async j=>{await c.mutateAsync({key:h.id,confirmedName:j}),be(n("ui.projects.project_detail.project_deleted")),r("/projects")}}),t.jsx(dl,{open:x,onClose:()=>w(!1),onStart:P,teamsEnabled:ye(a.data,"team_catalogue"),profilesEnabled:ye(a.data,"profile_catalogue")})]})})},vl="payments-migration",jr={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},kl=({open:e,onClose:s,onSubmit:r})=>{F();const[a,o]=d.useState(jr),[i,l]=d.useState({}),[c,u]=d.useState(null),m=d.useRef(null),[p,_]=d.useState(!1),[b,f]=d.useState(!1),[x,w]=d.useState(!1),g=d.useId(),h=d.useRef(null);d.useEffect(()=>{e&&(o({...jr,description:lr}),l({}),u(null),_(!1),f(!1),w(!1))},[e]),d.useEffect(()=>{c&&m.current?.scrollIntoView({block:"nearest"})},[c]);const v=(j,D)=>{o(R=>({...R,[j]:D}))},T=b?a.name:Cc(a.title),N=j=>fn(j,h,D=>v("description",D)),q=(j,D)=>{const R={},I=Wt(D);I&&(R.name=I);const K=sn(j.description);K&&(R.description=K);const B=ns(j.tags).error;B&&(R.tags=B);const Y=ss(j.startDate);Y&&(R.startDate=Y);const X=ss(j.targetDate);if(X)R.targetDate=X;else if(!Y){const ee=rs(j.startDate,j.targetDate);ee&&(R.targetDate=ee)}if(j.estimate.trim()){const ee=rn(j.estimate);ee&&(R.estimate=ee)}const Z=ts(j.title);Z&&(R.title=Z);const me=St(j.owner,"owner");me&&(R.owner=me);const oe=St(j.team,"team");return oe&&(R.team=oe),R},C=async()=>{const j=T.trim(),D=q(a,j);if(l(D),Object.keys(D).length>0)return;_(!0),u(null);const R=lt(a.tags);try{const I={};a.title.trim()&&(I.title=a.title.trim()),a.owner.trim()&&(I.owner=a.owner.trim()),a.team.trim()&&(I.team=a.team.trim()),a.startDate&&(I.start_date=a.startDate),a.targetDate&&(I.target_date=a.targetDate),a.estimate&&(I.estimate=Number(a.estimate),I.estimate_unit=a.estimateUnit),await r({fields:{name:j,...a.description.trim()&&a.description.trim()!==lr?{description:a.description.trim()}:{},status:a.status,...R.length>0?{tags:R}:{}},...Object.keys(I).length>0?{followUp:I}:{}}),s()}catch(I){const K=I instanceof Error&&I.message?I.message:"";u(_t(K)||n("ui.projects.project_form_dialog.the_project_was_not_saved"))}finally{_(!1)}},E=n("ui.projects.project_form_dialog.new_project"),P=a.description.length>Xe;return t.jsx(dt,{open:e,onClose:s,title:E,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:p,onEscapeKeyDown:j=>{p&&j.preventDefault()},onInteractOutside:j=>{p&&j.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(He,{onClick:s,disabled:p,children:n("ui.projects.project_form_dialog.cancel")}),t.jsxs(vt,{"data-project-submit":"",onClick:()=>void C(),disabled:p,children:[p&&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:j=>{j.preventDefault(),C()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${g}-title`,children:n("ui.projects.project_form_dialog.title")}),t.jsx(ue,{id:`${g}-title`,"data-project-title":"",value:a.title,onChange:j=>v("title",j.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:`${g}-key`,className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.key")}),t.jsx(ue,{id:`${g}-key`,"data-project-key":"",value:T,onChange:j=>{f(!0),v("name",j.target.value)},placeholder:vl,"aria-invalid":!!i.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:b?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:`${g}-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(j=>t.jsx("button",{type:"button","data-project-description-mode":j,"aria-pressed":x===(j==="preview"),onClick:()=>w(j==="preview"),className:M("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",x===(j==="preview")&&"bg-surface text-ink"),children:j==="write"?n("ui.projects.project_form_dialog.write"):n("ui.projects.project_form_dialog.preview")},j))})]})]}),x?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(ut,{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(Sr,{ref:h,id:`${g}-description`,"data-project-description":"",value:a.description,onChange:j=>v("description",j.target.value),onPaste:N,rows:8,placeholder:n("ui.projects.project_form_dialog.markdown_headings_lists_code"),"aria-invalid":P||!!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:M("text-meta tabular-nums",P?"text-danger":"text-ink-muted"),children:[a.description.length,"/",Xe]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{children:n("ui.projects.project_form_dialog.status")}),t.jsxs(Ke,{value:a.status,onValueChange:j=>v("status",j),children:[t.jsx(We,{"aria-label":n("ui.projects.project_form_dialog.status"),children:t.jsx(Ve,{})}),t.jsx(Qe,{children:Lr.map(j=>t.jsx(Ae,{value:j.value,children:j.label},j.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:`${g}-owner`,children:n("ui.projects.project_form_dialog.owner")}),t.jsx(ue,{id:`${g}-owner`,"data-project-owner":"",value:a.owner,onChange:j=>v("owner",j.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:`${g}-team`,children:n("ui.projects.project_form_dialog.team")}),t.jsx(ue,{id:`${g}-team`,value:a.team,onChange:j=>v("team",j.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:`${g}-target`,children:n("ui.projects.project_form_dialog.target_date")}),t.jsx(ue,{id:`${g}-target`,"data-project-target":"",value:a.targetDate,onChange:j=>v("targetDate",j.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:`${g}-start`,children:n("ui.projects.project_form_dialog.start_date")}),t.jsx(ue,{id:`${g}-start`,value:a.startDate,onChange:j=>v("startDate",j.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:`${g}-estimate`,children:n("ui.projects.project_form_dialog.estimate")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ue,{id:`${g}-estimate`,value:a.estimate,onChange:j=>v("estimate",j.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(Ke,{value:a.estimateUnit,onValueChange:j=>v("estimateUnit",j),children:[t.jsx(We,{"aria-label":n("ui.projects.project_form_dialog.estimate_unit"),className:"max-w-32",children:t.jsx(Ve,{})}),t.jsxs(Qe,{children:[t.jsx(Ae,{value:"points",children:n("ui.projects.project_form_dialog.points")}),t.jsx(Ae,{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:`${g}-tags`,children:n("ui.projects.project_form_dialog.tags")}),t.jsx(ue,{id:`${g}-tags`,value:a.tags,onChange:j=>v("tags",j.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:m,className:"text-body-sm text-danger",children:c})]})})},yn=({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:M("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",r&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},wl=({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(Er,{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})]})},Nl=({column:e,spec:s,onChange:r})=>{F();const a=d.useId(),o=s!==null&&s.key===e,i=o?s.direction:Bt(e),l=i==="asc"?"desc":"asc",c=()=>r({key:e,direction:o?l:Bt(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(Je(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:M("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:m=>{u==="sorted"&&(m.key!==" "&&m.key!=="Enter"||(m.preventDefault(),c()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:M("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(Je(e)),value2:String(ks(e,o?i:Bt(e)))})})]})]})},Sl=({facet:e,options:s,onToggle:r})=>(F(),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:ot[e]}),s.map(a=>t.jsx(wl,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>r(e,a.value)},`${e}:${a.value??"none"}`))]})),vn=({projects:e,state:s,query:r,todayMs:a,onToggle:o,onClearAll:i,scope:l,sort:c})=>{F();const u=l===void 0?_i(e,s,a):l===null?[]:[tn(l,e,s,a)],m=!ct(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")}),m&&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(Je(c.key))})}),t.jsx(Nl,{column:c.key,spec:c.spec,onChange:c.onChange})]}),u.map(p=>t.jsx(Sl,{facet:p.facet,options:p.options,onToggle:o},p.facet))]})},Cl=({team:e,count:s,headingId:r,className:a,...o})=>(F(),t.jsxs("div",{...o,"data-glass-well":"",className:M("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":po(s),children:s})]})),Ce=[{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 El(e,s){const r=pt(e.progress_updated_at,s);return r?mt(r):n("ui.projects.project_list.not_reported")}const Tl=({direction:e})=>e==="asc"?t.jsx(Dr,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Nr,{size:10,className:"shrink-0","aria-hidden":"true"}),Rl=({projects:e,nowMs:s,onOpen:r,sort:a,onSortChange:o,searchPopulation:i,filters:l,query:c,todayMs:u,onToggleFilter:m,onClearFilters:p,teamLabelFor:_=b=>b})=>{const b=F(),f=a?wi(e,a):e,x=bs(f,ft),w=d.useId(),g=C=>`${w}-team-${C}`,[h,v]=d.useState(0),T=d.useRef([]),N=(C,E)=>{const P=Ce.length;for(let j=1;j<=P;j+=1){const D=(C+E*j+P*P)%P,R=T.current[D];if(R&&R.offsetParent!==null){v(D),R.focus();return}}},q=C=>E=>{E.key!=="ArrowLeft"&&E.key!=="ArrowRight"||(E.preventDefault(),N(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:Ce.map((C,E)=>{const P=a!==null&&a.key===C.sort;return t.jsx("th",{scope:"col","aria-sort":P?a.direction==="desc"?"descending":"ascending":"none",className:M(C.className,"p-0 text-left font-normal"),children:t.jsxs(_s,{children:[t.jsx(js,{asChild:!0,children:t.jsxs("button",{type:"button",ref:j=>{T.current[E]=j},tabIndex:E===h?0:-1,"data-project-column":C.key,onFocus:()=>v(E),onKeyDown:q(E),className:M("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",P?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:C.label}),P?t.jsx(Tl,{direction:a.direction}):t.jsx(_a,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(hs,{align:"start","aria-label":n("ui.projects.project_list.label_column",{label:String(C.label)}),className:"w-72 p-0",children:t.jsx(yn,{children:t.jsx(vn,{projects:i,state:l,query:c,todayMs:u,onToggle:m,onClearAll:p,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:x.map((C,E)=>t.jsxs("li",{children:[t.jsx(Cl,{team:C.team==null?null:_(C.team),count:C.items.length,headingId:g(E),className:"sticky top-0 z-10","data-project-team":C.team??""}),t.jsx("ul",{"aria-labelledby":g(E),className:"divide-y divide-hairline",children:C.items.map(P=>{const j=new Map(Br(P,b).map(I=>[I.key,I.text])),D=Ur(P.milestones_completed,P.milestones_total),R=xs(P.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>r(P),"data-project-name":P.name,className:M("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:M(Ce[0].className,"truncate text-body-sm text-ink"),children:ne(P)}),t.jsx("span",{className:Ce[1].className,children:t.jsx(jn,{status:P.status})}),t.jsx("span",{className:M(Ce[2].className,"truncate text-meta text-ink-muted"),children:j.get("target")??j.get("completed")??""}),t.jsx("span",{className:M(Ce[3].className,"truncate text-meta text-ink-muted"),children:j.get("estimate")??""}),t.jsx("span",{className:M(Ce[4].className,"truncate text-meta text-ink-muted"),children:D}),t.jsx("span",{className:M(Ce[5].className,"truncate text-meta text-ink-muted"),children:R}),t.jsxs("span",{className:M(Ce[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:El(P,s)}),P.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]})},P.id)})})]},C.team??""))})]})},Tt=224,hr=36,Dl={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")}},Al=({items:e,nowMs:s,onOpen:r,pendingDetails:a,failedDetails:o,onRetryDetails:i,teamLabelFor:l=c=>c})=>{F();const[c,u]=d.useState(null),[m,p]=d.useState(0),_=d.useRef(null),b=Ns(s),f=d.useMemo(()=>Ci(e,b),[e,b]),x=d.useMemo(()=>Ei(e),[e]),w=d.useMemo(()=>bs(x.dated,C=>ft(C.project)),[x]);d.useLayoutEffect(()=>{const C=_.current;if(!C)return;const E=()=>p(C.clientWidth);if(E(),typeof ResizeObserver>"u")return;const P=new ResizeObserver(E);return P.observe(C),()=>P.disconnect()},[]);const g=Math.max(m-Tt-24,160),h=f?Ni(Js(f.startMs,f.endMs),g):"month",v=c??h,T=C=>{const E=De.indexOf(v),P=De[E-C];P&&u(P)},N=ws[v],q=f?Js(f.startMs,f.endMs)*N: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(x.dated.length,{useGrouping:!1}),length_2:V(x.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||v===De[0],onClick:()=>T(1),children:t.jsx(it,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Dl[v]}),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||v===De[De.length-1],onClick:()=>T(-1),children:t.jsx(Ca,{})})]})]}),f&&x.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(Ol,{startMs:f.startMs,endMs:f.endMs,tier:v,pxPerDay:N,trackPx:q}),w.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:Tt},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(Pl,{item:E,spanStart:f.startMs,pxPerDay:N,trackPx:q,today:b,onOpen:()=>r(E)},E.project.id))]},C.team??""))]})}):null,x.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(vr,{defaultOpen:x.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(Ga,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Ti(x.undated.length)})]}),children:[x.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:x.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))})]})})]})},Ol=({startMs:e,endMs:s,tier:r,pxPerDay:a,trackPx:o})=>{const i=Fi(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:Tt}}),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:Le(e,l.dayMs)*a},children:[t.jsx("span",{className:M("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))})]})},Pl=({item:e,spanStart:s,pxPerDay:r,trackPx:a,today:o,onOpen:i})=>{const{project:l}=e,c=Ri(e),u=Di(e),m=p=>new Date(p).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:Tt,height:hr},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:ne(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:hr},children:[c&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:Le(s,c.fromMs)*r,width:(Le(c.fromMs,c.toMs)+1)*r},title:`${Oe(m(c.fromMs))} → ${Oe(m(c.toMs))}`}),u.map(p=>t.jsx("span",{"data-milestone":p.status,className:M("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",p.status==="completed"&&"bg-success",p.status==="overdue"&&"bg-warning",p.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:Le(s,p.dayMs)*r},title:`${p.name} · ${p.status} · ${Oe(m(p.dayMs))}`},`${p.name}-${p.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:Le(s,o)*r},"aria-hidden":"true"})]})]})},Ml=({projects:e,query:s,onQueryChange:r,filters:a,onFiltersChange:o,onClearAll:i,todayMs:l,resultText:c,countRevealClass:u="@[37rem]:inline",trailing:m,disabled:p=!1,searchFieldRef:_})=>{F();const[b,f]=d.useState(!1),x=d.useRef(!1),w=di(a),g=Tr(c??"",300),h=s.trim()!==""||!ct(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(ja,{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:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(s?r(""):v.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:()=>ha(_.current,r),"aria-label":n("ui.projects.projects_toolbar.clear_search"),children:t.jsx(Pt,{"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(ga,{shortcut:"/"})})]}),t.jsxs(_s,{open:b,onOpenChange:f,children:[t.jsx(js,{asChild:!0,children:t.jsxs(G,{variant:"secondary",size:"sm",disabled:p,"data-project-filters-button":"",children:[t.jsx(Ha,{size:14,"aria-hidden":"true"}),n("ui.projects.projects_toolbar.filters"),w>0&&t.jsx(ke,{variant:"neutral",children:w})]})}),t.jsx(hs,{align:"end","aria-label":n("ui.projects.projects_toolbar.filters"),className:"w-80 p-0",onCloseAutoFocus:v=>{x.current&&(x.current=!1,v.preventDefault())},children:t.jsx(yn,{children:t.jsx(vn,{projects:e,state:a,query:s,todayMs:l,onToggle:(v,T)=>o(Jr(a,v,T)),onClearAll:()=>{i(),x.current=!0,f(!1),_.current?.focus()}})})})]}),h&&c!==null&&t.jsx("span",{className:M("hidden whitespace-nowrap text-meta text-ink-dim",u),"data-project-count":"",children:c}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:g}),m]})},Ll=({filters:e,sort:s,onFiltersChange:r,onSortChange:a,onClearAll:o,hideClearAll:i=!1,searchFieldRef:l})=>{F();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 m=[];for(const _ of et){const b=e[_];if(b.length===0)continue;const f=b.map(g=>Xr(_,g)),x=f[0],w=f.length>1?n("ui.projects.projects_toolbar.facet_labels_facet_first_length_1",{FACET_LABELS_facet:String(ot[_]),first:String(x),length___1:V(f.length-1,{useGrouping:!1})}):n("ui.projects.projects_toolbar.facet_labels_facet_first",{FACET_LABELS_facet:String(ot[_]),first:String(x)});m.push({kind:"facet",facet:_,label:w,ariaLabel:n("ui.projects.projects_toolbar.remove_filter_facet_labels_facet_join",{FACET_LABELS_facet:String(ot[_]),join:String(f.join(", "))}),clear:()=>r({...e,[_]:[]})})}if(s&&m.push({kind:"sort",spec:s,label:n("ui.projects.projects_toolbar.sort_key",{key:String(Je(s.key))}),ariaLabel:n("ui.projects.projects_toolbar.remove_sort_key_direction",{key:String(Je(s.key)),direction:String(ks(s.key,s.direction))}),clear:()=>a(null)}),m.length===0)return null;const p=(_,b)=>{b.clear();const f=m.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:[m.map((_,b)=>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":b,"aria-label":_.ariaLabel,onClick:()=>p(b,_),children:[_.kind==="sort"&&(_.spec.direction==="asc"?t.jsx(Dr,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Nr,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:_.label}),t.jsx(Pt,{className:M("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")})]})},kn="projects-view",Il=[{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 Fl(){try{const e=localStorage.getItem(kn);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function ql(e){try{localStorage.setItem(kn,e)}catch{}}const Ul=({value:e,onChange:s})=>(F(),t.jsx(Ea,{value:e,onValueChange:r=>s(r),children:t.jsx(Ta,{"aria-label":n("ui.projects.projects_view_switcher.project_view"),"data-tour-tag":"projects-view-switcher",children:Il.map(r=>t.jsx(Ra,{value:r.value,children:r.label},r.value))})})),Bl=["r1","r2","r3","r4","r5","r6"],$l=4e3,gr={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")}},Jl=({nowMs:e=Date.now()})=>{F();const{projectId:s}=xa(),r=Dt(),a=Ze(),o=ba(a.data,"projects",1),i=o==="enabled",l=ye(a.data,"projects",Ko),c=wr(ye(a.data,"team_catalogue")),u=Xa(i),m=Za(),p=Or(),_=Pr(),[b,f]=d.useState(!1),[x,w]=d.useState(()=>Fl()),[g,h]=d.useState(()=>yo()),[v,T]=d.useState(null),[N,q]=d.useState(""),[C,E]=d.useState(Ws),[P,j]=d.useState(()=>gi()),[D,R]=d.useState(""),I=d.useRef(""),K=d.useRef(null),B=d.useRef(null),Y=S=>{K.current!==null&&(window.cancelAnimationFrame(K.current),K.current=null),S!==""&&S===I.current?(R(""),K.current=window.requestAnimationFrame(()=>{K.current=null,R(S)})):R(S),I.current=S,B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,I.current="",R("")},$l)},X=()=>{K.current!==null&&(window.cancelAnimationFrame(K.current),K.current=null),B.current!==null&&(window.clearTimeout(B.current),B.current=null),I.current="",R("")},Z=S=>{q(S),X()},me=S=>{E(S),X()},oe=d.useRef(null),ee=nc(),te=u.data??[],y=Ns(e),k=oi(N,i&&l),O=Qr(N),L=d.useMemo(()=>k.answer?ni(te,k.answer.projects):null,[te,k.answer]),U=O!=="",H=d.useMemo(()=>U?L??ri(te,O):te,[te,O,U,L]),Q=L===null?"client":"backend",$=d.useMemo(()=>pi(H,C,y),[H,C,y]),je=l&&U&&k.pending,ie=U||!ct(C),z=d.useMemo(()=>$s(te,g,e),[te,g,e]),se=d.useMemo(()=>$s($,g,e),[$,g,e]),xe=bo(g),fe=x==="board"?se.length:$.length,Pe=!ie||!u.isSuccess?null:x==="board"?n("ui.projects.projects_page.length_of_length_2_in_window",{length:V(se.length,{useGrouping:!1}),length_2:V(z.length,{useGrouping:!1})}):n("ui.projects.projects_page.length_of_length_2_projects",{length:V($.length,{useGrouping:!1}),length_2:te.length}),re=u.isSuccess&&te.length>0,Re=re&&ie&&fe===0&&!je,Be=je&&fe===0&&re,[qt,st]=d.useState(!1);d.useEffect(()=>{if(!qt)return;const S=document.querySelector('[data-tour-tag="projects-board-window"]');S&&(S.focus(),st(!1))}),d.useEffect(()=>{if(!i||s)return;const S=W=>{const J=W.target;if(!J||J.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(J.tagName)||J.closest('[role="dialog"]'))return;const Se=W.key==="/"&&!W.metaKey&&!W.ctrlKey&&!W.altKey,le=(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="f";!Se&&!le||(W.preventDefault(),oe.current?.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[i,s]);const rt=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const S=rt.current;S!==null&&(S.scrollTop=0)},[s]);const ht=Ja(x==="timeline"?te.map(S=>S.id):[],i),A=new Map(te.map((S,W)=>[S.id,ht[W]])),ce=$.map(S=>({project:S,milestones:A.get(S.id)?.data?.project.milestones??[]})),nt=x==="timeline"?$.filter(S=>A.get(S.id)?.isLoading).length:0,we=x==="timeline"?$.filter(S=>A.get(S.id)?.isError).length:0,gt=()=>{for(const S of ht)S.isError&&S.refetch()},$e=S=>{j(S),xi(S),Y(bi(S))},wn=(S,W)=>{E(J=>Jr(J,S,W)),X()},xt=()=>{const S=N.trim()!=="",W=!ct(C),J=P!==null;q(""),E(Ws),P!==null&&$e(null),Y(yi({search:S,filters:W,sort:J}))},Es=()=>{h("all"),zs("all"),st(!0)},[Ne,Ts]=d.useState(null),Ut=d.useRef(!1),Rs=()=>{Ut.current=!1,Ts(null)},[Nn,Ds]=d.useState([]),Sn=ye(a.data,"projects_force_done"),Cn=(S,W)=>{const J=S.id,Se=ae(W).label;Ds(le=>le.includes(J)?le:[...le,J]),zi({move:()=>p.mutateAsync({key:J,fields:{status:W}}),forceDoneOffered:Sn,claimQuestion:()=>Ut.current?!1:(Ut.current=!0,!0)}).then(le=>{if(le.kind==="accepted"){be(n("ui.projects.projects_page.moved_to_label",{label:String(Se)})),u.refetch().then(()=>ee(J));return}if(le.kind==="question"){Ts({project:S,status:W,refusal:le.refusal});return}de(le.copy,le.refusal?{action:{get label(){return n("ui.projects.projects_page.view_project")},onClick:()=>void r(`/projects/${J}`)}}:void 0),ee(J)}).finally(()=>{Ds(le=>le.filter(En=>En!==J))})};return i?s?t.jsx("div",{ref:rt,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(yl,{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(Fs,{title:n("ui.projects.projects_page.projects"),icon:Us,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(Ma,{})}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(it,{}),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(Ul,{value:x,onChange:S=>{w(S),ql(S)}}),t.jsx(Ml,{projects:H,query:N,onQueryChange:Z,filters:C,onFiltersChange:me,onClearAll:xt,todayMs:y,resultText:Pe,countRevealClass:x==="board"?"@[47rem]:inline":void 0,disabled:u.isError,searchFieldRef:oe,trailing:x==="board"&&!(u.isSuccess&&u.data.length===0)?t.jsx(Gi,{value:g,onChange:S=>{h(S),zs(S)}}):null})]}),t.jsx(Ll,{filters:C,sort:P,onFiltersChange:me,onSortChange:$e,onClearAll:xt,hideClearAll:Re,searchFieldRef:oe}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:D})]})]}),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")}),Bl.map(S=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(ze,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(ze,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-40 shrink-0 bg-elevated"})]},S))]}),u.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Kt,{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(it,{}),n("ui.projects.projects_page.new_project")]})]}),Be&&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&&Re&&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.trim()?n("ui.projects.projects_page.no_projects_match_trim",{trim:String(N.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:N.trim()?Ho[Q]: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:()=>{xt(),oe.current?.focus()},children:n("ui.projects.projects_page.clear_all")}),x==="board"&&$.length>0&&t.jsx(G,{variant:"secondary",onClick:Es,children:n("ui.projects.projects_page.show_all_time")})]})]}),re&&!Re&&!Be&&x==="list"&&t.jsx(Rl,{projects:$,nowMs:e,onOpen:S=>void r(`/projects/${S.id}`),sort:P,onSortChange:$e,searchPopulation:H,filters:C,query:N,todayMs:y,onToggleFilter:wn,onClearFilters:xt,teamLabelFor:c}),re&&!Re&&x==="board"&&se.length>0&&t.jsx(oc,{projects:se,nowMs:e,onOpen:S=>void r(`/projects/${S.id}`),onEdit:S=>void r(`/projects/${S.id}`),onDelete:T,onMove:Cn,teamLabelFor:c,movingKeys:Nn}),re&&!Re&&!Be&&x==="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:Es,children:n("ui.projects.projects_page.show_all_time")})]}),re&&!Re&&!Be&&x==="timeline"&&t.jsx(Al,{items:ce,nowMs:e,onOpen:S=>void r(`/projects/${S.project.id}`),pendingDetails:nt,failedDetails:we,onRetryDetails:gt,teamLabelFor:c})]}),t.jsx(pn,{open:v!==null,projectName:v?.name??"",onClose:()=>T(null),onConfirm:async S=>{v&&(await _.mutateAsync({key:v.id,confirmedName:S}),be(n("ui.projects.projects_page.project_deleted")),T(null))}}),t.jsx(_n,{open:Ne!==null,refusal:Ne?.refusal??null,projectLabel:Ne?ne(Ne.project):"",onClose:()=>{Ne&&ee(Ne.project.id),Rs()},onConfirm:async()=>{if(!Ne)return;const{project:S,status:W,refusal:J}=Ne,Se=await p.mutateAsync({key:S.id,fields:{status:W},forceDone:!0});be(Vr(Se,J.count,ae(W).label)),u.refetch().then(()=>ee(S.id))},secondaryLabel:n("ui.projects.projects_page.open_project"),onSecondary:()=>{const S=Ne?.project.id;Rs(),S&&r(`/projects/${S}`)}}),t.jsx(kl,{open:b,onClose:()=>f(!1),onSubmit:async S=>{const W=await m.mutateAsync(S.fields),J=S.followUp?.title??S.fields.name;if(S.followUp)try{await p.mutateAsync({key:W.id,fields:S.followUp})}catch(Se){const le=Se instanceof Error&&Se.message?Se.message:"";de(n("ui.projects.projects_page.project_label_was_created_but_the_extra_fields_were_not_saved_val",{label:String(J),value2:String(_t(le)||n("ui.projects.projects_page.the_server_refused_them"))}));return}be(n("ui.projects.projects_page.project_label_created",{label:String(J)}))}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Fs,{title:n("ui.projects.projects_page.projects"),icon:Us}),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(Kt,{variant:"warning",children:gr[o]??gr.unknown})]})};export{Jl as ProjectsPage};
|
|
40
|
+
`).trim()}function fn(e,s,r){const a=e.clipboardData?.getData("text/html");if(!a)return;const o=Hc(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 m=l+o.length;u.setSelectionRange(m,m)})}const _n=({open:e,refusal:s,projectLabel:r,onClose:a,onConfirm:o,secondaryLabel:i,onSecondary:l})=>{F();const[c,u]=d.useState(!1),[m,p]=d.useState(null),_=d.useRef(!1),b=d.useRef(null);d.useEffect(()=>{e&&(u(!1),p(null),_.current=!1)},[e]);const f=async()=>{if(!_.current){_.current=!0,u(!0),p(null);try{await o(),a()}catch(w){p({copy:an(w),gone:nn(w)})}finally{_.current=!1,u(!1)}}},x=s?.names??[];return t.jsx(dt,{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:w=>{c&&w.preventDefault()},onInteractOutside:w=>{c&&w.preventDefault()},onOpenAutoFocus:w=>{w.preventDefault(),b.current?.focus()}},actions:t.jsxs("div",{className:"flex w-full min-w-0 flex-wrap justify-end gap-2",children:[t.jsx(Ye,{ref:b,onClick:a,disabled:c,children:n("ui.projects.project_done_anyway_dialog.cancel")}),!m?.gone&&t.jsx(Ye,{onClick:l,disabled:c,children:i}),m?.gone?t.jsx(vt,{"data-project-force-close":"",onClick:a,children:n("ui.projects.project_done_anyway_dialog.close")}):t.jsxs(vt,{"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?Go(s):""}),x.length>bt+1&&t.jsx("div",{className:"px-1.5",children:t.jsx(vr,{summary:n("ui.projects.project_done_anyway_dialog.show_all_length_open_milestones",{length:x.length}),children:t.jsx("ul",{"data-project-open-milestones":"",className:"flex flex-col gap-1 py-1 text-body-sm text-ink-muted",children:x.map((w,g)=>t.jsx("li",{className:"break-words",children:w},`${g}-${w}`))})})}),t.jsx("p",{role:"alert",className:"min-h-[1lh] text-body-sm text-danger break-words",children:m?.copy??""})]})})},jn=({status:e})=>{const s=ae(e);return t.jsxs(ke,{variant:s.variant,children:[no(e)&&t.jsx(gs,{"aria-hidden":!0}),s.label]})},Yc="project-key",Kc="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 Ft=({field:e,fieldRef:s,fieldProps:r,editing:a,label:o,bare:i=!1,display:l,editor:c,slot:u,feedback:m,controlsIdle:p="affordance",hug:_=!1,feedbackExtra:b,className:f,controlsClassName:x})=>t.jsxs("div",{ref:s,...r,"data-project-field":e,className:M(!i&&Cs,"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:M("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:M("min-w-0",_?"w-fit":"flex-1",!a&&"cursor-text"),onDoubleClick:a?void 0:u.begin,children:a?c:l}),t.jsx(cs,{api:u,idle:p,className:M("shrink-0",x)})]}),t.jsx("div",{className:M("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(ls,{api:m}),b]})})]})]}),Ie=({field:e,value:s,display:r,commitFields:a,validate:o,labels:i,commit:l,placeholder:c,mono:u=!1,ramp:m="text-body-sm",label:p,bare:_=!1,autoBegin:b=!1,maxLength:f,onRetire:x,className:w,controlsClassName:g})=>{const[h,v]=d.useState(b);d.useEffect(()=>{h&&s!==""&&(v(!1),x?.("filled"))},[h,s,x]);const T=jt({value:s,commit:async N=>{await l(a(N))},equals:(N,q)=>N.trim()===q.trim(),validate:o,labels:i,selectAllOnBegin:!0,beginOnMount:b,errorCopy:tt,onSettle:N=>{N==="cancelled"&&(v(!1),x?.("cancelled"))}});return!h&&s===""?null:t.jsx(Ft,{field:e,fieldRef:T.fieldRef,fieldProps:T.fieldProps,editing:T.editing,label:p,bare:_,display:r,slot:T,feedback:T,className:w,controlsClassName:g,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:N=>T.setDraft(N.target.value),spellCheck:!1,autoComplete:"off",className:M("h-8",u?"font-mono text-mono-sm":m)})})},Wc=({project:e,commit:s})=>{F();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:M(Cs,"flex min-w-0 flex-col gap-0.5"),children:[r?t.jsx(Ie,{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=>ts(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:wt,placeholder:n("ui.projects.project_editors.a_short_name_for_the_workstream"),ramp:"text-body",bare:!0,controlsClassName:"self-center"}):t.jsx(Ie,{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=>Wt(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:Zs,placeholder:Yc,ramp:"text-body",bare:!0,controlsClassName:"self-center"}),!r&&(a?t.jsx(Ie,{field:"title",value:"",display:null,commitFields:c=>({title:c.trim()}),validate:c=>ts(c),labels:ge("title",n("ui.projects.project_editors.title")),commit:s,maxLength:wt,placeholder:e.name,ramp:"text-body-sm",bare:!0,autoBegin:!0,onRetire:l}):t.jsx("button",{ref:i,type:"button","data-project-add-title":"",onClick:()=>o(!0),className:M("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(Ie,{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=>Wt(c.trim()),labels:ge("key",n("ui.projects.project_editors.key")),commit:s,maxLength:Zs,placeholder:Kc,mono:!0})]})},Vc=({project:e,commit:s})=>{F();const[r,a]=d.useState(!1),o=Ze(),i=ye(o.data,"projects_force_done"),[l,c]=d.useState(null),[u,m]=d.useState(null),p=d.useRef(!1),_=d.useRef(!1),b=d.useRef(null),f=jt({value:e.status,commit:async g=>{const h=p.current;p.current=!1,c(null);try{const v=await s({status:g},h?{forceDone:!0}:void 0);h&&be(Vr(v,l?.count??0,ae(g).label)),b.current?.resolve()}catch(v){throw c(on(v)),b.current?.reject(v),v}finally{b.current=null}},labels:ge("status",n("ui.projects.project_editors.status")),keyboardCommit:!1,errorCopy:tt,onBegin:()=>a(!0)}),x=i&&f.phase==="error"&&l!==null&&l.coded;d.useEffect(()=>{if(!_.current||f.phase!=="idle"&&f.phase!=="saved")return;_.current=!1;const g=document.querySelector("[data-project-milestones]");g&&(g.scrollIntoView({block:"start"}),g.querySelector("[data-project-milestones-heading]")?.focus({preventScroll:!0}))},[f.phase]);const w=()=>new Promise((g,h)=>{if(f.phase!=="error"||f.conflict!==null){h(new Error(""));return}if(!f.dirty){g();return}p.current=!0,b.current={resolve:g,reject:h},f.accept(f.draft,!0)});return t.jsx(Ft,{field:"status",fieldRef:f.fieldRef,fieldProps:f.fieldProps,editing:f.editing,display:t.jsx(jn,{status:e.status}),slot:f,feedback:f,hug:!0,feedbackExtra:t.jsxs(t.Fragment,{children:[x&&t.jsx(G,{variant:"ghost",size:"sm","data-project-force-done-door":"",onClick:()=>m(l),children:n("ui.projects.project_editors.mark_done_anyway")}),t.jsx(_n,{open:u!==null,refusal:u,projectLabel:ne(e),onClose:()=>m(null),onConfirm:w,secondaryLabel:n("ui.projects.project_editors.review_milestones"),onSecondary:()=>{m(null),_.current=!0,f.cancel()}})]}),editor:t.jsxs(Ke,{open:r,onOpenChange:a,value:f.draft,onValueChange:g=>{a(!1),f.accept(g)},children:[t.jsx(We,{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(Ve,{})}),t.jsx(Qe,{children:Lr.map(g=>t.jsx(Ae,{value:g.value,"data-project-status-option":g.value,children:g.label},g.value))})]})})},Qc=({project:e,commit:s})=>{F();const[r,a]=d.useState(!1),o=d.useRef(null),i=d.useRef(null),l=jt({value:e.description,commit:async m=>{await s({description:m.trim()})},equals:(m,p)=>m.trim()===p.trim(),validate:m=>sn(m),multiline:!0,labels:ge("description",n("ui.projects.project_editors.description")),errorCopy:tt,editorRef:o,onSettle:m=>{m==="cancelled"&&!e.description.trim()&&setTimeout(()=>i.current?.focus(),0)}});d.useEffect(()=>{if(r||!l.editing)return;const m=setTimeout(()=>o.current?.focus(),0);return()=>clearTimeout(m)},[r,l.editing]);const u=(l.editing?l.draft:l.displayValue).length>Xe;return t.jsx("div",{ref:l.fieldRef,...l.fieldProps,"data-project-field":"description",className:M(Cs,"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(m=>t.jsx("button",{type:"button","data-project-description-mode":m,"aria-pressed":r===(m==="preview"),onClick:()=>a(m==="preview"),className:M("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink",r===(m==="preview")&&"bg-surface text-ink"),children:m==="write"?n("ui.projects.project_editors.write"):n("ui.projects.project_editors.preview")},m))})]}),t.jsx(cs,{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(ut,{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(Sr,{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:m=>l.setDraft(m.target.value),onPaste:m=>fn(m,o,p=>l.setDraft(p)),className:"h-40 resize-none"}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(ls,{api:l}),t.jsxs("p",{className:M("shrink-0 text-meta tabular-nums",u?"text-danger":"text-ink-muted"),children:[l.draft.length,"/",Xe]})]})]}):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(ut,{className:"text-body",children:e.description??""})}),t.jsx(cs,{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(ls,{api:l})})]})})},Xc=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>(F(),t.jsx(Ie,{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=>St(o,"owner"),labels:ge("owner",n("ui.projects.project_editors.owner")),commit:s,maxLength:Nt,placeholder:n("ui.projects.examples.owner"),autoBegin:r,onRetire:a})),Jc=({project:e,commit:s,label:r=null,autoBegin:a=!1,onRetire:o})=>(F(),t.jsx(Ie,{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=>St(i,"team"),labels:ge("team",n("ui.projects.project_editors.team")),commit:s,maxLength:Nt,placeholder:n("ui.projects.examples.team"),autoBegin:a,onRetire:o})),mr=({project:e,commit:s,which:r,nowMs:a,autoBegin:o=!1,onRetire:i})=>{const l=r==="start"?e.start_date??"":e.target_date??"",c=F(),u=Oe(l,c,new Date(a)),m=r==="start"?n("ui.projects.project_editors.start"):n("ui.projects.project_editors.target");return t.jsx(Ie,{field:r==="start"?"start-date":"target-date",value:l,label:m,display:t.jsx("span",{className:"text-body-sm text-ink",children:u}),commitFields:p=>r==="start"?{start_date:p}:{target_date:p},validate:p=>{const _=ss(p);return _||(r==="start"?rs(p,e.target_date??""):rs(e.start_date??"",p))},labels:ge(n("ui.projects.project_editors.tolowercase_date",{toLowerCase:String(m.toLowerCase())}),m),commit:s,placeholder:"YYYY-MM-DD",autoBegin:o,onRetire:i})},Zc=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{F();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=jt({value:{number:e.estimate===null?"":String(e.estimate),unit:o.unit},equals:Ui,commit:async m=>{const p=$i(o,m);p&&await s(p)},validate:m=>rn(m.number),labels:ge("estimate",n("ui.projects.project_editors.estimate")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:tt,onSettle:m=>{m==="cancelled"&&(l(!1),a?.("cancelled"))}});if(!i&&e.estimate===null)return null;const u=qr(e.estimate,e.estimate_unit)||"—";return t.jsx(Ft,{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:m=>c.setDraft({...c.draft,number:m.target.value}),className:"h-8 max-w-24"}),t.jsxs(Ke,{value:c.draft.unit,onValueChange:m=>c.setDraft({...c.draft,unit:m}),children:[t.jsx(We,{"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(Ve,{})}),t.jsxs(Qe,{children:[t.jsx(Ae,{value:"points",children:n("ui.projects.project_editors.points")}),t.jsx(Ae,{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")})]})})},el=({project:e,commit:s,autoBegin:r=!1,onRetire:a})=>{F();const[o,i]=d.useState(r);d.useEffect(()=>{o&&e.tags.length>0&&(i(!1),a?.("filled"))},[o,e.tags,a]);const l=jt({value:e.tags.join(", "),equals:(u,m)=>Bi(lt(u),m),commit:async u=>{const{tags:m}=ns(u);await s({tags:m})},validate:u=>ns(u).error,labels:ge("tags",n("ui.projects.project_editors.tags")),selectAllOnBegin:!0,beginOnMount:r,errorCopy:tt,onSettle:u=>{u==="cancelled"&&(i(!1),a?.("cancelled"))}});if(!o&&e.tags.length===0)return null;const c=l.editing?lt(l.draft):e.tags;return t.jsx(Ft,{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))})]})})},tl="project-quick-send:no-target",sl=[],rl=({links:e,target:s,onTargetChange:r,onSend:a,focusTick:o})=>{F();const i=d.useRef(null),l=Wn(),{frontend:c,refresh:u}=qa(),[m,p]=d.useState(!1),_=Ze(),b=s??tl;d.useEffect(()=>{s&&u(s)},[s,u]),d.useEffect(()=>{o>0&&i.current?.focusInput()},[o]);const f=e.filter(g=>g.exists),w=(f.find(g=>g.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(Ke,{value:s??void 0,onValueChange:g=>r(g),children:[t.jsx(We,{"aria-label":n("ui.projects.project_quick_send.select_the_session_to_message"),className:"max-w-72",children:t.jsx(Ve,{placeholder:n("ui.projects.project_quick_send.no_session_selected")})}),t.jsx(Qe,{children:f.map(g=>t.jsx(Ae,{value:g.session_id,children:It(g)},g.session_id))})]}),m?t.jsx("span",{role:"status",className:"text-meta text-ink-muted",children:n("ui.projects.project_quick_send.sending")}):w?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:b,messages:sl,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(g,h)=>{if(!s)return!1;p(!0);try{return await a(s,g,w?"steer":"prompt",h)}finally{p(!1),i.current?.focusInput({preventScroll:!0})}}})]})},nl=({links:e,busy:s,onUnlink:r,onLink:a,onQuickSend:o,onStartSession:i})=>{F();const l=Dt(),c=kt(h=>h.sessions),[u,m]=d.useState(!1),[p,_]=d.useState(null),[b,f]=d.useState(0),x=p&&e.some(h=>h.session_id===p&&h.exists)?p:Io(e),w=d.useMemo(()=>{const h=new Set(e.map(v=>v.session_id));return c.filter(v=>!h.has(v.session_id)).map(v=>({id:v.session_id,name:v.title||v.session_id,description:v.cwd??void 0}))},[c,e]),g=h=>{kt.getState().openSession(h).then(v=>{v&&l(`/chat/${h}`)})};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(Aa,{}),n("ui.projects.project_links.new_session")]}),t.jsxs(G,{variant:"secondary",size:"sm",disabled:s,onClick:()=>m(!0),"data-tour-tag":"project-link-session",children:[t.jsx(Oa,{}),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(h=>{const v=fo(h),T=_o(h.subagents),N=jo(h.todos),q=h.title||h.session_id,C=h.exists;return t.jsxs("li",{"data-glass-block-row":"",className:M("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&&g(h.session_id)},className:M("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:M("min-w-0 truncate text-body-sm",h.title?"text-ink":"font-mono text-mono-sm text-ink-muted"),children:q})}),h.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}),N&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:N}),t.jsx(ke,{variant:v.variant,children:v.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:()=>{_(h.session_id),f(E=>E+1)},children:t.jsx(Pa,{})}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:s,"aria-label":n("ui.projects.project_links.unlink_title",{title:String(q)}),onClick:()=>r(h.session_id),children:t.jsx(Qa,{})})]},h.session_id)})}),e.some(h=>h.exists)&&t.jsx(rl,{links:e,target:x,onTargetChange:_,onSend:o,focusTick:b}),t.jsx(dt,{open:u,onClose:()=>m(!1),title:n("ui.projects.project_links.link_a_session"),maxWidth:"sm",dataTourTag:"project-link-dialog",actions:t.jsx(Ye,{onClick:()=>m(!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(Cr,{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:w,selected:null,onSelect:h=>{m(!1),a(h.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")})]})})]})},al=({milestones:e,summary:s,busy:r,onToggle:a,onRemove:o,onAdd:i})=>{const[l,c]=d.useState(""),[u,m]=d.useState(""),p=F(),_=!Ir.test(u.trim()),b=l.trim().length>0&&!_&&!r,f=()=>{b&&(i(l.trim(),u.trim()),c(""),m(""))};return t.jsxs("section",{"data-project-milestones":"",className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("h2",{className:"text-title text-ink",tabIndex:-1,"data-project-milestones-heading":"",children: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(x=>{const w=oo(x.status),g=x.completed_at!==null;return t.jsxs("li",{className:"flex items-center gap-3 rounded-sm px-2 py-2",children:[t.jsx(Er,{checked:g,disabled:r,onCheckedChange:h=>a(x.name,h===!0),"aria-label":g?n("ui.projects.project_milestones.mark_name_not_complete",{name:String(x.name)}):n("ui.projects.project_milestones.mark_name_complete",{name:String(x.name)})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:x.name}),x.target_date&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:Oe(x.target_date,p)}),t.jsx(ke,{variant:w.variant,children:w.label}),t.jsx(G,{variant:"ghost",size:"icon-sm",disabled:r,"aria-label":n("ui.projects.project_milestones.remove_name",{name:String(x.name)}),onClick:()=>o(x.name),children:t.jsx(Pt,{})})]},x.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:x=>c(x.target.value),placeholder:n("ui.projects.project_milestones.beta_cut"),onKeyDown:x=>{x.key==="Enter"&&(x.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:x=>m(x.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:!b,onClick:f,"data-tour-tag":"project-milestone-add",children:[t.jsx(it,{}),n("ui.projects.project_milestones.add")]})]})]})},ol=[{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")}}],fr=({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})]}),il=({project:e,nowMs:s,commit:r,teamLabel:a=null})=>{const o=F(),i=new Date(s),[l,c]=d.useState(null),u=d.useRef(null),m=d.useRef(!1),p={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,P)=>{c(j=>j===E?null:j),P==="cancelled"&&!p[E]&&setTimeout(()=>u.current?.focus(),0)},b=ol.filter(({field:E})=>!p[E]&&l!==E),f=Oe(e.completed_at,o,i),x=e.updated_at>0?mt(pt(e.updated_at,s)):"",w=e.updated_at>0?Qn(new Date(e.updated_at*1e3),{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},o):"",g=p.owner||l==="owner",h=p.team||l==="team",v=p.start||l==="start",T=p.target||l==="target",N=p.estimate||l==="estimate",q=p.tags||l==="tags",C=g||h||v||T||!!f||N||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")}),b.length>0&&t.jsxs(ps,{children:[t.jsx(ms,{asChild:!0,children:t.jsxs("button",{ref:u,type:"button","data-project-add-field":"",className:M("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(it,{className:"size-3","aria-hidden":"true"}),n("ui.projects.project_properties.add")]})}),t.jsx(fs,{align:"end",onCloseAutoFocus:E=>{m.current&&(m.current=!1,E.preventDefault())},children:b.map(({field:E,label:P})=>t.jsx(Ee,{"data-project-add-option":E,onSelect:()=>{m.current=!0,c(E)},children:P},E))})]})]}),C?t.jsxs("dl",{className:"flex flex-col gap-2",children:[g&&t.jsx(Xc,{project:e,commit:r,autoBegin:l==="owner",onRetire:E=>_("owner",E)}),h&&t.jsx(Jc,{project:e,commit:r,label:a,autoBegin:l==="team",onRetire:E=>_("team",E)}),v&&t.jsx(mr,{project:e,commit:r,which:"start",nowMs:s,autoBegin:l==="start",onRetire:E=>_("start",E)}),T&&t.jsx(mr,{project:e,commit:r,which:"target",nowMs:s,autoBegin:l==="target",onRetire:E=>_("target",E)}),f&&t.jsx(fr,{label:n("ui.projects.project_properties.completed"),children:f}),N&&t.jsx(Zc,{project:e,commit:r,autoBegin:l==="estimate",onRetire:E=>_("estimate",E)}),q&&t.jsx(el,{project:e,commit:r,autoBegin:l==="tags",onRetire:E=>_("tags",E)}),e.updated_at>0&&t.jsx(fr,{label:n("ui.projects.project_properties.updated"),children:t.jsx("time",{dateTime:new Date(e.updated_at*1e3).toISOString(),title:w,children:x})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.projects.project_properties.no_dates_estimate_tags_owner_or_team_yet")})]})},cl=({project:e})=>{F();const s=Ze(),r=dn(),{sending:a,cooling:o,cooldownRemainingMs:i}=rc(e.id);if(!ye(s.data,"projects_request_update"))return null;const l=ne(e),c=Wi(e.id);return t.jsxs(t.Fragment,{children:[t.jsx(Ot,{content:o&&i!==null?Ct(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(gs,{}):t.jsx(Wa,{}),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:Ct(l,i)})]})},hn="plain",gn=e=>`team:${e}`,xn=e=>`agent:${e}`;function ll(e){return e.startsWith("team:")?{kind:"team",name:e.slice(5)}:e.startsWith("agent:")?{kind:"agent",name:e.slice(6)}:{kind:"plain"}}function ul(e){return e.kind==="team"?gn(e.name):e.kind==="agent"?xn(e.name):hn}const _r={kind:"plain"},dl=({open:e,onClose:s,onStart:r,teamsEnabled:a,profilesEnabled:o})=>{F();const[i,l]=d.useState(_r),[c,u]=d.useState(null),[m,p]=d.useState(!1),_=Xn(e&&a),b=Jn(e&&o);d.useEffect(()=>{e&&(l(_r),u(null),p(!1))},[e]);const f=d.useMemo(()=>{const v=[{id:hn,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??[])v.push({id:gn(T.name),name:Is(T),keywords:T.name===Is(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(b.data??[]).filter(N=>N.source!=="builtin"))v.push({id:xn(T.name),name:T.name,description:T.description||T.kind,get group(){return n("ui.projects.project_start_session.agents")}});return v},[_.data,b.data]),x=f.find(v=>v.id===ul(i))??f[0],w=!a||!o,g=_.isLoading||b.isLoading,h=async()=>{p(!0),u(null);try{await r(i),s()}catch(v){u(v instanceof Error&&v.message?v.message:n("ui.projects.project_start_session.the_session_could_not_be_started"))}finally{p(!1)}};return t.jsx(dt,{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(Ye,{onClick:s,disabled:m,children:n("ui.projects.project_start_session.cancel")}),t.jsxs(vt,{onClick:()=>void h(),disabled:m,children:[m&&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(Cr,{label:n("ui.projects.project_start_session.work_with"),placeholder:n("ui.projects.project_start_session.search_teams_and_agents"),options:f,selected:x,onSelect:v=>l(ll(v.id)),busy:g,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")}),w&&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})]})})},pl=({links:e})=>{F();const s=Lo(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:Hs(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:It(a)}),a.todos&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:Hs(a.todos)})]},a.session_id))})]})},ml=({filePath:e,tooltip:s="File actions",icon:r,"aria-label":a="File actions",onShowInCanvas:o})=>{const i=async()=>{if(e)try{await navigator.clipboard.writeText(e),be("File path copied to clipboard")}catch(c){console.error("Failed to copy file path: ",c),de("Failed to copy file path")}},l=()=>{e&&window.api.openFile(e)};return t.jsxs(ps,{children:[t.jsx(Ot,{content:s,children:t.jsx(ms,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"icon-sm","aria-label":a,onClick:c=>c.stopPropagation(),children:r??t.jsx(yr,{"aria-hidden":"true"})})})}),t.jsxs(fs,{align:"end",className:"min-w-45",onClick:c=>c.stopPropagation(),children:[o&&t.jsxs(Ee,{onSelect:o,children:[t.jsx(Zn,{"aria-hidden":"true"}),t.jsx("span",{children:"Show in canvas"})]}),t.jsxs(Ee,{onSelect:l,children:[t.jsx(kr,{"aria-hidden":"true"}),t.jsx("span",{children:"Open file"})]}),t.jsxs(Ee,{onSelect:()=>window.api.showItemInFolder(e),children:[t.jsx(ea,{"aria-hidden":"true"}),t.jsx("span",{children:"Open folder"})]}),t.jsxs(Ee,{onSelect:i,children:[t.jsx(ta,{"aria-hidden":"true"}),t.jsx("span",{children:"Copy file path"})]})]})]})},fl=/[/\\]/;function bn(e){if(e.name)return e.name;const s=e.path.split(fl);return s[s.length-1]||n("ui.projects.project_updates.attachment")}const _l=({attachment:e})=>{F();const s=bn(e),r=Po(e.bytes);return t.jsxs("div",{className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-surface px-3 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2.5 text-left",onClick:()=>{window.api?.openFile(e.path)},title:n("ui.projects.project_updates.open_name",{name:String(s)}),children:[t.jsx(kr,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),t.jsx("span",{className:"truncate text-body-sm text-ink",children:s})]}),r&&t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:r}),t.jsx(ml,{filePath:e.path,"aria-label":n("ui.projects.project_updates.file_actions_for_name",{name:String(s)})})]})},jl=({attachment:e})=>{F();const s=bn(e),r=sa(e.path,{mimeType:ra(e.name||e.path),sizeBytes:e.bytes});return r.status==="ready"?t.jsx("div",{className:"inline-block max-w-full",children:t.jsx(na,{file:e.path,src:r.url,label:s,conversationId:""})}):r.status==="loading"?t.jsx(aa,{children:t.jsxs("span",{className:"sr-only",children:[n("ui.projects.project_updates.loading"),s]})}):t.jsx(oa,{name:s})},hl=({attachments:e})=>t.jsx("div",{className:"flex flex-wrap items-start gap-2",children:e.map(s=>s.kind==="image"?t.jsx(jl,{attachment:s},`${s.path}:${s.added_at}`):t.jsx(_l,{attachment:s},`${s.path}:${s.added_at}`))}),gl=({update:e,nowMs:s})=>{const r=F(),a=Ao(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(ut,{children:e.text}),e.attachments.length>0&&t.jsx(hl,{attachments:e.attachments})]})},xl=({updates:e,nowMs:s})=>{const r=F(),a=Co(e.length),o=Oo(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(gl,{update:l,nowMs:s},`${l.at}:${l.by}:${c}`))})]},i.key||"ungrouped"))})]})},bl="project_not_found",yl=({projectKey:e,nowMs:s})=>{F();const r=Dt(),a=Ze(),o=wr(ye(a.data,"team_catalogue")),i=Ar(e,!0),l=Or(),c=Pr(),u=so(),m=ro(),p=eo(),_=to(),[b,f]=d.useState(!1),[x,w]=d.useState(!1),g=l.isPending||c.isPending||u.isPending||m.isPending||p.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 j=i.error instanceof Rt&&(i.error.code===bl||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(Kt,{variant:"danger",className:"w-full",children:j?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(qs,{}),n("ui.projects.project_detail.all_projects")]})]})]})}const{project:h,links:v}=i.data,T=ne(h),N=(j,D)=>l.mutateAsync({key:h.id,fields:j,...D?.forceDone===!0?{forceDone:!0}:{}}),q=h.team?o(h.team):null,C=Mo(h.milestones.filter(j=>j.completed_at!==null).length,h.milestones.length),E=async(j,D,R,I)=>{const K=kt.getState(),B=ca(null,j,K.drafts);if(!B)return!1;try{const{images:H,unreadable:X,overflow:Z}=await la(I,D),me=ua(X);if(me)return de(me),!1;const oe=da(Z);if(oe)return de(oe),!1;const ee=pa(D,H);if(ee)return de(ee),!1;if(await ma(B,{text:D,attachments:I,images:H,mode:R,cwd:K.cwd},j)===null)return de(n("ui.projects.project_detail.that_session_already_has_a_message_going_out_try_again_in_a_momen")),!1;const y=v.find(k=>k.session_id===j);return be(n("ui.projects.project_detail.sent_to_value1",{value1:String(y?It(y):j)})),!0}catch(H){return de(H instanceof Error&&H.message?H.message:n("ui.projects.project_detail.the_message_was_not_sent")),!1}},P=async j=>{const D=kt.getState(),R=j.kind==="plain"?void 0:{kind:j.kind,name:j.name},I=await D.createSession(D.cwd||"~",R);if(!I)throw new Error(D.error??n("ui.projects.project_detail.the_session_could_not_be_started"));fa.getState().setCurrentInput(I,Fo(h));let K=null;try{await p.mutateAsync({key:h.id,sessionId:I})}catch(B){K=B instanceof Error&&B.message?B.message:n("ui.projects.project_detail.the_link_was_refused")}if(K)de(n("ui.projects.project_detail.session_started_but_linking_it_failed_linkfailure",{linkFailure:String(K)}));else{const B=R?n("ui.projects.project_detail.with_value1",{value1:String(qo(R))}):"";be(n("ui.projects.project_detail.session_started_withtarget_and_linked_to_displayname",{withTarget:String(B),displayName:String(T)}))}await Rr(r,I)};return t.jsx(gc,{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(qs,{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(Wc,{project:h,commit:N}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1.5",children:[t.jsx(Vc,{project:h,commit:N}),h.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(cl,{project:h}),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(Qc,{project:h,commit:N}),t.jsx(il,{project:h,nowMs:s,commit:N,teamLabel:q}),h.updates.length===0&&h.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(ut,{className:"text-body",children:h.progress}),t.jsx("p",{className:"text-meta text-ink-muted",children:lo(h,s)})]}),t.jsx(al,{milestones:h.milestones,summary:C,busy:g,onToggle:(j,D)=>{u.mutateAsync({key:h.id,name:j,completed:D}).catch(R=>{de(R instanceof Error&&R.message?R.message:n("ui.projects.project_detail.the_milestone_was_not_updated"))})},onRemove:j=>{m.mutateAsync({key:h.id,name:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_milestone_was_not_removed"))})},onAdd:(j,D)=>{u.mutateAsync({key:h.id,name:j,targetDate:D}).catch(R=>{de(R instanceof Error&&R.message?R.message:n("ui.projects.project_detail.the_milestone_was_not_added"))})}}),t.jsx(nl,{projectKey:h.id,links:v,busy:g,onStartSession:()=>w(!0),onQuickSend:E,onLink:j=>{p.mutateAsync({key:h.id,sessionId:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_session_was_not_linked"))})},onUnlink:j=>{_.mutateAsync({key:h.id,sessionId:j}).catch(D=>{de(D instanceof Error&&D.message?D.message:n("ui.projects.project_detail.the_session_was_not_unlinked"))})}}),t.jsx(pl,{links:v}),t.jsx(xl,{updates:h.updates,nowMs:s}),t.jsx(pn,{open:b,projectName:h.name,onClose:()=>f(!1),onConfirm:async j=>{await c.mutateAsync({key:h.id,confirmedName:j}),be(n("ui.projects.project_detail.project_deleted")),r("/projects")}}),t.jsx(dl,{open:x,onClose:()=>w(!1),onStart:P,teamsEnabled:ye(a.data,"team_catalogue"),profilesEnabled:ye(a.data,"profile_catalogue")})]})})},vl="payments-migration",jr={name:"",title:"",owner:"",team:"",description:"",status:"active",tags:"",startDate:"",targetDate:"",estimate:"",estimateUnit:"points"},kl=({open:e,onClose:s,onSubmit:r})=>{F();const[a,o]=d.useState(jr),[i,l]=d.useState({}),[c,u]=d.useState(null),m=d.useRef(null),[p,_]=d.useState(!1),[b,f]=d.useState(!1),[x,w]=d.useState(!1),g=d.useId(),h=d.useRef(null);d.useEffect(()=>{e&&(o({...jr,description:lr}),l({}),u(null),_(!1),f(!1),w(!1))},[e]),d.useEffect(()=>{c&&m.current?.scrollIntoView({block:"nearest"})},[c]);const v=(j,D)=>{o(R=>({...R,[j]:D}))},T=b?a.name:Cc(a.title),N=j=>fn(j,h,D=>v("description",D)),q=(j,D)=>{const R={},I=Wt(D);I&&(R.name=I);const K=sn(j.description);K&&(R.description=K);const B=ns(j.tags).error;B&&(R.tags=B);const H=ss(j.startDate);H&&(R.startDate=H);const X=ss(j.targetDate);if(X)R.targetDate=X;else if(!H){const ee=rs(j.startDate,j.targetDate);ee&&(R.targetDate=ee)}if(j.estimate.trim()){const ee=rn(j.estimate);ee&&(R.estimate=ee)}const Z=ts(j.title);Z&&(R.title=Z);const me=St(j.owner,"owner");me&&(R.owner=me);const oe=St(j.team,"team");return oe&&(R.team=oe),R},C=async()=>{const j=T.trim(),D=q(a,j);if(l(D),Object.keys(D).length>0)return;_(!0),u(null);const R=lt(a.tags);try{const I={};a.title.trim()&&(I.title=a.title.trim()),a.owner.trim()&&(I.owner=a.owner.trim()),a.team.trim()&&(I.team=a.team.trim()),a.startDate&&(I.start_date=a.startDate),a.targetDate&&(I.target_date=a.targetDate),a.estimate&&(I.estimate=Number(a.estimate),I.estimate_unit=a.estimateUnit),await r({fields:{name:j,...a.description.trim()&&a.description.trim()!==lr?{description:a.description.trim()}:{},status:a.status,...R.length>0?{tags:R}:{}},...Object.keys(I).length>0?{followUp:I}:{}}),s()}catch(I){const K=I instanceof Error&&I.message?I.message:"";u(_t(K)||n("ui.projects.project_form_dialog.the_project_was_not_saved"))}finally{_(!1)}},E=n("ui.projects.project_form_dialog.new_project"),P=a.description.length>Xe;return t.jsx(dt,{open:e,onClose:s,title:E,fullWidth:!0,maxWidth:"md",dialogProps:{closeDisabled:p,onEscapeKeyDown:j=>{p&&j.preventDefault()},onInteractOutside:j=>{p&&j.preventDefault()}},dataTourTag:"project-create-dialog",actions:t.jsxs(t.Fragment,{children:[t.jsx(Ye,{onClick:s,disabled:p,children:n("ui.projects.project_form_dialog.cancel")}),t.jsxs(vt,{"data-project-submit":"",onClick:()=>void C(),disabled:p,children:[p&&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:j=>{j.preventDefault(),C()},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`${g}-title`,children:n("ui.projects.project_form_dialog.title")}),t.jsx(ue,{id:`${g}-title`,"data-project-title":"",value:a.title,onChange:j=>v("title",j.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:`${g}-key`,className:"shrink-0 text-meta text-ink-muted",children:n("ui.projects.project_form_dialog.key")}),t.jsx(ue,{id:`${g}-key`,"data-project-key":"",value:T,onChange:j=>{f(!0),v("name",j.target.value)},placeholder:vl,"aria-invalid":!!i.name,className:"h-7 max-w-56 font-mono text-mono-sm"}),t.jsx("span",{className:"text-meta text-ink-muted",children:b?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:`${g}-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(j=>t.jsx("button",{type:"button","data-project-description-mode":j,"aria-pressed":x===(j==="preview"),onClick:()=>w(j==="preview"),className:M("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",x===(j==="preview")&&"bg-surface text-ink"),children:j==="write"?n("ui.projects.project_form_dialog.write"):n("ui.projects.project_form_dialog.preview")},j))})]})]}),x?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(ut,{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(Sr,{ref:h,id:`${g}-description`,"data-project-description":"",value:a.description,onChange:j=>v("description",j.target.value),onPaste:N,rows:8,placeholder:n("ui.projects.project_form_dialog.markdown_headings_lists_code"),"aria-invalid":P||!!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:M("text-meta tabular-nums",P?"text-danger":"text-ink-muted"),children:[a.description.length,"/",Xe]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{children:n("ui.projects.project_form_dialog.status")}),t.jsxs(Ke,{value:a.status,onValueChange:j=>v("status",j),children:[t.jsx(We,{"aria-label":n("ui.projects.project_form_dialog.status"),children:t.jsx(Ve,{})}),t.jsx(Qe,{children:Lr.map(j=>t.jsx(Ae,{value:j.value,children:j.label},j.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:`${g}-owner`,children:n("ui.projects.project_form_dialog.owner")}),t.jsx(ue,{id:`${g}-owner`,"data-project-owner":"",value:a.owner,onChange:j=>v("owner",j.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:`${g}-team`,children:n("ui.projects.project_form_dialog.team")}),t.jsx(ue,{id:`${g}-team`,value:a.team,onChange:j=>v("team",j.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:`${g}-target`,children:n("ui.projects.project_form_dialog.target_date")}),t.jsx(ue,{id:`${g}-target`,"data-project-target":"",value:a.targetDate,onChange:j=>v("targetDate",j.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:`${g}-start`,children:n("ui.projects.project_form_dialog.start_date")}),t.jsx(ue,{id:`${g}-start`,value:a.startDate,onChange:j=>v("startDate",j.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:`${g}-estimate`,children:n("ui.projects.project_form_dialog.estimate")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ue,{id:`${g}-estimate`,value:a.estimate,onChange:j=>v("estimate",j.target.value),placeholder:"13",inputMode:"decimal","aria-invalid":!!i.estimate,className:"max-w-28"}),t.jsxs(Ke,{value:a.estimateUnit,onValueChange:j=>v("estimateUnit",j),children:[t.jsx(We,{"aria-label":n("ui.projects.project_form_dialog.estimate_unit"),className:"max-w-32",children:t.jsx(Ve,{})}),t.jsxs(Qe,{children:[t.jsx(Ae,{value:"points",children:n("ui.projects.project_form_dialog.points")}),t.jsx(Ae,{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:`${g}-tags`,children:n("ui.projects.project_form_dialog.tags")}),t.jsx(ue,{id:`${g}-tags`,value:a.tags,onChange:j=>v("tags",j.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:m,className:"text-body-sm text-danger",children:c})]})})},yn=({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:M("max-h-[min(70vh,32rem)] overflow-y-auto overscroll-contain",r&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-12px),transparent)]"),children:e})},wl=({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(Er,{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})]})},Nl=({column:e,spec:s,onChange:r})=>{F();const a=d.useId(),o=s!==null&&s.key===e,i=o?s.direction:Bt(e),l=i==="asc"?"desc":"asc",c=()=>r({key:e,direction:o?l:Bt(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(Je(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:M("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:m=>{u==="sorted"&&(m.key!==" "&&m.key!=="Enter"||(m.preventDefault(),c()))},className:"m-0 size-3.5 shrink-0 accent-[var(--color-accent)]"}),t.jsx("span",{className:M("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(Je(e)),value2:String(ks(e,o?i:Bt(e)))})})]})]})},Sl=({facet:e,options:s,onToggle:r})=>(F(),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:ot[e]}),s.map(a=>t.jsx(wl,{label:a.label,count:a.count,selected:a.selected,onToggle:()=>r(e,a.value)},`${e}:${a.value??"none"}`))]})),vn=({projects:e,state:s,query:r,todayMs:a,onToggle:o,onClearAll:i,scope:l,sort:c})=>{F();const u=l===void 0?_i(e,s,a):l===null?[]:[tn(l,e,s,a)],m=!ct(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")}),m&&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(Je(c.key))})}),t.jsx(Nl,{column:c.key,spec:c.spec,onChange:c.onChange})]}),u.map(p=>t.jsx(Sl,{facet:p.facet,options:p.options,onToggle:o},p.facet))]})},Cl=({team:e,count:s,headingId:r,className:a,...o})=>(F(),t.jsxs("div",{...o,"data-glass-well":"",className:M("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":po(s),children:s})]})),Ce=[{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 El(e,s){const r=pt(e.progress_updated_at,s);return r?mt(r):n("ui.projects.project_list.not_reported")}const Tl=({direction:e})=>e==="asc"?t.jsx(Dr,{size:10,className:"shrink-0","aria-hidden":"true"}):t.jsx(Nr,{size:10,className:"shrink-0","aria-hidden":"true"}),Rl=({projects:e,nowMs:s,onOpen:r,sort:a,onSortChange:o,searchPopulation:i,filters:l,query:c,todayMs:u,onToggleFilter:m,onClearFilters:p,teamLabelFor:_=b=>b})=>{const b=F(),f=a?wi(e,a):e,x=bs(f,ft),w=d.useId(),g=C=>`${w}-team-${C}`,[h,v]=d.useState(0),T=d.useRef([]),N=(C,E)=>{const P=Ce.length;for(let j=1;j<=P;j+=1){const D=(C+E*j+P*P)%P,R=T.current[D];if(R&&R.offsetParent!==null){v(D),R.focus();return}}},q=C=>E=>{E.key!=="ArrowLeft"&&E.key!=="ArrowRight"||(E.preventDefault(),N(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:Ce.map((C,E)=>{const P=a!==null&&a.key===C.sort;return t.jsx("th",{scope:"col","aria-sort":P?a.direction==="desc"?"descending":"ascending":"none",className:M(C.className,"p-0 text-left font-normal"),children:t.jsxs(_s,{children:[t.jsx(js,{asChild:!0,children:t.jsxs("button",{type:"button",ref:j=>{T.current[E]=j},tabIndex:E===h?0:-1,"data-project-column":C.key,onFocus:()=>v(E),onKeyDown:q(E),className:M("group flex w-full min-w-0 items-center gap-1 rounded-xs text-left","transition-colors duration-fast ease-out-quart",P?"text-ink":"hover:text-ink"),children:[t.jsx("span",{className:"truncate",children:C.label}),P?t.jsx(Tl,{direction:a.direction}):t.jsx(_a,{size:10,className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink","aria-hidden":"true"})]})}),t.jsx(hs,{align:"start","aria-label":n("ui.projects.project_list.label_column",{label:String(C.label)}),className:"w-72 p-0",children:t.jsx(yn,{children:t.jsx(vn,{projects:i,state:l,query:c,todayMs:u,onToggle:m,onClearAll:p,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:x.map((C,E)=>t.jsxs("li",{children:[t.jsx(Cl,{team:C.team==null?null:_(C.team),count:C.items.length,headingId:g(E),className:"sticky top-0 z-10","data-project-team":C.team??""}),t.jsx("ul",{"aria-labelledby":g(E),className:"divide-y divide-hairline",children:C.items.map(P=>{const j=new Map(Br(P,b).map(I=>[I.key,I.text])),D=Ur(P.milestones_completed,P.milestones_total),R=xs(P.live_sessions);return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>r(P),"data-project-name":P.name,className:M("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:M(Ce[0].className,"truncate text-body-sm text-ink"),children:ne(P)}),t.jsx("span",{className:Ce[1].className,children:t.jsx(jn,{status:P.status})}),t.jsx("span",{className:M(Ce[2].className,"truncate text-meta text-ink-muted"),children:j.get("target")??j.get("completed")??""}),t.jsx("span",{className:M(Ce[3].className,"truncate text-meta text-ink-muted"),children:j.get("estimate")??""}),t.jsx("span",{className:M(Ce[4].className,"truncate text-meta text-ink-muted"),children:D}),t.jsx("span",{className:M(Ce[5].className,"truncate text-meta text-ink-muted"),children:R}),t.jsxs("span",{className:M(Ce[6].className,"flex items-center gap-2"),children:[t.jsx("span",{className:"truncate text-meta text-ink-muted",children:El(P,s)}),P.progress_stale&&t.jsx(ke,{variant:"warning",children:n("ui.projects.project_model.stale")})]})]})},P.id)})})]},C.team??""))})]})},Tt=224,hr=36,Dl={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")}},Al=({items:e,nowMs:s,onOpen:r,pendingDetails:a,failedDetails:o,onRetryDetails:i,teamLabelFor:l=c=>c})=>{F();const[c,u]=d.useState(null),[m,p]=d.useState(0),_=d.useRef(null),b=Ns(s),f=d.useMemo(()=>Ci(e,b),[e,b]),x=d.useMemo(()=>Ei(e),[e]),w=d.useMemo(()=>bs(x.dated,C=>ft(C.project)),[x]);d.useLayoutEffect(()=>{const C=_.current;if(!C)return;const E=()=>p(C.clientWidth);if(E(),typeof ResizeObserver>"u")return;const P=new ResizeObserver(E);return P.observe(C),()=>P.disconnect()},[]);const g=Math.max(m-Tt-24,160),h=f?Ni(Js(f.startMs,f.endMs),g):"month",v=c??h,T=C=>{const E=De.indexOf(v),P=De[E-C];P&&u(P)},N=ws[v],q=f?Js(f.startMs,f.endMs)*N: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(x.dated.length,{useGrouping:!1}),length_2:V(x.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||v===De[0],onClick:()=>T(1),children:t.jsx(it,{})}),t.jsx("span",{className:"w-16 text-center text-meta text-ink-muted",children:Dl[v]}),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||v===De[De.length-1],onClick:()=>T(-1),children:t.jsx(Ca,{})})]})]}),f&&x.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(Ol,{startMs:f.startMs,endMs:f.endMs,tier:v,pxPerDay:N,trackPx:q}),w.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:Tt},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(Pl,{item:E,spanStart:f.startMs,pxPerDay:N,trackPx:q,today:b,onOpen:()=>r(E)},E.project.id))]},C.team??""))]})}):null,x.undated.length>0&&t.jsx("div",{className:"shrink-0 px-9 py-2","data-project-undated-callout":"",children:t.jsxs(vr,{defaultOpen:x.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(Ga,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"truncate text-ink",children:Ti(x.undated.length)})]}),children:[x.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:x.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))})]})})]})},Ol=({startMs:e,endMs:s,tier:r,pxPerDay:a,trackPx:o})=>{const i=Fi(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:Tt}}),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:Le(e,l.dayMs)*a},children:[t.jsx("span",{className:M("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))})]})},Pl=({item:e,spanStart:s,pxPerDay:r,trackPx:a,today:o,onOpen:i})=>{const{project:l}=e,c=Ri(e),u=Di(e),m=p=>new Date(p).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:Tt,height:hr},children:t.jsx("span",{className:"truncate text-body-sm text-ink",children:ne(l)})}),t.jsxs("span",{className:"relative block",style:{width:a,height:hr},children:[c&&t.jsx("span",{className:"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-accent/75",style:{left:Le(s,c.fromMs)*r,width:(Le(c.fromMs,c.toMs)+1)*r},title:`${Oe(m(c.fromMs))} → ${Oe(m(c.toMs))}`}),u.map(p=>t.jsx("span",{"data-milestone":p.status,className:M("absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rotate-45",p.status==="completed"&&"bg-success",p.status==="overdue"&&"bg-warning",p.status==="upcoming"&&"border-[1.5px] border-ink-muted bg-surface"),style:{left:Le(s,p.dayMs)*r},title:`${p.name} · ${p.status} · ${Oe(m(p.dayMs))}`},`${p.name}-${p.dayMs}`)),t.jsx("span",{className:"absolute inset-y-0 w-px bg-accent/75",style:{left:Le(s,o)*r},"aria-hidden":"true"})]})]})},Ml=({projects:e,query:s,onQueryChange:r,filters:a,onFiltersChange:o,onClearAll:i,todayMs:l,resultText:c,countRevealClass:u="@[37rem]:inline",trailing:m,disabled:p=!1,searchFieldRef:_})=>{F();const[b,f]=d.useState(!1),x=d.useRef(!1),w=di(a),g=Tr(c??"",300),h=s.trim()!==""||!ct(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(ja,{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:v=>r(v.target.value),onKeyDown:v=>{v.key==="Escape"&&(s?r(""):v.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:()=>ha(_.current,r),"aria-label":n("ui.projects.projects_toolbar.clear_search"),children:t.jsx(Pt,{"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(ga,{shortcut:"/"})})]}),t.jsxs(_s,{open:b,onOpenChange:f,children:[t.jsx(js,{asChild:!0,children:t.jsxs(G,{variant:"secondary",size:"sm",disabled:p,"data-project-filters-button":"",children:[t.jsx(Ya,{size:14,"aria-hidden":"true"}),n("ui.projects.projects_toolbar.filters"),w>0&&t.jsx(ke,{variant:"neutral",children:w})]})}),t.jsx(hs,{align:"end","aria-label":n("ui.projects.projects_toolbar.filters"),className:"w-80 p-0",onCloseAutoFocus:v=>{x.current&&(x.current=!1,v.preventDefault())},children:t.jsx(yn,{children:t.jsx(vn,{projects:e,state:a,query:s,todayMs:l,onToggle:(v,T)=>o(Jr(a,v,T)),onClearAll:()=>{i(),x.current=!0,f(!1),_.current?.focus()}})})})]}),h&&c!==null&&t.jsx("span",{className:M("hidden whitespace-nowrap text-meta text-ink-dim",u),"data-project-count":"",children:c}),t.jsx("output",{className:"sr-only","aria-live":"polite",children:g}),m]})},Ll=({filters:e,sort:s,onFiltersChange:r,onSortChange:a,onClearAll:o,hideClearAll:i=!1,searchFieldRef:l})=>{F();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 m=[];for(const _ of et){const b=e[_];if(b.length===0)continue;const f=b.map(g=>Xr(_,g)),x=f[0],w=f.length>1?n("ui.projects.projects_toolbar.facet_labels_facet_first_length_1",{FACET_LABELS_facet:String(ot[_]),first:String(x),length___1:V(f.length-1,{useGrouping:!1})}):n("ui.projects.projects_toolbar.facet_labels_facet_first",{FACET_LABELS_facet:String(ot[_]),first:String(x)});m.push({kind:"facet",facet:_,label:w,ariaLabel:n("ui.projects.projects_toolbar.remove_filter_facet_labels_facet_join",{FACET_LABELS_facet:String(ot[_]),join:String(f.join(", "))}),clear:()=>r({...e,[_]:[]})})}if(s&&m.push({kind:"sort",spec:s,label:n("ui.projects.projects_toolbar.sort_key",{key:String(Je(s.key))}),ariaLabel:n("ui.projects.projects_toolbar.remove_sort_key_direction",{key:String(Je(s.key)),direction:String(ks(s.key,s.direction))}),clear:()=>a(null)}),m.length===0)return null;const p=(_,b)=>{b.clear();const f=m.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:[m.map((_,b)=>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":b,"aria-label":_.ariaLabel,onClick:()=>p(b,_),children:[_.kind==="sort"&&(_.spec.direction==="asc"?t.jsx(Dr,{size:10,className:"text-ink-muted","aria-hidden":"true"}):t.jsx(Nr,{size:10,className:"text-ink-muted","aria-hidden":"true"})),t.jsx("span",{className:"truncate",children:_.label}),t.jsx(Pt,{className:M("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")})]})},kn="projects-view",Il=[{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 Fl(){try{const e=localStorage.getItem(kn);if(e==="board"||e==="timeline"||e==="list")return e}catch{}return"board"}function ql(e){try{localStorage.setItem(kn,e)}catch{}}const Ul=({value:e,onChange:s})=>(F(),t.jsx(Ea,{value:e,onValueChange:r=>s(r),children:t.jsx(Ta,{"aria-label":n("ui.projects.projects_view_switcher.project_view"),"data-tour-tag":"projects-view-switcher",children:Il.map(r=>t.jsx(Ra,{value:r.value,children:r.label},r.value))})})),Bl=["r1","r2","r3","r4","r5","r6"],$l=4e3,gr={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")}},Jl=({nowMs:e=Date.now()})=>{F();const{projectId:s}=xa(),r=Dt(),a=Ze(),o=ba(a.data,"projects",1),i=o==="enabled",l=ye(a.data,"projects",Ko),c=wr(ye(a.data,"team_catalogue")),u=Xa(i),m=Za(),p=Or(),_=Pr(),[b,f]=d.useState(!1),[x,w]=d.useState(()=>Fl()),[g,h]=d.useState(()=>yo()),[v,T]=d.useState(null),[N,q]=d.useState(""),[C,E]=d.useState(Ws),[P,j]=d.useState(()=>gi()),[D,R]=d.useState(""),I=d.useRef(""),K=d.useRef(null),B=d.useRef(null),H=S=>{K.current!==null&&(window.cancelAnimationFrame(K.current),K.current=null),S!==""&&S===I.current?(R(""),K.current=window.requestAnimationFrame(()=>{K.current=null,R(S)})):R(S),I.current=S,B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,I.current="",R("")},$l)},X=()=>{K.current!==null&&(window.cancelAnimationFrame(K.current),K.current=null),B.current!==null&&(window.clearTimeout(B.current),B.current=null),I.current="",R("")},Z=S=>{q(S),X()},me=S=>{E(S),X()},oe=d.useRef(null),ee=nc(),te=u.data??[],y=Ns(e),k=oi(N,i&&l),O=Qr(N),L=d.useMemo(()=>k.answer?ni(te,k.answer.projects):null,[te,k.answer]),U=O!=="",Y=d.useMemo(()=>U?L??ri(te,O):te,[te,O,U,L]),Q=L===null?"client":"backend",$=d.useMemo(()=>pi(Y,C,y),[Y,C,y]),je=l&&U&&k.pending,ie=U||!ct(C),z=d.useMemo(()=>$s(te,g,e),[te,g,e]),se=d.useMemo(()=>$s($,g,e),[$,g,e]),xe=bo(g),fe=x==="board"?se.length:$.length,Pe=!ie||!u.isSuccess?null:x==="board"?n("ui.projects.projects_page.length_of_length_2_in_window",{length:V(se.length,{useGrouping:!1}),length_2:V(z.length,{useGrouping:!1})}):n("ui.projects.projects_page.length_of_length_2_projects",{length:V($.length,{useGrouping:!1}),length_2:te.length}),re=u.isSuccess&&te.length>0,Re=re&&ie&&fe===0&&!je,Be=je&&fe===0&&re,[qt,st]=d.useState(!1);d.useEffect(()=>{if(!qt)return;const S=document.querySelector('[data-tour-tag="projects-board-window"]');S&&(S.focus(),st(!1))}),d.useEffect(()=>{if(!i||s)return;const S=W=>{const J=W.target;if(!J||J.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(J.tagName)||J.closest('[role="dialog"]'))return;const Se=W.key==="/"&&!W.metaKey&&!W.ctrlKey&&!W.altKey,le=(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="f";!Se&&!le||(W.preventDefault(),oe.current?.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[i,s]);const rt=d.useRef(null);d.useLayoutEffect(()=>{if(!s)return;const S=rt.current;S!==null&&(S.scrollTop=0)},[s]);const ht=Ja(x==="timeline"?te.map(S=>S.id):[],i),A=new Map(te.map((S,W)=>[S.id,ht[W]])),ce=$.map(S=>({project:S,milestones:A.get(S.id)?.data?.project.milestones??[]})),nt=x==="timeline"?$.filter(S=>A.get(S.id)?.isLoading).length:0,we=x==="timeline"?$.filter(S=>A.get(S.id)?.isError).length:0,gt=()=>{for(const S of ht)S.isError&&S.refetch()},$e=S=>{j(S),xi(S),H(bi(S))},wn=(S,W)=>{E(J=>Jr(J,S,W)),X()},xt=()=>{const S=N.trim()!=="",W=!ct(C),J=P!==null;q(""),E(Ws),P!==null&&$e(null),H(yi({search:S,filters:W,sort:J}))},Es=()=>{h("all"),zs("all"),st(!0)},[Ne,Ts]=d.useState(null),Ut=d.useRef(!1),Rs=()=>{Ut.current=!1,Ts(null)},[Nn,Ds]=d.useState([]),Sn=ye(a.data,"projects_force_done"),Cn=(S,W)=>{const J=S.id,Se=ae(W).label;Ds(le=>le.includes(J)?le:[...le,J]),zi({move:()=>p.mutateAsync({key:J,fields:{status:W}}),forceDoneOffered:Sn,claimQuestion:()=>Ut.current?!1:(Ut.current=!0,!0)}).then(le=>{if(le.kind==="accepted"){be(n("ui.projects.projects_page.moved_to_label",{label:String(Se)})),u.refetch().then(()=>ee(J));return}if(le.kind==="question"){Ts({project:S,status:W,refusal:le.refusal});return}de(le.copy,le.refusal?{action:{get label(){return n("ui.projects.projects_page.view_project")},onClick:()=>void r(`/projects/${J}`)}}:void 0),ee(J)}).finally(()=>{Ds(le=>le.filter(En=>En!==J))})};return i?s?t.jsx("div",{ref:rt,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(yl,{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(Fs,{title:n("ui.projects.projects_page.projects"),icon:Us,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(Ma,{})}),t.jsxs(G,{variant:"secondary",onClick:()=>f(!0),"data-tour-tag":"create-project-button",children:[t.jsx(it,{}),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(Ul,{value:x,onChange:S=>{w(S),ql(S)}}),t.jsx(Ml,{projects:Y,query:N,onQueryChange:Z,filters:C,onFiltersChange:me,onClearAll:xt,todayMs:y,resultText:Pe,countRevealClass:x==="board"?"@[47rem]:inline":void 0,disabled:u.isError,searchFieldRef:oe,trailing:x==="board"&&!(u.isSuccess&&u.data.length===0)?t.jsx(Gi,{value:g,onChange:S=>{h(S),zs(S)}}):null})]}),t.jsx(Ll,{filters:C,sort:P,onFiltersChange:me,onSortChange:$e,onClearAll:xt,hideClearAll:Re,searchFieldRef:oe}),t.jsx("output",{"data-project-announcement":"",className:"sr-only","aria-live":"polite",children:D})]})]}),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")}),Bl.map(S=>t.jsxs("div",{className:"flex items-center gap-3 px-9 py-2","aria-hidden":"true",children:[t.jsx(ze,{className:"h-4 min-w-0 flex-1 bg-elevated"}),t.jsx(ze,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-32 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-16 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-20 shrink-0 bg-elevated"}),t.jsx(ze,{className:"h-4 w-40 shrink-0 bg-elevated"})]},S))]}),u.isError&&t.jsxs("div",{className:"flex flex-col items-start gap-2 px-6",children:[t.jsx(Kt,{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(it,{}),n("ui.projects.projects_page.new_project")]})]}),Be&&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&&Re&&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.trim()?n("ui.projects.projects_page.no_projects_match_trim",{trim:String(N.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:N.trim()?Yo[Q]: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:()=>{xt(),oe.current?.focus()},children:n("ui.projects.projects_page.clear_all")}),x==="board"&&$.length>0&&t.jsx(G,{variant:"secondary",onClick:Es,children:n("ui.projects.projects_page.show_all_time")})]})]}),re&&!Re&&!Be&&x==="list"&&t.jsx(Rl,{projects:$,nowMs:e,onOpen:S=>void r(`/projects/${S.id}`),sort:P,onSortChange:$e,searchPopulation:Y,filters:C,query:N,todayMs:y,onToggleFilter:wn,onClearFilters:xt,teamLabelFor:c}),re&&!Re&&x==="board"&&se.length>0&&t.jsx(oc,{projects:se,nowMs:e,onOpen:S=>void r(`/projects/${S.id}`),onEdit:S=>void r(`/projects/${S.id}`),onDelete:T,onMove:Cn,teamLabelFor:c,movingKeys:Nn}),re&&!Re&&!Be&&x==="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:Es,children:n("ui.projects.projects_page.show_all_time")})]}),re&&!Re&&!Be&&x==="timeline"&&t.jsx(Al,{items:ce,nowMs:e,onOpen:S=>void r(`/projects/${S.project.id}`),pendingDetails:nt,failedDetails:we,onRetryDetails:gt,teamLabelFor:c})]}),t.jsx(pn,{open:v!==null,projectName:v?.name??"",onClose:()=>T(null),onConfirm:async S=>{v&&(await _.mutateAsync({key:v.id,confirmedName:S}),be(n("ui.projects.projects_page.project_deleted")),T(null))}}),t.jsx(_n,{open:Ne!==null,refusal:Ne?.refusal??null,projectLabel:Ne?ne(Ne.project):"",onClose:()=>{Ne&&ee(Ne.project.id),Rs()},onConfirm:async()=>{if(!Ne)return;const{project:S,status:W,refusal:J}=Ne,Se=await p.mutateAsync({key:S.id,fields:{status:W},forceDone:!0});be(Vr(Se,J.count,ae(W).label)),u.refetch().then(()=>ee(S.id))},secondaryLabel:n("ui.projects.projects_page.open_project"),onSecondary:()=>{const S=Ne?.project.id;Rs(),S&&r(`/projects/${S}`)}}),t.jsx(kl,{open:b,onClose:()=>f(!1),onSubmit:async S=>{const W=await m.mutateAsync(S.fields),J=S.followUp?.title??S.fields.name;if(S.followUp)try{await p.mutateAsync({key:W.id,fields:S.followUp})}catch(Se){const le=Se instanceof Error&&Se.message?Se.message:"";de(n("ui.projects.projects_page.project_label_was_created_but_the_extra_fields_were_not_saved_val",{label:String(J),value2:String(_t(le)||n("ui.projects.projects_page.the_server_refused_them"))}));return}be(n("ui.projects.projects_page.project_label_created",{label:String(J)}))}})]}):t.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[t.jsx(Fs,{title:n("ui.projects.projects_page.projects"),icon:Us}),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(Kt,{variant:"warning",children:gr[o]??gr.unknown})]})};export{Jl as ProjectsPage};
|