@harnspec/ui 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/bin/harnspec-ui.js +46 -29
  2. package/dist/assets/{ChatSettingsPage-JPXu3eH0.js → ChatSettingsPage-CHSjd3vp.js} +1 -1
  3. package/dist/assets/{ContextPage-BLFL7v_u.js → ContextPage-BaNHyJAS.js} +1 -1
  4. package/dist/assets/{DashboardPage-D-pA0AIe.js → DashboardPage-DCb6-5kD.js} +1 -1
  5. package/dist/assets/{DependenciesPage-DjavTkHz.js → DependenciesPage-DmcZ0HId.js} +1 -1
  6. package/dist/assets/{FilesPage-BxxpK9Bt.js → FilesPage-DZzXXnSe.js} +1 -1
  7. package/dist/assets/{SessionDetailPage-iEL9xj4a.js → SessionDetailPage-DpLwCjal.js} +1 -1
  8. package/dist/assets/{SessionsPage-CO68ICYO.js → SessionsPage-BKKyO4A_.js} +1 -1
  9. package/dist/assets/{SpecDetailPage-9MMpkW8X.js → SpecDetailPage-B0cx1uxg.js} +2 -2
  10. package/dist/assets/{SpecsPage-1nVMIoG9.js → SpecsPage-CF_GhEVh.js} +1 -1
  11. package/dist/assets/{StatsPage-BvmDcqy8.js → StatsPage-CHongCio.js} +1 -1
  12. package/dist/assets/{_baseUniq-BRyOJSQv.js → _baseUniq-BWXYSgg3.js} +1 -1
  13. package/dist/assets/{arc-ljNi3wsf.js → arc-DVUWV1Ux.js} +1 -1
  14. package/dist/assets/{architectureDiagram-VXUJARFQ-CAly0kzY.js → architectureDiagram-VXUJARFQ-DtTMloLc.js} +1 -1
  15. package/dist/assets/{blockDiagram-VD42YOAC-BOl04R0o.js → blockDiagram-VD42YOAC-5FgtpUfA.js} +1 -1
  16. package/dist/assets/{c4Diagram-YG6GDRKO-S5hXNTsJ.js → c4Diagram-YG6GDRKO-DL2TZvVA.js} +1 -1
  17. package/dist/assets/channel-DRaxx9t9.js +1 -0
  18. package/dist/assets/{chunk-4BX2VUAB-iNaFpgQz.js → chunk-4BX2VUAB-DuxW4ARi.js} +1 -1
  19. package/dist/assets/{chunk-55IACEB6-DqKEYEHN.js → chunk-55IACEB6-jI95g37A.js} +1 -1
  20. package/dist/assets/{chunk-B4BG7PRW-z9_0Jmwe.js → chunk-B4BG7PRW-DjnYS36d.js} +1 -1
  21. package/dist/assets/{chunk-DI55MBZ5-BX1YqnSd.js → chunk-DI55MBZ5-BKKp8oyH.js} +1 -1
  22. package/dist/assets/{chunk-FMBD7UC4-CUWgtpIs.js → chunk-FMBD7UC4-Kf-ovOBd.js} +1 -1
  23. package/dist/assets/{chunk-QN33PNHL-kfBxkNBp.js → chunk-QN33PNHL-Ct8TKBeY.js} +1 -1
  24. package/dist/assets/{chunk-QZHKN3VN-N9ia6yy2.js → chunk-QZHKN3VN-BmSaNL6k.js} +1 -1
  25. package/dist/assets/{chunk-TZMSLE5B-sKnpnnNJ.js → chunk-TZMSLE5B-DQvOFmy4.js} +1 -1
  26. package/dist/assets/classDiagram-2ON5EDUG-MuAiNNYp.js +1 -0
  27. package/dist/assets/classDiagram-v2-WZHVMYZB-MuAiNNYp.js +1 -0
  28. package/dist/assets/clone-C-DQbIm8.js +1 -0
  29. package/dist/assets/{code-block-37QAKDTI-DeQWV7FO.js → code-block-37QAKDTI-C5riIxE5.js} +1 -1
  30. package/dist/assets/{cose-bilkent-S5V4N54A-gY03429f.js → cose-bilkent-S5V4N54A-DhwtA41M.js} +1 -1
  31. package/dist/assets/{dagre-6UL2VRFP-DSANw7dB.js → dagre-6UL2VRFP-B4ns4hkv.js} +1 -1
  32. package/dist/assets/{diagram-PSM6KHXK-ButP3OXt.js → diagram-PSM6KHXK-C6vBYdLz.js} +1 -1
  33. package/dist/assets/{diagram-QEK2KX5R-B_kcqC9w.js → diagram-QEK2KX5R-D5hNzEvu.js} +1 -1
  34. package/dist/assets/{diagram-S2PKOQOG-CEZf1YN1.js → diagram-S2PKOQOG-B7hU4Vir.js} +1 -1
  35. package/dist/assets/{erDiagram-Q2GNP2WA-2_Q02Cxk.js → erDiagram-Q2GNP2WA-GT38PoiU.js} +1 -1
  36. package/dist/assets/{flowDiagram-NV44I4VS-zHYqmkyx.js → flowDiagram-NV44I4VS-CG1t4tHV.js} +1 -1
  37. package/dist/assets/{funnel-x-BS_Cfod-.js → funnel-x-DVbrqcHk.js} +1 -1
  38. package/dist/assets/{ganttDiagram-JELNMOA3-6Yspdlny.js → ganttDiagram-JELNMOA3-BXKmb-ii.js} +1 -1
  39. package/dist/assets/{gitGraphDiagram-NY62KEGX-B9FE0mj2.js → gitGraphDiagram-NY62KEGX-AzgnB9fT.js} +1 -1
  40. package/dist/assets/{graph-Dj86lVww.js → graph-dOzOTENu.js} +1 -1
  41. package/dist/assets/{index-Bo42UlS3.js → index-BlyOVhDj.js} +6 -6
  42. package/dist/assets/{info-CjwfpSMh.js → info-Cl-KzKzC.js} +1 -1
  43. package/dist/assets/{infoDiagram-WHAUD3N6-BGRk5inn.js → infoDiagram-WHAUD3N6-D0wkBIMn.js} +1 -1
  44. package/dist/assets/{journeyDiagram-XKPGCS4Q-DkLUAT8H.js → journeyDiagram-XKPGCS4Q-Cmxvw-CF.js} +1 -1
  45. package/dist/assets/{kanban-definition-3W4ZIXB7-Cz5Z2HI7.js → kanban-definition-3W4ZIXB7-YdVwldix.js} +1 -1
  46. package/dist/assets/{layout-CBJU43bb.js → layout--LdX6GN6.js} +1 -1
  47. package/dist/assets/{linear-DEceC7GR.js → linear-CcZ9lo23.js} +1 -1
  48. package/dist/assets/{min-C3REIl55.js → min-C_YM2Fvy.js} +1 -1
  49. package/dist/assets/{mindmap-definition-VGOIOE7T-DK-dKLTa.js → mindmap-definition-VGOIOE7T-Bo3LAno7.js} +1 -1
  50. package/dist/assets/{page-transition-BKC5kVS6.js → page-transition-DY_O2TfZ.js} +1 -1
  51. package/dist/assets/{pieDiagram-ADFJNKIX--hXf44AA.js → pieDiagram-ADFJNKIX-TY170q2q.js} +1 -1
  52. package/dist/assets/{quadrantDiagram-AYHSOK5B-BP4dBgbK.js → quadrantDiagram-AYHSOK5B-CaGT9oCS.js} +1 -1
  53. package/dist/assets/{refresh-ccw-CfzFVZ57.js → refresh-ccw-DZO2C09G.js} +1 -1
  54. package/dist/assets/{requirementDiagram-UZGBJVZJ-BjJP3Slm.js → requirementDiagram-UZGBJVZJ-cjPEHOn1.js} +1 -1
  55. package/dist/assets/{sankeyDiagram-TZEHDZUN-DSt3qjc-.js → sankeyDiagram-TZEHDZUN-C1jZ6BzB.js} +1 -1
  56. package/dist/assets/{sequenceDiagram-WL72ISMW-CLo7P2AR.js → sequenceDiagram-WL72ISMW-CfbBeFLR.js} +1 -1
  57. package/dist/assets/{session-mode-badge-BQaNgsJN.js → session-mode-badge-BAcHdIhX.js} +1 -1
  58. package/dist/assets/{stat-card-CZ-HGUBa.js → stat-card-BEjjOCD2.js} +1 -1
  59. package/dist/assets/{stateDiagram-FKZM4ZOC-D5NKNKls.js → stateDiagram-FKZM4ZOC-BHdZJa9R.js} +1 -1
  60. package/dist/assets/stateDiagram-v2-4FDKWEC3-CnXnQZrS.js +1 -0
  61. package/dist/assets/{table-of-contents-BiPY4Kr6.js → table-of-contents-Cnkk8UZa.js} +1 -1
  62. package/dist/assets/{time-B8z8CeFv.js → time-yYkNCeI6.js} +1 -1
  63. package/dist/assets/{timeline-definition-IT6M3QCI-BJI5Adg7.js → timeline-definition-IT6M3QCI-DbB6dLD9.js} +1 -1
  64. package/dist/assets/{treemap-KMMF4GRG-DzpCHjjP.js → treemap-KMMF4GRG-Cm_v04dc.js} +1 -1
  65. package/dist/assets/{trending-up-COWs9Nc7.js → trending-up-C8H38O_j.js} +1 -1
  66. package/dist/assets/{validation-badge-IPkKaNb8.js → validation-badge-Bg0rq4Tp.js} +1 -1
  67. package/dist/assets/{xychartDiagram-PRI3JC2R-CFAKvOPr.js → xychartDiagram-PRI3JC2R-DCoq2bZ7.js} +1 -1
  68. package/dist/index.html +1 -1
  69. package/package.json +4 -4
  70. package/dist/assets/channel-DTtYVPxU.js +0 -1
  71. package/dist/assets/classDiagram-2ON5EDUG-DEiSx8NZ.js +0 -1
  72. package/dist/assets/classDiagram-v2-WZHVMYZB-DEiSx8NZ.js +0 -1
  73. package/dist/assets/clone-B-FuuJTp.js +0 -1
  74. package/dist/assets/stateDiagram-v2-4FDKWEC3-oN7y0aok.js +0 -1
@@ -1,4 +1,4 @@
1
- import{h as $,cf as ke,u as Ce,bg as Le,bh as De,r,c7 as g,cg as te,ch as Ee,ci as Te,cj as $e,ck as Me,bv as Pe,cl as ze,cm as Ie,j as e,bs as Ae,cn as ae,c8 as ne,a as l,bq as Re,B as b,f as x,bu as re,co as _e,cp as Oe,cq as Fe,bF as Ue,bG as ie,bH as qe,bn as oe,cr as le,bV as ce,cs as de,ct as Je,cu as Ve,cv as me,cw as Be,cx as ue,cy as He}from"./index-Bo42UlS3.js";import{P as We}from"./page-transition-BKC5kVS6.js";import{S as Qe}from"./session-mode-badge-BQaNgsJN.js";const Ze=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ge=$("activity",Ze);const Xe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],xe=$("file-code",Xe);const Ye=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Ke=$("panel-left",Ye);function es(){return ke()}const T=new Set(["pending","running","paused"]);function rs(){const{t:n}=Ce("common"),{sessionId:d,projectId:S}=Le(),{currentProject:p,loading:w}=De(),M=S??(p==null?void 0:p.id),P=M?`/projects/${M}`:"/projects",j=!S||(p==null?void 0:p.id)===S,[a,z]=r.useState(null),[k,I]=r.useState([]),[A,R]=r.useState([]),[pe,_]=r.useState(!0),[C,O]=r.useState(!0),[F,U]=r.useState(null),[q,he]=r.useState(null),[fe,J]=r.useState(new Set),[h,V]=r.useState(""),[y,ge]=r.useState("messages"),[B,H]=r.useState(!1),[ve,be]=r.useState(()=>Date.now()),L=r.useRef(null),{setMobileOpen:we}=es(),c=r.useCallback(async(s=!1)=>{if(!(!d||!j||w)){s||_(!0);try{const t=await g.getSession(d);z(t),U(null)}catch(t){U(t instanceof Error?t.message:n("sessions.errors.load"))}finally{s||_(!1)}}},[w,j,d,n]),f=r.useCallback(async(s=!1)=>{if(!(!d||!j||w)){s||O(!0);try{const t=await g.getSessionLogs(d);I(t);const i=t.reduce((o,D)=>te(o,Ee(D)),[]);R(Te(i))}finally{s||O(!1)}}},[w,j,d]);r.useEffect(()=>{c(),f()},[c,f]),r.useEffect(()=>{if(!a||!T.has(a.status))return;const t=window.location.origin.replace(/^http/,"ws")+`/api/sessions/${a.id}/stream`,i=new WebSocket(t);return i.onmessage=o=>{try{const D=JSON.parse(o.data),u=$e(D);u&&(R(E=>te(E,u)),u.type==="log"&&I(E=>[...E,{id:Date.now(),timestamp:u.timestamp,level:u.level,message:u.message}]),u.type==="complete"&&(c(!0),f(!0)))}catch{}},()=>i.close()},[a,c,f]),r.useEffect(()=>{if(!a||!T.has(a.status))return;const s=window.setInterval(()=>{c(!0),f(!0)},2e3);return()=>window.clearInterval(s)},[f,c,a]),r.useEffect(()=>{if(!a||!T.has(a.status))return;const s=window.setInterval(()=>{be(Date.now())},1e3);return()=>window.clearInterval(s)},[a]),r.useEffect(()=>{const s=L.current;if(!s)return;const t=s.querySelector("[data-radix-scroll-area-viewport]");t?t.scrollTop=t.scrollHeight:s.scrollTop=s.scrollHeight},[k]);const m=Me(a),N=y==="verbose",v=r.useMemo(()=>{const s=h.trim().toLowerCase();return k.filter(t=>!(!N&&t.message.includes("Session still running")||s&&!`${t.level} ${t.message}`.toLowerCase().includes(s)))},[k,h,N]),W=r.useMemo(()=>{if(!m)return[];const s=h.trim().toLowerCase();return A.filter(t=>y==="messages"&&t.type==="log"||t.type==="log"&&!N&&t.message.includes("Session still running")?!1:s?t.type==="acp_message"||t.type==="acp_thought"?t.content.toLowerCase().includes(s):t.type==="acp_tool_call"?`${t.tool} ${JSON.stringify(t.args)} ${JSON.stringify(t.result??"")}`.toLowerCase().includes(s):t.type==="acp_plan"?t.entries.some(i=>i.title.toLowerCase().includes(s)):!1:!0)},[m,h,A,N,y]),Q=a?Pe(a,ve):null,Z=a?ze(a.tokenCount):null,G=a?Ie(a.tokenCount):null,je=s=>s.length>12?s.slice(0,8):s,X=async()=>{a&&(await g.stopSession(a.id),await c())},ye=async()=>{a&&(await g.pauseSession(a.id),await c())},Ne=async()=>{a&&(await g.resumeSession(a.id),await c())},Y=()=>m?JSON.stringify(W,null,2):v.map(s=>`[${s.timestamp}] ${s.level.toUpperCase()} ${s.message}`).join(`
1
+ import{h as $,cf as ke,u as Ce,bg as Le,bh as De,r,c7 as g,cg as te,ch as Ee,ci as Te,cj as $e,ck as Me,bv as Pe,cl as ze,cm as Ie,j as e,bs as Ae,cn as ae,c8 as ne,a as l,bq as Re,B as b,f as x,bu as re,co as _e,cp as Oe,cq as Fe,bF as Ue,bG as ie,bH as qe,bn as oe,cr as le,bV as ce,cs as de,ct as Je,cu as Ve,cv as me,cw as Be,cx as ue,cy as He}from"./index-BlyOVhDj.js";import{P as We}from"./page-transition-DY_O2TfZ.js";import{S as Qe}from"./session-mode-badge-BAcHdIhX.js";const Ze=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ge=$("activity",Ze);const Xe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],xe=$("file-code",Xe);const Ye=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Ke=$("panel-left",Ye);function es(){return ke()}const T=new Set(["pending","running","paused"]);function rs(){const{t:n}=Ce("common"),{sessionId:d,projectId:S}=Le(),{currentProject:p,loading:w}=De(),M=S??(p==null?void 0:p.id),P=M?`/projects/${M}`:"/projects",j=!S||(p==null?void 0:p.id)===S,[a,z]=r.useState(null),[k,I]=r.useState([]),[A,R]=r.useState([]),[pe,_]=r.useState(!0),[C,O]=r.useState(!0),[F,U]=r.useState(null),[q,he]=r.useState(null),[fe,J]=r.useState(new Set),[h,V]=r.useState(""),[y,ge]=r.useState("messages"),[B,H]=r.useState(!1),[ve,be]=r.useState(()=>Date.now()),L=r.useRef(null),{setMobileOpen:we}=es(),c=r.useCallback(async(s=!1)=>{if(!(!d||!j||w)){s||_(!0);try{const t=await g.getSession(d);z(t),U(null)}catch(t){U(t instanceof Error?t.message:n("sessions.errors.load"))}finally{s||_(!1)}}},[w,j,d,n]),f=r.useCallback(async(s=!1)=>{if(!(!d||!j||w)){s||O(!0);try{const t=await g.getSessionLogs(d);I(t);const i=t.reduce((o,D)=>te(o,Ee(D)),[]);R(Te(i))}finally{s||O(!1)}}},[w,j,d]);r.useEffect(()=>{c(),f()},[c,f]),r.useEffect(()=>{if(!a||!T.has(a.status))return;const t=window.location.origin.replace(/^http/,"ws")+`/api/sessions/${a.id}/stream`,i=new WebSocket(t);return i.onmessage=o=>{try{const D=JSON.parse(o.data),u=$e(D);u&&(R(E=>te(E,u)),u.type==="log"&&I(E=>[...E,{id:Date.now(),timestamp:u.timestamp,level:u.level,message:u.message}]),u.type==="complete"&&(c(!0),f(!0)))}catch{}},()=>i.close()},[a,c,f]),r.useEffect(()=>{if(!a||!T.has(a.status))return;const s=window.setInterval(()=>{c(!0),f(!0)},2e3);return()=>window.clearInterval(s)},[f,c,a]),r.useEffect(()=>{if(!a||!T.has(a.status))return;const s=window.setInterval(()=>{be(Date.now())},1e3);return()=>window.clearInterval(s)},[a]),r.useEffect(()=>{const s=L.current;if(!s)return;const t=s.querySelector("[data-radix-scroll-area-viewport]");t?t.scrollTop=t.scrollHeight:s.scrollTop=s.scrollHeight},[k]);const m=Me(a),N=y==="verbose",v=r.useMemo(()=>{const s=h.trim().toLowerCase();return k.filter(t=>!(!N&&t.message.includes("Session still running")||s&&!`${t.level} ${t.message}`.toLowerCase().includes(s)))},[k,h,N]),W=r.useMemo(()=>{if(!m)return[];const s=h.trim().toLowerCase();return A.filter(t=>y==="messages"&&t.type==="log"||t.type==="log"&&!N&&t.message.includes("Session still running")?!1:s?t.type==="acp_message"||t.type==="acp_thought"?t.content.toLowerCase().includes(s):t.type==="acp_tool_call"?`${t.tool} ${JSON.stringify(t.args)} ${JSON.stringify(t.result??"")}`.toLowerCase().includes(s):t.type==="acp_plan"?t.entries.some(i=>i.title.toLowerCase().includes(s)):!1:!0)},[m,h,A,N,y]),Q=a?Pe(a,ve):null,Z=a?ze(a.tokenCount):null,G=a?Ie(a.tokenCount):null,je=s=>s.length>12?s.slice(0,8):s,X=async()=>{a&&(await g.stopSession(a.id),await c())},ye=async()=>{a&&(await g.pauseSession(a.id),await c())},Ne=async()=>{a&&(await g.resumeSession(a.id),await c())},Y=()=>m?JSON.stringify(W,null,2):v.map(s=>`[${s.timestamp}] ${s.level.toUpperCase()} ${s.message}`).join(`
2
2
  `),K=()=>{const s=Y(),t=new Blob([s],{type:m?"application/json;charset=utf-8":"text/plain;charset=utf-8"}),i=URL.createObjectURL(t),o=document.createElement("a");o.href=i,o.download=`session-${d??n("sessions.export.fallbackName")}.${m?"json":"txt"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(i)},ee=5e5,se=async()=>{const s=Y(),t=s.length>ee?s.slice(0,ee)+`
3
3
 
4
4
  … (truncated)`:s;await navigator.clipboard.writeText(t),H(!0),setTimeout(()=>H(!1),2e3)},Se=async(s,t)=>{if(a){J(i=>{const o=new Set(i);return o.add(s),o});try{const i=await g.respondToSessionPermission(a.id,s,t);z(i)}catch(i){he(i instanceof Error?i.message:n("sessions.errors.load"))}finally{J(i=>{const o=new Set(i);return o.delete(s),o})}}};return pe?e.jsx("div",{className:"flex-1 min-w-0 py-10 text-center text-sm text-muted-foreground",children:n("actions.loading")}):F||!a?e.jsx("div",{className:"flex-1 min-w-0 flex items-center justify-center",children:e.jsx(Ae,{icon:ae,title:n("sessionDetail.state.notFoundTitle"),description:F||n("sessionDetail.state.notFoundDescription"),tone:"error",actions:e.jsx(ne,{to:`${P}/sessions`,className:"inline-flex",children:e.jsx(l,{variant:"outline",size:"sm",className:"gap-2",children:n("sessions.actions.back")})})})}):e.jsx(We,{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"h-[calc(100dvh-3.5rem)] flex flex-col",children:[e.jsx("header",{className:"shrink-0 border-b bg-card",children:e.jsxs("div",{className:"px-4 sm:px-6 py-2 sm:py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 sm:mb-2",children:[e.jsx(l,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 lg:hidden shrink-0",onClick:()=>we(!0),children:e.jsx(Ke,{className:"h-4 w-4"})}),e.jsx(Re,{runnerId:a.runner,size:24}),e.jsx("h1",{className:"text-lg sm:text-xl font-bold tracking-tight",children:n("sessionDetail.title",{id:je(a.id)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsxs(b,{variant:"outline",className:x("flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium",re[a.status].className),children:[(()=>{const s=re[a.status].icon;return e.jsx(s,{className:"h-3.5 w-3.5"})})(),n(`sessions.status.${a.status}`)]}),e.jsx(Qe,{mode:a.mode}),e.jsxs(b,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(Ge,{className:"h-3.5 w-3.5"}),n(m?"sessions.labels.protocolAcp":"sessions.labels.protocolCli")]}),Q&&e.jsxs(b,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),Q]}),Z&&e.jsxs(b,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(Oe,{className:"h-3.5 w-3.5"}),Z]}),G!=null&&e.jsxs(b,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),n("sessions.labels.costApprox",{value:G.toFixed(2)})]})]}),a.specIds&&a.specIds.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground mt-1.5",children:[e.jsxs("span",{children:[n("sessions.labels.specs"),":"]}),a.specIds.map(s=>e.jsx(ne,{to:`${P}/specs/${s}`,className:"hover:text-primary hover:underline font-medium",children:s},s))]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.status==="running"&&e.jsxs(e.Fragment,{children:[e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{ye()},className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.pause")]}),e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{X()},className:"h-8 rounded-full border px-3 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.stop")]})]}),a.status==="paused"&&e.jsxs(e.Fragment,{children:[e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{Ne()},className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(qe,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.resume")]}),e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{X()},className:"h-8 rounded-full border px-3 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.stop")]})]}),!1]})]})}),q&&e.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive font-medium flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),q]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden w-full",children:m?e.jsxs(Je,{value:y,onValueChange:s=>ge(s),className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"border-b px-4 py-2 flex items-center justify-between bg-muted/20 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(oe,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx("input",{value:h,onChange:s=>V(s.target.value),placeholder:n("sessionDetail.filters.search"),className:"h-8 w-full rounded-md border border-border bg-background pl-8 pr-3 text-xs focus:outline-none focus:ring-1 focus:ring-ring"})]})}),e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsxs(Ve,{className:"h-8 bg-muted/50 p-0.5",children:[e.jsx(me,{value:"messages",className:"text-xs h-7 px-3 data-[state=active]:bg-background data-[state=active]:shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:n("sessionDetail.displayMode.messages")})]})}),e.jsx(me,{value:"verbose",className:"text-xs h-7 px-3 data-[state=active]:bg-background data-[state=active]:shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:n("sessionDetail.displayMode.verbose")})]})})]}),e.jsx("div",{className:"h-4 w-px bg-border mx-1"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:K,title:n("sessionDetail.actions.download"),children:e.jsx(le,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"ghost",className:x("h-8 w-8 p-0",B&&"text-emerald-500"),onClick:()=>{se()},title:n("sessionDetail.actions.copyLogs"),children:e.jsx(ce,{className:"h-4 w-4"})})]})]}),e.jsx(ue,{value:"messages",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden relative",children:e.jsx("div",{className:"absolute inset-0",children:e.jsx(He,{className:"h-full border-0 rounded-none bg-transparent",events:W,loading:C,emptyTitle:n("sessions.emptyLogs"),emptyDescription:n("sessionDetail.logsDescription"),onPermissionResponse:(s,t)=>{Se(s,t)},isPermissionResponding:s=>fe.has(s)})})}),e.jsx(ue,{value:"verbose",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden relative h-full",children:e.jsx(de,{className:"h-full bg-background",ref:L,children:e.jsx("div",{className:"p-4 font-mono text-xs",children:C?e.jsx("div",{className:"text-muted-foreground",children:n("actions.loading")}):v.length===0?e.jsx("div",{className:"text-muted-foreground text-center italic opacity-60 py-8",children:n("sessions.emptyLogs")}):v.map(s=>{const t=s.message.trim().startsWith("{")||s.message.trim().startsWith("[");return e.jsxs("div",{className:"mb-0.5 group hover:bg-muted/30 -mx-4 px-4 py-1 flex gap-3 items-start border-l-2 border-transparent",children:[e.jsxs("span",{className:"text-muted-foreground/40 whitespace-nowrap select-none w-24 shrink-0 text-[10px] pt-0.5 text-right font-light tabular-nums",children:[new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),".",e.jsx("span",{className:"opacity-50",children:new Date(s.timestamp).getMilliseconds().toString().padStart(3,"0")})]}),e.jsx("span",{className:x("uppercase text-[10px] font-bold w-14 shrink-0 pt-0.5 select-none text-center rounded-sm bg-muted/30",s.level==="error"?"text-rose-600 bg-rose-500/10 dark:text-rose-400":s.level==="warn"?"text-amber-600 bg-amber-500/10 dark:text-amber-400":s.level==="info"?"text-sky-600 bg-sky-500/10 dark:text-sky-400":s.level==="debug"?"text-violet-600 bg-violet-500/10 dark:text-violet-400":"text-muted-foreground"),children:s.level}),e.jsx("div",{className:x("flex-1 min-w-0 break-all whitespace-pre-wrap leading-relaxed",t&&"text-emerald-600 dark:text-emerald-400"),children:s.message})]},`${s.id}-${s.timestamp}`)})})})})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"border-b px-4 py-2 flex items-center justify-between bg-muted/20 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(oe,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx("input",{value:h,onChange:s=>V(s.target.value),placeholder:n("sessionDetail.filters.search"),className:"h-8 w-full rounded-md border border-border bg-background pl-8 pr-3 text-xs focus:outline-none focus:ring-1 focus:ring-ring"})]})}),e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm text-muted-foreground mr-2",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx("span",{children:"Verbose Logs"})]}),e.jsx("div",{className:"h-4 w-px bg-border mx-1"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:K,title:n("sessionDetail.actions.download"),children:e.jsx(le,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"ghost",className:x("h-8 w-8 p-0",B&&"text-emerald-500"),onClick:()=>{se()},title:n("sessionDetail.actions.copyLogs"),children:e.jsx(ce,{className:"h-4 w-4"})})]})]}),e.jsx(de,{className:"flex-1 h-full bg-background",ref:L,children:e.jsx("div",{className:"p-4 font-mono text-xs",children:C?e.jsx("div",{className:"text-muted-foreground",children:n("actions.loading")}):v.length===0?e.jsx("div",{className:"text-muted-foreground text-center italic opacity-60 py-8",children:n("sessions.emptyLogs")}):v.map(s=>{const t=s.message.trim().startsWith("{")||s.message.trim().startsWith("[");return e.jsxs("div",{className:"mb-0.5 group hover:bg-muted/30 -mx-4 px-4 py-1 flex gap-3 items-start border-l-2 border-transparent",children:[e.jsxs("span",{className:"text-muted-foreground/40 whitespace-nowrap select-none w-24 shrink-0 text-[10px] pt-0.5 text-right font-light tabular-nums",children:[new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),".",e.jsx("span",{className:"opacity-50",children:new Date(s.timestamp).getMilliseconds().toString().padStart(3,"0")})]}),e.jsx("span",{className:x("uppercase text-[10px] font-bold w-14 shrink-0 pt-0.5 select-none text-center rounded-sm bg-muted/30",s.level==="error"?"text-rose-600 bg-rose-500/10 dark:text-rose-400":s.level==="warn"?"text-amber-600 bg-amber-500/10 dark:text-amber-400":s.level==="info"?"text-sky-600 bg-sky-500/10 dark:text-sky-400":s.level==="debug"?"text-violet-600 bg-violet-500/10 dark:text-violet-400":"text-muted-foreground"),children:s.level}),e.jsx("div",{className:x("flex-1 min-w-0 break-all whitespace-pre-wrap leading-relaxed",t&&"text-emerald-600 dark:text-emerald-400"),children:s.message})]},`${s.id}-${s.timestamp}`)})})})]})})]})})}export{rs as SessionDetailPage};
@@ -1 +1 @@
1
- import{u as U,r as n,j as s,b5 as ys,b6 as Cs,a as u,b7 as ws,b8 as Ss,b9 as Ps,ba as ks,bb as Ds,bc as Fs,bd as Ts,be as Rs,bf as Is,f as W,bg as Ls,bh as zs,bi as Ms,bj as Bs,bk as As,bl as $s,aS as J,C as K,l as ss,bm as Os,aW as Es,bn as Vs,b0 as qs,bo as Qs,aX as z,aY as M,aZ as B,a_ as A,a$ as p,bp as rs,bq as ls,br as Gs,bs as es,bt as Hs,aP as Xs,bu as Zs,bv as _s,bw as Js,bx as Us,by as Ws,bz as Ys,B as as,bA as Ks,bB as se,bC as ee,bD as ae,bE as te,bF as ne,bG as ts,bH as re,bI as le,bJ as ns}from"./index-Bo42UlS3.js";import{P as ie}from"./page-transition-BKC5kVS6.js";import{S as oe}from"./session-mode-badge-BQaNgsJN.js";import{F as ce,a as de}from"./funnel-x-BS_Cfod-.js";import{R as ue}from"./refresh-ccw-CfzFVZ57.js";function me({value:a,onValueChange:t,options:c,placeholder:g,searchPlaceholder:x,emptyText:f}){var N;const{t:i}=U("common"),[j,b]=n.useState(!1);return s.jsxs(ys,{open:j,onOpenChange:b,children:[s.jsx(Cs,{asChild:!0,children:s.jsxs(u,{variant:"outline",role:"combobox","aria-expanded":j,className:"w-full justify-between font-normal",children:[a?((N=c.find(m=>m.value===a))==null?void 0:N.label)??a:g??i("sessions.select.placeholder"),s.jsx(ws,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),s.jsx(Ss,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:s.jsxs(Ps,{children:[s.jsx(ks,{placeholder:x??i("sessions.select.search")}),s.jsxs(Ds,{children:[s.jsx(Fs,{children:f??i("sessions.select.empty")}),s.jsx(Ts,{children:c.map(m=>s.jsxs(Rs,{value:m.label,className:"cursor-pointer",onSelect:()=>{t(m.value),b(!1)},children:[s.jsx(Is,{className:W("mr-2 h-4 w-4",a===m.value?"opacity-100":"opacity-0")}),m.label]},m.value))})]})]})})]})}const v=20;function xe(a){if(a.status==="running"||a.status==="pending")return"active";const t=ns(a.startedAt),g=ns().startOf("day"),x=g.subtract(1,"day"),f=t.startOf("day");return f.isSame(g)?"today":f.isSame(x)?"yesterday":"older"}function he(a){const t={active:[],today:[],yesterday:[],older:[]};return a.forEach(c=>{t[xe(c)].push(c)}),t}function ye(){const{t:a}=U("common"),{projectId:t}=Ls(),{currentProject:c,loading:g}=zs(),x=t??(c==null?void 0:c.id),f=x?`/projects/${x}`:"/projects",i=Ms(x??null),j=Bs(x??null),{stopSession:b,pauseSession:N,resumeSession:m}=As(x??null),d=n.useMemo(()=>i.data??[],[i.data]),P=n.useMemo(()=>j.data??[],[j.data]),T=g||i.isLoading,R=i.error?a("sessions.errors.load"):null,[$]=$s(),[y,O]=n.useState(""),[r,k]=n.useState("all"),[D,is]=n.useState("all"),[F,os]=n.useState("all"),[S,cs]=n.useState(()=>$.get("spec")??"all"),[E,ds]=n.useState("started-desc"),[us,C]=n.useState(v),[ms,V]=n.useState(!1),q=n.useCallback(e=>{O(e),C(v)},[]),Q=n.useCallback(e=>{k(e),C(v)},[]),G=n.useCallback(e=>{is(e),C(v)},[]),H=n.useCallback(e=>{os(e),C(v)},[]),X=n.useCallback(e=>{cs(e),C(v)},[]),xs=n.useCallback(e=>{ds(e),C(v)},[]),Z=n.useCallback(async()=>{await i.refetch(),await j.refetch()},[i,j]),hs=n.useMemo(()=>{const e=d.map(o=>o.status).filter(Boolean);return Array.from(new Set(e))},[d]),ps=n.useMemo(()=>{const e=d.map(o=>o.runner).filter(Boolean);return Array.from(new Set(e))},[d]),gs=n.useMemo(()=>{const e=d.map(o=>o.mode).filter(Boolean);return Array.from(new Set(e))},[d]),js=n.useMemo(()=>P.map(e=>({id:e.specName,label:e.specNumber?`#${e.specNumber} ${e.title??e.specName}`:e.title??e.specName})).sort((e,o)=>e.label.localeCompare(o.label)),[P]),I=n.useMemo(()=>{const o=[...d.filter(l=>{var h,L,_;if(y){const w=y.toLowerCase();if(!(l.id.toLowerCase().includes(w)||(((h=l.specIds)==null?void 0:h.some(vs=>vs.toLowerCase().includes(w)))??!1)||l.runner.toLowerCase().includes(w)||(((L=l.prompt)==null?void 0:L.toLowerCase().includes(w))??!1)))return!1}return!(r!=="all"&&l.status!==r||D!=="all"&&l.runner!==D||F!=="all"&&l.mode!==F||S!=="all"&&(!((_=l.specIds)!=null&&_.length)||!l.specIds.some(w=>w===S||w.includes(S))))})];switch(E){case"started-asc":o.sort((l,h)=>new Date(l.startedAt).getTime()-new Date(h.startedAt).getTime());break;case"duration-desc":o.sort((l,h)=>{const L=l.durationMs??0;return(h.durationMs??0)-L});break;case"status":o.sort((l,h)=>l.status.localeCompare(h.status));break;default:o.sort((l,h)=>new Date(h.startedAt).getTime()-new Date(l.startedAt).getTime());break}return o},[F,y,d,E,S,r,D]),Y=I.slice(0,us),fs=n.useCallback(async e=>{await b(e)},[b]),bs=n.useCallback(async e=>{await N(e)},[N]),Ns=n.useCallback(async e=>{await m(e)},[m]);return T?s.jsx(J,{children:s.jsx(K,{children:s.jsx(ss,{className:"py-10 text-center text-sm text-muted-foreground",children:a("actions.loading")})})}):R?s.jsx(J,{children:s.jsx(K,{children:s.jsxs(ss,{className:"py-10 text-center space-y-3",children:[s.jsx("div",{className:"text-lg font-semibold",children:a("sessionsPage.state.errorTitle")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:R}),s.jsx(u,{variant:"secondary",size:"sm",onClick:Z,className:"mt-2",children:a("actions.retry")})]})})}):s.jsxs(ie,{className:W("flex-1 min-w-0"),children:[s.jsxs(J,{className:"h-[calc(100dvh-3.5rem)]",contentClassName:"flex h-full flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-4 sticky top-0 bg-background mt-0 py-2 z-10",children:[s.jsx(Os,{title:a("sessionsPage.title"),description:a("sessionsPage.description"),actions:s.jsxs(u,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>V(!0),children:[s.jsx(Es,{className:"h-4 w-4"}),a("sessions.actions.new")]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Vs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),s.jsx(qs,{value:y,onChange:e=>q(e.target.value),placeholder:a("sessionsPage.filters.search"),className:"w-full pl-10 pr-4 py-2"})]}),s.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(Qs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:a("specsNavSidebar.filtersLabel")})]}),s.jsxs(z,{value:r,onValueChange:Q,children:[s.jsx(M,{className:"w-[140px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.filters.status")})}),s.jsxs(A,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.status")}),hs.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:a(`sessions.status.${e}`)},e))]})]}),s.jsxs(z,{value:D,onValueChange:G,children:[s.jsx(M,{className:"w-[140px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.filters.runner")})}),s.jsxs(A,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.runner")}),ps.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ls,{runnerId:e,size:16}),rs(e,a)]})},e))]})]}),s.jsxs(z,{value:F,onValueChange:H,children:[s.jsx(M,{className:"w-[140px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.filters.mode")})}),s.jsxs(A,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.mode")}),gs.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:a(`sessions.modes.${e}`)},e))]})]}),s.jsx("div",{className:"w-[180px]",children:s.jsx(me,{value:S,onValueChange:X,options:[{value:"all",label:a("sessionsPage.filters.spec")},...js.map(e=>({value:e.id,label:e.label}))],placeholder:a("sessionsPage.filters.spec"),searchPlaceholder:a("sessions.select.search"),emptyText:a("sessions.select.empty")})}),s.jsxs(z,{value:E,onValueChange:e=>xs(e),children:[s.jsx(M,{className:"w-[160px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.sort.startedDesc")})}),s.jsxs(A,{children:[s.jsx(p,{value:"started-desc",className:"cursor-pointer",children:a("sessionsPage.sort.startedDesc")}),s.jsx(p,{value:"started-asc",className:"cursor-pointer",children:a("sessionsPage.sort.startedAsc")}),s.jsx(p,{value:"duration-desc",className:"cursor-pointer",children:a("sessionsPage.sort.durationDesc")}),s.jsx(p,{value:"status",className:"cursor-pointer",children:a("sessionsPage.sort.status")})]})]}),(y||r!=="all"||D!=="all"||F!=="all"||S!=="all")&&s.jsxs(u,{onClick:()=>{q(""),Q("all"),G("all"),H("all"),X("all")},variant:"ghost",size:"sm",className:"h-9 gap-1",children:[s.jsx(Gs,{className:"w-4 h-4"}),a("specsNavSidebar.clearFilters")]}),s.jsx("span",{className:"text-sm text-muted-foreground",children:a("specsPage.filters.filteredCount",{filtered:I.length,total:d.length})})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0",children:d.length===0?s.jsx(es,{icon:ce,title:a("sessionsPage.state.emptyTitle"),description:a("sessionsPage.state.emptyDescription"),actions:s.jsx(u,{variant:"secondary",size:"sm",onClick:()=>V(!0),children:a("sessions.actions.new")})}):I.length===0?s.jsx(es,{icon:de,title:a("sessionsPage.state.noResultsTitle"),description:a("sessionsPage.state.noResultsDescription"),actions:s.jsxs("div",{className:"flex gap-2 flex-wrap justify-center",children:[s.jsx(u,{variant:"outline",size:"sm",onClick:()=>{q(""),Q("all"),G("all"),H("all"),X("all")},children:a("specsNavSidebar.clearFilters")}),s.jsxs(u,{variant:"secondary",size:"sm",onClick:Z,children:[s.jsx(ue,{className:"h-4 w-4 mr-2"}),a("sessionsPage.buttons.refresh")]})]})}):s.jsxs("div",{className:"space-y-6",children:[["active","today","yesterday","older"].map(e=>{const o=he(Y)[e];return o.length===0?null:s.jsxs("section",{className:"space-y-2",children:[s.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[a(`sessionsPage.groups.${e}`)," (",o.length,")"]}),s.jsx("div",{className:"space-y-2",children:o.map(l=>s.jsx(pe,{session:l,basePath:f,onStop:fs,onPause:bs,onResume:Ns},l.id))})]},e)}),Y.length<I.length&&s.jsx("div",{className:"flex justify-center",children:s.jsx(u,{variant:"outline",size:"sm",onClick:()=>C(e=>e+v),children:a("sessionsPage.buttons.loadMore")})})]})})]}),s.jsx(Hs,{open:ms,onOpenChange:V,projectPath:c==null?void 0:c.path,onCreated:()=>{Z()}})]})}const pe=n.memo(function({session:t,basePath:c,onStop:g,onPause:x,onResume:f}){const{t:i,i18n:j}=U("common"),b=Xs(),N=Zs[t.status],m=N.icon,d=_s(t),[P,T]=n.useState(!1),R=t.prompt||t.id.slice(0,8),$=t.status==="running"||t.status==="paused",y=r=>{r.target.closest("button, a")||b(`${c}/sessions/${t.id}`)},O=r=>{r.stopPropagation(),T(k=>!k)};return s.jsx("div",{className:"block border rounded-lg hover:bg-secondary/50 transition-colors bg-background cursor-pointer",onClick:y,children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-8 h-full invisible flex items-center text-muted-foreground"}),s.jsxs("div",{className:"flex-1 p-4 pl-0",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-2",children:[s.jsxs("div",{className:"flex items-start gap-2 min-w-0 pr-4",children:[s.jsx(Js,{children:s.jsxs(Us,{children:[s.jsx(Ws,{asChild:!0,children:s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:s.jsx(ls,{runnerId:t.runner,size:24})})}),s.jsx(Ys,{children:rs(t.runner,i)})]})}),s.jsx("div",{children:s.jsx("h3",{className:"font-medium line-clamp-2 leading-relaxed",children:R})})]}),s.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.jsxs(as,{variant:"outline",className:W("flex items-center gap-1.5 w-fit border-transparent h-6 px-2 py-0.5 text-xs font-medium",N.className),children:[s.jsx(m,{className:"h-3.5 w-3.5"}),i(`sessions.status.${t.status}`)]}),s.jsx(oe,{mode:t.mode})]})]}),s.jsx("div",{className:"mb-3 flex items-center gap-2 flex-wrap",children:!t.specIds||t.specIds.length===0?s.jsx("span",{className:"text-xs text-muted-foreground italic",children:i("sessionsPage.labels.noSpecs","No specs")}):t.specIds.map(r=>s.jsxs(as,{variant:"secondary",className:"flex items-center gap-1 text-xs hover:bg-secondary/80 cursor-pointer",onClick:k=>{k.stopPropagation(),b(`${c}/specs/${r}`)},children:[s.jsx(Ks,{className:"h-3 w-3"}),r]},r))}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground min-w-0",children:[t.startedAt&&s.jsx("span",{className:"shrink-0 text-xs",children:se(t.startedAt,j.language)}),d?s.jsx(ee,{duration:d}):null,s.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:O,children:[P?s.jsx(ae,{className:"h-3 w-3 mr-1"}):s.jsx(te,{className:"h-3 w-3 mr-1"}),"Logs"]})]}),$&&s.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0",children:[t.status==="running"&&s.jsxs(s.Fragment,{children:[s.jsxs(u,{size:"sm",variant:"secondary",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),x(t.id)},children:[s.jsx(ne,{className:"h-3 w-3"}),i("sessions.actions.pause")]}),s.jsxs(u,{size:"sm",variant:"destructive",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),g(t.id)},children:[s.jsx(ts,{className:"h-3 w-3"}),i("sessions.actions.stop")]})]}),t.status==="paused"&&s.jsxs(s.Fragment,{children:[s.jsxs(u,{size:"sm",variant:"secondary",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),f(t.id)},children:[s.jsx(re,{className:"h-3 w-3"}),i("sessions.actions.resume")]}),s.jsxs(u,{size:"sm",variant:"destructive",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),g(t.id)},children:[s.jsx(ts,{className:"h-3 w-3"}),i("sessions.actions.stop")]})]})]})]}),P&&s.jsx("div",{className:"mt-4 border-t pt-4",onClick:r=>r.stopPropagation(),children:s.jsx("div",{className:"h-[300px] overflow-hidden rounded-md border",children:s.jsx(le,{sessionId:t.id,onBack:()=>T(!1)})})})]})]})})});export{ye as SessionsPage};
1
+ import{u as U,r as n,j as s,b5 as ys,b6 as Cs,a as u,b7 as ws,b8 as Ss,b9 as Ps,ba as ks,bb as Ds,bc as Fs,bd as Ts,be as Rs,bf as Is,f as W,bg as Ls,bh as zs,bi as Ms,bj as Bs,bk as As,bl as $s,aS as J,C as K,l as ss,bm as Os,aW as Es,bn as Vs,b0 as qs,bo as Qs,aX as z,aY as M,aZ as B,a_ as A,a$ as p,bp as rs,bq as ls,br as Gs,bs as es,bt as Hs,aP as Xs,bu as Zs,bv as _s,bw as Js,bx as Us,by as Ws,bz as Ys,B as as,bA as Ks,bB as se,bC as ee,bD as ae,bE as te,bF as ne,bG as ts,bH as re,bI as le,bJ as ns}from"./index-BlyOVhDj.js";import{P as ie}from"./page-transition-DY_O2TfZ.js";import{S as oe}from"./session-mode-badge-BAcHdIhX.js";import{F as ce,a as de}from"./funnel-x-DVbrqcHk.js";import{R as ue}from"./refresh-ccw-DZO2C09G.js";function me({value:a,onValueChange:t,options:c,placeholder:g,searchPlaceholder:x,emptyText:f}){var N;const{t:i}=U("common"),[j,b]=n.useState(!1);return s.jsxs(ys,{open:j,onOpenChange:b,children:[s.jsx(Cs,{asChild:!0,children:s.jsxs(u,{variant:"outline",role:"combobox","aria-expanded":j,className:"w-full justify-between font-normal",children:[a?((N=c.find(m=>m.value===a))==null?void 0:N.label)??a:g??i("sessions.select.placeholder"),s.jsx(ws,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),s.jsx(Ss,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:s.jsxs(Ps,{children:[s.jsx(ks,{placeholder:x??i("sessions.select.search")}),s.jsxs(Ds,{children:[s.jsx(Fs,{children:f??i("sessions.select.empty")}),s.jsx(Ts,{children:c.map(m=>s.jsxs(Rs,{value:m.label,className:"cursor-pointer",onSelect:()=>{t(m.value),b(!1)},children:[s.jsx(Is,{className:W("mr-2 h-4 w-4",a===m.value?"opacity-100":"opacity-0")}),m.label]},m.value))})]})]})})]})}const v=20;function xe(a){if(a.status==="running"||a.status==="pending")return"active";const t=ns(a.startedAt),g=ns().startOf("day"),x=g.subtract(1,"day"),f=t.startOf("day");return f.isSame(g)?"today":f.isSame(x)?"yesterday":"older"}function he(a){const t={active:[],today:[],yesterday:[],older:[]};return a.forEach(c=>{t[xe(c)].push(c)}),t}function ye(){const{t:a}=U("common"),{projectId:t}=Ls(),{currentProject:c,loading:g}=zs(),x=t??(c==null?void 0:c.id),f=x?`/projects/${x}`:"/projects",i=Ms(x??null),j=Bs(x??null),{stopSession:b,pauseSession:N,resumeSession:m}=As(x??null),d=n.useMemo(()=>i.data??[],[i.data]),P=n.useMemo(()=>j.data??[],[j.data]),T=g||i.isLoading,R=i.error?a("sessions.errors.load"):null,[$]=$s(),[y,O]=n.useState(""),[r,k]=n.useState("all"),[D,is]=n.useState("all"),[F,os]=n.useState("all"),[S,cs]=n.useState(()=>$.get("spec")??"all"),[E,ds]=n.useState("started-desc"),[us,C]=n.useState(v),[ms,V]=n.useState(!1),q=n.useCallback(e=>{O(e),C(v)},[]),Q=n.useCallback(e=>{k(e),C(v)},[]),G=n.useCallback(e=>{is(e),C(v)},[]),H=n.useCallback(e=>{os(e),C(v)},[]),X=n.useCallback(e=>{cs(e),C(v)},[]),xs=n.useCallback(e=>{ds(e),C(v)},[]),Z=n.useCallback(async()=>{await i.refetch(),await j.refetch()},[i,j]),hs=n.useMemo(()=>{const e=d.map(o=>o.status).filter(Boolean);return Array.from(new Set(e))},[d]),ps=n.useMemo(()=>{const e=d.map(o=>o.runner).filter(Boolean);return Array.from(new Set(e))},[d]),gs=n.useMemo(()=>{const e=d.map(o=>o.mode).filter(Boolean);return Array.from(new Set(e))},[d]),js=n.useMemo(()=>P.map(e=>({id:e.specName,label:e.specNumber?`#${e.specNumber} ${e.title??e.specName}`:e.title??e.specName})).sort((e,o)=>e.label.localeCompare(o.label)),[P]),I=n.useMemo(()=>{const o=[...d.filter(l=>{var h,L,_;if(y){const w=y.toLowerCase();if(!(l.id.toLowerCase().includes(w)||(((h=l.specIds)==null?void 0:h.some(vs=>vs.toLowerCase().includes(w)))??!1)||l.runner.toLowerCase().includes(w)||(((L=l.prompt)==null?void 0:L.toLowerCase().includes(w))??!1)))return!1}return!(r!=="all"&&l.status!==r||D!=="all"&&l.runner!==D||F!=="all"&&l.mode!==F||S!=="all"&&(!((_=l.specIds)!=null&&_.length)||!l.specIds.some(w=>w===S||w.includes(S))))})];switch(E){case"started-asc":o.sort((l,h)=>new Date(l.startedAt).getTime()-new Date(h.startedAt).getTime());break;case"duration-desc":o.sort((l,h)=>{const L=l.durationMs??0;return(h.durationMs??0)-L});break;case"status":o.sort((l,h)=>l.status.localeCompare(h.status));break;default:o.sort((l,h)=>new Date(h.startedAt).getTime()-new Date(l.startedAt).getTime());break}return o},[F,y,d,E,S,r,D]),Y=I.slice(0,us),fs=n.useCallback(async e=>{await b(e)},[b]),bs=n.useCallback(async e=>{await N(e)},[N]),Ns=n.useCallback(async e=>{await m(e)},[m]);return T?s.jsx(J,{children:s.jsx(K,{children:s.jsx(ss,{className:"py-10 text-center text-sm text-muted-foreground",children:a("actions.loading")})})}):R?s.jsx(J,{children:s.jsx(K,{children:s.jsxs(ss,{className:"py-10 text-center space-y-3",children:[s.jsx("div",{className:"text-lg font-semibold",children:a("sessionsPage.state.errorTitle")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:R}),s.jsx(u,{variant:"secondary",size:"sm",onClick:Z,className:"mt-2",children:a("actions.retry")})]})})}):s.jsxs(ie,{className:W("flex-1 min-w-0"),children:[s.jsxs(J,{className:"h-[calc(100dvh-3.5rem)]",contentClassName:"flex h-full flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-4 sticky top-0 bg-background mt-0 py-2 z-10",children:[s.jsx(Os,{title:a("sessionsPage.title"),description:a("sessionsPage.description"),actions:s.jsxs(u,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>V(!0),children:[s.jsx(Es,{className:"h-4 w-4"}),a("sessions.actions.new")]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Vs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),s.jsx(qs,{value:y,onChange:e=>q(e.target.value),placeholder:a("sessionsPage.filters.search"),className:"w-full pl-10 pr-4 py-2"})]}),s.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(Qs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:a("specsNavSidebar.filtersLabel")})]}),s.jsxs(z,{value:r,onValueChange:Q,children:[s.jsx(M,{className:"w-[140px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.filters.status")})}),s.jsxs(A,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.status")}),hs.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:a(`sessions.status.${e}`)},e))]})]}),s.jsxs(z,{value:D,onValueChange:G,children:[s.jsx(M,{className:"w-[140px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.filters.runner")})}),s.jsxs(A,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.runner")}),ps.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ls,{runnerId:e,size:16}),rs(e,a)]})},e))]})]}),s.jsxs(z,{value:F,onValueChange:H,children:[s.jsx(M,{className:"w-[140px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.filters.mode")})}),s.jsxs(A,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.mode")}),gs.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:a(`sessions.modes.${e}`)},e))]})]}),s.jsx("div",{className:"w-[180px]",children:s.jsx(me,{value:S,onValueChange:X,options:[{value:"all",label:a("sessionsPage.filters.spec")},...js.map(e=>({value:e.id,label:e.label}))],placeholder:a("sessionsPage.filters.spec"),searchPlaceholder:a("sessions.select.search"),emptyText:a("sessions.select.empty")})}),s.jsxs(z,{value:E,onValueChange:e=>xs(e),children:[s.jsx(M,{className:"w-[160px] h-9",children:s.jsx(B,{placeholder:a("sessionsPage.sort.startedDesc")})}),s.jsxs(A,{children:[s.jsx(p,{value:"started-desc",className:"cursor-pointer",children:a("sessionsPage.sort.startedDesc")}),s.jsx(p,{value:"started-asc",className:"cursor-pointer",children:a("sessionsPage.sort.startedAsc")}),s.jsx(p,{value:"duration-desc",className:"cursor-pointer",children:a("sessionsPage.sort.durationDesc")}),s.jsx(p,{value:"status",className:"cursor-pointer",children:a("sessionsPage.sort.status")})]})]}),(y||r!=="all"||D!=="all"||F!=="all"||S!=="all")&&s.jsxs(u,{onClick:()=>{q(""),Q("all"),G("all"),H("all"),X("all")},variant:"ghost",size:"sm",className:"h-9 gap-1",children:[s.jsx(Gs,{className:"w-4 h-4"}),a("specsNavSidebar.clearFilters")]}),s.jsx("span",{className:"text-sm text-muted-foreground",children:a("specsPage.filters.filteredCount",{filtered:I.length,total:d.length})})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0",children:d.length===0?s.jsx(es,{icon:ce,title:a("sessionsPage.state.emptyTitle"),description:a("sessionsPage.state.emptyDescription"),actions:s.jsx(u,{variant:"secondary",size:"sm",onClick:()=>V(!0),children:a("sessions.actions.new")})}):I.length===0?s.jsx(es,{icon:de,title:a("sessionsPage.state.noResultsTitle"),description:a("sessionsPage.state.noResultsDescription"),actions:s.jsxs("div",{className:"flex gap-2 flex-wrap justify-center",children:[s.jsx(u,{variant:"outline",size:"sm",onClick:()=>{q(""),Q("all"),G("all"),H("all"),X("all")},children:a("specsNavSidebar.clearFilters")}),s.jsxs(u,{variant:"secondary",size:"sm",onClick:Z,children:[s.jsx(ue,{className:"h-4 w-4 mr-2"}),a("sessionsPage.buttons.refresh")]})]})}):s.jsxs("div",{className:"space-y-6",children:[["active","today","yesterday","older"].map(e=>{const o=he(Y)[e];return o.length===0?null:s.jsxs("section",{className:"space-y-2",children:[s.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[a(`sessionsPage.groups.${e}`)," (",o.length,")"]}),s.jsx("div",{className:"space-y-2",children:o.map(l=>s.jsx(pe,{session:l,basePath:f,onStop:fs,onPause:bs,onResume:Ns},l.id))})]},e)}),Y.length<I.length&&s.jsx("div",{className:"flex justify-center",children:s.jsx(u,{variant:"outline",size:"sm",onClick:()=>C(e=>e+v),children:a("sessionsPage.buttons.loadMore")})})]})})]}),s.jsx(Hs,{open:ms,onOpenChange:V,projectPath:c==null?void 0:c.path,onCreated:()=>{Z()}})]})}const pe=n.memo(function({session:t,basePath:c,onStop:g,onPause:x,onResume:f}){const{t:i,i18n:j}=U("common"),b=Xs(),N=Zs[t.status],m=N.icon,d=_s(t),[P,T]=n.useState(!1),R=t.prompt||t.id.slice(0,8),$=t.status==="running"||t.status==="paused",y=r=>{r.target.closest("button, a")||b(`${c}/sessions/${t.id}`)},O=r=>{r.stopPropagation(),T(k=>!k)};return s.jsx("div",{className:"block border rounded-lg hover:bg-secondary/50 transition-colors bg-background cursor-pointer",onClick:y,children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-8 h-full invisible flex items-center text-muted-foreground"}),s.jsxs("div",{className:"flex-1 p-4 pl-0",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-2",children:[s.jsxs("div",{className:"flex items-start gap-2 min-w-0 pr-4",children:[s.jsx(Js,{children:s.jsxs(Us,{children:[s.jsx(Ws,{asChild:!0,children:s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:s.jsx(ls,{runnerId:t.runner,size:24})})}),s.jsx(Ys,{children:rs(t.runner,i)})]})}),s.jsx("div",{children:s.jsx("h3",{className:"font-medium line-clamp-2 leading-relaxed",children:R})})]}),s.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.jsxs(as,{variant:"outline",className:W("flex items-center gap-1.5 w-fit border-transparent h-6 px-2 py-0.5 text-xs font-medium",N.className),children:[s.jsx(m,{className:"h-3.5 w-3.5"}),i(`sessions.status.${t.status}`)]}),s.jsx(oe,{mode:t.mode})]})]}),s.jsx("div",{className:"mb-3 flex items-center gap-2 flex-wrap",children:!t.specIds||t.specIds.length===0?s.jsx("span",{className:"text-xs text-muted-foreground italic",children:i("sessionsPage.labels.noSpecs","No specs")}):t.specIds.map(r=>s.jsxs(as,{variant:"secondary",className:"flex items-center gap-1 text-xs hover:bg-secondary/80 cursor-pointer",onClick:k=>{k.stopPropagation(),b(`${c}/specs/${r}`)},children:[s.jsx(Ks,{className:"h-3 w-3"}),r]},r))}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground min-w-0",children:[t.startedAt&&s.jsx("span",{className:"shrink-0 text-xs",children:se(t.startedAt,j.language)}),d?s.jsx(ee,{duration:d}):null,s.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:O,children:[P?s.jsx(ae,{className:"h-3 w-3 mr-1"}):s.jsx(te,{className:"h-3 w-3 mr-1"}),"Logs"]})]}),$&&s.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0",children:[t.status==="running"&&s.jsxs(s.Fragment,{children:[s.jsxs(u,{size:"sm",variant:"secondary",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),x(t.id)},children:[s.jsx(ne,{className:"h-3 w-3"}),i("sessions.actions.pause")]}),s.jsxs(u,{size:"sm",variant:"destructive",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),g(t.id)},children:[s.jsx(ts,{className:"h-3 w-3"}),i("sessions.actions.stop")]})]}),t.status==="paused"&&s.jsxs(s.Fragment,{children:[s.jsxs(u,{size:"sm",variant:"secondary",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),f(t.id)},children:[s.jsx(re,{className:"h-3 w-3"}),i("sessions.actions.resume")]}),s.jsxs(u,{size:"sm",variant:"destructive",className:"gap-1 h-6 text-xs px-2",onClick:r=>{r.stopPropagation(),g(t.id)},children:[s.jsx(ts,{className:"h-3 w-3"}),i("sessions.actions.stop")]})]})]})]}),P&&s.jsx("div",{className:"mt-4 border-t pt-4",onClick:r=>r.stopPropagation(),children:s.jsx("div",{className:"h-[300px] overflow-hidden rounded-md border",children:s.jsx(le,{sessionId:t.id,onBack:()=>T(!1)})})})]})]})})});export{ye as SessionsPage};
@@ -1,3 +1,3 @@
1
- import{h as I,j as e,f as L,dZ as os,bB as Re,bX as Pe,cb as ls,d_ as Te,cc as cs,cI as ds,cf as ms,d$ as us,e0 as ps,e1 as ze,e2 as hs,e3 as le,c4 as xs,bU as fs,u as U,r as i,b5 as ce,b6 as de,a as M,aW as ee,b8 as me,b9 as Fe,bn as gs,ba as Ie,bb as $e,bc as Be,be as se,bf as Ns,B as ue,br as Ve,aP as qe,c7 as A,D as pe,b as he,c as xe,d as fe,b1 as ge,e4 as Ne,aX as Ue,aY as He,cE as je,aZ as Ke,a_ as Qe,a$ as We,e5 as js,e6 as ys,bd as De,aS as ye,e7 as vs,e8 as bs,e9 as Ee,c8 as Ge,bE as ws,L as Ss,bY as Oe,ea as ks,eb as Cs,ec as Ts,bZ as Ds,b$ as Es,b_ as Os,ed as Ms,c0 as Ls,c1 as As,ee as _s,ef as Rs,bg as Ps,bl as zs,bh as Fs,cU as Is,eg as $s,bi as Bs,eh as Vs,cT as qs,ei as Us,bs as Hs,cn as Ks}from"./index-Bo42UlS3.js";import{P as Qs}from"./page-transition-BKC5kVS6.js";import{c as Ws,T as Me,V as Le,C as Gs,a as Xs,b as Ys}from"./validation-badge-IPkKaNb8.js";import{T as Zs}from"./trending-up-COWs9Nc7.js";import{T as Js,a as et}from"./table-of-contents-BiPY4Kr6.js";import{R as st}from"./refresh-ccw-CfzFVZ57.js";import"./token-utils-x_d_uTQu.js";import"./info-CjwfpSMh.js";const tt=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],at=I("database",tt);const nt=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],rt=I("lightbulb",nt);const it=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Xe=I("link-2",it);const ot=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],lt=I("map",ot);const ct=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],dt=I("maximize-2",ct);const mt=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],ut=I("minimize-2",mt);const pt=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],ht=I("rocket",pt);const xt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ft=I("shield",xt);const gt=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Nt=I("square-check-big",gt);const jt=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],yt=I("test-tube",jt);const vt=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],bt=I("users",vt),Ae={created:"Created",inProgress:"In Progress",complete:"Complete",archived:"Archived",awaiting:"Awaiting",queued:"Queued",pending:"Pending"};function wt({createdAt:t,updatedAt:o,completedAt:p,status:h,className:d,labels:m=Ae,language:l="en"}){const a={...Ae,...m},u=[];return t&&u.push({label:a.created,date:t,isActive:!0,isFuture:!1,icon:Pe,color:"text-blue-600"}),h==="in-progress"||h==="complete"||h==="archived"?u.push({label:a.inProgress,date:o||t,isActive:!0,isFuture:!1,icon:ls,color:"text-orange-600"}):u.push({label:a.inProgress,date:null,isActive:!1,isFuture:!0,icon:Te,color:"text-muted-foreground"}),h==="complete"||h==="archived"?u.push({label:a.complete,date:p||o,isActive:!0,isFuture:!1,icon:cs,color:"text-green-600"}):u.push({label:a.complete,date:null,isActive:!1,isFuture:!0,icon:Te,color:"text-muted-foreground"}),h==="archived"&&u.push({label:a.archived,date:o,isActive:!0,isFuture:!1,icon:ds,color:"text-gray-600"}),u.length===0?null:e.jsx("div",{className:L("flex items-start gap-2",d),children:u.map((n,y)=>{const s=n.icon,S=y===u.length-1,v=S?null:u[y+1],b=n.date&&(v!=null&&v.date)&&!v.isFuture?os(n.date,v.date,l):"";return e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 min-w-0",children:[e.jsx("div",{className:L("w-8 h-8 rounded-full border-2 bg-background flex items-center justify-center shrink-0",n.isActive&&!n.isFuture?"border-primary":"border-muted-foreground/40"),children:s&&e.jsx(s,{className:L("h-4 w-4",n.isActive&&!n.isFuture?"text-primary":"text-muted-foreground/60")})}),e.jsx("div",{className:L("text-xs font-medium text-center whitespace-nowrap",n.isActive&&!n.isFuture?"text-foreground":"text-muted-foreground"),children:n.label}),e.jsxs("div",{className:"text-[10px] text-center min-h-[14px]",children:[n.date&&!n.isFuture&&e.jsx("span",{className:"text-muted-foreground",children:Re(n.date,l)}),!n.date&&n.isFuture&&e.jsx("span",{className:"text-muted-foreground/70",children:a.awaiting}),n.date&&n.isFuture&&e.jsx("span",{className:"text-muted-foreground/70",children:a.queued}),!n.date&&!n.isFuture&&e.jsx("span",{className:"text-muted-foreground/60",children:a.pending})]})]}),!S&&e.jsxs("div",{className:"flex flex-col items-center flex-1 min-w-4 gap-0.5",children:[e.jsx("div",{className:L("h-0.5 w-full",n.isActive&&!n.isFuture?"bg-primary":"bg-muted-foreground/40")}),b&&e.jsx("div",{className:"text-[10px] text-muted-foreground font-medium whitespace-nowrap",children:b})]})]},y)})})}function St(){return ms()}const kt={NOT_FOUND:"apiCodes.notFound",PROJECT_NOT_FOUND:"apiCodes.projectNotFound",SPEC_NOT_FOUND:"apiCodes.specNotFound",NO_PROJECT:"apiCodes.noProject",INVALID_REQUEST:"apiCodes.invalidRequest",UNAUTHORIZED:"apiCodes.unauthorized",VALIDATION_FAILED:"apiCodes.validationFailed",DATABASE_ERROR:"apiCodes.databaseError",CONFIG_ERROR:"apiCodes.configError",TOOL_NOT_FOUND:"apiCodes.toolNotFound",TOOL_ERROR:"apiCodes.toolError",INTERNAL_ERROR:"apiCodes.internalError"};function Ct(t,o){if(t instanceof us){if(t.code){const p=kt[t.code];if(p)return o(p,{ns:"errors",defaultValue:t.message})}switch(t.status){case 404:return o("specNotFound",{ns:"errors"});case 400:return o("invalidInput",{ns:"errors"});case 500:return o("unknownError",{ns:"errors"});default:return o("loadingError",{ns:"errors"})}}return t instanceof Error&&t.message.includes("Failed to fetch")?o("networkError",{ns:"errors"}):t instanceof Error?t.message:o("unknownError",{ns:"errors"})}const Tt=[{keywords:["architecture","system","structure","diagram"],icon:lt,color:"text-indigo-600"},{keywords:["ui","ux","mockup","wireframe","prototype","design"],icon:ps,color:"text-purple-600"},{keywords:["implementation","code","develop","build"],icon:Ws,color:"text-green-600"},{keywords:["api","endpoint","integration","interface"],icon:ze,color:"text-blue-600"},{keywords:["test","qa","quality","validation"],icon:yt,color:"text-orange-600"},{keywords:["task","todo","checklist","milestone"],icon:Nt,color:"text-slate-600"},{keywords:["config","setup","settings","environment"],icon:hs,color:"text-amber-600"},{keywords:["deploy","devops","ci","cd","pipeline","release"],icon:ht,color:"text-rose-600"},{keywords:["migration","upgrade","refactor","transition"],icon:le,color:"text-cyan-600"},{keywords:["security","auth","permission","access","encryption"],icon:ft,color:"text-red-600"},{keywords:["performance","optimization","speed","cache","benchmark"],icon:Zs,color:"text-emerald-600"},{keywords:["database","data","schema","model","query"],icon:at,color:"text-sky-600"},{keywords:["notes","research","findings","considerations","exploration"],icon:rt,color:"text-yellow-600"},{keywords:["doc","guide","manual","reference","readme"],icon:xs,color:"text-gray-500"},{keywords:["github","git","vcs","version"],icon:le,color:"text-pink-600"}],Dt={icon:fs,color:"text-gray-600"};function Et(t){const o=t.toLowerCase();for(const p of Tt)if(p.keywords.some(h=>o.includes(h)))return{icon:p.icon,color:p.color};return Dt}function Ot(t){return t.replace(/\.md$/i,"").split(/[-_]/).map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ")}const Mt=t=>t!=null?t.toString().padStart(3,"0"):null;function Z({specs:t,onSelect:o,disabled:p,excludeSpecNames:h=[],placeholder:d,emptyLabel:m}){const{t:l}=U("common"),[a,u]=i.useState(!1),[n,y]=i.useState(""),s=d??l("search.placeholder"),S=m??l("relationships.empty.noSpecs"),v=i.useMemo(()=>new Set(h),[h]),b=i.useMemo(()=>{const x=n.trim().toLowerCase();return t.filter(j=>!v.has(j.specName)).filter(j=>{var w;return x?[j.title,j.specName,(w=j.specNumber)==null?void 0:w.toString()].filter(Boolean).join(" ").toLowerCase().includes(x):!0}).slice(0,20)},[v,n,t]);return e.jsxs(ce,{open:a,onOpenChange:u,children:[e.jsx(de,{asChild:!0,children:e.jsxs(M,{type:"button",variant:"outline",size:"sm",disabled:p,className:"h-7 px-2 text-xs gap-1",children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),s]})}),e.jsx(me,{className:"w-72 p-0",align:"start",children:e.jsxs(Fe,{children:[e.jsxs("div",{className:"flex items-center px-3 border-b",children:[e.jsx(gs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Ie,{placeholder:s,value:n,onValueChange:y,className:"border-0 focus:ring-0"})]}),e.jsxs($e,{children:[e.jsx(Be,{children:S}),b.map(x=>{const j=Mt(x.specNumber??null),c=x.title||x.specName;return e.jsx(se,{value:`${j?`#${j}`:""} ${c}`.trim(),onSelect:()=>{o(x),u(!1),y("")},children:e.jsxs("div",{className:"flex items-start gap-2 w-full",children:[e.jsx(Ns,{className:L("mt-0.5 h-4 w-4 text-muted-foreground","opacity-0")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[j&&e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",j]}),e.jsx("span",{className:"truncate text-sm font-medium",children:c})]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:x.specName})]})]})},x.specName)})]})]})})]})}const Lt=t=>t!=null?t.toString().padStart(3,"0"):null;function J({title:t,items:o,emptyLabel:p,canEdit:h,onNavigate:d,onRemove:m,actions:l}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t}),l]}),o.length===0?e.jsx("div",{className:"text-xs text-muted-foreground italic",children:p}):e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(a=>{const u=Lt(a.specNumber??null),n=a.title||a.specName;return e.jsxs(ue,{variant:"secondary",className:L("flex items-center gap-2 px-2 py-1 text-xs"),children:[e.jsxs("button",{type:"button",onClick:()=>d(a.specName),className:"flex items-center gap-1 text-left hover:text-primary",children:[u&&e.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",u]}),e.jsx("span",{className:"max-w-[160px] truncate",children:n})]}),h&&m&&e.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 p-0",onClick:()=>m(a.specName),children:e.jsx(Ve,{className:"h-3 w-3"})})]},a.specName)})})]})}function At({spec:t,open:o,onOpenChange:p,basePath:h,disabled:d,onUpdated:m}){const{t:l}=U("common"),a=qe(),[u,n]=i.useState([]),[y,s]=i.useState(!1),S=i.useMemo(()=>new Map(u.map(r=>[r.specName,r])),[u]),v=i.useCallback(async()=>{try{s(!0);const r=await A.getSpecs();n(r)}catch{n([])}finally{s(!1)}},[]);i.useEffect(()=>{o&&v()},[v,o]);const b=i.useCallback(r=>window.confirm(l("relationships.confirmRemove",{label:r})),[l]),x=i.useCallback(r=>{a(`${h}/specs/${r}`),p(!1)},[h,a,p]),j=i.useCallback(async r=>{await r(),m()},[m]),c=i.useCallback(r=>{const C=S.get(r);return C?{specName:C.specName,title:C.title,specNumber:C.specNumber}:{specName:r}},[S]),w=t.parent?c(t.parent):null,T=(t.children||[]).map(c),f=(t.dependsOn||[]).map(c),P=(t.requiredBy||[]).map(c);return e.jsx(pe,{open:o,onOpenChange:p,children:e.jsxs(he,{className:"w-[min(720px,95vw)] max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(xe,{children:[e.jsx(fe,{children:l("relationships.title")}),e.jsx(ge,{children:l("relationships.description")})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(ze,{className:"h-4 w-4"}),l("relationships.sections.hierarchy")]}),e.jsx(J,{title:l("relationships.parent"),items:w?[w]:[],emptyLabel:l("relationships.empty.parent"),canEdit:!d,onNavigate:x,onRemove:w&&!d?()=>{b(w.title||w.specName)&&j(()=>A.updateSpec(t.specName,{parent:null}))}:void 0,actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{j(()=>A.updateSpec(t.specName,{parent:r.specName}))},disabled:y||d,excludeSpecNames:[t.specName],placeholder:l("relationships.actions.setParent"),emptyLabel:l("relationships.empty.noSpecs")})}),e.jsx(J,{title:l("relationships.children"),items:T,emptyLabel:l("relationships.empty.children"),canEdit:!d,onNavigate:x,onRemove:d?void 0:r=>{const C=c(r);b(C.title||C.specName)&&j(()=>A.updateSpec(r,{parent:null}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==t.specName&&j(()=>A.updateSpec(r.specName,{parent:t.specName}))},disabled:y||d,excludeSpecNames:[t.specName,...t.children||[]],placeholder:l("relationships.actions.addChild"),emptyLabel:l("relationships.empty.noSpecs")})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(le,{className:"h-4 w-4"}),l("relationships.sections.dependencies")]}),e.jsx(J,{title:l("relationships.dependsOn"),items:f,emptyLabel:l("relationships.empty.dependsOn"),canEdit:!d,onNavigate:x,onRemove:d?void 0:r=>{const C=c(r);b(C.title||C.specName)&&j(()=>A.updateSpec(t.specName,{removeDependsOn:[r]}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==t.specName&&j(()=>A.updateSpec(t.specName,{addDependsOn:[r.specName]}))},disabled:y||d,excludeSpecNames:[t.specName,...t.dependsOn||[]],placeholder:l("relationships.actions.addDependsOn"),emptyLabel:l("relationships.empty.noSpecs")})}),e.jsx(J,{title:l("relationships.requiredBy"),items:P,emptyLabel:l("relationships.empty.requiredBy"),canEdit:!d,onNavigate:x,onRemove:d?void 0:r=>{const C=c(r);b(C.title||C.specName)&&j(()=>A.updateSpec(r,{removeDependsOn:[t.specName]}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==t.specName&&j(()=>A.updateSpec(r.specName,{addDependsOn:[t.specName]}))},disabled:y||d,excludeSpecNames:[t.specName,...t.requiredBy||[]],placeholder:l("relationships.actions.addRequiredBy"),emptyLabel:l("relationships.empty.noSpecs")})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t pt-4",children:[e.jsxs(M,{variant:"outline",size:"sm",type:"button",onClick:()=>a(`${h}/specs?view=board&groupByParent=1`),className:"gap-2",children:[e.jsx(bt,{className:"h-4 w-4"}),l("relationships.actions.viewHierarchy")]}),e.jsxs(M,{variant:"outline",size:"sm",type:"button",onClick:()=>a(`${h}/dependencies?spec=${t.specNumber||t.id}`),className:"gap-2",children:[e.jsx(Xe,{className:"h-4 w-4"}),l("relationships.actions.viewDependencies")]})]})]})]})})}const ie=Object.entries(js).map(([t,o])=>({value:t,labelKey:o.labelKey,className:o.className,Icon:o.icon}));function _t({specName:t,value:o,onChange:p,expectedContentHash:h,disabled:d=!1,className:m}){const l=o||"planned",[a,u]=i.useState(l),[n,y]=i.useState(!1),[s,S]=i.useState(null),[v,b]=i.useState(null),{t:x}=U("common"),j=Ne();i.useEffect(()=>{u(o||"planned"),y(!1),S(null)},[o,t]);const c=ie.find(f=>f.value===a)||ie[0],w=async(f,P=!1)=>{if(f===a)return;const r=a;u(f),y(!0),S(null);try{await A.updateSpec(t,{status:f,expectedContentHash:h,force:P}),p==null||p(f),j()}catch(C){u(r);const B=C instanceof Error?C.message:x("editors.statusError");S(B)}finally{y(!1)}},T=f=>{if(f!==a){if(a==="draft"&&(f==="in-progress"||f==="complete")){b(f);return}w(f)}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ue,{value:a,onValueChange:f=>T(f),disabled:d||n,children:[e.jsx(He,{className:L("h-7 w-fit min-w-0 sm:min-w-[120px] border-0 px-2 text-xs font-medium justify-center sm:justify-start",c.className,m,n&&"opacity-70"),"aria-label":x("editors.changeStatus"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[n?e.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(c.Icon,{className:"h-3.5 w-3.5"}),e.jsx(Ke,{placeholder:x("specsPage.filters.status"),children:e.jsx("span",{className:"hidden sm:inline",children:x(c.labelKey)})})]})}),e.jsx(Qe,{children:ie.map(f=>e.jsx(We,{value:f.value,className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f.Icon,{className:"h-4 w-4"}),e.jsx("span",{children:x(f.labelKey)})]})},f.value))})]}),s&&e.jsx("p",{className:"text-xs text-destructive",children:s}),e.jsx(pe,{open:v!==null,onOpenChange:f=>!f&&b(null),children:e.jsxs(he,{children:[e.jsxs(xe,{children:[e.jsx(fe,{children:x("editors.draftSkipTitle")}),e.jsx(ge,{children:x("editors.draftSkipDescription")})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(M,{type:"button",variant:"outline",size:"sm",onClick:()=>{b(null),w("planned")},children:x("editors.draftSkipPlanned")}),e.jsx(M,{type:"button",size:"sm",onClick:()=>{if(!v)return;const f=v;b(null),w(f,!0)},children:x("editors.draftSkipForce")})]})]})})]})}const oe=Object.entries(ys).map(([t,o])=>({value:t,labelKey:o.labelKey,className:o.className,Icon:o.icon}));function Rt({specName:t,value:o,onChange:p,expectedContentHash:h,disabled:d=!1,className:m}){const l=o||"medium",[a,u]=i.useState(l),[n,y]=i.useState(!1),[s,S]=i.useState(null),{t:v}=U("common"),b=Ne();i.useEffect(()=>{u(o||"medium"),y(!1),S(null)},[o,t]);const x=oe.find(c=>c.value===a)||oe[1],j=async c=>{if(c===a)return;const w=a;u(c),y(!0),S(null);try{await A.updateSpec(t,{priority:c,expectedContentHash:h}),p==null||p(c),b()}catch(T){u(w);const f=T instanceof Error?T.message:v("editors.priorityError");S(f)}finally{y(!1)}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ue,{value:a,onValueChange:c=>j(c),disabled:d||n,children:[e.jsx(He,{className:L("h-7 w-fit min-w-0 sm:min-w-[100px] border-0 px-2 text-xs font-medium justify-center sm:justify-start",x.className,m,n&&"opacity-70"),"aria-label":v("editors.changePriority"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[n?e.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(x.Icon,{className:"h-3.5 w-3.5"}),e.jsx(Ke,{placeholder:v("specsPage.filters.priority"),children:e.jsx("span",{className:"hidden sm:inline",children:v(x.labelKey)})})]})}),e.jsx(Qe,{children:oe.map(c=>e.jsx(We,{value:c.value,className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c.Icon,{className:"h-4 w-4"}),e.jsx("span",{children:v(c.labelKey)})]})},c.value))})]}),s&&e.jsx("p",{className:"text-xs text-destructive",children:s})]})}function Pt({specName:t,value:o,onChange:p,expectedContentHash:h,disabled:d=!1,className:m,compact:l=!1}){const[a,u]=i.useState(o||[]),[n,y]=i.useState([]),[s,S]=i.useState(!1),[v,b]=i.useState(null),[x,j]=i.useState(!1),[c,w]=i.useState(""),{t:T}=U("common"),f=Ne();i.useEffect(()=>{x&&n.length===0&&(async()=>{try{const E=await A.getSpecs(),R=new Set;E.forEach(K=>{var Q;return(Q=K.tags)==null?void 0:Q.forEach(te=>R.add(te))}),y(Array.from(R).sort())}catch(E){console.error("Failed to fetch tags:",E)}})()},[x,n.length]);const P=async k=>{const E=a;u(k),S(!0),b(null);try{await A.updateSpec(t,{tags:k,expectedContentHash:h}),p==null||p(k),f()}catch(R){u(E);const K=R instanceof Error?R.message:T("editors.tagsError");b(K)}finally{S(!1)}},r=k=>{const E=k.trim();if(!E)return;if(a.includes(E)){b(T("editors.tagExists"));return}const R=[...a,E];P(R),w(""),j(!1)},C=k=>{const E=a.filter(R=>R!==k);P(E)},B=i.useMemo(()=>{const k=c.toLowerCase();return n.filter(E=>!a.includes(E)).filter(E=>!k||E.toLowerCase().includes(k))},[n,a,c]),$=c.trim()&&!a.includes(c.trim())&&!n.includes(c.trim()),z=3,W=l&&a.length>z?a.slice(0,z):a,H=a.length-W.length,G=k=>e.jsxs(ue,{variant:"outline",className:L("text-xs pr-1 gap-1",d&&"opacity-50"),children:[k,!d&&e.jsx("button",{onClick:()=>C(k),disabled:s,className:"ml-1 rounded-full hover:bg-muted p-0.5 transition-colors","aria-label":T("editors.removeTag",{tag:k}),children:e.jsx(Ve,{className:"h-3 w-3"})})]},k);return e.jsx("div",{className:L("relative",m),children:e.jsxs("div",{className:"flex gap-1 flex-wrap items-center",children:[W.map(G),H>0&&e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsxs(ue,{variant:"outline",className:"cursor-pointer hover:bg-muted h-6 px-2 text-xs",children:["+",H]})}),e.jsx(me,{className:"w-64 p-2",align:"start",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:a.map(G)})})]}),!d&&e.jsxs(ce,{open:x,onOpenChange:j,children:[e.jsx(de,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"sm",className:"h-6 px-2 text-xs",disabled:s,"aria-label":T("editors.addTag"),children:s?e.jsx(je,{className:"h-3 w-3 animate-spin"}):e.jsx(ee,{className:"h-3 w-3"})})}),e.jsxs(me,{className:"w-56 p-0",align:"start",children:[e.jsxs(Fe,{children:[e.jsx(Ie,{placeholder:T("editors.searchTag"),value:c,onValueChange:w}),e.jsxs($e,{children:[e.jsx(Be,{children:$?e.jsxs(se,{onSelect:()=>r(c),className:"cursor-pointer",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),T("editors.createTag",{tag:c.trim()})]}):e.jsx("span",{className:"text-muted-foreground px-2 py-1.5 text-sm",children:T("editors.noTagResults")})}),B.length>0&&e.jsx(De,{heading:T("editors.existingTags"),children:B.slice(0,10).map(k=>e.jsx(se,{value:k,onSelect:()=>r(k),className:"cursor-pointer",children:k},k))}),$&&B.length>0&&e.jsx(De,{heading:T("editors.createSection"),children:e.jsxs(se,{onSelect:()=>r(c),className:"cursor-pointer",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),T("editors.createTag",{tag:c.trim()})]})})]})]}),v&&e.jsx("p",{className:"text-xs text-destructive px-2 pb-2",children:v})]})]})]})})}function zt({spec:t,basePath:o,displayTitle:p,tags:h,updatedRelative:d,isFocusMode:m,setIsFocusMode:l,headerRef:a,machineModeEnabled:u,isMachineAvailable:n,applySpecPatch:y,onOpenTimeline:s,onOpenRelationships:S,onOpenSessions:v,onOpenMobile:b,timelineDialogOpen:x,setTimelineDialogOpen:j,currentTokenCount:c,currentValidationStatus:w,asyncMetadata:T,onOpenTokenDialog:f,onOpenValidationDialog:P,t:r,i18n:C}){var $;const B=c!==void 0||w!==void 0;return e.jsx("header",{ref:a,className:"lg:sticky lg:top-0 lg:z-20 border-b bg-card",children:e.jsx(ye,{padding:"none",contentClassName:L("px-4 sm:px-6 lg:px-8",m?"py-1.5":"py-2 sm:py-3"),children:m?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("h1",{className:"text-base font-semibold tracking-tight truncate",children:[t.specNumber&&e.jsxs("span",{className:"text-muted-foreground",children:["#",t.specNumber," "]}),p]}),e.jsx(vs,{status:t.status||"planned"}),e.jsx(bs,{priority:t.priority||"medium"}),t.children&&t.children.length>0&&e.jsx(Ee,{count:t.children.length}),e.jsx(Me,{count:c,size:"sm",onClick:f}),e.jsx(Le,{status:w,errorCount:T.validationErrors,size:"sm",onClick:P})]}),e.jsx(M,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(!1),className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground shrink-0",title:r("specDetail.buttons.exitFocus"),children:e.jsx(ut,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[t.parent&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-3",children:[e.jsxs(Ge,{to:`${o}/specs/${t.parent}`,className:"hover:text-primary hover:underline flex items-center gap-1 group",children:[e.jsx(Gs,{className:"h-3 w-3 group-hover:text-primary"}),e.jsx("span",{className:"font-medium",children:t.parent})]}),e.jsx(ws,{className:"h-3 w-3 opacity-50"}),e.jsx("span",{className:"truncate opacity-70",children:p})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 sm:mb-2",children:[t.children&&t.children.length>0&&e.jsx(Ee,{iconOnly:!0}),e.jsxs("h1",{className:"text-lg sm:text-xl font-bold tracking-tight",children:[t.specNumber&&e.jsxs("span",{className:"text-muted-foreground",children:["#",t.specNumber," "]}),p]}),e.jsxs(M,{variant:"ghost",size:"icon",className:"lg:hidden h-8 w-8 -mr-2 shrink-0 text-muted-foreground",onClick:b,children:[e.jsx(Ss,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:r("specDetail.toggleSidebar")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_t,{specName:t.specName,value:t.status,expectedContentHash:t.contentHash,disabled:u&&!n(),onChange:z=>y({status:z})}),e.jsx(Rt,{specName:t.specName,value:t.priority,expectedContentHash:t.contentHash,disabled:u&&!n(),onChange:z=>y({priority:z})}),B&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-px bg-border mx-1 hidden sm:block"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{count:c,size:"md",onClick:f}),e.jsx(Le,{status:w,errorCount:T.validationErrors,size:"md",onClick:P})]})]}),e.jsx("div",{className:"h-4 w-px bg-border mx-1 hidden sm:block"}),e.jsx(Pt,{specName:t.specName,value:h,expectedContentHash:t.contentHash,disabled:u&&!n(),onChange:z=>y({tags:z}),compact:!0,className:"min-w-0"})]}),u&&!n()&&e.jsx("div",{className:"text-xs text-destructive mt-2",children:r("machines.unavailable")}),e.jsxs("div",{className:"flex flex-wrap gap-2 sm:gap-4 text-xs text-muted-foreground mt-1.5 sm:mt-2",children:[e.jsxs("span",{className:"hidden sm:inline",children:[r("specDetail.metadata.created"),": ",Oe(t.createdAt,C.language)]}),e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{children:[r("specDetail.metadata.updated"),": ",Oe(t.updatedAt,C.language),d&&e.jsxs("span",{className:"ml-1 text-[11px] text-muted-foreground/80",children:["(",d,")"]})]}),e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{className:"hidden md:inline",children:[r("specDetail.metadata.name"),": ",t.specName]}),($=t.metadata)!=null&&$.assignee?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{className:"hidden sm:inline",children:[r("specDetail.metadata.assignee"),": ",String(t.metadata.assignee)]})]}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[e.jsxs(pe,{open:x,onOpenChange:j,children:[e.jsxs(M,{type:"button",variant:"outline",size:"sm","aria-haspopup":"dialog","aria-expanded":x,onClick:s,className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Pe,{className:"mr-1.5 h-3.5 w-3.5"}),r("specDetail.buttons.viewTimeline")]}),e.jsxs(he,{className:"w-[min(900px,90vw)] max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xe,{children:[e.jsx(fe,{children:r("specDetail.dialogs.timelineTitle")}),e.jsx(ge,{children:r("specDetail.dialogs.timelineDescription")})]}),e.jsx("div",{className:"rounded-xl border border-border bg-muted/30 p-4",children:e.jsx(wt,{createdAt:t.createdAt,updatedAt:t.updatedAt,completedAt:t.completedAt,status:t.status||"planned",labels:{created:r("specTimeline.events.created"),inProgress:r("specTimeline.events.inProgress"),complete:r("specTimeline.events.complete"),archived:r("specTimeline.events.archived"),awaiting:r("specTimeline.state.awaiting"),queued:r("specTimeline.state.queued"),pending:r("specTimeline.state.pending")},language:C.language})})]})]}),e.jsxs(M,{type:"button",variant:"outline",size:"sm","aria-haspopup":"dialog",onClick:S,className:L("h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground"),children:[e.jsx(Xe,{className:"mr-1.5 h-3.5 w-3.5"}),r("relationships.button")]}),e.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:v,className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(ks,{className:"mr-1.5 h-3.5 w-3.5"}),r("navigation.sessions")]}),e.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:()=>l(!0),className:"hidden lg:inline-flex h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",title:r("specDetail.buttons.focus"),children:[e.jsx(dt,{className:"mr-1.5 h-3.5 w-3.5"}),r("specDetail.buttons.focus")]})]})]})})})}function Ft({subSpecs:t,currentSubSpec:o,onSwitch:p,t:h}){return t.length===0?null:e.jsx("div",{className:"border-t bg-muted/30",children:e.jsx(ye,{padding:"none",contentClassName:"px-4 sm:px-6 lg:px-8 overflow-x-auto",children:e.jsxs("div",{className:"flex gap-1 py-2 min-w-max",children:[e.jsxs("button",{onClick:()=>p(null),className:`flex items-center gap-2 px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium rounded-md whitespace-nowrap transition-colors ${o?"text-muted-foreground hover:text-foreground hover:bg-muted/50":"bg-background text-foreground shadow-sm"}`,children:[e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:h("specDetail.tabs.overview")})]}),t.map(d=>{const m=d.icon;return e.jsxs("button",{onClick:()=>p(d.file??null),className:`flex items-center gap-2 px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium rounded-md whitespace-nowrap transition-colors ${o===d.file?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(m,{className:`h-4 w-4 ${d.color}`}),e.jsx("span",{className:"hidden sm:inline",children:d.name})]},d.file)})]})})})}function It({content:t,specName:o="",basePath:p="",onChecklistToggle:h}){const d=Ts(o,p,h);return e.jsx("article",{className:"prose prose-sm sm:prose-base dark:prose-invert max-w-none",children:e.jsx(Ds,{remarkPlugins:[Ls,As,_s],rehypePlugins:[Es,Os,Ms],components:d,children:t})})}function $t({displayContent:t,specName:o,basePath:p,hasSubSpecs:h,onChecklistToggle:d}){const[m,l]=i.useState(()=>typeof window<"u"?window.innerWidth>=1024:!0),a=i.useRef(null),u=i.useCallback(n=>{a.current&&(a.current.disconnect(),a.current=null),n&&(l(n.clientWidth>=1024),a.current=new ResizeObserver(y=>{for(const s of y)l(s.contentRect.width>=1024)}),a.current.observe(n))},[]);return i.useEffect(()=>()=>{a.current&&a.current.disconnect()},[]),e.jsxs(e.Fragment,{children:[e.jsx(ye,{padding:"none",contentClassName:L("flex flex-col w-full",m?"lg:flex-row items-start":""),children:e.jsxs("div",{ref:u,className:"flex w-full",children:[e.jsx("main",{className:"flex-1 px-4 sm:px-6 lg:px-8 py-3 sm:py-6 min-w-0",children:e.jsx(It,{content:t,specName:o,basePath:p,onChecklistToggle:d})}),e.jsx("aside",{className:L("w-72 shrink-0 px-6 py-6 sticky overflow-y-auto scrollbar-auto-hide",m?"block":"hidden",h?"top-[calc(16.375rem-3.5rem)] h-[calc(100dvh-16.375rem)]":"top-[calc(13.125rem-3.5rem)] h-[calc(100dvh-13.125rem)]"),children:e.jsx(Js,{content:t})})]})}),e.jsx("div",{className:m?"hidden":"block",children:e.jsx(et,{content:t})}),e.jsx(Rs,{targetId:"spec-detail-main"})]})}function _e(t,o,p){const h=t.split(`
1
+ import{h as I,j as e,f as L,dZ as os,bB as Re,bX as Pe,cb as ls,d_ as Te,cc as cs,cI as ds,cf as ms,d$ as us,e0 as ps,e1 as ze,e2 as hs,e3 as le,c4 as xs,bU as fs,u as U,r as i,b5 as ce,b6 as de,a as M,aW as ee,b8 as me,b9 as Fe,bn as gs,ba as Ie,bb as $e,bc as Be,be as se,bf as Ns,B as ue,br as Ve,aP as qe,c7 as A,D as pe,b as he,c as xe,d as fe,b1 as ge,e4 as Ne,aX as Ue,aY as He,cE as je,aZ as Ke,a_ as Qe,a$ as We,e5 as js,e6 as ys,bd as De,aS as ye,e7 as vs,e8 as bs,e9 as Ee,c8 as Ge,bE as ws,L as Ss,bY as Oe,ea as ks,eb as Cs,ec as Ts,bZ as Ds,b$ as Es,b_ as Os,ed as Ms,c0 as Ls,c1 as As,ee as _s,ef as Rs,bg as Ps,bl as zs,bh as Fs,cU as Is,eg as $s,bi as Bs,eh as Vs,cT as qs,ei as Us,bs as Hs,cn as Ks}from"./index-BlyOVhDj.js";import{P as Qs}from"./page-transition-DY_O2TfZ.js";import{c as Ws,T as Me,V as Le,C as Gs,a as Xs,b as Ys}from"./validation-badge-Bg0rq4Tp.js";import{T as Zs}from"./trending-up-C8H38O_j.js";import{T as Js,a as et}from"./table-of-contents-Cnkk8UZa.js";import{R as st}from"./refresh-ccw-DZO2C09G.js";import"./token-utils-x_d_uTQu.js";import"./info-Cl-KzKzC.js";const tt=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],at=I("database",tt);const nt=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],rt=I("lightbulb",nt);const it=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Xe=I("link-2",it);const ot=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],lt=I("map",ot);const ct=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],dt=I("maximize-2",ct);const mt=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],ut=I("minimize-2",mt);const pt=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],ht=I("rocket",pt);const xt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ft=I("shield",xt);const gt=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Nt=I("square-check-big",gt);const jt=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],yt=I("test-tube",jt);const vt=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],bt=I("users",vt),Ae={created:"Created",inProgress:"In Progress",complete:"Complete",archived:"Archived",awaiting:"Awaiting",queued:"Queued",pending:"Pending"};function wt({createdAt:t,updatedAt:o,completedAt:p,status:h,className:d,labels:m=Ae,language:l="en"}){const a={...Ae,...m},u=[];return t&&u.push({label:a.created,date:t,isActive:!0,isFuture:!1,icon:Pe,color:"text-blue-600"}),h==="in-progress"||h==="complete"||h==="archived"?u.push({label:a.inProgress,date:o||t,isActive:!0,isFuture:!1,icon:ls,color:"text-orange-600"}):u.push({label:a.inProgress,date:null,isActive:!1,isFuture:!0,icon:Te,color:"text-muted-foreground"}),h==="complete"||h==="archived"?u.push({label:a.complete,date:p||o,isActive:!0,isFuture:!1,icon:cs,color:"text-green-600"}):u.push({label:a.complete,date:null,isActive:!1,isFuture:!0,icon:Te,color:"text-muted-foreground"}),h==="archived"&&u.push({label:a.archived,date:o,isActive:!0,isFuture:!1,icon:ds,color:"text-gray-600"}),u.length===0?null:e.jsx("div",{className:L("flex items-start gap-2",d),children:u.map((n,y)=>{const s=n.icon,S=y===u.length-1,v=S?null:u[y+1],b=n.date&&(v!=null&&v.date)&&!v.isFuture?os(n.date,v.date,l):"";return e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 min-w-0",children:[e.jsx("div",{className:L("w-8 h-8 rounded-full border-2 bg-background flex items-center justify-center shrink-0",n.isActive&&!n.isFuture?"border-primary":"border-muted-foreground/40"),children:s&&e.jsx(s,{className:L("h-4 w-4",n.isActive&&!n.isFuture?"text-primary":"text-muted-foreground/60")})}),e.jsx("div",{className:L("text-xs font-medium text-center whitespace-nowrap",n.isActive&&!n.isFuture?"text-foreground":"text-muted-foreground"),children:n.label}),e.jsxs("div",{className:"text-[10px] text-center min-h-[14px]",children:[n.date&&!n.isFuture&&e.jsx("span",{className:"text-muted-foreground",children:Re(n.date,l)}),!n.date&&n.isFuture&&e.jsx("span",{className:"text-muted-foreground/70",children:a.awaiting}),n.date&&n.isFuture&&e.jsx("span",{className:"text-muted-foreground/70",children:a.queued}),!n.date&&!n.isFuture&&e.jsx("span",{className:"text-muted-foreground/60",children:a.pending})]})]}),!S&&e.jsxs("div",{className:"flex flex-col items-center flex-1 min-w-4 gap-0.5",children:[e.jsx("div",{className:L("h-0.5 w-full",n.isActive&&!n.isFuture?"bg-primary":"bg-muted-foreground/40")}),b&&e.jsx("div",{className:"text-[10px] text-muted-foreground font-medium whitespace-nowrap",children:b})]})]},y)})})}function St(){return ms()}const kt={NOT_FOUND:"apiCodes.notFound",PROJECT_NOT_FOUND:"apiCodes.projectNotFound",SPEC_NOT_FOUND:"apiCodes.specNotFound",NO_PROJECT:"apiCodes.noProject",INVALID_REQUEST:"apiCodes.invalidRequest",UNAUTHORIZED:"apiCodes.unauthorized",VALIDATION_FAILED:"apiCodes.validationFailed",DATABASE_ERROR:"apiCodes.databaseError",CONFIG_ERROR:"apiCodes.configError",TOOL_NOT_FOUND:"apiCodes.toolNotFound",TOOL_ERROR:"apiCodes.toolError",INTERNAL_ERROR:"apiCodes.internalError"};function Ct(t,o){if(t instanceof us){if(t.code){const p=kt[t.code];if(p)return o(p,{ns:"errors",defaultValue:t.message})}switch(t.status){case 404:return o("specNotFound",{ns:"errors"});case 400:return o("invalidInput",{ns:"errors"});case 500:return o("unknownError",{ns:"errors"});default:return o("loadingError",{ns:"errors"})}}return t instanceof Error&&t.message.includes("Failed to fetch")?o("networkError",{ns:"errors"}):t instanceof Error?t.message:o("unknownError",{ns:"errors"})}const Tt=[{keywords:["architecture","system","structure","diagram"],icon:lt,color:"text-indigo-600"},{keywords:["ui","ux","mockup","wireframe","prototype","design"],icon:ps,color:"text-purple-600"},{keywords:["implementation","code","develop","build"],icon:Ws,color:"text-green-600"},{keywords:["api","endpoint","integration","interface"],icon:ze,color:"text-blue-600"},{keywords:["test","qa","quality","validation"],icon:yt,color:"text-orange-600"},{keywords:["task","todo","checklist","milestone"],icon:Nt,color:"text-slate-600"},{keywords:["config","setup","settings","environment"],icon:hs,color:"text-amber-600"},{keywords:["deploy","devops","ci","cd","pipeline","release"],icon:ht,color:"text-rose-600"},{keywords:["migration","upgrade","refactor","transition"],icon:le,color:"text-cyan-600"},{keywords:["security","auth","permission","access","encryption"],icon:ft,color:"text-red-600"},{keywords:["performance","optimization","speed","cache","benchmark"],icon:Zs,color:"text-emerald-600"},{keywords:["database","data","schema","model","query"],icon:at,color:"text-sky-600"},{keywords:["notes","research","findings","considerations","exploration"],icon:rt,color:"text-yellow-600"},{keywords:["doc","guide","manual","reference","readme"],icon:xs,color:"text-gray-500"},{keywords:["github","git","vcs","version"],icon:le,color:"text-pink-600"}],Dt={icon:fs,color:"text-gray-600"};function Et(t){const o=t.toLowerCase();for(const p of Tt)if(p.keywords.some(h=>o.includes(h)))return{icon:p.icon,color:p.color};return Dt}function Ot(t){return t.replace(/\.md$/i,"").split(/[-_]/).map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ")}const Mt=t=>t!=null?t.toString().padStart(3,"0"):null;function Z({specs:t,onSelect:o,disabled:p,excludeSpecNames:h=[],placeholder:d,emptyLabel:m}){const{t:l}=U("common"),[a,u]=i.useState(!1),[n,y]=i.useState(""),s=d??l("search.placeholder"),S=m??l("relationships.empty.noSpecs"),v=i.useMemo(()=>new Set(h),[h]),b=i.useMemo(()=>{const x=n.trim().toLowerCase();return t.filter(j=>!v.has(j.specName)).filter(j=>{var w;return x?[j.title,j.specName,(w=j.specNumber)==null?void 0:w.toString()].filter(Boolean).join(" ").toLowerCase().includes(x):!0}).slice(0,20)},[v,n,t]);return e.jsxs(ce,{open:a,onOpenChange:u,children:[e.jsx(de,{asChild:!0,children:e.jsxs(M,{type:"button",variant:"outline",size:"sm",disabled:p,className:"h-7 px-2 text-xs gap-1",children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),s]})}),e.jsx(me,{className:"w-72 p-0",align:"start",children:e.jsxs(Fe,{children:[e.jsxs("div",{className:"flex items-center px-3 border-b",children:[e.jsx(gs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Ie,{placeholder:s,value:n,onValueChange:y,className:"border-0 focus:ring-0"})]}),e.jsxs($e,{children:[e.jsx(Be,{children:S}),b.map(x=>{const j=Mt(x.specNumber??null),c=x.title||x.specName;return e.jsx(se,{value:`${j?`#${j}`:""} ${c}`.trim(),onSelect:()=>{o(x),u(!1),y("")},children:e.jsxs("div",{className:"flex items-start gap-2 w-full",children:[e.jsx(Ns,{className:L("mt-0.5 h-4 w-4 text-muted-foreground","opacity-0")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[j&&e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",j]}),e.jsx("span",{className:"truncate text-sm font-medium",children:c})]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:x.specName})]})]})},x.specName)})]})]})})]})}const Lt=t=>t!=null?t.toString().padStart(3,"0"):null;function J({title:t,items:o,emptyLabel:p,canEdit:h,onNavigate:d,onRemove:m,actions:l}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t}),l]}),o.length===0?e.jsx("div",{className:"text-xs text-muted-foreground italic",children:p}):e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(a=>{const u=Lt(a.specNumber??null),n=a.title||a.specName;return e.jsxs(ue,{variant:"secondary",className:L("flex items-center gap-2 px-2 py-1 text-xs"),children:[e.jsxs("button",{type:"button",onClick:()=>d(a.specName),className:"flex items-center gap-1 text-left hover:text-primary",children:[u&&e.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",u]}),e.jsx("span",{className:"max-w-[160px] truncate",children:n})]}),h&&m&&e.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 p-0",onClick:()=>m(a.specName),children:e.jsx(Ve,{className:"h-3 w-3"})})]},a.specName)})})]})}function At({spec:t,open:o,onOpenChange:p,basePath:h,disabled:d,onUpdated:m}){const{t:l}=U("common"),a=qe(),[u,n]=i.useState([]),[y,s]=i.useState(!1),S=i.useMemo(()=>new Map(u.map(r=>[r.specName,r])),[u]),v=i.useCallback(async()=>{try{s(!0);const r=await A.getSpecs();n(r)}catch{n([])}finally{s(!1)}},[]);i.useEffect(()=>{o&&v()},[v,o]);const b=i.useCallback(r=>window.confirm(l("relationships.confirmRemove",{label:r})),[l]),x=i.useCallback(r=>{a(`${h}/specs/${r}`),p(!1)},[h,a,p]),j=i.useCallback(async r=>{await r(),m()},[m]),c=i.useCallback(r=>{const C=S.get(r);return C?{specName:C.specName,title:C.title,specNumber:C.specNumber}:{specName:r}},[S]),w=t.parent?c(t.parent):null,T=(t.children||[]).map(c),f=(t.dependsOn||[]).map(c),P=(t.requiredBy||[]).map(c);return e.jsx(pe,{open:o,onOpenChange:p,children:e.jsxs(he,{className:"w-[min(720px,95vw)] max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(xe,{children:[e.jsx(fe,{children:l("relationships.title")}),e.jsx(ge,{children:l("relationships.description")})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(ze,{className:"h-4 w-4"}),l("relationships.sections.hierarchy")]}),e.jsx(J,{title:l("relationships.parent"),items:w?[w]:[],emptyLabel:l("relationships.empty.parent"),canEdit:!d,onNavigate:x,onRemove:w&&!d?()=>{b(w.title||w.specName)&&j(()=>A.updateSpec(t.specName,{parent:null}))}:void 0,actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{j(()=>A.updateSpec(t.specName,{parent:r.specName}))},disabled:y||d,excludeSpecNames:[t.specName],placeholder:l("relationships.actions.setParent"),emptyLabel:l("relationships.empty.noSpecs")})}),e.jsx(J,{title:l("relationships.children"),items:T,emptyLabel:l("relationships.empty.children"),canEdit:!d,onNavigate:x,onRemove:d?void 0:r=>{const C=c(r);b(C.title||C.specName)&&j(()=>A.updateSpec(r,{parent:null}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==t.specName&&j(()=>A.updateSpec(r.specName,{parent:t.specName}))},disabled:y||d,excludeSpecNames:[t.specName,...t.children||[]],placeholder:l("relationships.actions.addChild"),emptyLabel:l("relationships.empty.noSpecs")})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(le,{className:"h-4 w-4"}),l("relationships.sections.dependencies")]}),e.jsx(J,{title:l("relationships.dependsOn"),items:f,emptyLabel:l("relationships.empty.dependsOn"),canEdit:!d,onNavigate:x,onRemove:d?void 0:r=>{const C=c(r);b(C.title||C.specName)&&j(()=>A.updateSpec(t.specName,{removeDependsOn:[r]}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==t.specName&&j(()=>A.updateSpec(t.specName,{addDependsOn:[r.specName]}))},disabled:y||d,excludeSpecNames:[t.specName,...t.dependsOn||[]],placeholder:l("relationships.actions.addDependsOn"),emptyLabel:l("relationships.empty.noSpecs")})}),e.jsx(J,{title:l("relationships.requiredBy"),items:P,emptyLabel:l("relationships.empty.requiredBy"),canEdit:!d,onNavigate:x,onRemove:d?void 0:r=>{const C=c(r);b(C.title||C.specName)&&j(()=>A.updateSpec(r,{removeDependsOn:[t.specName]}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==t.specName&&j(()=>A.updateSpec(r.specName,{addDependsOn:[t.specName]}))},disabled:y||d,excludeSpecNames:[t.specName,...t.requiredBy||[]],placeholder:l("relationships.actions.addRequiredBy"),emptyLabel:l("relationships.empty.noSpecs")})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t pt-4",children:[e.jsxs(M,{variant:"outline",size:"sm",type:"button",onClick:()=>a(`${h}/specs?view=board&groupByParent=1`),className:"gap-2",children:[e.jsx(bt,{className:"h-4 w-4"}),l("relationships.actions.viewHierarchy")]}),e.jsxs(M,{variant:"outline",size:"sm",type:"button",onClick:()=>a(`${h}/dependencies?spec=${t.specNumber||t.id}`),className:"gap-2",children:[e.jsx(Xe,{className:"h-4 w-4"}),l("relationships.actions.viewDependencies")]})]})]})]})})}const ie=Object.entries(js).map(([t,o])=>({value:t,labelKey:o.labelKey,className:o.className,Icon:o.icon}));function _t({specName:t,value:o,onChange:p,expectedContentHash:h,disabled:d=!1,className:m}){const l=o||"planned",[a,u]=i.useState(l),[n,y]=i.useState(!1),[s,S]=i.useState(null),[v,b]=i.useState(null),{t:x}=U("common"),j=Ne();i.useEffect(()=>{u(o||"planned"),y(!1),S(null)},[o,t]);const c=ie.find(f=>f.value===a)||ie[0],w=async(f,P=!1)=>{if(f===a)return;const r=a;u(f),y(!0),S(null);try{await A.updateSpec(t,{status:f,expectedContentHash:h,force:P}),p==null||p(f),j()}catch(C){u(r);const B=C instanceof Error?C.message:x("editors.statusError");S(B)}finally{y(!1)}},T=f=>{if(f!==a){if(a==="draft"&&(f==="in-progress"||f==="complete")){b(f);return}w(f)}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ue,{value:a,onValueChange:f=>T(f),disabled:d||n,children:[e.jsx(He,{className:L("h-7 w-fit min-w-0 sm:min-w-[120px] border-0 px-2 text-xs font-medium justify-center sm:justify-start",c.className,m,n&&"opacity-70"),"aria-label":x("editors.changeStatus"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[n?e.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(c.Icon,{className:"h-3.5 w-3.5"}),e.jsx(Ke,{placeholder:x("specsPage.filters.status"),children:e.jsx("span",{className:"hidden sm:inline",children:x(c.labelKey)})})]})}),e.jsx(Qe,{children:ie.map(f=>e.jsx(We,{value:f.value,className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f.Icon,{className:"h-4 w-4"}),e.jsx("span",{children:x(f.labelKey)})]})},f.value))})]}),s&&e.jsx("p",{className:"text-xs text-destructive",children:s}),e.jsx(pe,{open:v!==null,onOpenChange:f=>!f&&b(null),children:e.jsxs(he,{children:[e.jsxs(xe,{children:[e.jsx(fe,{children:x("editors.draftSkipTitle")}),e.jsx(ge,{children:x("editors.draftSkipDescription")})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(M,{type:"button",variant:"outline",size:"sm",onClick:()=>{b(null),w("planned")},children:x("editors.draftSkipPlanned")}),e.jsx(M,{type:"button",size:"sm",onClick:()=>{if(!v)return;const f=v;b(null),w(f,!0)},children:x("editors.draftSkipForce")})]})]})})]})}const oe=Object.entries(ys).map(([t,o])=>({value:t,labelKey:o.labelKey,className:o.className,Icon:o.icon}));function Rt({specName:t,value:o,onChange:p,expectedContentHash:h,disabled:d=!1,className:m}){const l=o||"medium",[a,u]=i.useState(l),[n,y]=i.useState(!1),[s,S]=i.useState(null),{t:v}=U("common"),b=Ne();i.useEffect(()=>{u(o||"medium"),y(!1),S(null)},[o,t]);const x=oe.find(c=>c.value===a)||oe[1],j=async c=>{if(c===a)return;const w=a;u(c),y(!0),S(null);try{await A.updateSpec(t,{priority:c,expectedContentHash:h}),p==null||p(c),b()}catch(T){u(w);const f=T instanceof Error?T.message:v("editors.priorityError");S(f)}finally{y(!1)}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ue,{value:a,onValueChange:c=>j(c),disabled:d||n,children:[e.jsx(He,{className:L("h-7 w-fit min-w-0 sm:min-w-[100px] border-0 px-2 text-xs font-medium justify-center sm:justify-start",x.className,m,n&&"opacity-70"),"aria-label":v("editors.changePriority"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[n?e.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(x.Icon,{className:"h-3.5 w-3.5"}),e.jsx(Ke,{placeholder:v("specsPage.filters.priority"),children:e.jsx("span",{className:"hidden sm:inline",children:v(x.labelKey)})})]})}),e.jsx(Qe,{children:oe.map(c=>e.jsx(We,{value:c.value,className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c.Icon,{className:"h-4 w-4"}),e.jsx("span",{children:v(c.labelKey)})]})},c.value))})]}),s&&e.jsx("p",{className:"text-xs text-destructive",children:s})]})}function Pt({specName:t,value:o,onChange:p,expectedContentHash:h,disabled:d=!1,className:m,compact:l=!1}){const[a,u]=i.useState(o||[]),[n,y]=i.useState([]),[s,S]=i.useState(!1),[v,b]=i.useState(null),[x,j]=i.useState(!1),[c,w]=i.useState(""),{t:T}=U("common"),f=Ne();i.useEffect(()=>{x&&n.length===0&&(async()=>{try{const E=await A.getSpecs(),R=new Set;E.forEach(K=>{var Q;return(Q=K.tags)==null?void 0:Q.forEach(te=>R.add(te))}),y(Array.from(R).sort())}catch(E){console.error("Failed to fetch tags:",E)}})()},[x,n.length]);const P=async k=>{const E=a;u(k),S(!0),b(null);try{await A.updateSpec(t,{tags:k,expectedContentHash:h}),p==null||p(k),f()}catch(R){u(E);const K=R instanceof Error?R.message:T("editors.tagsError");b(K)}finally{S(!1)}},r=k=>{const E=k.trim();if(!E)return;if(a.includes(E)){b(T("editors.tagExists"));return}const R=[...a,E];P(R),w(""),j(!1)},C=k=>{const E=a.filter(R=>R!==k);P(E)},B=i.useMemo(()=>{const k=c.toLowerCase();return n.filter(E=>!a.includes(E)).filter(E=>!k||E.toLowerCase().includes(k))},[n,a,c]),$=c.trim()&&!a.includes(c.trim())&&!n.includes(c.trim()),z=3,W=l&&a.length>z?a.slice(0,z):a,H=a.length-W.length,G=k=>e.jsxs(ue,{variant:"outline",className:L("text-xs pr-1 gap-1",d&&"opacity-50"),children:[k,!d&&e.jsx("button",{onClick:()=>C(k),disabled:s,className:"ml-1 rounded-full hover:bg-muted p-0.5 transition-colors","aria-label":T("editors.removeTag",{tag:k}),children:e.jsx(Ve,{className:"h-3 w-3"})})]},k);return e.jsx("div",{className:L("relative",m),children:e.jsxs("div",{className:"flex gap-1 flex-wrap items-center",children:[W.map(G),H>0&&e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsxs(ue,{variant:"outline",className:"cursor-pointer hover:bg-muted h-6 px-2 text-xs",children:["+",H]})}),e.jsx(me,{className:"w-64 p-2",align:"start",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:a.map(G)})})]}),!d&&e.jsxs(ce,{open:x,onOpenChange:j,children:[e.jsx(de,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"sm",className:"h-6 px-2 text-xs",disabled:s,"aria-label":T("editors.addTag"),children:s?e.jsx(je,{className:"h-3 w-3 animate-spin"}):e.jsx(ee,{className:"h-3 w-3"})})}),e.jsxs(me,{className:"w-56 p-0",align:"start",children:[e.jsxs(Fe,{children:[e.jsx(Ie,{placeholder:T("editors.searchTag"),value:c,onValueChange:w}),e.jsxs($e,{children:[e.jsx(Be,{children:$?e.jsxs(se,{onSelect:()=>r(c),className:"cursor-pointer",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),T("editors.createTag",{tag:c.trim()})]}):e.jsx("span",{className:"text-muted-foreground px-2 py-1.5 text-sm",children:T("editors.noTagResults")})}),B.length>0&&e.jsx(De,{heading:T("editors.existingTags"),children:B.slice(0,10).map(k=>e.jsx(se,{value:k,onSelect:()=>r(k),className:"cursor-pointer",children:k},k))}),$&&B.length>0&&e.jsx(De,{heading:T("editors.createSection"),children:e.jsxs(se,{onSelect:()=>r(c),className:"cursor-pointer",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),T("editors.createTag",{tag:c.trim()})]})})]})]}),v&&e.jsx("p",{className:"text-xs text-destructive px-2 pb-2",children:v})]})]})]})})}function zt({spec:t,basePath:o,displayTitle:p,tags:h,updatedRelative:d,isFocusMode:m,setIsFocusMode:l,headerRef:a,machineModeEnabled:u,isMachineAvailable:n,applySpecPatch:y,onOpenTimeline:s,onOpenRelationships:S,onOpenSessions:v,onOpenMobile:b,timelineDialogOpen:x,setTimelineDialogOpen:j,currentTokenCount:c,currentValidationStatus:w,asyncMetadata:T,onOpenTokenDialog:f,onOpenValidationDialog:P,t:r,i18n:C}){var $;const B=c!==void 0||w!==void 0;return e.jsx("header",{ref:a,className:"lg:sticky lg:top-0 lg:z-20 border-b bg-card",children:e.jsx(ye,{padding:"none",contentClassName:L("px-4 sm:px-6 lg:px-8",m?"py-1.5":"py-2 sm:py-3"),children:m?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("h1",{className:"text-base font-semibold tracking-tight truncate",children:[t.specNumber&&e.jsxs("span",{className:"text-muted-foreground",children:["#",t.specNumber," "]}),p]}),e.jsx(vs,{status:t.status||"planned"}),e.jsx(bs,{priority:t.priority||"medium"}),t.children&&t.children.length>0&&e.jsx(Ee,{count:t.children.length}),e.jsx(Me,{count:c,size:"sm",onClick:f}),e.jsx(Le,{status:w,errorCount:T.validationErrors,size:"sm",onClick:P})]}),e.jsx(M,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(!1),className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground shrink-0",title:r("specDetail.buttons.exitFocus"),children:e.jsx(ut,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[t.parent&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-3",children:[e.jsxs(Ge,{to:`${o}/specs/${t.parent}`,className:"hover:text-primary hover:underline flex items-center gap-1 group",children:[e.jsx(Gs,{className:"h-3 w-3 group-hover:text-primary"}),e.jsx("span",{className:"font-medium",children:t.parent})]}),e.jsx(ws,{className:"h-3 w-3 opacity-50"}),e.jsx("span",{className:"truncate opacity-70",children:p})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 sm:mb-2",children:[t.children&&t.children.length>0&&e.jsx(Ee,{iconOnly:!0}),e.jsxs("h1",{className:"text-lg sm:text-xl font-bold tracking-tight",children:[t.specNumber&&e.jsxs("span",{className:"text-muted-foreground",children:["#",t.specNumber," "]}),p]}),e.jsxs(M,{variant:"ghost",size:"icon",className:"lg:hidden h-8 w-8 -mr-2 shrink-0 text-muted-foreground",onClick:b,children:[e.jsx(Ss,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:r("specDetail.toggleSidebar")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_t,{specName:t.specName,value:t.status,expectedContentHash:t.contentHash,disabled:u&&!n(),onChange:z=>y({status:z})}),e.jsx(Rt,{specName:t.specName,value:t.priority,expectedContentHash:t.contentHash,disabled:u&&!n(),onChange:z=>y({priority:z})}),B&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-px bg-border mx-1 hidden sm:block"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{count:c,size:"md",onClick:f}),e.jsx(Le,{status:w,errorCount:T.validationErrors,size:"md",onClick:P})]})]}),e.jsx("div",{className:"h-4 w-px bg-border mx-1 hidden sm:block"}),e.jsx(Pt,{specName:t.specName,value:h,expectedContentHash:t.contentHash,disabled:u&&!n(),onChange:z=>y({tags:z}),compact:!0,className:"min-w-0"})]}),u&&!n()&&e.jsx("div",{className:"text-xs text-destructive mt-2",children:r("machines.unavailable")}),e.jsxs("div",{className:"flex flex-wrap gap-2 sm:gap-4 text-xs text-muted-foreground mt-1.5 sm:mt-2",children:[e.jsxs("span",{className:"hidden sm:inline",children:[r("specDetail.metadata.created"),": ",Oe(t.createdAt,C.language)]}),e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{children:[r("specDetail.metadata.updated"),": ",Oe(t.updatedAt,C.language),d&&e.jsxs("span",{className:"ml-1 text-[11px] text-muted-foreground/80",children:["(",d,")"]})]}),e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{className:"hidden md:inline",children:[r("specDetail.metadata.name"),": ",t.specName]}),($=t.metadata)!=null&&$.assignee?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{className:"hidden sm:inline",children:[r("specDetail.metadata.assignee"),": ",String(t.metadata.assignee)]})]}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[e.jsxs(pe,{open:x,onOpenChange:j,children:[e.jsxs(M,{type:"button",variant:"outline",size:"sm","aria-haspopup":"dialog","aria-expanded":x,onClick:s,className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Pe,{className:"mr-1.5 h-3.5 w-3.5"}),r("specDetail.buttons.viewTimeline")]}),e.jsxs(he,{className:"w-[min(900px,90vw)] max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(xe,{children:[e.jsx(fe,{children:r("specDetail.dialogs.timelineTitle")}),e.jsx(ge,{children:r("specDetail.dialogs.timelineDescription")})]}),e.jsx("div",{className:"rounded-xl border border-border bg-muted/30 p-4",children:e.jsx(wt,{createdAt:t.createdAt,updatedAt:t.updatedAt,completedAt:t.completedAt,status:t.status||"planned",labels:{created:r("specTimeline.events.created"),inProgress:r("specTimeline.events.inProgress"),complete:r("specTimeline.events.complete"),archived:r("specTimeline.events.archived"),awaiting:r("specTimeline.state.awaiting"),queued:r("specTimeline.state.queued"),pending:r("specTimeline.state.pending")},language:C.language})})]})]}),e.jsxs(M,{type:"button",variant:"outline",size:"sm","aria-haspopup":"dialog",onClick:S,className:L("h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground"),children:[e.jsx(Xe,{className:"mr-1.5 h-3.5 w-3.5"}),r("relationships.button")]}),e.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:v,className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(ks,{className:"mr-1.5 h-3.5 w-3.5"}),r("navigation.sessions")]}),e.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:()=>l(!0),className:"hidden lg:inline-flex h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",title:r("specDetail.buttons.focus"),children:[e.jsx(dt,{className:"mr-1.5 h-3.5 w-3.5"}),r("specDetail.buttons.focus")]})]})]})})})}function Ft({subSpecs:t,currentSubSpec:o,onSwitch:p,t:h}){return t.length===0?null:e.jsx("div",{className:"border-t bg-muted/30",children:e.jsx(ye,{padding:"none",contentClassName:"px-4 sm:px-6 lg:px-8 overflow-x-auto",children:e.jsxs("div",{className:"flex gap-1 py-2 min-w-max",children:[e.jsxs("button",{onClick:()=>p(null),className:`flex items-center gap-2 px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium rounded-md whitespace-nowrap transition-colors ${o?"text-muted-foreground hover:text-foreground hover:bg-muted/50":"bg-background text-foreground shadow-sm"}`,children:[e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:h("specDetail.tabs.overview")})]}),t.map(d=>{const m=d.icon;return e.jsxs("button",{onClick:()=>p(d.file??null),className:`flex items-center gap-2 px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium rounded-md whitespace-nowrap transition-colors ${o===d.file?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(m,{className:`h-4 w-4 ${d.color}`}),e.jsx("span",{className:"hidden sm:inline",children:d.name})]},d.file)})]})})})}function It({content:t,specName:o="",basePath:p="",onChecklistToggle:h}){const d=Ts(o,p,h);return e.jsx("article",{className:"prose prose-sm sm:prose-base dark:prose-invert max-w-none",children:e.jsx(Ds,{remarkPlugins:[Ls,As,_s],rehypePlugins:[Es,Os,Ms],components:d,children:t})})}function $t({displayContent:t,specName:o,basePath:p,hasSubSpecs:h,onChecklistToggle:d}){const[m,l]=i.useState(()=>typeof window<"u"?window.innerWidth>=1024:!0),a=i.useRef(null),u=i.useCallback(n=>{a.current&&(a.current.disconnect(),a.current=null),n&&(l(n.clientWidth>=1024),a.current=new ResizeObserver(y=>{for(const s of y)l(s.contentRect.width>=1024)}),a.current.observe(n))},[]);return i.useEffect(()=>()=>{a.current&&a.current.disconnect()},[]),e.jsxs(e.Fragment,{children:[e.jsx(ye,{padding:"none",contentClassName:L("flex flex-col w-full",m?"lg:flex-row items-start":""),children:e.jsxs("div",{ref:u,className:"flex w-full",children:[e.jsx("main",{className:"flex-1 px-4 sm:px-6 lg:px-8 py-3 sm:py-6 min-w-0",children:e.jsx(It,{content:t,specName:o,basePath:p,onChecklistToggle:d})}),e.jsx("aside",{className:L("w-72 shrink-0 px-6 py-6 sticky overflow-y-auto scrollbar-auto-hide",m?"block":"hidden",h?"top-[calc(16.375rem-3.5rem)] h-[calc(100dvh-16.375rem)]":"top-[calc(13.125rem-3.5rem)] h-[calc(100dvh-13.125rem)]"),children:e.jsx(Js,{content:t})})]})}),e.jsx("div",{className:m?"hidden":"block",children:e.jsx(et,{content:t})}),e.jsx(Rs,{targetId:"spec-detail-main"})]})}function _e(t,o,p){const h=t.split(`
2
2
  `),d=o.trim().toLowerCase();for(let m=0;m<h.length;m++){const l=h[m],a=l.trim().toLowerCase();if((a.startsWith("- [ ]")||a.startsWith("- [x]"))&&a.includes(d)){h[m]=p?l.replace(/- \[[ ]\]/,"- [x]"):l.replace(/- \[[xX]\]/,"- [ ]");break}}return h.join(`
3
- `)}function Xt(){const{specName:t,projectId:o}=Ps(),[p]=zs(),h=qe(),{currentProject:d}=Fs(),m=o??(d==null?void 0:d.id),l=m?`/projects/${m}`:"/projects",{machineModeEnabled:a,isMachineAvailable:u}=Is(),{t:n,i18n:y}=U(["common","errors"]),[s,S]=i.useState(null),[v,b]=i.useState(!0),[x,j]=i.useState(null),c=p.get("subspec"),w=i.useRef(null),[T,f]=i.useState(!1),[P,r]=i.useState(!1),[C,B]=i.useState(!1),[$,z]=i.useState(!1),[W,H]=i.useState(!1),[G,k]=i.useState(null),[E,R]=i.useState(!1),[K,Q]=i.useState(!1),[te,ae]=i.useState(null),[ne,re]=i.useState({}),{setMobileOpen:ve}=St(),{openDrawer:Ye}=$s(),X=Bs(m??null).data??[],_=Vs(m??null,t??null),V=qs(),be=i.useCallback(g=>Ct(g,n),[n]),we=i.useCallback(async()=>{b(!0),await _.refetch()},[_]);i.useEffect(()=>{if(!(s!=null&&s.specName)||!m)return;re({});const g=s.specName;(async()=>{try{const N=await V.getSpecTokens(m,g);re(D=>({...D,tokenCount:N.tokenCount,tokenStatus:N.tokenStatus}))}catch(N){console.debug("Failed to async fetch tokens",N)}})(),(async()=>{try{const N=await V.getSpecValidation(m,g);re(D=>({...D,validationStatus:N.status,validationErrors:N.errors.length}))}catch(N){console.debug("Failed to async fetch validation",N)}})()},[V,m,s==null?void 0:s.specName]),i.useEffect(()=>{_.data&&(S(_.data),j(null),b(!1))},[_.data]),i.useEffect(()=>{_.error&&(j(be(_.error)),b(!1))},[be,_.error]),i.useEffect(()=>{_.isLoading&&b(!0)},[_.isLoading,t,m]),i.useEffect(()=>{!$||!m||!(s!=null&&s.specName)||(H(!0),V.getSpecTokens(m,s.specName).then(g=>k(g)).catch(()=>k(null)).finally(()=>H(!1)))},[V,m,s==null?void 0:s.specName,$]),i.useEffect(()=>{!E||!m||!(s!=null&&s.specName)||(Q(!0),V.getSpecValidation(m,s.specName).then(g=>ae(g)).catch(()=>ae(null)).finally(()=>Q(!1)))},[V,m,s==null?void 0:s.specName,E]);const Ze=i.useMemo(()=>s!=null&&s.specName?X.filter(g=>{var N;return(((N=g.specIds)==null?void 0:N.includes(s.specName))??!1)&&(g.status==="running"||g.status==="pending")}).length:0,[X,s==null?void 0:s.specName]),Je=i.useMemo(()=>s!=null&&s.specName?X.filter(g=>{var N;return((N=g.specIds)==null?void 0:N.includes(s.specName))??!1}).length:0,[X,s==null?void 0:s.specName]),Y=i.useMemo(()=>{var N;const g=(s==null?void 0:s.subSpecs)??((N=s==null?void 0:s.metadata)==null?void 0:N.sub_specs);return Array.isArray(g)?g.map(D=>{if(!D||typeof D!="object")return null;const O=D,F=typeof O.content=="string"?O.content:typeof O.contentMd=="string"?O.contentMd:null;if(typeof F!="string")return null;const q=typeof O.filename=="string"?O.filename:typeof O.file=="string"?O.file:typeof O.name=="string"?O.name:"",Ce=Et(q);return{name:Ot(q),content:F,file:q,icon:Ce.icon,color:Ce.color}}).filter(Boolean):[]},[s]),es=g=>{S(N=>N&&{...N,...g})},ss=i.useCallback(async(g,N)=>{if(s!=null&&s.specName){S(c?D=>{if(!D||!D.subSpecs)return D;const O=D.subSpecs.map(F=>{if(F.file===c){const q=_e(F.content||F.contentMd||"",g,N);return{...F,content:q,contentMd:q}}return F});return{...D,subSpecs:O}}:D=>{if(!D)return D;const O=_e(D.contentMd||"",g,N);return{...D,contentMd:O}});try{await A.toggleSpecChecklist(s.specName,[{itemText:g,checked:N}],{subspec:c||void 0}),_.refetch()}catch(D){console.error("Failed to toggle checklist item:",D),_.refetch()}}},[s==null?void 0:s.specName,c,_]),ts=g=>{const N=g?`${l}/specs/${t}?subspec=${g}`:`${l}/specs/${t}`;h(N)};let Se=(s==null?void 0:s.content)||(s==null?void 0:s.contentMd)||"";if(c&&s&&Y.length>0){const g=Y.find(N=>N.file===c);g&&(Se=g.content??g.contentMd??"")}const as=(s==null?void 0:s.title)||(s==null?void 0:s.specName)||"",ke=i.useMemo(()=>(s==null?void 0:s.tags)||[],[s==null?void 0:s.tags]),ns=s!=null&&s.updatedAt?Re(s.updatedAt,y.language):null,rs=ne.tokenCount??(s==null?void 0:s.tokenCount),is=ne.validationStatus??(s==null?void 0:s.validationStatus);return i.useEffect(()=>{const g=()=>{let O=0;window.innerWidth>=1024&&w.current&&(O+=w.current.offsetHeight-56);const F=document.querySelector("#spec-detail-main");F&&(F.style.scrollPaddingTop=`${O}px`)};g(),window.addEventListener("resize",g);const N=new ResizeObserver(g);return w.current&&N.observe(w.current),()=>{window.removeEventListener("resize",g),N.disconnect(),document.documentElement.style.scrollPaddingTop=""}},[s,ke]),v?e.jsx(Us,{}):x||!s?e.jsx(Hs,{icon:Ks,title:n("specDetail.state.unavailableTitle"),description:x||n("specDetail.state.unavailableDescription"),tone:"error",actions:e.jsxs(e.Fragment,{children:[e.jsx(Ge,{to:`${l}/specs`,className:"inline-flex",children:e.jsx(M,{variant:"outline",size:"sm",className:"gap-2",children:n("specDetail.links.backToSpecs")})}),e.jsxs(M,{variant:"secondary",size:"sm",className:"gap-2",onClick:()=>{we()},children:[e.jsx(st,{className:"h-4 w-4"}),n("actions.retry")]}),e.jsx("a",{href:"https://github.com/codervisor/harnspec/issues",target:"_blank",rel:"noreferrer",className:"inline-flex",children:e.jsx(M,{variant:"ghost",size:"sm",className:"gap-2",children:n("specDetail.links.reportIssue")})})]})}):e.jsxs(Qs,{className:"flex-1 min-w-0",children:[e.jsxs("div",{id:"spec-detail-main",className:"overflow-y-auto h-[calc(100dvh-3.5rem)]",children:[e.jsxs("div",{className:"lg:hidden sticky top-0 z-20 flex items-center justify-between bg-background/95 backdrop-blur border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-semibold",children:n("specsNavSidebar.title")}),e.jsx(M,{size:"sm",variant:"outline",onClick:()=>ve(!0),children:n("actions.openSidebar")})]}),e.jsx(zt,{spec:s,basePath:l,displayTitle:as,tags:ke,updatedRelative:ns,isFocusMode:C,setIsFocusMode:B,headerRef:w,machineModeEnabled:a,isMachineAvailable:u,applySpecPatch:es,onOpenTimeline:()=>f(!0),onOpenRelationships:()=>r(!0),onOpenSessions:()=>Ye(s.specName),onOpenMobile:()=>ve(!0),timelineDialogOpen:T,setTimelineDialogOpen:f,activeSessionsCount:Ze,totalSessionsCount:Je,currentTokenCount:rs,currentValidationStatus:is,asyncMetadata:ne,onOpenTokenDialog:()=>{m&&z(!0)},onOpenValidationDialog:()=>{m&&R(!0)},t:n,i18n:y}),e.jsx(Ft,{subSpecs:Y,currentSubSpec:c,onSwitch:ts,t:n}),e.jsx($t,{displayContent:Se,specName:t,basePath:l,hasSubSpecs:Y.length>0,onChecklistToggle:ss})]}),s&&e.jsx(At,{spec:s,open:P,onOpenChange:r,basePath:l,disabled:a&&!u(),onUpdated:()=>{we()}}),(s==null?void 0:s.specName)&&$&&e.jsx(Xs,{open:$,onClose:()=>{z(!1),k(null)},specName:s.specName,data:G,loading:W}),(s==null?void 0:s.specName)&&E&&e.jsx(Ys,{open:E,onClose:()=>{R(!1),ae(null)},specName:s.specName,data:te,loading:K})]})}export{Xt as SpecDetailPage};
3
+ `)}function Xt(){const{specName:t,projectId:o}=Ps(),[p]=zs(),h=qe(),{currentProject:d}=Fs(),m=o??(d==null?void 0:d.id),l=m?`/projects/${m}`:"/projects",{machineModeEnabled:a,isMachineAvailable:u}=Is(),{t:n,i18n:y}=U(["common","errors"]),[s,S]=i.useState(null),[v,b]=i.useState(!0),[x,j]=i.useState(null),c=p.get("subspec"),w=i.useRef(null),[T,f]=i.useState(!1),[P,r]=i.useState(!1),[C,B]=i.useState(!1),[$,z]=i.useState(!1),[W,H]=i.useState(!1),[G,k]=i.useState(null),[E,R]=i.useState(!1),[K,Q]=i.useState(!1),[te,ae]=i.useState(null),[ne,re]=i.useState({}),{setMobileOpen:ve}=St(),{openDrawer:Ye}=$s(),X=Bs(m??null).data??[],_=Vs(m??null,t??null),V=qs(),be=i.useCallback(g=>Ct(g,n),[n]),we=i.useCallback(async()=>{b(!0),await _.refetch()},[_]);i.useEffect(()=>{if(!(s!=null&&s.specName)||!m)return;re({});const g=s.specName;(async()=>{try{const N=await V.getSpecTokens(m,g);re(D=>({...D,tokenCount:N.tokenCount,tokenStatus:N.tokenStatus}))}catch(N){console.debug("Failed to async fetch tokens",N)}})(),(async()=>{try{const N=await V.getSpecValidation(m,g);re(D=>({...D,validationStatus:N.status,validationErrors:N.errors.length}))}catch(N){console.debug("Failed to async fetch validation",N)}})()},[V,m,s==null?void 0:s.specName]),i.useEffect(()=>{_.data&&(S(_.data),j(null),b(!1))},[_.data]),i.useEffect(()=>{_.error&&(j(be(_.error)),b(!1))},[be,_.error]),i.useEffect(()=>{_.isLoading&&b(!0)},[_.isLoading,t,m]),i.useEffect(()=>{!$||!m||!(s!=null&&s.specName)||(H(!0),V.getSpecTokens(m,s.specName).then(g=>k(g)).catch(()=>k(null)).finally(()=>H(!1)))},[V,m,s==null?void 0:s.specName,$]),i.useEffect(()=>{!E||!m||!(s!=null&&s.specName)||(Q(!0),V.getSpecValidation(m,s.specName).then(g=>ae(g)).catch(()=>ae(null)).finally(()=>Q(!1)))},[V,m,s==null?void 0:s.specName,E]);const Ze=i.useMemo(()=>s!=null&&s.specName?X.filter(g=>{var N;return(((N=g.specIds)==null?void 0:N.includes(s.specName))??!1)&&(g.status==="running"||g.status==="pending")}).length:0,[X,s==null?void 0:s.specName]),Je=i.useMemo(()=>s!=null&&s.specName?X.filter(g=>{var N;return((N=g.specIds)==null?void 0:N.includes(s.specName))??!1}).length:0,[X,s==null?void 0:s.specName]),Y=i.useMemo(()=>{var N;const g=(s==null?void 0:s.subSpecs)??((N=s==null?void 0:s.metadata)==null?void 0:N.sub_specs);return Array.isArray(g)?g.map(D=>{if(!D||typeof D!="object")return null;const O=D,F=typeof O.content=="string"?O.content:typeof O.contentMd=="string"?O.contentMd:null;if(typeof F!="string")return null;const q=typeof O.filename=="string"?O.filename:typeof O.file=="string"?O.file:typeof O.name=="string"?O.name:"",Ce=Et(q);return{name:Ot(q),content:F,file:q,icon:Ce.icon,color:Ce.color}}).filter(Boolean):[]},[s]),es=g=>{S(N=>N&&{...N,...g})},ss=i.useCallback(async(g,N)=>{if(s!=null&&s.specName){S(c?D=>{if(!D||!D.subSpecs)return D;const O=D.subSpecs.map(F=>{if(F.file===c){const q=_e(F.content||F.contentMd||"",g,N);return{...F,content:q,contentMd:q}}return F});return{...D,subSpecs:O}}:D=>{if(!D)return D;const O=_e(D.contentMd||"",g,N);return{...D,contentMd:O}});try{await A.toggleSpecChecklist(s.specName,[{itemText:g,checked:N}],{subspec:c||void 0}),_.refetch()}catch(D){console.error("Failed to toggle checklist item:",D),_.refetch()}}},[s==null?void 0:s.specName,c,_]),ts=g=>{const N=g?`${l}/specs/${t}?subspec=${g}`:`${l}/specs/${t}`;h(N)};let Se=(s==null?void 0:s.content)||(s==null?void 0:s.contentMd)||"";if(c&&s&&Y.length>0){const g=Y.find(N=>N.file===c);g&&(Se=g.content??g.contentMd??"")}const as=(s==null?void 0:s.title)||(s==null?void 0:s.specName)||"",ke=i.useMemo(()=>(s==null?void 0:s.tags)||[],[s==null?void 0:s.tags]),ns=s!=null&&s.updatedAt?Re(s.updatedAt,y.language):null,rs=ne.tokenCount??(s==null?void 0:s.tokenCount),is=ne.validationStatus??(s==null?void 0:s.validationStatus);return i.useEffect(()=>{const g=()=>{let O=0;window.innerWidth>=1024&&w.current&&(O+=w.current.offsetHeight-56);const F=document.querySelector("#spec-detail-main");F&&(F.style.scrollPaddingTop=`${O}px`)};g(),window.addEventListener("resize",g);const N=new ResizeObserver(g);return w.current&&N.observe(w.current),()=>{window.removeEventListener("resize",g),N.disconnect(),document.documentElement.style.scrollPaddingTop=""}},[s,ke]),v?e.jsx(Us,{}):x||!s?e.jsx(Hs,{icon:Ks,title:n("specDetail.state.unavailableTitle"),description:x||n("specDetail.state.unavailableDescription"),tone:"error",actions:e.jsxs(e.Fragment,{children:[e.jsx(Ge,{to:`${l}/specs`,className:"inline-flex",children:e.jsx(M,{variant:"outline",size:"sm",className:"gap-2",children:n("specDetail.links.backToSpecs")})}),e.jsxs(M,{variant:"secondary",size:"sm",className:"gap-2",onClick:()=>{we()},children:[e.jsx(st,{className:"h-4 w-4"}),n("actions.retry")]}),e.jsx("a",{href:"https://github.com/harnspec/harnspec/issues",target:"_blank",rel:"noreferrer",className:"inline-flex",children:e.jsx(M,{variant:"ghost",size:"sm",className:"gap-2",children:n("specDetail.links.reportIssue")})})]})}):e.jsxs(Qs,{className:"flex-1 min-w-0",children:[e.jsxs("div",{id:"spec-detail-main",className:"overflow-y-auto h-[calc(100dvh-3.5rem)]",children:[e.jsxs("div",{className:"lg:hidden sticky top-0 z-20 flex items-center justify-between bg-background/95 backdrop-blur border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-semibold",children:n("specsNavSidebar.title")}),e.jsx(M,{size:"sm",variant:"outline",onClick:()=>ve(!0),children:n("actions.openSidebar")})]}),e.jsx(zt,{spec:s,basePath:l,displayTitle:as,tags:ke,updatedRelative:ns,isFocusMode:C,setIsFocusMode:B,headerRef:w,machineModeEnabled:a,isMachineAvailable:u,applySpecPatch:es,onOpenTimeline:()=>f(!0),onOpenRelationships:()=>r(!0),onOpenSessions:()=>Ye(s.specName),onOpenMobile:()=>ve(!0),timelineDialogOpen:T,setTimelineDialogOpen:f,activeSessionsCount:Ze,totalSessionsCount:Je,currentTokenCount:rs,currentValidationStatus:is,asyncMetadata:ne,onOpenTokenDialog:()=>{m&&z(!0)},onOpenValidationDialog:()=>{m&&R(!0)},t:n,i18n:y}),e.jsx(Ft,{subSpecs:Y,currentSubSpec:c,onSwitch:ts,t:n}),e.jsx($t,{displayContent:Se,specName:t,basePath:l,hasSubSpecs:Y.length>0,onChecklistToggle:ss})]}),s&&e.jsx(At,{spec:s,open:P,onOpenChange:r,basePath:l,disabled:a&&!u(),onUpdated:()=>{we()}}),(s==null?void 0:s.specName)&&$&&e.jsx(Xs,{open:$,onClose:()=>{z(!1),k(null)},specName:s.specName,data:G,loading:W}),(s==null?void 0:s.specName)&&E&&e.jsx(Ys,{open:E,onClose:()=>{R(!1),ae(null)},specName:s.specName,data:te,loading:K})]})}export{Xt as SpecDetailPage};
@@ -1 +1 @@
1
- import{h as Xe,r,u as xe,j as e,cI as Oe,cc as Ye,cb as Je,bX as es,bU as ss,f as P,c8 as ge,ca as fe,bW as ts,bD as ee,bE as $e,cJ as hs,c9 as as,cK as xs,cL as gs,bn as fs,b0 as Ns,br as Ge,bo as bs,b5 as Ce,b6 as De,a as z,b8 as Me,bf as Le,cM as js,cN as vs,cO as ys,aT as rs,aX as ws,aY as ks,aZ as Ss,a_ as Cs,a$ as J,cE as Ds,cP as Ms,cQ as Ls,c5 as Ts,cR as As,cS as Te,cn as Ps,L as Is,cT as Os,bg as Es,bh as Bs,cU as Vs,cV as $s,cW as Hs,cX as Ae,cY as qs,bl as zs,cZ as _s,c_ as Ks,c7 as Ue,aS as Pe,c$ as Rs,C as Fs,l as Qs,bm as Gs,bs as Ze,D as Us,b as Zs,c as Ws,d as Xs,b1 as Ys}from"./index-Bo42UlS3.js";import{C as Js,T as Ne,V as be,a as et,b as st}from"./validation-badge-IPkKaNb8.js";import{F as tt,a as at}from"./funnel-x-BS_Cfod-.js";import{R as We}from"./refresh-ccw-CfzFVZ57.js";import"./token-utils-x_d_uTQu.js";import"./info-CjwfpSMh.js";const rt=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],se=Xe("folder-tree",rt);const nt=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ct=Xe("layout-grid",nt),lt=3,Ee={draft:{icon:ss,titleKey:"status.draft",colorClass:"text-slate-600 dark:text-slate-300",bgClass:"bg-slate-50 dark:bg-slate-900/20",borderClass:"border-slate-200 dark:border-slate-800"},planned:{icon:es,titleKey:"status.planned",colorClass:"text-blue-600 dark:text-blue-400",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800"},"in-progress":{icon:Je,titleKey:"status.inProgress",colorClass:"text-orange-600 dark:text-orange-400",bgClass:"bg-orange-50 dark:bg-orange-900/20",borderClass:"border-orange-200 dark:border-orange-800"},complete:{icon:Ye,titleKey:"status.complete",colorClass:"text-green-600 dark:text-green-400",bgClass:"bg-green-50 dark:bg-green-900/20",borderClass:"border-green-200 dark:border-green-800"},archived:{icon:Oe,titleKey:"status.archived",colorClass:"text-gray-600 dark:text-gray-400",bgClass:"bg-gray-50 dark:bg-gray-900/20",borderClass:"border-gray-200 dark:border-gray-800"}};function Be({spec:n,basePath:s,canEdit:d=!0,draggingId:i,onDragStart:a,onDragEnd:x,onTokenClick:c,onValidationClick:l,onPriorityChange:f,childCount:j,isExpanded:M,onToggle:g}){const T=j!==void 0&&g!==void 0;return e.jsxs("div",{className:P("bg-background rounded-xl border border-primary/20 shadow-sm relative overflow-hidden group/parent hover:border-primary/50 hover:shadow-md transition-all",i===n.specName&&"opacity-50",d?"cursor-move":"cursor-not-allowed opacity-70"),draggable:d,onDragStart:a?y=>a(n,y):void 0,onDragEnd:x,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-primary/40 to-primary/10"}),e.jsxs("div",{className:"p-3 pb-2 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs(ge,{to:`${s}/specs/${n.specName}`,className:"flex-1 min-w-0 group hover:text-primary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsxs("span",{className:"text-[10px] font-mono font-medium text-primary/70 bg-primary/5 px-1 rounded",children:["#",n.specNumber||n.specName.split("-")[0].replace(/^0+/,"")]}),T&&e.jsx(se,{className:"h-3 w-3 text-primary/40"})]}),e.jsx("h4",{className:"font-semibold text-sm truncate leading-tight",title:n.title||n.specName,children:n.title||n.specName})]}),T&&e.jsx("button",{onClick:y=>{y.preventDefault(),g()},className:"p-1 hover:bg-muted rounded-md text-muted-foreground transition-colors",children:M?e.jsx(ee,{className:"h-4 w-4"}):e.jsx($e,{className:"h-4 w-4"})})]}),n.tags&&n.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.tags.slice(0,3).map(y=>e.jsx("span",{className:"text-[10px] bg-secondary text-secondary-foreground px-1.5 py-0.5 rounded-full",children:y},y)),n.tags.length>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",n.tags.length-3]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[n.status&&Ee[n.status]&&(()=>{const y=Ee[n.status],o=y.icon;return e.jsx(o,{className:P("h-3.5 w-3.5",y.colorClass)})})(),n.priority&&e.jsx(fe,{priority:n.priority,className:"h-5 text-[10px] px-1.5",editable:!!f&&d,onChange:y=>f==null?void 0:f(n,y)}),T&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",title:`${j} children`,children:[e.jsx(ts,{className:"h-3 w-3"}),j]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ne,{count:n.tokenCount,size:"sm",onClick:c?()=>c(n.specName):void 0,className:"h-5 px-1.5 scale-90 origin-right"}),n.validationStatus&&n.validationStatus!=="pass"&&e.jsx(be,{status:n.validationStatus,size:"sm",onClick:l?()=>l(n.specName):void 0,className:"h-5 px-1.5 scale-90 origin-right"})]})]})]}),T&&!M&&e.jsx("div",{onClick:g,className:"bg-muted/30 p-1 flex justify-center cursor-pointer hover:bg-muted/50 transition-colors border-t border-border/20",children:e.jsx(ee,{className:"h-3 w-3 text-muted-foreground/50"})})]})}function it({parentName:n,specs:s,parentSpec:d,basePath:i,onTokenClick:a,onValidationClick:x,onPriorityChange:c,canEdit:l,draggingId:f,onDragStart:j,onDragEnd:M}){const g=`harnspec_board_expanded_${n}`,T=s.length<=lt,[y,o]=r.useState(()=>{try{const C=sessionStorage.getItem(g);return C!==null?C==="true":T}catch{return T}}),L=()=>{const C=!y;o(C);try{sessionStorage.setItem(g,String(C))}catch{}};return e.jsxs("div",{className:"space-y-2 mt-4 first:mt-0",children:[d?e.jsx(Be,{spec:d,childCount:s.length,isExpanded:y,onToggle:L,basePath:i,canEdit:l,draggingId:f,onDragStart:j,onDragEnd:M,onTokenClick:a,onValidationClick:x,onPriorityChange:c}):e.jsxs("div",{className:"flex items-center gap-2 px-1 pb-1 border-b border-border/30 cursor-pointer hover:bg-muted/20 rounded p-1",onClick:L,children:[e.jsx(se,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsx("h5",{className:"text-xs font-semibold text-foreground/80 truncate flex-1",title:n,children:n}),e.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground font-mono",children:s.length}),y?e.jsx(ee,{className:"h-3 w-3 text-muted-foreground"}):e.jsx($e,{className:"h-3 w-3 text-muted-foreground"})]}),y&&e.jsx("div",{className:P("space-y-2 transition-all",d&&"pl-2 border-l-2 border-border/30 ml-2"),children:s.map(C=>e.jsx(Be,{spec:C,basePath:i,canEdit:l,draggingId:f,onDragStart:j,onDragEnd:M,onTokenClick:a,onValidationClick:x,onPriorityChange:c},C.specName))})]})}const ot=r.memo(function({specs:s,onStatusChange:d,onPriorityChange:i,basePath:a="/projects",canEdit:x=!0,groupByParent:c=!1,showArchived:l=!1,onTokenClick:f,onValidationClick:j}){const[M,g]=r.useState(null),[T,y]=r.useState(null),{t:o}=xe("common"),L=r.useMemo(()=>new Map(s.map(t=>[t.specName,t])),[s]),C=r.useMemo(()=>{const p=s.some(w=>w.status==="draft")?["draft","planned","in-progress","complete"]:["planned","in-progress","complete"];return l&&p.push("archived"),p},[l,s]),$=r.useMemo(()=>{const t={draft:[],planned:[],"in-progress":[],complete:[],archived:[]};return s.forEach(p=>{const w=p.status;w&&t[w].push(p)}),t},[s]),_=(t,p)=>{x&&(g(t.specName),p.dataTransfer.effectAllowed="move")},H=()=>{g(null),y(null)},I=t=>{t.currentTarget.contains(t.relatedTarget)||y(null)},F=(t,p)=>{x&&(p.preventDefault(),p.dataTransfer.dropEffect="move",T!==t&&y(t))},U=(t,p)=>{if(x&&(p.preventDefault(),y(null),M)){const w=s.find(q=>q.specName===M);w&&w.status!==t&&d(w,t),g(null)}},te=(t,p=!1)=>e.jsx("div",{draggable:x,onDragStart:w=>_(t,w),onDragEnd:H,className:P("bg-background rounded-xl border shadow-sm cursor-move hover:border-primary/50 transition-all group/card relative",p?"p-2.5 border-border/50 text-sm shadow-none bg-background/50":"p-4",M===t.specName&&"opacity-50",!x&&"cursor-not-allowed opacity-70"),children:e.jsxs(ge,{to:`${a}/specs/${t.specName}`,className:"select-none h-full flex flex-col",children:[t.children&&t.children.length>0&&!p&&e.jsx("div",{className:"absolute top-3 right-3 text-primary/50",title:o("specs.hierarchy.umbrella"),children:e.jsx(se,{className:"w-4 h-4"})}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono mb-1 flex items-center gap-1",children:[e.jsxs("span",{className:P(p&&"text-[10px]"),children:["#",t.specNumber||t.specName.split("-")[0].replace(/^0+/,"")]}),p&&t.children&&t.children.length>0&&e.jsx(se,{className:"w-3 h-3 text-primary/40 ml-1"})]}),e.jsxs("div",{className:P("space-y-1 mb-3 flex-1",p?"mb-1.5":"mb-4"),children:[e.jsx("h4",{className:P("font-semibold leading-snug group-hover/card:text-primary transition-colors pr-6",p?"text-xs":"text-base"),children:t.title||t.specName}),!p&&e.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:t.specName}),t.parent&&!c&&e.jsxs("div",{className:"flex items-center text-xs text-muted-foreground mt-1 bg-muted/30 p-1 rounded w-fit max-w-full",children:[e.jsx(Js,{className:"h-3 w-3 mr-1 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:o("specs.hierarchy.inParent",{parent:t.parent})})]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{className:P("flex flex-wrap gap-1.5 mb-3",p?"mb-1.5":"mb-3"),children:[t.tags.slice(0,p?2:4).map(w=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-secondary/30 border border-border/50 rounded-md text-muted-foreground font-mono truncate max-w-[120px]",children:w},w)),t.tags.length>(p?2:4)&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-secondary/20 border border-border/30 rounded-md text-muted-foreground/70 font-mono",children:["+",t.tags.length-(p?2:4)]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-auto",children:[t.priority&&e.jsx(fe,{priority:t.priority,className:P("rounded-md",p?"h-5 text-[10px] px-1.5 scale-90 origin-left":"h-6 px-2.5"),iconOnly:p,editable:!!i&&x,onChange:w=>i==null?void 0:i(t,w)}),e.jsxs("div",{className:"flex items-center gap-1.5 justify-end ml-auto",children:[e.jsx(Ne,{count:t.tokenCount,size:"sm",onClick:f?()=>f(t.specName):void 0,className:P(p&&"px-1.5 h-5 scale-90 origin-right"),showIcon:!p}),e.jsx(be,{status:t.validationStatus,size:"sm",onClick:j?()=>j(t.specName):void 0,className:P(p&&"px-1.5 h-5 scale-90 origin-right")}),t.children&&t.children.length>0&&!p&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 bg-primary/10 border border-primary/20 rounded-md text-primary font-medium flex items-center gap-1",children:[e.jsx(ts,{className:"h-3 w-3"}),t.children.length]})]})]})]})},t.specName),Z=t=>{if(!c)return e.jsx("div",{className:"space-y-2",children:t.map(S=>te(S))});const p=[],w=[],q=new Set;return s.forEach(S=>{S.children&&S.children.length>0&&S.children.forEach(V=>q.add(V))}),t.forEach(S=>{q.has(S.specName)||(S.children&&S.children.length>0?p.push(S):w.push(S))}),p.sort((S,V)=>S.specName.localeCompare(V.specName)),e.jsxs("div",{className:"space-y-2",children:[w.map(S=>e.jsx(Be,{spec:S,basePath:a,canEdit:x,draggingId:M,onDragStart:_,onDragEnd:H,onTokenClick:f,onValidationClick:j,onPriorityChange:i},S.specName)),p.map(S=>{const V=(S.children||[]).map(R=>L.get(R)).filter(R=>R!==void 0);return e.jsx(it,{parentName:S.specName,specs:V,parentSpec:S,basePath:a,canEdit:x,draggingId:M,onDragStart:_,onDragEnd:H,onTokenClick:f,onValidationClick:j,onPriorityChange:i},S.specName)})]})},k=t=>{if(!c)return t.length;const p=new Set;return s.forEach(w=>{w.children&&w.children.length>0&&w.children.forEach(q=>p.add(q))}),t.filter(w=>!p.has(w.specName)).length};return e.jsx("div",{className:"flex flex-col md:flex-row gap-3 sm:gap-4 md:gap-6 h-full pb-2 md:snap-x md:snap-mandatory overflow-y-auto md:overflow-y-hidden md:overflow-x-auto",children:C.map(t=>{const p=Ee[t],w=$[t]||[],q=p.icon,S=T===t;return e.jsxs("div",{className:P("flex-shrink-0 w-80 flex flex-col rounded-lg bg-secondary/30 border border-transparent transition-colors",S&&"bg-secondary/60 border-primary/50 ring-2 ring-primary/20"),onDragOver:V=>F(t,V),onDragLeave:I,onDrop:V=>U(t,V),children:[e.jsx("div",{className:P("p-3 flex items-center justify-between border-b sticky top-0 z-10 backdrop-blur-sm bg-opacity-90",p.borderClass,p.bgClass,"rounded-t-lg"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:P("w-4 h-4",p.colorClass)}),e.jsx("span",{className:P("font-medium text-sm",p.colorClass),children:o(p.titleKey)}),e.jsx("span",{className:"text-xs px-2 py-0.5 bg-background/50 rounded-full text-muted-foreground",children:k(w)})]})}),e.jsx("div",{className:"flex-1 p-2 overflow-y-auto",children:Z(w)})]},t)})})});function ns(n,s){const d=[...n];switch(s){case"id-asc":d.sort((i,a)=>(i.specNumber||0)-(a.specNumber||0));break;case"priority-desc":d.sort((i,a)=>{const x={critical:4,high:3,medium:2,low:1},c=x[i.priority||""]||0,f=(x[a.priority||""]||0)-c;return f!==0?f:(a.specNumber||0)-(i.specNumber||0)});break;case"priority-asc":d.sort((i,a)=>{const x={critical:4,high:3,medium:2,low:1},c=x[i.priority||""]||0,l=x[a.priority||""]||0,f=c-l;return f!==0?f:(a.specNumber||0)-(i.specNumber||0)});break;case"updated-desc":d.sort((i,a)=>{const x="updatedAt"in i?i.updatedAt:void 0,c="updatedAt"in a?a.updatedAt:void 0;if(!x)return 1;if(!c)return-1;const l=new Date(x).getTime(),j=new Date(c).getTime()-l;return j!==0?j:(a.specNumber||0)-(i.specNumber||0)});break;case"title-asc":d.sort((i,a)=>{const x=(i.title||i.specName).toLowerCase(),c=(a.title||a.specName).toLowerCase(),l=x.localeCompare(c);return l!==0?l:(a.specNumber||0)-(i.specNumber||0)});break;default:d.sort((i,a)=>(a.specNumber||0)-(i.specNumber||0));break}return d}const dt=r.memo(function n({node:s,basePath:d,depth:i=0,sortBy:a="id-desc",onTokenClick:x,onValidationClick:c,onNodeStatusChange:l,onNodePriorityChange:f}){const[j,M]=r.useState(i<1),g=s.childNodes&&s.childNodes.length>0,T=r.useCallback(o=>{o.stopPropagation(),M(L=>!L)},[]),y=r.useMemo(()=>g?ns(s.childNodes,a):[],[g,s.childNodes,a]);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:P("border rounded-lg bg-background transition-colors","hover:bg-secondary/50"),children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:P("w-8 h-full px-2 py-5 cursor-pointer text-muted-foreground hover:text-foreground flex items-center",!g&&"invisible pointer-events-none"),onClick:T,children:g&&e.jsx($e,{className:P("h-4 w-4 transition-transform",j&&"rotate-90")})}),e.jsxs(ge,{to:`${d}/specs/${s.specName}`,className:"flex-1 p-4 pl-0 block",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[g&&e.jsx(se,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:["#",s.specNumber]}),e.jsx("h3",{className:"font-medium truncate",children:s.title||s.specName})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.specName})]}),e.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.status&&e.jsx(as,{status:s.status,editable:!!l,onChange:o=>l==null?void 0:l(s.specName,o)}),s.priority&&e.jsx(fe,{priority:s.priority,editable:!!f,onChange:o=>f==null?void 0:f(s.specName,o)}),e.jsx(Ne,{count:s.tokenCount,size:"sm",onClick:x?()=>x(s.specName):void 0}),e.jsx(be,{status:s.validationStatus,size:"sm",onClick:c?()=>c(s.specName):void 0})]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex gap-2 mt-3 flex-wrap",children:s.tags.map(o=>e.jsx("span",{className:"text-xs px-2 py-0.5 bg-secondary rounded text-secondary-foreground",children:o},o))})]})]})}),g&&e.jsx(xs,{open:j,children:e.jsx(gs,{forceMount:j?!0:void 0,children:e.jsx("div",{className:"ml-4 pl-4 border-l-2 border-border/40 space-y-2 mt-2 mb-4",children:y.map(o=>e.jsx(n,{node:o,basePath:d,depth:i+1,sortBy:a,onTokenClick:x,onValidationClick:c,onNodeStatusChange:l,onNodePriorityChange:f},o.specName))})})})]})});function Ve(n,s){const d=[];for(const i of n)if(s.has(i.specName)){const a=i.childNodes?Ve(i.childNodes,s):[];d.push({...i,childNodes:a})}else if(i.childNodes&&i.childNodes.length>0){const a=Ve(i.childNodes,s);a.length>0&&d.push({...i,childNodes:a})}return d}const mt=r.memo(function({specs:s,hierarchy:d,basePath:i="/projects",sortBy:a="id-desc",onTokenClick:x,onValidationClick:c,onStatusChange:l,onPriorityChange:f}){const j=r.useMemo(()=>new Set(s.map(o=>o.specName)),[s]),M=r.useMemo(()=>new Map(s.map(o=>[o.specName,o])),[s]),g=r.useCallback((o,L)=>{const C=M.get(o);C&&l&&l(C,L)},[M,l]),T=r.useCallback((o,L)=>{const C=M.get(o);C&&f&&f(C,L)},[M,f]),y=r.useMemo(()=>{let o;return d!==void 0?o=Ve(d,j):o=hs(s),ns(o,a)},[d,s,a,j]);return s.length===0?null:e.jsx("div",{className:"h-full overflow-y-auto space-y-2",children:y.map(o=>e.jsx(dt,{node:o,basePath:i,depth:0,sortBy:a,onTokenClick:x,onValidationClick:c,onNodeStatusChange:l?g:void 0,onNodePriorityChange:f?T:void 0},o.specName))})}),Ie=120,ut=120,pt=r.memo(function({spec:s,basePath:d,onTokenClick:i,onValidationClick:a,onStatusChange:x,onPriorityChange:c}){return e.jsx(ge,{to:`${d}/specs/${s.specName}`,className:"block border rounded-lg hover:bg-secondary/50 transition-colors bg-background",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"w-8 h-full invisible flex items-center text-muted-foreground"}),e.jsxs("div",{className:"flex-1 p-4 pl-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:["#",s.specNumber]}),e.jsx("h3",{className:"font-medium truncate",children:s.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.specName})]}),e.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.status&&e.jsx(as,{status:s.status,editable:!!x,onChange:l=>x==null?void 0:x(s,l)}),s.priority&&e.jsx(fe,{priority:s.priority,editable:!!c,onChange:l=>c==null?void 0:c(s,l)}),e.jsx(Ne,{count:s.tokenCount,size:"sm",onClick:()=>i(s.specName)}),e.jsx(be,{status:s.validationStatus,size:"sm",onClick:()=>a(s.specName)})]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex gap-2 mt-3 flex-wrap",children:s.tags.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 bg-secondary rounded text-secondary-foreground",children:l},l))})]})]})})}),ht=r.memo(function({specs:s,hierarchy:d,basePath:i="/projects",groupByParent:a=!1,sortBy:x="id-desc",onTokenClick:c,onValidationClick:l,onStatusChange:f,onPriorityChange:j}){const{t:M}=xe("common"),[g,T]=r.useState(Ie);r.useEffect(()=>{if(a)return;const o=s.length,L=Math.min(Ie,o);if(typeof window>"u")return;let C=null,$=!1;const _=()=>{if($||(T(L),o<=Ie))return;const H=()=>{$||T(I=>{const F=Math.min(I+ut,o);return F<o&&!$&&(C=window.requestAnimationFrame(H)),F})};C=window.requestAnimationFrame(H)};return C=window.requestAnimationFrame(_),()=>{$=!0,C!==null&&window.cancelAnimationFrame(C)}},[a,s.length]);const y=r.useMemo(()=>a?s:s.slice(0,g),[a,s,g]);return s.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground border rounded-lg bg-secondary/10",children:M("specsPage.list.empty")}):a?e.jsx(mt,{specs:s,hierarchy:d,basePath:i,sortBy:x,onTokenClick:c,onValidationClick:l,onStatusChange:f,onPriorityChange:j}):e.jsxs("div",{className:"h-full overflow-y-auto space-y-2",children:[y.map(o=>e.jsx(pt,{spec:o,basePath:i,onTokenClick:L=>c==null?void 0:c(L),onValidationClick:L=>l==null?void 0:l(L),onStatusChange:f,onPriorityChange:j},o.specName)),!a&&g<s.length&&e.jsx("div",{className:"py-3 text-center text-xs text-muted-foreground",children:M("specsPage.list.loadingMore",{visible:g,total:s.length,defaultValue:"Rendering {{visible}} / {{total}} specs..."})})]})});function xt({searchQuery:n,onSearchChange:s,statusFilter:d,onStatusFilterChange:i,priorityFilter:a,onPriorityFilterChange:x,tagFilter:c,onTagFilterChange:l,sortBy:f,onSortByChange:j,uniqueStatuses:M,uniquePriorities:g,uniqueTags:T,onClearFilters:y,totalSpecs:o,filteredCount:L,viewMode:C,onViewModeChange:$,groupByParent:_,onGroupByParentChange:H,showValidationIssuesOnly:I,onShowValidationIssuesOnlyChange:F,showArchived:U,onShowArchivedChange:te,loadingValidation:Z}){const{t:k}=xe("common"),[t,p]=r.useState(n);r.useEffect(()=>{p(n)},[n]),r.useEffect(()=>{const N=setTimeout(()=>{t!==n&&s(t)},120);return()=>clearTimeout(N)},[t,s,n]);const w={draft:ss,planned:es,"in-progress":Je,complete:Ye,archived:Oe},q={critical:rs,high:ys,medium:vs,low:js},S={draft:"status.draft",planned:"status.planned","in-progress":"status.inProgress",complete:"status.complete",archived:"status.archived"},V={critical:"priority.critical",high:"priority.high",medium:"priority.medium",low:"priority.low"},R=N=>S[N]?k(S[N]):N,W=N=>V[N]?k(V[N]):N,ae=n||d.length>0||a.length>0||c.length>0||I,X=_||I||U,je=N=>{i(d.includes(N)?d.filter(O=>O!==N):[...d,N])},ie=N=>{x(a.includes(N)?a.filter(O=>O!==N):[...a,N])},ve=N=>{l(c.includes(N)?c.filter(O=>O!==N):[...c,N])};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ns,{type:"text",placeholder:k("specsPage.searchPlaceholder"),value:t,onChange:N=>p(N.target.value),className:"w-full pl-10 pr-10 py-2"}),t&&e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>{p(""),s("")},children:e.jsx(Ge,{className:"w-4 h-4"})})]}),t&&e.jsx("p",{className:"text-xs text-muted-foreground pl-1",children:k("specsPage.searchHint")})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(bs,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:k("specsNavSidebar.filtersLabel")})]}),e.jsxs(Ce,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(z,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:d.length===0?k("specsPage.filters.statusAll"):d.length===1?R(d[0]):`${d.length} ${k("specsNavSidebar.selected")}`}),e.jsx(ee,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1",children:M.map(N=>{const O=w[N],K=d.includes(N);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>je(N),children:[e.jsx("div",{className:P("flex items-center justify-center w-4 h-4 border rounded transition-colors",K?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:K&&e.jsx(Le,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O&&e.jsx(O,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:R(N)})]})]},N)})})})]}),e.jsxs(Ce,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(z,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:a.length===0?k("specsPage.filters.priorityAll"):a.length===1?W(a[0]):`${a.length} ${k("specsNavSidebar.selected")}`}),e.jsx(ee,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1",children:g.map(N=>{const O=q[N],K=a.includes(N);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>ie(N),children:[e.jsx("div",{className:P("flex items-center justify-center w-4 h-4 border rounded transition-colors",K?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:K&&e.jsx(Le,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O&&e.jsx(O,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:W(N)})]})]},N)})})})]}),e.jsxs(Ce,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(z,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:c.length===0?k("specsNavSidebar.select.tag.all"):c.length===1?c[0]:`${c.length} ${k("specsNavSidebar.selected")}`}),e.jsx(ee,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:T.map(N=>{const O=c.includes(N);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>ve(N),children:[e.jsx("div",{className:P("flex items-center justify-center w-4 h-4 border rounded transition-colors",O?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:O&&e.jsx(Le,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm flex-1 break-all",children:N})]},N)})})})]}),e.jsxs(ws,{value:f,onValueChange:j,children:[e.jsx(ks,{className:"w-[160px]",children:e.jsx(Ss,{placeholder:k("specsPage.filters.sort")})}),e.jsxs(Cs,{children:[e.jsx(J,{value:"id-desc",children:k("specsPage.filters.sortOptions.id-desc")}),e.jsx(J,{value:"id-asc",children:k("specsPage.filters.sortOptions.id-asc")}),e.jsx(J,{value:"updated-desc",children:k("specsPage.filters.sortOptions.updated-desc")}),e.jsx(J,{value:"title-asc",children:k("specsPage.filters.sortOptions.title-asc")}),e.jsx(J,{value:"priority-desc",children:k("specsPage.filters.sortOptions.priority-desc")}),e.jsx(J,{value:"priority-asc",children:k("specsPage.filters.sortOptions.priority-asc")})]})]}),ae&&e.jsxs(z,{onClick:y,variant:"ghost",size:"sm",className:"h-9 gap-1",children:[e.jsx(Ge,{className:"w-4 h-4"}),k("specsNavSidebar.clearFilters")]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1.5",children:[Z&&I&&e.jsx(Ds,{className:"w-3 h-3 animate-spin"}),k("specsPage.filters.filteredCount",{filtered:L,total:o})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ms,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(z,{variant:X?"secondary":"outline",size:"sm",className:"h-9 gap-1.5",children:[e.jsx(Ts,{className:P("w-4 h-4",X?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"hidden sm:inline",children:k("specsPage.filters.settings")})]})}),e.jsxs(As,{align:"end",className:"w-48",children:[e.jsxs(Te,{checked:_,onCheckedChange:H,children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.groupByParent")]}),e.jsxs(Te,{checked:I,onCheckedChange:F,children:[e.jsx(Ps,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.withErrors")]}),e.jsxs(Te,{checked:U,onCheckedChange:te,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.showArchived")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-secondary/50 p-1 rounded-lg border h-9",children:[e.jsxs(z,{variant:C==="list"?"secondary":"ghost",size:"sm",onClick:()=>$("list"),className:P("h-7",C==="list"&&"bg-background shadow-sm"),title:k("specsPage.views.listTooltip"),children:[e.jsx(Is,{className:"w-4 h-4 mr-1.5"}),k("specsPage.views.list")]}),e.jsxs(z,{variant:C==="board"?"secondary":"ghost",size:"sm",onClick:()=>$("board"),className:P("h-7",C==="board"&&"bg-background shadow-sm"),title:k("specsPage.views.boardTooltip"),children:[e.jsx(ct,{className:"w-4 h-4 mr-1.5"}),k("specsPage.views.board")]})]})]})]})]})}function gt(n){const[s,d]=r.useState(null),[i,a]=r.useState(!1),[x,c]=r.useState(!1),[l,f]=r.useState(null),[j,M]=r.useState(!1),[g,T]=r.useState(!1),[y,o]=r.useState(null),L=Os(),C=r.useCallback(()=>{a(!1),c(!1),f(null)},[]),$=r.useCallback(()=>{M(!1),T(!1),o(null)},[]),_=r.useCallback(I=>{n&&(d(I),a(!0))},[n]),H=r.useCallback(I=>{n&&(d(I),M(!0))},[n]);return r.useEffect(()=>{!i||!s||!n||(c(!0),L.getSpecTokens(n,s).then(I=>f(I)).catch(()=>f(null)).finally(()=>c(!1)))},[s,L,n,i]),r.useEffect(()=>{!j||!s||!n||(T(!0),L.getSpecValidation(n,s).then(I=>o(I)).catch(()=>o(null)).finally(()=>T(!1)))},[s,L,n,j]),{activeSpecName:s,tokenDialogOpen:i,tokenDialogLoading:x,tokenDialogData:l,closeTokenDialog:C,handleTokenClick:_,validationDialogOpen:j,validationDialogLoading:g,validationDialogData:y,closeValidationDialog:$,handleValidationClick:H}}const ft=120;function kt(){const{projectId:n}=Es(),{currentProject:s}=Bs(),d=n??(s==null?void 0:s.id),i=d?`/projects/${d}`:"/projects",{machineModeEnabled:a,isMachineAvailable:x}=Vs(),c=$s(d??null,{hierarchy:!0}),l=r.useMemo(()=>{var m;return((m=c.data)==null?void 0:m.specs)??[]},[c.data]),f=Hs(),j=r.useCallback(m=>{f.setQueriesData({queryKey:Ae.lists()},b=>{if(!b)return b;if(Array.isArray(b))return m(b);if(typeof b=="object"&&b&&"specs"in b){const D=b;return{...D,specs:m(D.specs??[])}}return b})},[f]),M=r.useMemo(()=>{var m;return(m=c.data)==null?void 0:m.hierarchy},[c.data]),{t:g}=xe("common"),T=c.isLoading&&!c.data,y=c.error?g("specsPage.state.errorDescription"):null,{activeSpecName:o,tokenDialogOpen:L,tokenDialogLoading:C,tokenDialogData:$,closeTokenDialog:_,handleTokenClick:H,validationDialogOpen:I,validationDialogLoading:F,validationDialogData:U,closeValidationDialog:te,handleValidationClick:Z}=gt(d),{statusFilter:k,priorityFilter:t,tagFilter:p,sortBy:w,hierarchyView:q,showArchived:S,pageViewMode:V,showValidationIssuesOnly:R,setStatusFilter:W,setPriorityFilter:ae,setTagFilter:X,setSortBy:je,setHierarchyView:ie,setShowArchived:ve,setPageViewMode:N,setShowValidationIssuesOnly:O}=qs(),[K]=zs(),oe=r.useMemo(()=>({tag:K.get("tag"),query:K.get("q"),view:K.get("view"),groupByParent:K.get("groupByParent")}),[K]),cs=oe.query??"",ye=oe.tag,de=oe.view,we=oe.groupByParent,[He,qe]=r.useState(cs),re=r.useDeferredValue(He),me=_s(d??null,re),ne=r.useMemo(()=>k.filter(m=>m!=="archived"),[k]),ue=r.useMemo(()=>ye?[ye]:p,[ye,p]),ce=r.useMemo(()=>we==="1"||we==="true"?!0:q,[we,q]),ze=r.useMemo(()=>de==="board"||de==="list"?de:V,[de,V]),ls=r.useCallback(m=>ie(m),[ie]),is=r.useCallback(m=>N(m),[N]),os=r.useMemo(()=>l.map(m=>m.specName),[l]),G=Ks(d??null,os),[Y,pe]=r.useState(null);r.useEffect(()=>{if(!G.data)return;const m=G.data;j(b=>b.map(D=>{const v=m.specs[D.specName];return v?{...D,tokenCount:v.tokenCount,tokenStatus:v.tokenStatus,validationStatus:v.validationStatus}:D}))},[G.data,j]);const _e=r.useMemo(()=>{if(!G.data)return{};const m={};for(const[b,D]of Object.entries(G.data.specs))m[b]=D.validationStatus;return m},[G.data]),ds=G.isLoading,he=r.useCallback(async(m,b,D=!1)=>{if(!(a&&!x())){j(v=>v.map(u=>u.specName===m.specName?{...u,status:b}:u));try{await Ue.updateSpec(m.specName,{status:b,expectedContentHash:m.contentHash,force:D}),f.invalidateQueries({queryKey:Ae.lists()})}catch(v){j(u=>u.map(h=>h.specName===m.specName?{...h,status:m.status}:h)),console.error("Failed to update status:",v)}}},[x,a,f,j]),Ke=r.useCallback((m,b)=>{if(m.status==="draft"&&(b==="in-progress"||b==="complete")){pe({spec:m,nextStatus:b});return}he(m,b)},[he]),Re=r.useCallback(async(m,b)=>{if(a&&!x())return;const D=m.priority;j(v=>v.map(u=>u.specName===m.specName?{...u,priority:b}:u));try{await Ue.updateSpec(m.specName,{priority:b,expectedContentHash:m.contentHash}),f.invalidateQueries({queryKey:Ae.lists()})}catch(v){j(u=>u.map(h=>h.specName===m.specName?{...h,priority:D}:h)),console.error("Failed to update priority:",v)}},[x,a,f,j]),ke=r.useCallback(()=>{c.refetch()},[c]),ms=r.useMemo(()=>{const m=l.map(v=>v.status).filter(v=>!!v),b=Array.from(new Set(m)).filter(v=>S||v!=="archived"),D={draft:0,planned:1,"in-progress":2,complete:3,archived:4};return b.sort((v,u)=>D[v]-D[u])},[l,S]),us=r.useMemo(()=>{const m=Array.from(new Set(l.map(D=>D.priority).filter(Boolean))),b={critical:1,high:2,medium:3,low:4};return m.sort((D,v)=>(b[D]||999)-(b[v]||999))},[l]),ps=r.useMemo(()=>Array.from(new Set(l.flatMap(b=>b.tags||[]))).sort((b,D)=>b.toLowerCase().localeCompare(D.toLowerCase())),[l]),Fe=r.useCallback(()=>{qe(""),W([]),ae([]),X([]),O(!1)},[W,ae,X,O]),Qe=r.useCallback((m,b)=>{const D=new Map;for(const h of b){const A=h.parent;A&&(D.has(A)||D.set(A,[]),D.get(A).push(h))}const v=new Set(m.map(h=>h.specName||h.id)),u=h=>{const A=D.get(h);if(A)for(const E of A){const B=E.specName||E.id;B&&!v.has(B)&&(v.add(B),u(B))}};for(const h of m)u(h.specName||h.id||"");return b.filter(h=>v.has(h.specName||h.id||""))},[]),le=r.useMemo(()=>{let m=l;const b=re&&me.data;if(b){const u=new Set(me.data.results.map(h=>h.specName));m=l.filter(h=>u.has(h.specName))}let D=m.filter(u=>{var h,A;if(!S&&u.status==="archived")return!1;if(re&&!b){const E=re.toLowerCase();if(!(u.specName.toLowerCase().includes(E)||(u.title?u.title.toLowerCase().includes(E):!1)||((h=u.tags)==null?void 0:h.some(Q=>Q.toLowerCase().includes(E)))))return!1}if(ne.length>0&&u.status&&!ne.includes(u.status)||t.length>0&&u.priority&&!t.includes(u.priority)||ue.length>0&&!((A=u.tags)!=null&&A.some(E=>ue.includes(E))))return!1;if(R){const E=_e[u.specName],B=u.validationStatus||E;if(!(B&&B!=="pass"))return!1}return!0});ce&&(ne.length>0||t.length>0)&&(D=Qe(D,l));const v=[...D];if(b){const u=new Map(me.data.results.map((h,A)=>[h.specName,A]));v.sort((h,A)=>(u.get(h.specName)??9999)-(u.get(A.specName)??9999))}else switch(w){case"id-asc":v.sort((u,h)=>(u.specNumber||0)-(h.specNumber||0));break;case"priority-desc":v.sort((u,h)=>{const A={critical:4,high:3,medium:2,low:1},E=A[u.priority||""]||0,Q=(A[h.priority||""]||0)-E;return Q!==0?Q:(h.specNumber||0)-(u.specNumber||0)});break;case"priority-asc":v.sort((u,h)=>{const A={critical:4,high:3,medium:2,low:1},E=A[u.priority||""]||0,B=A[h.priority||""]||0,Q=E-B;return Q!==0?Q:(h.specNumber||0)-(u.specNumber||0)});break;case"updated-desc":v.sort((u,h)=>{if(!u.updatedAt)return 1;if(!h.updatedAt)return-1;const A=new Date(u.updatedAt).getTime(),B=new Date(h.updatedAt).getTime()-A;return B!==0?B:(h.specNumber||0)-(u.specNumber||0)});break;case"title-asc":v.sort((u,h)=>{const A=(u.title||u.specName).toLowerCase(),E=(h.title||h.specName).toLowerCase(),B=A.localeCompare(E);return B!==0?B:(h.specNumber||0)-(u.specNumber||0)});break;default:v.sort((u,h)=>(h.specNumber||0)-(u.specNumber||0));break}return v},[t,re,w,l,ne,ue,ce,Qe,R,S,_e,me.data]),Se=le.length<=ft;return T?e.jsx(Pe,{children:e.jsx(Rs,{})}):y?e.jsx(Pe,{children:e.jsx(Fs,{children:e.jsxs(Qs,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(rs,{className:"h-6 w-6 text-destructive"})}),e.jsx("div",{className:"text-lg font-semibold",children:g("specsPage.state.errorTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:y||g("specsPage.state.errorDescription")}),e.jsx(z,{variant:"secondary",size:"sm",onClick:ke,className:"mt-2",children:g("actions.retry")})]})})}):e.jsxs(Pe,{className:"h-[calc(100dvh-3.5rem)]",contentClassName:"flex h-full flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 sticky top-0 bg-background mt-0 py-2 z-10",children:[e.jsx(Gs,{title:g("specsPage.title"),description:g("specsPage.description")}),a&&!x()&&e.jsx("div",{className:"text-xs text-destructive",children:g("machines.unavailable")}),e.jsx(xt,{searchQuery:He,onSearchChange:qe,statusFilter:ne,onStatusFilterChange:W,priorityFilter:t,onPriorityFilterChange:ae,tagFilter:ue,onTagFilterChange:X,sortBy:w,onSortByChange:m=>je(m),uniqueStatuses:ms,uniquePriorities:us,uniqueTags:ps,onClearFilters:Fe,totalSpecs:l.length,filteredCount:le.length,viewMode:ze,onViewModeChange:is,groupByParent:ce,onGroupByParentChange:ls,showValidationIssuesOnly:R,onShowValidationIssuesOnlyChange:O,showArchived:S,onShowArchivedChange:ve,loadingValidation:ds})]}),e.jsx("div",{className:"flex-1 min-h-0",children:l.length===0?e.jsx(Ze,{icon:tt,title:g("specsPage.state.noSpecsTitle"),description:g("specsPage.state.noSpecsDescription"),actions:e.jsxs(z,{variant:"secondary",size:"sm",onClick:ke,children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),g("specsPage.buttons.refreshList")]})}):le.length===0?e.jsx(Ze,{icon:at,title:g("specsPage.state.noFiltersTitle"),description:g("specsPage.state.noFiltersDescription"),actions:e.jsxs("div",{className:"flex gap-2 flex-wrap justify-center",children:[e.jsx(z,{variant:"outline",size:"sm",onClick:Fe,children:g("specsNavSidebar.clearFilters")}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:ke,children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),g("specsPage.buttons.reloadData")]})]})}):ze==="list"?e.jsx(ht,{specs:le,hierarchy:M,basePath:i,groupByParent:ce,sortBy:w,onTokenClick:H,onValidationClick:Z,onStatusChange:Se?Ke:void 0,onPriorityChange:Se?Re:void 0}):e.jsx(ot,{specs:le,onStatusChange:Ke,onPriorityChange:Se?Re:void 0,canEdit:!a||x(),basePath:i,groupByParent:ce,showArchived:S,onTokenClick:H,onValidationClick:Z})}),o&&L&&e.jsx(et,{open:L,onClose:_,specName:o,data:$,loading:C}),o&&I&&e.jsx(st,{open:I,onClose:te,specName:o,data:U,loading:F}),e.jsx(Us,{open:!!Y,onOpenChange:m=>!m&&pe(null),children:e.jsxs(Zs,{children:[e.jsxs(Ws,{children:[e.jsx(Xs,{children:g("editors.draftSkipTitle")}),e.jsx(Ys,{children:g("editors.draftSkipDescription")})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(z,{variant:"outline",onClick:()=>{Y&&(he(Y.spec,"planned"),pe(null))},children:g("editors.draftSkipPlanned")}),e.jsx(z,{onClick:()=>{Y&&(he(Y.spec,Y.nextStatus,!0),pe(null))},children:g("editors.draftSkipForce")})]})]})})]})}export{kt as SpecsPage};
1
+ import{h as Xe,r,u as xe,j as e,cI as Oe,cc as Ye,cb as Je,bX as es,bU as ss,f as P,c8 as ge,ca as fe,bW as ts,bD as ee,bE as $e,cJ as hs,c9 as as,cK as xs,cL as gs,bn as fs,b0 as Ns,br as Ge,bo as bs,b5 as Ce,b6 as De,a as z,b8 as Me,bf as Le,cM as js,cN as vs,cO as ys,aT as rs,aX as ws,aY as ks,aZ as Ss,a_ as Cs,a$ as J,cE as Ds,cP as Ms,cQ as Ls,c5 as Ts,cR as As,cS as Te,cn as Ps,L as Is,cT as Os,bg as Es,bh as Bs,cU as Vs,cV as $s,cW as Hs,cX as Ae,cY as qs,bl as zs,cZ as _s,c_ as Ks,c7 as Ue,aS as Pe,c$ as Rs,C as Fs,l as Qs,bm as Gs,bs as Ze,D as Us,b as Zs,c as Ws,d as Xs,b1 as Ys}from"./index-BlyOVhDj.js";import{C as Js,T as Ne,V as be,a as et,b as st}from"./validation-badge-Bg0rq4Tp.js";import{F as tt,a as at}from"./funnel-x-DVbrqcHk.js";import{R as We}from"./refresh-ccw-DZO2C09G.js";import"./token-utils-x_d_uTQu.js";import"./info-Cl-KzKzC.js";const rt=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],se=Xe("folder-tree",rt);const nt=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ct=Xe("layout-grid",nt),lt=3,Ee={draft:{icon:ss,titleKey:"status.draft",colorClass:"text-slate-600 dark:text-slate-300",bgClass:"bg-slate-50 dark:bg-slate-900/20",borderClass:"border-slate-200 dark:border-slate-800"},planned:{icon:es,titleKey:"status.planned",colorClass:"text-blue-600 dark:text-blue-400",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800"},"in-progress":{icon:Je,titleKey:"status.inProgress",colorClass:"text-orange-600 dark:text-orange-400",bgClass:"bg-orange-50 dark:bg-orange-900/20",borderClass:"border-orange-200 dark:border-orange-800"},complete:{icon:Ye,titleKey:"status.complete",colorClass:"text-green-600 dark:text-green-400",bgClass:"bg-green-50 dark:bg-green-900/20",borderClass:"border-green-200 dark:border-green-800"},archived:{icon:Oe,titleKey:"status.archived",colorClass:"text-gray-600 dark:text-gray-400",bgClass:"bg-gray-50 dark:bg-gray-900/20",borderClass:"border-gray-200 dark:border-gray-800"}};function Be({spec:n,basePath:s,canEdit:d=!0,draggingId:i,onDragStart:a,onDragEnd:x,onTokenClick:c,onValidationClick:l,onPriorityChange:f,childCount:j,isExpanded:M,onToggle:g}){const T=j!==void 0&&g!==void 0;return e.jsxs("div",{className:P("bg-background rounded-xl border border-primary/20 shadow-sm relative overflow-hidden group/parent hover:border-primary/50 hover:shadow-md transition-all",i===n.specName&&"opacity-50",d?"cursor-move":"cursor-not-allowed opacity-70"),draggable:d,onDragStart:a?y=>a(n,y):void 0,onDragEnd:x,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-primary/40 to-primary/10"}),e.jsxs("div",{className:"p-3 pb-2 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs(ge,{to:`${s}/specs/${n.specName}`,className:"flex-1 min-w-0 group hover:text-primary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsxs("span",{className:"text-[10px] font-mono font-medium text-primary/70 bg-primary/5 px-1 rounded",children:["#",n.specNumber||n.specName.split("-")[0].replace(/^0+/,"")]}),T&&e.jsx(se,{className:"h-3 w-3 text-primary/40"})]}),e.jsx("h4",{className:"font-semibold text-sm truncate leading-tight",title:n.title||n.specName,children:n.title||n.specName})]}),T&&e.jsx("button",{onClick:y=>{y.preventDefault(),g()},className:"p-1 hover:bg-muted rounded-md text-muted-foreground transition-colors",children:M?e.jsx(ee,{className:"h-4 w-4"}):e.jsx($e,{className:"h-4 w-4"})})]}),n.tags&&n.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.tags.slice(0,3).map(y=>e.jsx("span",{className:"text-[10px] bg-secondary text-secondary-foreground px-1.5 py-0.5 rounded-full",children:y},y)),n.tags.length>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",n.tags.length-3]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[n.status&&Ee[n.status]&&(()=>{const y=Ee[n.status],o=y.icon;return e.jsx(o,{className:P("h-3.5 w-3.5",y.colorClass)})})(),n.priority&&e.jsx(fe,{priority:n.priority,className:"h-5 text-[10px] px-1.5",editable:!!f&&d,onChange:y=>f==null?void 0:f(n,y)}),T&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",title:`${j} children`,children:[e.jsx(ts,{className:"h-3 w-3"}),j]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ne,{count:n.tokenCount,size:"sm",onClick:c?()=>c(n.specName):void 0,className:"h-5 px-1.5 scale-90 origin-right"}),n.validationStatus&&n.validationStatus!=="pass"&&e.jsx(be,{status:n.validationStatus,size:"sm",onClick:l?()=>l(n.specName):void 0,className:"h-5 px-1.5 scale-90 origin-right"})]})]})]}),T&&!M&&e.jsx("div",{onClick:g,className:"bg-muted/30 p-1 flex justify-center cursor-pointer hover:bg-muted/50 transition-colors border-t border-border/20",children:e.jsx(ee,{className:"h-3 w-3 text-muted-foreground/50"})})]})}function it({parentName:n,specs:s,parentSpec:d,basePath:i,onTokenClick:a,onValidationClick:x,onPriorityChange:c,canEdit:l,draggingId:f,onDragStart:j,onDragEnd:M}){const g=`harnspec_board_expanded_${n}`,T=s.length<=lt,[y,o]=r.useState(()=>{try{const C=sessionStorage.getItem(g);return C!==null?C==="true":T}catch{return T}}),L=()=>{const C=!y;o(C);try{sessionStorage.setItem(g,String(C))}catch{}};return e.jsxs("div",{className:"space-y-2 mt-4 first:mt-0",children:[d?e.jsx(Be,{spec:d,childCount:s.length,isExpanded:y,onToggle:L,basePath:i,canEdit:l,draggingId:f,onDragStart:j,onDragEnd:M,onTokenClick:a,onValidationClick:x,onPriorityChange:c}):e.jsxs("div",{className:"flex items-center gap-2 px-1 pb-1 border-b border-border/30 cursor-pointer hover:bg-muted/20 rounded p-1",onClick:L,children:[e.jsx(se,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsx("h5",{className:"text-xs font-semibold text-foreground/80 truncate flex-1",title:n,children:n}),e.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground font-mono",children:s.length}),y?e.jsx(ee,{className:"h-3 w-3 text-muted-foreground"}):e.jsx($e,{className:"h-3 w-3 text-muted-foreground"})]}),y&&e.jsx("div",{className:P("space-y-2 transition-all",d&&"pl-2 border-l-2 border-border/30 ml-2"),children:s.map(C=>e.jsx(Be,{spec:C,basePath:i,canEdit:l,draggingId:f,onDragStart:j,onDragEnd:M,onTokenClick:a,onValidationClick:x,onPriorityChange:c},C.specName))})]})}const ot=r.memo(function({specs:s,onStatusChange:d,onPriorityChange:i,basePath:a="/projects",canEdit:x=!0,groupByParent:c=!1,showArchived:l=!1,onTokenClick:f,onValidationClick:j}){const[M,g]=r.useState(null),[T,y]=r.useState(null),{t:o}=xe("common"),L=r.useMemo(()=>new Map(s.map(t=>[t.specName,t])),[s]),C=r.useMemo(()=>{const p=s.some(w=>w.status==="draft")?["draft","planned","in-progress","complete"]:["planned","in-progress","complete"];return l&&p.push("archived"),p},[l,s]),$=r.useMemo(()=>{const t={draft:[],planned:[],"in-progress":[],complete:[],archived:[]};return s.forEach(p=>{const w=p.status;w&&t[w].push(p)}),t},[s]),_=(t,p)=>{x&&(g(t.specName),p.dataTransfer.effectAllowed="move")},H=()=>{g(null),y(null)},I=t=>{t.currentTarget.contains(t.relatedTarget)||y(null)},F=(t,p)=>{x&&(p.preventDefault(),p.dataTransfer.dropEffect="move",T!==t&&y(t))},U=(t,p)=>{if(x&&(p.preventDefault(),y(null),M)){const w=s.find(q=>q.specName===M);w&&w.status!==t&&d(w,t),g(null)}},te=(t,p=!1)=>e.jsx("div",{draggable:x,onDragStart:w=>_(t,w),onDragEnd:H,className:P("bg-background rounded-xl border shadow-sm cursor-move hover:border-primary/50 transition-all group/card relative",p?"p-2.5 border-border/50 text-sm shadow-none bg-background/50":"p-4",M===t.specName&&"opacity-50",!x&&"cursor-not-allowed opacity-70"),children:e.jsxs(ge,{to:`${a}/specs/${t.specName}`,className:"select-none h-full flex flex-col",children:[t.children&&t.children.length>0&&!p&&e.jsx("div",{className:"absolute top-3 right-3 text-primary/50",title:o("specs.hierarchy.umbrella"),children:e.jsx(se,{className:"w-4 h-4"})}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono mb-1 flex items-center gap-1",children:[e.jsxs("span",{className:P(p&&"text-[10px]"),children:["#",t.specNumber||t.specName.split("-")[0].replace(/^0+/,"")]}),p&&t.children&&t.children.length>0&&e.jsx(se,{className:"w-3 h-3 text-primary/40 ml-1"})]}),e.jsxs("div",{className:P("space-y-1 mb-3 flex-1",p?"mb-1.5":"mb-4"),children:[e.jsx("h4",{className:P("font-semibold leading-snug group-hover/card:text-primary transition-colors pr-6",p?"text-xs":"text-base"),children:t.title||t.specName}),!p&&e.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:t.specName}),t.parent&&!c&&e.jsxs("div",{className:"flex items-center text-xs text-muted-foreground mt-1 bg-muted/30 p-1 rounded w-fit max-w-full",children:[e.jsx(Js,{className:"h-3 w-3 mr-1 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:o("specs.hierarchy.inParent",{parent:t.parent})})]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{className:P("flex flex-wrap gap-1.5 mb-3",p?"mb-1.5":"mb-3"),children:[t.tags.slice(0,p?2:4).map(w=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-secondary/30 border border-border/50 rounded-md text-muted-foreground font-mono truncate max-w-[120px]",children:w},w)),t.tags.length>(p?2:4)&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-secondary/20 border border-border/30 rounded-md text-muted-foreground/70 font-mono",children:["+",t.tags.length-(p?2:4)]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-auto",children:[t.priority&&e.jsx(fe,{priority:t.priority,className:P("rounded-md",p?"h-5 text-[10px] px-1.5 scale-90 origin-left":"h-6 px-2.5"),iconOnly:p,editable:!!i&&x,onChange:w=>i==null?void 0:i(t,w)}),e.jsxs("div",{className:"flex items-center gap-1.5 justify-end ml-auto",children:[e.jsx(Ne,{count:t.tokenCount,size:"sm",onClick:f?()=>f(t.specName):void 0,className:P(p&&"px-1.5 h-5 scale-90 origin-right"),showIcon:!p}),e.jsx(be,{status:t.validationStatus,size:"sm",onClick:j?()=>j(t.specName):void 0,className:P(p&&"px-1.5 h-5 scale-90 origin-right")}),t.children&&t.children.length>0&&!p&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 bg-primary/10 border border-primary/20 rounded-md text-primary font-medium flex items-center gap-1",children:[e.jsx(ts,{className:"h-3 w-3"}),t.children.length]})]})]})]})},t.specName),Z=t=>{if(!c)return e.jsx("div",{className:"space-y-2",children:t.map(S=>te(S))});const p=[],w=[],q=new Set;return s.forEach(S=>{S.children&&S.children.length>0&&S.children.forEach(V=>q.add(V))}),t.forEach(S=>{q.has(S.specName)||(S.children&&S.children.length>0?p.push(S):w.push(S))}),p.sort((S,V)=>S.specName.localeCompare(V.specName)),e.jsxs("div",{className:"space-y-2",children:[w.map(S=>e.jsx(Be,{spec:S,basePath:a,canEdit:x,draggingId:M,onDragStart:_,onDragEnd:H,onTokenClick:f,onValidationClick:j,onPriorityChange:i},S.specName)),p.map(S=>{const V=(S.children||[]).map(R=>L.get(R)).filter(R=>R!==void 0);return e.jsx(it,{parentName:S.specName,specs:V,parentSpec:S,basePath:a,canEdit:x,draggingId:M,onDragStart:_,onDragEnd:H,onTokenClick:f,onValidationClick:j,onPriorityChange:i},S.specName)})]})},k=t=>{if(!c)return t.length;const p=new Set;return s.forEach(w=>{w.children&&w.children.length>0&&w.children.forEach(q=>p.add(q))}),t.filter(w=>!p.has(w.specName)).length};return e.jsx("div",{className:"flex flex-col md:flex-row gap-3 sm:gap-4 md:gap-6 h-full pb-2 md:snap-x md:snap-mandatory overflow-y-auto md:overflow-y-hidden md:overflow-x-auto",children:C.map(t=>{const p=Ee[t],w=$[t]||[],q=p.icon,S=T===t;return e.jsxs("div",{className:P("flex-shrink-0 w-80 flex flex-col rounded-lg bg-secondary/30 border border-transparent transition-colors",S&&"bg-secondary/60 border-primary/50 ring-2 ring-primary/20"),onDragOver:V=>F(t,V),onDragLeave:I,onDrop:V=>U(t,V),children:[e.jsx("div",{className:P("p-3 flex items-center justify-between border-b sticky top-0 z-10 backdrop-blur-sm bg-opacity-90",p.borderClass,p.bgClass,"rounded-t-lg"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{className:P("w-4 h-4",p.colorClass)}),e.jsx("span",{className:P("font-medium text-sm",p.colorClass),children:o(p.titleKey)}),e.jsx("span",{className:"text-xs px-2 py-0.5 bg-background/50 rounded-full text-muted-foreground",children:k(w)})]})}),e.jsx("div",{className:"flex-1 p-2 overflow-y-auto",children:Z(w)})]},t)})})});function ns(n,s){const d=[...n];switch(s){case"id-asc":d.sort((i,a)=>(i.specNumber||0)-(a.specNumber||0));break;case"priority-desc":d.sort((i,a)=>{const x={critical:4,high:3,medium:2,low:1},c=x[i.priority||""]||0,f=(x[a.priority||""]||0)-c;return f!==0?f:(a.specNumber||0)-(i.specNumber||0)});break;case"priority-asc":d.sort((i,a)=>{const x={critical:4,high:3,medium:2,low:1},c=x[i.priority||""]||0,l=x[a.priority||""]||0,f=c-l;return f!==0?f:(a.specNumber||0)-(i.specNumber||0)});break;case"updated-desc":d.sort((i,a)=>{const x="updatedAt"in i?i.updatedAt:void 0,c="updatedAt"in a?a.updatedAt:void 0;if(!x)return 1;if(!c)return-1;const l=new Date(x).getTime(),j=new Date(c).getTime()-l;return j!==0?j:(a.specNumber||0)-(i.specNumber||0)});break;case"title-asc":d.sort((i,a)=>{const x=(i.title||i.specName).toLowerCase(),c=(a.title||a.specName).toLowerCase(),l=x.localeCompare(c);return l!==0?l:(a.specNumber||0)-(i.specNumber||0)});break;default:d.sort((i,a)=>(a.specNumber||0)-(i.specNumber||0));break}return d}const dt=r.memo(function n({node:s,basePath:d,depth:i=0,sortBy:a="id-desc",onTokenClick:x,onValidationClick:c,onNodeStatusChange:l,onNodePriorityChange:f}){const[j,M]=r.useState(i<1),g=s.childNodes&&s.childNodes.length>0,T=r.useCallback(o=>{o.stopPropagation(),M(L=>!L)},[]),y=r.useMemo(()=>g?ns(s.childNodes,a):[],[g,s.childNodes,a]);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:P("border rounded-lg bg-background transition-colors","hover:bg-secondary/50"),children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:P("w-8 h-full px-2 py-5 cursor-pointer text-muted-foreground hover:text-foreground flex items-center",!g&&"invisible pointer-events-none"),onClick:T,children:g&&e.jsx($e,{className:P("h-4 w-4 transition-transform",j&&"rotate-90")})}),e.jsxs(ge,{to:`${d}/specs/${s.specName}`,className:"flex-1 p-4 pl-0 block",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[g&&e.jsx(se,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:["#",s.specNumber]}),e.jsx("h3",{className:"font-medium truncate",children:s.title||s.specName})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.specName})]}),e.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.status&&e.jsx(as,{status:s.status,editable:!!l,onChange:o=>l==null?void 0:l(s.specName,o)}),s.priority&&e.jsx(fe,{priority:s.priority,editable:!!f,onChange:o=>f==null?void 0:f(s.specName,o)}),e.jsx(Ne,{count:s.tokenCount,size:"sm",onClick:x?()=>x(s.specName):void 0}),e.jsx(be,{status:s.validationStatus,size:"sm",onClick:c?()=>c(s.specName):void 0})]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex gap-2 mt-3 flex-wrap",children:s.tags.map(o=>e.jsx("span",{className:"text-xs px-2 py-0.5 bg-secondary rounded text-secondary-foreground",children:o},o))})]})]})}),g&&e.jsx(xs,{open:j,children:e.jsx(gs,{forceMount:j?!0:void 0,children:e.jsx("div",{className:"ml-4 pl-4 border-l-2 border-border/40 space-y-2 mt-2 mb-4",children:y.map(o=>e.jsx(n,{node:o,basePath:d,depth:i+1,sortBy:a,onTokenClick:x,onValidationClick:c,onNodeStatusChange:l,onNodePriorityChange:f},o.specName))})})})]})});function Ve(n,s){const d=[];for(const i of n)if(s.has(i.specName)){const a=i.childNodes?Ve(i.childNodes,s):[];d.push({...i,childNodes:a})}else if(i.childNodes&&i.childNodes.length>0){const a=Ve(i.childNodes,s);a.length>0&&d.push({...i,childNodes:a})}return d}const mt=r.memo(function({specs:s,hierarchy:d,basePath:i="/projects",sortBy:a="id-desc",onTokenClick:x,onValidationClick:c,onStatusChange:l,onPriorityChange:f}){const j=r.useMemo(()=>new Set(s.map(o=>o.specName)),[s]),M=r.useMemo(()=>new Map(s.map(o=>[o.specName,o])),[s]),g=r.useCallback((o,L)=>{const C=M.get(o);C&&l&&l(C,L)},[M,l]),T=r.useCallback((o,L)=>{const C=M.get(o);C&&f&&f(C,L)},[M,f]),y=r.useMemo(()=>{let o;return d!==void 0?o=Ve(d,j):o=hs(s),ns(o,a)},[d,s,a,j]);return s.length===0?null:e.jsx("div",{className:"h-full overflow-y-auto space-y-2",children:y.map(o=>e.jsx(dt,{node:o,basePath:i,depth:0,sortBy:a,onTokenClick:x,onValidationClick:c,onNodeStatusChange:l?g:void 0,onNodePriorityChange:f?T:void 0},o.specName))})}),Ie=120,ut=120,pt=r.memo(function({spec:s,basePath:d,onTokenClick:i,onValidationClick:a,onStatusChange:x,onPriorityChange:c}){return e.jsx(ge,{to:`${d}/specs/${s.specName}`,className:"block border rounded-lg hover:bg-secondary/50 transition-colors bg-background",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"w-8 h-full invisible flex items-center text-muted-foreground"}),e.jsxs("div",{className:"flex-1 p-4 pl-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:["#",s.specNumber]}),e.jsx("h3",{className:"font-medium truncate",children:s.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.specName})]}),e.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.status&&e.jsx(as,{status:s.status,editable:!!x,onChange:l=>x==null?void 0:x(s,l)}),s.priority&&e.jsx(fe,{priority:s.priority,editable:!!c,onChange:l=>c==null?void 0:c(s,l)}),e.jsx(Ne,{count:s.tokenCount,size:"sm",onClick:()=>i(s.specName)}),e.jsx(be,{status:s.validationStatus,size:"sm",onClick:()=>a(s.specName)})]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex gap-2 mt-3 flex-wrap",children:s.tags.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 bg-secondary rounded text-secondary-foreground",children:l},l))})]})]})})}),ht=r.memo(function({specs:s,hierarchy:d,basePath:i="/projects",groupByParent:a=!1,sortBy:x="id-desc",onTokenClick:c,onValidationClick:l,onStatusChange:f,onPriorityChange:j}){const{t:M}=xe("common"),[g,T]=r.useState(Ie);r.useEffect(()=>{if(a)return;const o=s.length,L=Math.min(Ie,o);if(typeof window>"u")return;let C=null,$=!1;const _=()=>{if($||(T(L),o<=Ie))return;const H=()=>{$||T(I=>{const F=Math.min(I+ut,o);return F<o&&!$&&(C=window.requestAnimationFrame(H)),F})};C=window.requestAnimationFrame(H)};return C=window.requestAnimationFrame(_),()=>{$=!0,C!==null&&window.cancelAnimationFrame(C)}},[a,s.length]);const y=r.useMemo(()=>a?s:s.slice(0,g),[a,s,g]);return s.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground border rounded-lg bg-secondary/10",children:M("specsPage.list.empty")}):a?e.jsx(mt,{specs:s,hierarchy:d,basePath:i,sortBy:x,onTokenClick:c,onValidationClick:l,onStatusChange:f,onPriorityChange:j}):e.jsxs("div",{className:"h-full overflow-y-auto space-y-2",children:[y.map(o=>e.jsx(pt,{spec:o,basePath:i,onTokenClick:L=>c==null?void 0:c(L),onValidationClick:L=>l==null?void 0:l(L),onStatusChange:f,onPriorityChange:j},o.specName)),!a&&g<s.length&&e.jsx("div",{className:"py-3 text-center text-xs text-muted-foreground",children:M("specsPage.list.loadingMore",{visible:g,total:s.length,defaultValue:"Rendering {{visible}} / {{total}} specs..."})})]})});function xt({searchQuery:n,onSearchChange:s,statusFilter:d,onStatusFilterChange:i,priorityFilter:a,onPriorityFilterChange:x,tagFilter:c,onTagFilterChange:l,sortBy:f,onSortByChange:j,uniqueStatuses:M,uniquePriorities:g,uniqueTags:T,onClearFilters:y,totalSpecs:o,filteredCount:L,viewMode:C,onViewModeChange:$,groupByParent:_,onGroupByParentChange:H,showValidationIssuesOnly:I,onShowValidationIssuesOnlyChange:F,showArchived:U,onShowArchivedChange:te,loadingValidation:Z}){const{t:k}=xe("common"),[t,p]=r.useState(n);r.useEffect(()=>{p(n)},[n]),r.useEffect(()=>{const N=setTimeout(()=>{t!==n&&s(t)},120);return()=>clearTimeout(N)},[t,s,n]);const w={draft:ss,planned:es,"in-progress":Je,complete:Ye,archived:Oe},q={critical:rs,high:ys,medium:vs,low:js},S={draft:"status.draft",planned:"status.planned","in-progress":"status.inProgress",complete:"status.complete",archived:"status.archived"},V={critical:"priority.critical",high:"priority.high",medium:"priority.medium",low:"priority.low"},R=N=>S[N]?k(S[N]):N,W=N=>V[N]?k(V[N]):N,ae=n||d.length>0||a.length>0||c.length>0||I,X=_||I||U,je=N=>{i(d.includes(N)?d.filter(O=>O!==N):[...d,N])},ie=N=>{x(a.includes(N)?a.filter(O=>O!==N):[...a,N])},ve=N=>{l(c.includes(N)?c.filter(O=>O!==N):[...c,N])};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ns,{type:"text",placeholder:k("specsPage.searchPlaceholder"),value:t,onChange:N=>p(N.target.value),className:"w-full pl-10 pr-10 py-2"}),t&&e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>{p(""),s("")},children:e.jsx(Ge,{className:"w-4 h-4"})})]}),t&&e.jsx("p",{className:"text-xs text-muted-foreground pl-1",children:k("specsPage.searchHint")})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(bs,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:k("specsNavSidebar.filtersLabel")})]}),e.jsxs(Ce,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(z,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:d.length===0?k("specsPage.filters.statusAll"):d.length===1?R(d[0]):`${d.length} ${k("specsNavSidebar.selected")}`}),e.jsx(ee,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1",children:M.map(N=>{const O=w[N],K=d.includes(N);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>je(N),children:[e.jsx("div",{className:P("flex items-center justify-center w-4 h-4 border rounded transition-colors",K?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:K&&e.jsx(Le,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O&&e.jsx(O,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:R(N)})]})]},N)})})})]}),e.jsxs(Ce,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(z,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:a.length===0?k("specsPage.filters.priorityAll"):a.length===1?W(a[0]):`${a.length} ${k("specsNavSidebar.selected")}`}),e.jsx(ee,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1",children:g.map(N=>{const O=q[N],K=a.includes(N);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>ie(N),children:[e.jsx("div",{className:P("flex items-center justify-center w-4 h-4 border rounded transition-colors",K?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:K&&e.jsx(Le,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O&&e.jsx(O,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:W(N)})]})]},N)})})})]}),e.jsxs(Ce,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(z,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:c.length===0?k("specsNavSidebar.select.tag.all"):c.length===1?c[0]:`${c.length} ${k("specsNavSidebar.selected")}`}),e.jsx(ee,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:T.map(N=>{const O=c.includes(N);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>ve(N),children:[e.jsx("div",{className:P("flex items-center justify-center w-4 h-4 border rounded transition-colors",O?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:O&&e.jsx(Le,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm flex-1 break-all",children:N})]},N)})})})]}),e.jsxs(ws,{value:f,onValueChange:j,children:[e.jsx(ks,{className:"w-[160px]",children:e.jsx(Ss,{placeholder:k("specsPage.filters.sort")})}),e.jsxs(Cs,{children:[e.jsx(J,{value:"id-desc",children:k("specsPage.filters.sortOptions.id-desc")}),e.jsx(J,{value:"id-asc",children:k("specsPage.filters.sortOptions.id-asc")}),e.jsx(J,{value:"updated-desc",children:k("specsPage.filters.sortOptions.updated-desc")}),e.jsx(J,{value:"title-asc",children:k("specsPage.filters.sortOptions.title-asc")}),e.jsx(J,{value:"priority-desc",children:k("specsPage.filters.sortOptions.priority-desc")}),e.jsx(J,{value:"priority-asc",children:k("specsPage.filters.sortOptions.priority-asc")})]})]}),ae&&e.jsxs(z,{onClick:y,variant:"ghost",size:"sm",className:"h-9 gap-1",children:[e.jsx(Ge,{className:"w-4 h-4"}),k("specsNavSidebar.clearFilters")]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1.5",children:[Z&&I&&e.jsx(Ds,{className:"w-3 h-3 animate-spin"}),k("specsPage.filters.filteredCount",{filtered:L,total:o})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ms,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(z,{variant:X?"secondary":"outline",size:"sm",className:"h-9 gap-1.5",children:[e.jsx(Ts,{className:P("w-4 h-4",X?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"hidden sm:inline",children:k("specsPage.filters.settings")})]})}),e.jsxs(As,{align:"end",className:"w-48",children:[e.jsxs(Te,{checked:_,onCheckedChange:H,children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.groupByParent")]}),e.jsxs(Te,{checked:I,onCheckedChange:F,children:[e.jsx(Ps,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.withErrors")]}),e.jsxs(Te,{checked:U,onCheckedChange:te,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.showArchived")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-secondary/50 p-1 rounded-lg border h-9",children:[e.jsxs(z,{variant:C==="list"?"secondary":"ghost",size:"sm",onClick:()=>$("list"),className:P("h-7",C==="list"&&"bg-background shadow-sm"),title:k("specsPage.views.listTooltip"),children:[e.jsx(Is,{className:"w-4 h-4 mr-1.5"}),k("specsPage.views.list")]}),e.jsxs(z,{variant:C==="board"?"secondary":"ghost",size:"sm",onClick:()=>$("board"),className:P("h-7",C==="board"&&"bg-background shadow-sm"),title:k("specsPage.views.boardTooltip"),children:[e.jsx(ct,{className:"w-4 h-4 mr-1.5"}),k("specsPage.views.board")]})]})]})]})]})}function gt(n){const[s,d]=r.useState(null),[i,a]=r.useState(!1),[x,c]=r.useState(!1),[l,f]=r.useState(null),[j,M]=r.useState(!1),[g,T]=r.useState(!1),[y,o]=r.useState(null),L=Os(),C=r.useCallback(()=>{a(!1),c(!1),f(null)},[]),$=r.useCallback(()=>{M(!1),T(!1),o(null)},[]),_=r.useCallback(I=>{n&&(d(I),a(!0))},[n]),H=r.useCallback(I=>{n&&(d(I),M(!0))},[n]);return r.useEffect(()=>{!i||!s||!n||(c(!0),L.getSpecTokens(n,s).then(I=>f(I)).catch(()=>f(null)).finally(()=>c(!1)))},[s,L,n,i]),r.useEffect(()=>{!j||!s||!n||(T(!0),L.getSpecValidation(n,s).then(I=>o(I)).catch(()=>o(null)).finally(()=>T(!1)))},[s,L,n,j]),{activeSpecName:s,tokenDialogOpen:i,tokenDialogLoading:x,tokenDialogData:l,closeTokenDialog:C,handleTokenClick:_,validationDialogOpen:j,validationDialogLoading:g,validationDialogData:y,closeValidationDialog:$,handleValidationClick:H}}const ft=120;function kt(){const{projectId:n}=Es(),{currentProject:s}=Bs(),d=n??(s==null?void 0:s.id),i=d?`/projects/${d}`:"/projects",{machineModeEnabled:a,isMachineAvailable:x}=Vs(),c=$s(d??null,{hierarchy:!0}),l=r.useMemo(()=>{var m;return((m=c.data)==null?void 0:m.specs)??[]},[c.data]),f=Hs(),j=r.useCallback(m=>{f.setQueriesData({queryKey:Ae.lists()},b=>{if(!b)return b;if(Array.isArray(b))return m(b);if(typeof b=="object"&&b&&"specs"in b){const D=b;return{...D,specs:m(D.specs??[])}}return b})},[f]),M=r.useMemo(()=>{var m;return(m=c.data)==null?void 0:m.hierarchy},[c.data]),{t:g}=xe("common"),T=c.isLoading&&!c.data,y=c.error?g("specsPage.state.errorDescription"):null,{activeSpecName:o,tokenDialogOpen:L,tokenDialogLoading:C,tokenDialogData:$,closeTokenDialog:_,handleTokenClick:H,validationDialogOpen:I,validationDialogLoading:F,validationDialogData:U,closeValidationDialog:te,handleValidationClick:Z}=gt(d),{statusFilter:k,priorityFilter:t,tagFilter:p,sortBy:w,hierarchyView:q,showArchived:S,pageViewMode:V,showValidationIssuesOnly:R,setStatusFilter:W,setPriorityFilter:ae,setTagFilter:X,setSortBy:je,setHierarchyView:ie,setShowArchived:ve,setPageViewMode:N,setShowValidationIssuesOnly:O}=qs(),[K]=zs(),oe=r.useMemo(()=>({tag:K.get("tag"),query:K.get("q"),view:K.get("view"),groupByParent:K.get("groupByParent")}),[K]),cs=oe.query??"",ye=oe.tag,de=oe.view,we=oe.groupByParent,[He,qe]=r.useState(cs),re=r.useDeferredValue(He),me=_s(d??null,re),ne=r.useMemo(()=>k.filter(m=>m!=="archived"),[k]),ue=r.useMemo(()=>ye?[ye]:p,[ye,p]),ce=r.useMemo(()=>we==="1"||we==="true"?!0:q,[we,q]),ze=r.useMemo(()=>de==="board"||de==="list"?de:V,[de,V]),ls=r.useCallback(m=>ie(m),[ie]),is=r.useCallback(m=>N(m),[N]),os=r.useMemo(()=>l.map(m=>m.specName),[l]),G=Ks(d??null,os),[Y,pe]=r.useState(null);r.useEffect(()=>{if(!G.data)return;const m=G.data;j(b=>b.map(D=>{const v=m.specs[D.specName];return v?{...D,tokenCount:v.tokenCount,tokenStatus:v.tokenStatus,validationStatus:v.validationStatus}:D}))},[G.data,j]);const _e=r.useMemo(()=>{if(!G.data)return{};const m={};for(const[b,D]of Object.entries(G.data.specs))m[b]=D.validationStatus;return m},[G.data]),ds=G.isLoading,he=r.useCallback(async(m,b,D=!1)=>{if(!(a&&!x())){j(v=>v.map(u=>u.specName===m.specName?{...u,status:b}:u));try{await Ue.updateSpec(m.specName,{status:b,expectedContentHash:m.contentHash,force:D}),f.invalidateQueries({queryKey:Ae.lists()})}catch(v){j(u=>u.map(h=>h.specName===m.specName?{...h,status:m.status}:h)),console.error("Failed to update status:",v)}}},[x,a,f,j]),Ke=r.useCallback((m,b)=>{if(m.status==="draft"&&(b==="in-progress"||b==="complete")){pe({spec:m,nextStatus:b});return}he(m,b)},[he]),Re=r.useCallback(async(m,b)=>{if(a&&!x())return;const D=m.priority;j(v=>v.map(u=>u.specName===m.specName?{...u,priority:b}:u));try{await Ue.updateSpec(m.specName,{priority:b,expectedContentHash:m.contentHash}),f.invalidateQueries({queryKey:Ae.lists()})}catch(v){j(u=>u.map(h=>h.specName===m.specName?{...h,priority:D}:h)),console.error("Failed to update priority:",v)}},[x,a,f,j]),ke=r.useCallback(()=>{c.refetch()},[c]),ms=r.useMemo(()=>{const m=l.map(v=>v.status).filter(v=>!!v),b=Array.from(new Set(m)).filter(v=>S||v!=="archived"),D={draft:0,planned:1,"in-progress":2,complete:3,archived:4};return b.sort((v,u)=>D[v]-D[u])},[l,S]),us=r.useMemo(()=>{const m=Array.from(new Set(l.map(D=>D.priority).filter(Boolean))),b={critical:1,high:2,medium:3,low:4};return m.sort((D,v)=>(b[D]||999)-(b[v]||999))},[l]),ps=r.useMemo(()=>Array.from(new Set(l.flatMap(b=>b.tags||[]))).sort((b,D)=>b.toLowerCase().localeCompare(D.toLowerCase())),[l]),Fe=r.useCallback(()=>{qe(""),W([]),ae([]),X([]),O(!1)},[W,ae,X,O]),Qe=r.useCallback((m,b)=>{const D=new Map;for(const h of b){const A=h.parent;A&&(D.has(A)||D.set(A,[]),D.get(A).push(h))}const v=new Set(m.map(h=>h.specName||h.id)),u=h=>{const A=D.get(h);if(A)for(const E of A){const B=E.specName||E.id;B&&!v.has(B)&&(v.add(B),u(B))}};for(const h of m)u(h.specName||h.id||"");return b.filter(h=>v.has(h.specName||h.id||""))},[]),le=r.useMemo(()=>{let m=l;const b=re&&me.data;if(b){const u=new Set(me.data.results.map(h=>h.specName));m=l.filter(h=>u.has(h.specName))}let D=m.filter(u=>{var h,A;if(!S&&u.status==="archived")return!1;if(re&&!b){const E=re.toLowerCase();if(!(u.specName.toLowerCase().includes(E)||(u.title?u.title.toLowerCase().includes(E):!1)||((h=u.tags)==null?void 0:h.some(Q=>Q.toLowerCase().includes(E)))))return!1}if(ne.length>0&&u.status&&!ne.includes(u.status)||t.length>0&&u.priority&&!t.includes(u.priority)||ue.length>0&&!((A=u.tags)!=null&&A.some(E=>ue.includes(E))))return!1;if(R){const E=_e[u.specName],B=u.validationStatus||E;if(!(B&&B!=="pass"))return!1}return!0});ce&&(ne.length>0||t.length>0)&&(D=Qe(D,l));const v=[...D];if(b){const u=new Map(me.data.results.map((h,A)=>[h.specName,A]));v.sort((h,A)=>(u.get(h.specName)??9999)-(u.get(A.specName)??9999))}else switch(w){case"id-asc":v.sort((u,h)=>(u.specNumber||0)-(h.specNumber||0));break;case"priority-desc":v.sort((u,h)=>{const A={critical:4,high:3,medium:2,low:1},E=A[u.priority||""]||0,Q=(A[h.priority||""]||0)-E;return Q!==0?Q:(h.specNumber||0)-(u.specNumber||0)});break;case"priority-asc":v.sort((u,h)=>{const A={critical:4,high:3,medium:2,low:1},E=A[u.priority||""]||0,B=A[h.priority||""]||0,Q=E-B;return Q!==0?Q:(h.specNumber||0)-(u.specNumber||0)});break;case"updated-desc":v.sort((u,h)=>{if(!u.updatedAt)return 1;if(!h.updatedAt)return-1;const A=new Date(u.updatedAt).getTime(),B=new Date(h.updatedAt).getTime()-A;return B!==0?B:(h.specNumber||0)-(u.specNumber||0)});break;case"title-asc":v.sort((u,h)=>{const A=(u.title||u.specName).toLowerCase(),E=(h.title||h.specName).toLowerCase(),B=A.localeCompare(E);return B!==0?B:(h.specNumber||0)-(u.specNumber||0)});break;default:v.sort((u,h)=>(h.specNumber||0)-(u.specNumber||0));break}return v},[t,re,w,l,ne,ue,ce,Qe,R,S,_e,me.data]),Se=le.length<=ft;return T?e.jsx(Pe,{children:e.jsx(Rs,{})}):y?e.jsx(Pe,{children:e.jsx(Fs,{children:e.jsxs(Qs,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(rs,{className:"h-6 w-6 text-destructive"})}),e.jsx("div",{className:"text-lg font-semibold",children:g("specsPage.state.errorTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:y||g("specsPage.state.errorDescription")}),e.jsx(z,{variant:"secondary",size:"sm",onClick:ke,className:"mt-2",children:g("actions.retry")})]})})}):e.jsxs(Pe,{className:"h-[calc(100dvh-3.5rem)]",contentClassName:"flex h-full flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 sticky top-0 bg-background mt-0 py-2 z-10",children:[e.jsx(Gs,{title:g("specsPage.title"),description:g("specsPage.description")}),a&&!x()&&e.jsx("div",{className:"text-xs text-destructive",children:g("machines.unavailable")}),e.jsx(xt,{searchQuery:He,onSearchChange:qe,statusFilter:ne,onStatusFilterChange:W,priorityFilter:t,onPriorityFilterChange:ae,tagFilter:ue,onTagFilterChange:X,sortBy:w,onSortByChange:m=>je(m),uniqueStatuses:ms,uniquePriorities:us,uniqueTags:ps,onClearFilters:Fe,totalSpecs:l.length,filteredCount:le.length,viewMode:ze,onViewModeChange:is,groupByParent:ce,onGroupByParentChange:ls,showValidationIssuesOnly:R,onShowValidationIssuesOnlyChange:O,showArchived:S,onShowArchivedChange:ve,loadingValidation:ds})]}),e.jsx("div",{className:"flex-1 min-h-0",children:l.length===0?e.jsx(Ze,{icon:tt,title:g("specsPage.state.noSpecsTitle"),description:g("specsPage.state.noSpecsDescription"),actions:e.jsxs(z,{variant:"secondary",size:"sm",onClick:ke,children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),g("specsPage.buttons.refreshList")]})}):le.length===0?e.jsx(Ze,{icon:at,title:g("specsPage.state.noFiltersTitle"),description:g("specsPage.state.noFiltersDescription"),actions:e.jsxs("div",{className:"flex gap-2 flex-wrap justify-center",children:[e.jsx(z,{variant:"outline",size:"sm",onClick:Fe,children:g("specsNavSidebar.clearFilters")}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:ke,children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),g("specsPage.buttons.reloadData")]})]})}):ze==="list"?e.jsx(ht,{specs:le,hierarchy:M,basePath:i,groupByParent:ce,sortBy:w,onTokenClick:H,onValidationClick:Z,onStatusChange:Se?Ke:void 0,onPriorityChange:Se?Re:void 0}):e.jsx(ot,{specs:le,onStatusChange:Ke,onPriorityChange:Se?Re:void 0,canEdit:!a||x(),basePath:i,groupByParent:ce,showArchived:S,onTokenClick:H,onValidationClick:Z})}),o&&L&&e.jsx(et,{open:L,onClose:_,specName:o,data:$,loading:C}),o&&I&&e.jsx(st,{open:I,onClose:te,specName:o,data:U,loading:F}),e.jsx(Us,{open:!!Y,onOpenChange:m=>!m&&pe(null),children:e.jsxs(Zs,{children:[e.jsxs(Ws,{children:[e.jsx(Xs,{children:g("editors.draftSkipTitle")}),e.jsx(Ys,{children:g("editors.draftSkipDescription")})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(z,{variant:"outline",onClick:()=>{Y&&(he(Y.spec,"planned"),pe(null))},children:g("editors.draftSkipPlanned")}),e.jsx(z,{onClick:()=>{Y&&(he(Y.spec,Y.nextStatus,!0),pe(null))},children:g("editors.draftSkipForce")})]})]})})]})}export{kt as SpecsPage};