@straiffi/archon 1.8.18 → 1.8.19

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 (68) hide show
  1. package/dist/client/assets/{ActivityView-nPkZZ0JB.js → ActivityView-BaoAJ8JM.js} +1 -1
  2. package/dist/client/assets/{GitHubActionsDialog-Bo-6r-yS.js → GitHubActionsDialog-D7iT7xTt.js} +1 -1
  3. package/dist/client/assets/{VerificationDialog-DXoUeYip.js → VerificationDialog-ayyiyvGt.js} +1 -1
  4. package/dist/client/assets/{architectureDiagram-3BPJPVTR-DCkl8h2Z.js → architectureDiagram-3BPJPVTR-8hDT9YFW.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-GPEHLZMM-CyiRWLEs.js → blockDiagram-GPEHLZMM-DrSgZhh1.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-AAUBKEIU-DXvU6VXI.js → c4Diagram-AAUBKEIU-BjowoLmV.js} +1 -1
  7. package/dist/client/assets/channel-CGc3oFdr.js +1 -0
  8. package/dist/client/assets/{chunk-2J33WTMH-BKgS-yt3.js → chunk-2J33WTMH-BwZDhXTf.js} +1 -1
  9. package/dist/client/assets/{chunk-3OPIFGDE-QtuCD2Q2.js → chunk-3OPIFGDE-CVc43Ukf.js} +1 -1
  10. package/dist/client/assets/{chunk-5ZQYHXKU-D39gTBWf.js → chunk-5ZQYHXKU-D5FDCGhy.js} +1 -1
  11. package/dist/client/assets/{chunk-727SXJPM-CrROa9vl.js → chunk-727SXJPM-CJSR5Mh2.js} +1 -1
  12. package/dist/client/assets/{chunk-AQP2D5EJ-CzCE7Ly-.js → chunk-AQP2D5EJ-B6kTsClX.js} +1 -1
  13. package/dist/client/assets/{chunk-CSCIHK7Q-8GC-E83m.js → chunk-CSCIHK7Q-C5UH_dAR.js} +1 -1
  14. package/dist/client/assets/{chunk-KSCS5N6A--w54oW-H.js → chunk-KSCS5N6A-D_rzcB2b.js} +1 -1
  15. package/dist/client/assets/{chunk-L5ZTLDWV-As7Y7CIE.js → chunk-L5ZTLDWV-CztP7jdd.js} +1 -1
  16. package/dist/client/assets/{chunk-LZXEDZCA-nQ3OKGDG.js → chunk-LZXEDZCA-wTLCL7Pg.js} +2 -2
  17. package/dist/client/assets/{chunk-ND2GUHAM-BXYfWf_t.js → chunk-ND2GUHAM-B5AHIrUy.js} +1 -1
  18. package/dist/client/assets/{chunk-NZK2D7GU-D8ju9Sx9.js → chunk-NZK2D7GU-D3MtrIk4.js} +1 -1
  19. package/dist/client/assets/{chunk-O5CBEL6O-BVLHEQ1H.js → chunk-O5CBEL6O-iIPXNV3t.js} +1 -1
  20. package/dist/client/assets/{chunk-WU5MYG2G-CngTiTFp.js → chunk-WU5MYG2G-Cwu-Oylq.js} +1 -1
  21. package/dist/client/assets/classDiagram-4FO5ZUOK-CBhybRSO.js +1 -0
  22. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-C9ErMU7v.js +1 -0
  23. package/dist/client/assets/{dagre-BM42HDAG-CQSaAIdi.js → dagre-BM42HDAG-D3wiIOnk.js} +1 -1
  24. package/dist/client/assets/{diagram-2AECGRRQ-BETIcP-k.js → diagram-2AECGRRQ-Bysb-ntU.js} +1 -1
  25. package/dist/client/assets/{diagram-5GNKFQAL-DkxvZt8V.js → diagram-5GNKFQAL-CtS_bpE5.js} +1 -1
  26. package/dist/client/assets/{diagram-KO2AKTUF-t-6dpc03.js → diagram-KO2AKTUF-_PI56fZq.js} +1 -1
  27. package/dist/client/assets/{diagram-LMA3HP47-CmB4LwSG.js → diagram-LMA3HP47-BNgWnFoz.js} +1 -1
  28. package/dist/client/assets/{diagram-OG6HWLK6-WJPdO1hb.js → diagram-OG6HWLK6-BM-wG_lJ.js} +1 -1
  29. package/dist/client/assets/{erDiagram-TEJ5UH35-Dazbp1kL.js → erDiagram-TEJ5UH35-BPqNBsVc.js} +1 -1
  30. package/dist/client/assets/{flowDiagram-I6XJVG4X-XkWw21cY.js → flowDiagram-I6XJVG4X-BgA6MiBD.js} +1 -1
  31. package/dist/client/assets/{ganttDiagram-6RSMTGT7-B95LBden.js → ganttDiagram-6RSMTGT7-BMDzgC7L.js} +1 -1
  32. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-E-ram2aT.js → gitGraphDiagram-PVQCEYII-C0cZUYmG.js} +1 -1
  33. package/dist/client/assets/{index-DBzMRUJD.js → index-Ci2Or91O.js} +6 -6
  34. package/dist/client/assets/{infoDiagram-5YYISTIA-Dg4XUTE_.js → infoDiagram-5YYISTIA-DelAWwhC.js} +1 -1
  35. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-fIaaz0nX.js → ishikawaDiagram-YF4QCWOH-D62h0NJG.js} +1 -1
  36. package/dist/client/assets/{journeyDiagram-JHISSGLW-BNhbQ3Fr.js → journeyDiagram-JHISSGLW-BXwYQf_j.js} +1 -1
  37. package/dist/client/assets/{kanban-definition-UN3LZRKU-UwtJCm6I.js → kanban-definition-UN3LZRKU-x5KfcIYo.js} +1 -1
  38. package/dist/client/assets/{line-Dhxm5enf.js → line-Blzshjst.js} +1 -1
  39. package/dist/client/assets/{mermaid-parser.core-CfSmOhjh.js → mermaid-parser.core-Dnu-fpL9.js} +1 -1
  40. package/dist/client/assets/{mermaid.core-C_NlQFLU.js → mermaid.core-BngDHztH.js} +3 -3
  41. package/dist/client/assets/{mindmap-definition-RKZ34NQL-DQtb9AMZ.js → mindmap-definition-RKZ34NQL-BRB9WnNL.js} +1 -1
  42. package/dist/client/assets/{pieDiagram-4H26LBE5-CK-pLy3h.js → pieDiagram-4H26LBE5-Ddzhxmp2.js} +1 -1
  43. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-DAyEK3JC.js → quadrantDiagram-W4KKPZXB-CWKRt2y6.js} +1 -1
  44. package/dist/client/assets/{requirementDiagram-4Y6WPE33-Ed6F4ODv.js → requirementDiagram-4Y6WPE33-D309qLEz.js} +1 -1
  45. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-BO-89QCT.js → sankeyDiagram-5OEKKPKP-0Ukkluzd.js} +1 -1
  46. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-BS6h9l_o.js → sequenceDiagram-3UESZ5HK-DkvDbOkQ.js} +1 -1
  47. package/dist/client/assets/{stateDiagram-AJRCARHV-DsKt8LXj.js → stateDiagram-AJRCARHV-LRTZRjK3.js} +1 -1
  48. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BDLRoPbQ.js +1 -0
  49. package/dist/client/assets/{timeline-definition-PNZ67QCA-XCwwiASE.js → timeline-definition-PNZ67QCA-CTwwDhpg.js} +1 -1
  50. package/dist/client/assets/{vennDiagram-CIIHVFJN-ByKqNvGe.js → vennDiagram-CIIHVFJN-BqldUpJn.js} +1 -1
  51. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-CcBrW5Lm.js → wardleyDiagram-YWT4CUSO-DPCPZAsx.js} +1 -1
  52. package/dist/client/assets/{xychartDiagram-2RQKCTM6-DWyh6Upq.js → xychartDiagram-2RQKCTM6-DWkIjgNu.js} +1 -1
  53. package/dist/client/index.html +1 -1
  54. package/dist/server/lib/agent.js +3 -0
  55. package/dist/server/lib/agent.js.map +1 -1
  56. package/dist/server/lib/claudeValidationOutput.js +62 -0
  57. package/dist/server/lib/claudeValidationOutput.js.map +1 -0
  58. package/dist/server/lib/executionEnvironmentRoutes.js +2 -0
  59. package/dist/server/lib/executionEnvironmentRoutes.js.map +1 -1
  60. package/dist/server/lib/executionEnvironmentValidation.js +68 -81
  61. package/dist/server/lib/executionEnvironmentValidation.js.map +1 -1
  62. package/dist/server/lib/parseJsonLines.js +25 -0
  63. package/dist/server/lib/parseJsonLines.js.map +1 -0
  64. package/package.json +1 -1
  65. package/dist/client/assets/channel-CIqVfhIu.js +0 -1
  66. package/dist/client/assets/classDiagram-4FO5ZUOK-B7Zu7Okr.js +0 -1
  67. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-Co7nwA_j.js +0 -1
  68. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BkWiZIXx.js +0 -1
@@ -1 +1 @@
1
- import{dt as e,r as t}from"./index-DBzMRUJD.js";var n=e(),r=({projectId:e,onClose:r,onNavigateToLifecycleSource:i,initialRunId:a,initialEventId:o,onRunSelectionChange:s,onUnavailable:c})=>e?(0,n.jsx)(t,{projectId:e,scope:{type:`project`},initialRunId:a,initialEventId:o,onRunSelectionChange:s,onUnavailable:c,onClose:r,onNavigateToLifecycleSource:i}):null;export{r as ActivityView};
1
+ import{dt as e,r as t}from"./index-Ci2Or91O.js";var n=e(),r=({projectId:e,onClose:r,onNavigateToLifecycleSource:i,initialRunId:a,initialEventId:o,onRunSelectionChange:s,onUnavailable:c})=>e?(0,n.jsx)(t,{projectId:e,scope:{type:`project`},initialRunId:a,initialEventId:o,onRunSelectionChange:s,onUnavailable:c,onClose:r,onNavigateToLifecycleSource:i}):null;export{r as ActivityView};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{B as t,C as n,E as r,F as i,H as a,J as o,M as s,P as c,S as l,T as u,U as d,V as f,W as p,Y as m,b as h,ct as ee,dt as g,ft as _,lt as te,mt as v,q as y,st as ne,u as b,ut as re,vt as x,w as S,x as C,z as w}from"./index-DBzMRUJD.js";var T=e(x(),1),E=g(),ie=`https://docs.github.com/en/actions`,D=5e3,O=(e,t)=>u.t(`common:githubActions.${e}`,t),k=e=>O(`status.${e}`),A=e=>e?O(`conclusion.${e}`):null,j=e=>e.status===`completed`?e.conclusion===`success`?`border-emerald-400/40 bg-emerald-500/10 text-emerald-200`:e.conclusion===`failure`||e.conclusion===`timed_out`?`border-rose-400/40 bg-rose-500/10 text-rose-200`:e.conclusion===`cancelled`?`border-amber-400/40 bg-amber-500/10 text-amber-200`:`border-border/70 bg-background/60 text-muted-foreground`:e.status===`in_progress`?`border-sky-400/40 bg-sky-500/10 text-sky-200`:e.status===`queued`?`border-violet-400/40 bg-violet-500/10 text-violet-200`:`border-border/70 bg-background/60 text-muted-foreground`,M=e=>e.status===`completed`?e.conclusion===`success`?`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`:e.conclusion===`failure`?`border-rose-400/30 bg-rose-500/10 text-rose-200`:`border-border/70 bg-background/60 text-muted-foreground`:e.status===`in_progress`?`border-sky-400/30 bg-sky-500/10 text-sky-200`:`border-border/70 bg-background/60 text-muted-foreground`,N=e=>{let t=e.run_started_at??e.created_at,n=e.updated_at;if(!t||!n)return null;let r=Date.parse(t),i=Date.parse(n);if(!Number.isFinite(r)||!Number.isFinite(i)||i<r)return null;let a=i-r;if(a<1e3)return`${a} ms`;let o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60;return s>0?`${s}h ${c}m ${l}s`:c>0?`${c}m ${l}s`:`${(a/1e3).toFixed(a>=1e4?0:1)} s`},P=e=>e.status===`completed`?A(e.conclusion)??O(`status.completed`):k(e.status),F=e=>{let t={};for(let n of e){if(n.type===`boolean`){t[n.name]=n.default===!0;continue}typeof n.default==`string`&&n.default!==``&&(t[n.name]=n.default)}return t},I=({workflow:e,inputsState:t,isSelected:n,onSelect:r})=>{let a=e.state===`active`,s=t?.dispatchable??!0,l=a&&s&&!t?.isLoading,u=e.path.split(`/`).pop();return(0,E.jsxs)(`div`,{className:m(`flex flex-col gap-3 rounded-2xl border px-4 py-3 transition-colors`,n?`border-sky-400/45 bg-sky-500/10`:`border-border/60 bg-background/20 hover:bg-accent/20`),children:[(0,E.jsx)(`p`,{className:`line-clamp-2 break-words text-sm font-medium text-foreground`,children:e.name}),(0,E.jsx)(`p`,{className:`min-w-0 break-words text-[11px] text-muted-foreground`,children:u}),(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0.5 text-[10px] uppercase tracking-[0.18em]`,a?`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`:`border-border/70 bg-background/60 text-muted-foreground`),children:O(a?`workflows.stateActive`:`workflows.stateDisabled`)}),(0,E.jsxs)(o,{type:`button`,variant:n?`secondary`:`outline`,size:`sm`,className:`h-8 gap-1.5 px-3 text-xs`,disabled:!l,"aria-label":O(`workflows.runAriaLabel`,{name:e.name}),title:!s&&t?O(`inputs.notDispatchable`):void 0,onClick:r,children:[t?.isLoading?(0,E.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}):(0,E.jsx)(c,{className:`h-3.5 w-3.5`}),(0,E.jsx)(`span`,{children:O(`actions.run`)})]})]})]})},ae=({workflow:e,inputsState:n,refValue:r,onRefChange:a,values:s,onValueChange:l,isDispatching:u,onDispatch:d,onCancel:f})=>{let p=n.inputs.filter(e=>e.required&&!L(s[e.name],e)),m=n.dispatchable&&!n.isLoading&&!n.error&&r.trim()!==``&&p.length===0&&!u;return(0,E.jsxs)(`div`,{className:`space-y-4 rounded-2xl border border-border/70 bg-background/20 p-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:O(`inputs.title`)}),(0,E.jsx)(`p`,{className:`mt-0.5 truncate text-sm font-medium text-foreground`,children:e.name})]}),(0,E.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":O(`actions.cancel`),onClick:f,children:(0,E.jsx)(S,{className:`h-4 w-4`})})]}),(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(w,{htmlFor:`github-actions-ref`,children:O(`inputs.refLabel`)}),(0,E.jsx)(t,{id:`github-actions-ref`,type:`text`,value:r,onChange:e=>{a(e.target.value)},placeholder:O(`inputs.refPlaceholder`),"aria-label":O(`inputs.refAriaLabel`)})]}),n.isLoading&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,E.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:O(`inputs.loading`)})]}),n.error&&(0,E.jsx)(`p`,{className:`text-xs text-rose-200`,children:n.error}),!n.dispatchable&&!n.isLoading&&!n.error&&(0,E.jsx)(`p`,{className:`text-xs text-amber-200`,children:O(`inputs.notDispatchable`)}),n.inputs.map(e=>(0,E.jsx)(R,{input:e,value:s[e.name],onChange:t=>{l(e.name,t)}},e.name)),p.length>0&&(0,E.jsx)(`p`,{className:`text-xs text-rose-200`,children:O(`inputs.requiredValidationError`)}),(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,E.jsx)(o,{type:`button`,variant:`ghost`,onClick:f,disabled:u,children:O(`actions.cancel`)}),(0,E.jsxs)(o,{type:`button`,variant:`success`,onClick:d,disabled:!m,children:[u?(0,E.jsx)(i,{className:`h-4 w-4 animate-spin`}):(0,E.jsx)(c,{className:`h-4 w-4`}),(0,E.jsx)(`span`,{children:O(`actions.dispatch`)})]})]})]})},L=(e,t)=>t.type===`boolean`?typeof e==`boolean`:typeof e==`string`&&e.trim()!==``,R=({input:e,value:t,onChange:n})=>{let r=`github-actions-input-${e.name}`;return(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsxs)(w,{htmlFor:r,className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{children:e.name}),e.required&&(0,E.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.18em] text-rose-200/80`,children:O(`inputs.requiredLabel`)})]}),e.description&&(0,E.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.description}),z(e,r,t,n)]})},z=(e,n,r,i)=>{if(e.type===`boolean`){let t=typeof r==`boolean`?r:e.default===!0;return(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(b,{id:n,checked:t,onCheckedChange:e=>{i(e)}}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(t?`inputs.booleanYes`:`inputs.booleanNo`)})]})}if(e.type===`choice`){let t=e.options??[],a=typeof r==`string`?r:typeof e.default==`string`?e.default:``;return(0,E.jsxs)(`select`,{id:n,className:`h-9 w-full rounded-lg border border-border/70 bg-background/60 px-3 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,value:a,onChange:e=>{i(e.target.value)},children:[a===``&&(0,E.jsx)(`option`,{value:``,children:O(`inputs.selectPlaceholder`)}),t.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]})}return(0,E.jsx)(t,{id:n,type:`text`,value:typeof r==`string`?r:typeof e.default==`string`?e.default:``,onChange:e=>{i(e.target.value)}})},B=({job:e})=>e.steps.length===0?null:(0,E.jsx)(`div`,{className:`mt-2 ml-4 space-y-1 border-l border-border/60 pl-4`,children:e.steps.map(t=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0 text-[10px] uppercase tracking-[0.16em]`,M(t)),children:t.status===`completed`?A(t.conclusion)??O(`status.completed`):k(t.status)}),(0,E.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:t.name})]},`${e.id}-${t.number}`))}),oe=({run:e})=>{let t=N(e),n=P(e);return(0,E.jsxs)(`div`,{className:`rounded-2xl border border-border/60 bg-background/20 px-4 py-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name??`#${e.id}`}),(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0.5 text-[10px] uppercase tracking-[0.18em]`,j(e)),children:n})]}),(0,E.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t&&(0,E.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}),e.html_url&&(0,E.jsxs)(`a`,{href:e.html_url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-sky-200 hover:text-sky-100`,children:[O(`actions.openOnGithub`),(0,E.jsx)(C,{className:`h-3 w-3`})]})]})]}),e.head_branch&&(0,E.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:e.head_branch}),e.jobs.map(e=>(0,E.jsxs)(`div`,{className:`mt-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0 text-[10px] uppercase tracking-[0.16em]`,j(e)),children:e.status===`completed`?A(e.conclusion)??O(`status.completed`):k(e.status)}),(0,E.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.name})]}),(0,E.jsx)(B,{job:e})]},e.id))]})},se=({tracked:e})=>{let t=e.state===`resolving`,n=e.failure?.message??O(`runs.trackingState.${e.state}`);return(0,E.jsxs)(`div`,{className:m(`flex items-start gap-2 rounded-2xl border px-4 py-3`,t?`border-border/60 bg-background/20`:`border-red-400/25 bg-red-500/8`),children:[t&&(0,E.jsx)(i,{className:`mt-0.5 h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`span`,{className:m(`block break-words text-xs`,t?`text-muted-foreground`:`text-red-200`),children:n}),(0,E.jsx)(`span`,{className:`mt-1 block text-[11px] text-muted-foreground`,children:e.ref??O(`runs.unknownRef`)})]})]})},V=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=n.get(e.id);(!t||(e.updated_at??``)>=(t.updated_at??``))&&n.set(e.id,e)}return[...n.values()]},H=(e,t)=>{let n=new Map(e.map(e=>[e.execution_run_id,e]));for(let e of t){let t=n.get(e.execution_run_id),r=t&&![`queued`,`waiting`,`running`].includes(t.execution_status),i=[`queued`,`waiting`,`running`].includes(e.execution_status);(!r||!i)&&n.set(e.execution_run_id,e)}return[...n.values()]},U=(e,t,n)=>{let r=t.filter(e=>e.run===null),i=new Set(r.map(e=>e.tracking_key));return H(e.filter(e=>i.has(e.tracking_key)||n.get(e.tracking_key)?.run===null),r.filter(e=>!n.has(e.tracking_key)))},W=e=>({ref:e??`main`}),G=({projectId:e,defaultBranch:t,onClose:c})=>{let[u,m]=(0,T.useState)([]),[h,g]=(0,T.useState)(!0),[b,x]=(0,T.useState)(null),[w,k]=(0,T.useState)([]),[A,j]=(0,T.useState)([]),[M,N]=(0,T.useState)({}),[P,L]=(0,T.useState)(null),[R,z]=(0,T.useState)(!1),[B]=(0,T.useState)(()=>W(t)),H=(0,T.useRef)({}),G=(0,T.useRef)({}),K=(0,T.useRef)(null),q=(0,T.useRef)(!1),J=(0,T.useRef)(0),Y=(0,T.useRef)(new Map),X=(0,T.useCallback)(async t=>{N(e=>{let n=e[t.id];return n?.isLoading?e:{...e,[t.id]:{inputs:n?.inputs??[],dispatchable:n?.dispatchable??!0,isLoading:!0,error:null}}});try{let n=await ee(e,t.id,t.path);return N(e=>({...e,[t.id]:{inputs:n.inputs,dispatchable:n.dispatchable,isLoading:!1,error:null}})),n}catch(e){return N(n=>({...n,[t.id]:{inputs:[],dispatchable:!0,isLoading:!1,error:e instanceof _?e.message:O(`workflows.loadError`)}})),null}},[e]),Z=(0,T.useCallback)(async()=>{g(!0),x(null);try{let t=await re(e);m(t.workflows),Promise.allSettled(t.workflows.map(e=>X(e)))}catch(e){x(e instanceof _?e.message:O(`workflows.loadError`))}finally{g(!1)}},[X,e]),Q=(0,T.useCallback)(async t=>{if(q.current)return;q.current=!0;let n=J.current;try{let r=await te(e,t);k(e=>V(e,r.runs)),j(e=>{let t=new Map([...Y.current.entries()].filter(([,e])=>e.revision>n).map(([e,t])=>[e,t.event]));return U(e,r.tracked_runs??[],t)})}catch(e){v(e)||console.warn(`[github-actions] unable to load runs`,e)}finally{q.current=!1}},[e]);(0,T.useEffect)(()=>{Z()},[Z]),(0,T.useEffect)(()=>{let e=new AbortController,t=()=>{document.visibilityState===`visible`&&Q(e.signal)};t();let r=window.setInterval(t,D),i=n(t);return()=>{e.abort(),window.clearInterval(r),i()}},[Q]);let ce=(0,T.useCallback)(async e=>{if(P?.workflow.id===e.id)return;K.current=e.id,L({workflow:e,ref:B.ref,values:{}});let t=M[e.id];if(t&&!t.isLoading&&!t.error){L(n=>!n||n.workflow.id!==e.id?n:{...n,values:F(t.inputs)});return}let n=await X(e);n&&L(t=>!t||t.workflow.id!==e.id?t:{...t,values:F(n.inputs)})},[B.ref,M,X,P]),le=(0,T.useCallback)(async()=>{if(!P)return;let t=M[P.workflow.id];if(!t||!t.dispatchable)return;z(!0);let n={};for(let e of t.inputs){let t=P.values[e.name];e.type===`boolean`?n[e.name]=typeof t==`boolean`?t:e.default===!0:typeof t==`string`&&t!==``?n[e.name]=t:typeof e.default==`string`&&e.default!==``&&(n[e.name]=e.default)}try{await ne(e,P.workflow.id,{ref:P.ref,workflowName:P.workflow.name,workflowUrl:P.workflow.url,inputs:n}),s.success(O(`messages.dispatched`)),L(null),Q()}catch(e){s.error(e instanceof _?e.message:O(`messages.dispatchError`))}finally{z(!1)}},[M,Q,e,P]);(0,T.useEffect)(()=>{let t=t=>{!t||t.project_id!==e||(J.current+=1,Y.current.set(t.tracking_key,{revision:J.current,event:t}),j(e=>{let n=e.filter(e=>e.tracking_key!==t.tracking_key);return t.run?n:[...n,t]}),t.run&&k(e=>V(e,[t.run])))};return l.on(`github-actions:updated`,t),()=>{l.off(`github-actions:updated`,t)}},[e]),(0,T.useEffect)(()=>{let e=P?.workflow.id;!e||K.current!==e||(H.current[e]?.scrollIntoView({block:`nearest`}),G.current[e]?.scrollIntoView({block:`nearest`}),K.current=null)},[P?.workflow.id]);let $=(0,T.useMemo)(()=>[...w].sort((e,t)=>{let n=e.updated_at?Date.parse(e.updated_at):0;return(t.updated_at?Date.parse(t.updated_at):0)-n}),[w]);return(0,E.jsx)(f,{open:!0,onOpenChange:e=>{e||c()},children:(0,E.jsxs)(d,{showCloseButton:!1,overlayClassName:`bg-black/70`,className:`flex h-[calc(100vh-2rem)] max-h-[58rem] w-full max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden rounded-3xl border border-[#2a2a38] bg-[#16161f] p-0 shadow-2xl sm:max-w-5xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,E.jsx)(y,{className:`sr-only`,children:O(`dialog.srTitle`)}),(0,E.jsx)(p,{className:`sr-only`,children:O(`dialog.srDescription`)}),(0,E.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-border px-6 py-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-2xl border border-border/70 bg-background/60 text-violet-200`,children:(0,E.jsx)(r,{className:`h-5 w-5`})}),(0,E.jsx)(`div`,{children:(0,E.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:O(`dialog.title`)})})]}),(0,E.jsx)(a,{asChild:!0,children:(0,E.jsx)(o,{type:`button`,"aria-label":O(`dialog.closeAriaLabel`),variant:`ghost`,size:`icon-sm`,className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:(0,E.jsx)(S,{className:`h-4 w-4`})})})]}),(0,E.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-0 overflow-hidden lg:grid-cols-[22rem_minmax(0,1fr)]`,children:[(0,E.jsxs)(`aside`,{"aria-label":O(`workflows.ariaLabel`),className:`flex min-h-0 flex-col gap-3 overflow-y-auto border-b border-border/70 px-4 py-4 lg:border-r lg:border-b-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,E.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:O(`workflows.title`)}),(0,E.jsx)(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>{Z(),Q()},children:O(`actions.refresh`)})]}),h&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2 px-2 text-xs text-muted-foreground`,children:[(0,E.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:O(`workflows.loading`)})]}),b&&(0,E.jsx)(`div`,{className:`rounded-2xl border border-rose-500/30 bg-rose-500/10 px-4 py-3 text-sm text-rose-200`,children:b}),!h&&u.length===0&&!b&&(0,E.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:[(0,E.jsx)(`p`,{children:O(`workflows.empty`)}),(0,E.jsx)(`p`,{className:`mt-1`,children:O(`workflows.emptyHint`)}),(0,E.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,className:`mt-2 inline-flex items-center gap-1 text-xs text-sky-200 hover:text-sky-100`,children:[O(`workflows.docsLink`),(0,E.jsx)(C,{className:`h-3 w-3`})]})]}),(0,E.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>{let t=P?.workflow.id===e.id;return(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(`div`,{ref:t=>{H.current[e.id]=t},children:(0,E.jsx)(I,{workflow:e,inputsState:M[e.id]??null,isSelected:t,onSelect:()=>{ce(e)}})}),t&&P&&(0,E.jsx)(`div`,{ref:t=>{G.current[e.id]=t},children:(0,E.jsx)(ae,{workflow:e,inputsState:M[e.id]??{inputs:[],dispatchable:!0,isLoading:!1,error:null},refValue:P.ref,onRefChange:e=>{L(t=>t&&{...t,ref:e})},values:P.values,onValueChange:(e,t)=>{L(n=>n&&{...n,values:{...n.values,[e]:t}})},isDispatching:R,onDispatch:()=>{le()},onCancel:()=>{L(null)}})})]},e.id)})})]}),(0,E.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-3 overflow-y-auto px-4 py-4`,children:[(0,E.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:O(`runs.title`)}),A.map(e=>(0,E.jsx)(se,{tracked:e},e.tracking_key)),$.map(e=>(0,E.jsx)(oe,{run:e},e.id)),$.length===0&&A.length===0&&(0,E.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:O(`runs.empty`)})]})]})]})})};export{G as GitHubActionsDialog};
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{B as t,C as n,E as r,F as i,H as a,J as o,M as s,P as c,S as l,T as u,U as d,V as f,W as p,Y as m,b as h,ct as ee,dt as g,ft as _,lt as te,mt as v,q as y,st as ne,u as b,ut as re,vt as x,w as S,x as C,z as w}from"./index-Ci2Or91O.js";var T=e(x(),1),E=g(),ie=`https://docs.github.com/en/actions`,D=5e3,O=(e,t)=>u.t(`common:githubActions.${e}`,t),k=e=>O(`status.${e}`),A=e=>e?O(`conclusion.${e}`):null,j=e=>e.status===`completed`?e.conclusion===`success`?`border-emerald-400/40 bg-emerald-500/10 text-emerald-200`:e.conclusion===`failure`||e.conclusion===`timed_out`?`border-rose-400/40 bg-rose-500/10 text-rose-200`:e.conclusion===`cancelled`?`border-amber-400/40 bg-amber-500/10 text-amber-200`:`border-border/70 bg-background/60 text-muted-foreground`:e.status===`in_progress`?`border-sky-400/40 bg-sky-500/10 text-sky-200`:e.status===`queued`?`border-violet-400/40 bg-violet-500/10 text-violet-200`:`border-border/70 bg-background/60 text-muted-foreground`,M=e=>e.status===`completed`?e.conclusion===`success`?`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`:e.conclusion===`failure`?`border-rose-400/30 bg-rose-500/10 text-rose-200`:`border-border/70 bg-background/60 text-muted-foreground`:e.status===`in_progress`?`border-sky-400/30 bg-sky-500/10 text-sky-200`:`border-border/70 bg-background/60 text-muted-foreground`,N=e=>{let t=e.run_started_at??e.created_at,n=e.updated_at;if(!t||!n)return null;let r=Date.parse(t),i=Date.parse(n);if(!Number.isFinite(r)||!Number.isFinite(i)||i<r)return null;let a=i-r;if(a<1e3)return`${a} ms`;let o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60;return s>0?`${s}h ${c}m ${l}s`:c>0?`${c}m ${l}s`:`${(a/1e3).toFixed(a>=1e4?0:1)} s`},P=e=>e.status===`completed`?A(e.conclusion)??O(`status.completed`):k(e.status),F=e=>{let t={};for(let n of e){if(n.type===`boolean`){t[n.name]=n.default===!0;continue}typeof n.default==`string`&&n.default!==``&&(t[n.name]=n.default)}return t},I=({workflow:e,inputsState:t,isSelected:n,onSelect:r})=>{let a=e.state===`active`,s=t?.dispatchable??!0,l=a&&s&&!t?.isLoading,u=e.path.split(`/`).pop();return(0,E.jsxs)(`div`,{className:m(`flex flex-col gap-3 rounded-2xl border px-4 py-3 transition-colors`,n?`border-sky-400/45 bg-sky-500/10`:`border-border/60 bg-background/20 hover:bg-accent/20`),children:[(0,E.jsx)(`p`,{className:`line-clamp-2 break-words text-sm font-medium text-foreground`,children:e.name}),(0,E.jsx)(`p`,{className:`min-w-0 break-words text-[11px] text-muted-foreground`,children:u}),(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0.5 text-[10px] uppercase tracking-[0.18em]`,a?`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`:`border-border/70 bg-background/60 text-muted-foreground`),children:O(a?`workflows.stateActive`:`workflows.stateDisabled`)}),(0,E.jsxs)(o,{type:`button`,variant:n?`secondary`:`outline`,size:`sm`,className:`h-8 gap-1.5 px-3 text-xs`,disabled:!l,"aria-label":O(`workflows.runAriaLabel`,{name:e.name}),title:!s&&t?O(`inputs.notDispatchable`):void 0,onClick:r,children:[t?.isLoading?(0,E.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}):(0,E.jsx)(c,{className:`h-3.5 w-3.5`}),(0,E.jsx)(`span`,{children:O(`actions.run`)})]})]})]})},ae=({workflow:e,inputsState:n,refValue:r,onRefChange:a,values:s,onValueChange:l,isDispatching:u,onDispatch:d,onCancel:f})=>{let p=n.inputs.filter(e=>e.required&&!L(s[e.name],e)),m=n.dispatchable&&!n.isLoading&&!n.error&&r.trim()!==``&&p.length===0&&!u;return(0,E.jsxs)(`div`,{className:`space-y-4 rounded-2xl border border-border/70 bg-background/20 p-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:O(`inputs.title`)}),(0,E.jsx)(`p`,{className:`mt-0.5 truncate text-sm font-medium text-foreground`,children:e.name})]}),(0,E.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":O(`actions.cancel`),onClick:f,children:(0,E.jsx)(S,{className:`h-4 w-4`})})]}),(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(w,{htmlFor:`github-actions-ref`,children:O(`inputs.refLabel`)}),(0,E.jsx)(t,{id:`github-actions-ref`,type:`text`,value:r,onChange:e=>{a(e.target.value)},placeholder:O(`inputs.refPlaceholder`),"aria-label":O(`inputs.refAriaLabel`)})]}),n.isLoading&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,E.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:O(`inputs.loading`)})]}),n.error&&(0,E.jsx)(`p`,{className:`text-xs text-rose-200`,children:n.error}),!n.dispatchable&&!n.isLoading&&!n.error&&(0,E.jsx)(`p`,{className:`text-xs text-amber-200`,children:O(`inputs.notDispatchable`)}),n.inputs.map(e=>(0,E.jsx)(R,{input:e,value:s[e.name],onChange:t=>{l(e.name,t)}},e.name)),p.length>0&&(0,E.jsx)(`p`,{className:`text-xs text-rose-200`,children:O(`inputs.requiredValidationError`)}),(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,E.jsx)(o,{type:`button`,variant:`ghost`,onClick:f,disabled:u,children:O(`actions.cancel`)}),(0,E.jsxs)(o,{type:`button`,variant:`success`,onClick:d,disabled:!m,children:[u?(0,E.jsx)(i,{className:`h-4 w-4 animate-spin`}):(0,E.jsx)(c,{className:`h-4 w-4`}),(0,E.jsx)(`span`,{children:O(`actions.dispatch`)})]})]})]})},L=(e,t)=>t.type===`boolean`?typeof e==`boolean`:typeof e==`string`&&e.trim()!==``,R=({input:e,value:t,onChange:n})=>{let r=`github-actions-input-${e.name}`;return(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsxs)(w,{htmlFor:r,className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{children:e.name}),e.required&&(0,E.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.18em] text-rose-200/80`,children:O(`inputs.requiredLabel`)})]}),e.description&&(0,E.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.description}),z(e,r,t,n)]})},z=(e,n,r,i)=>{if(e.type===`boolean`){let t=typeof r==`boolean`?r:e.default===!0;return(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(b,{id:n,checked:t,onCheckedChange:e=>{i(e)}}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(t?`inputs.booleanYes`:`inputs.booleanNo`)})]})}if(e.type===`choice`){let t=e.options??[],a=typeof r==`string`?r:typeof e.default==`string`?e.default:``;return(0,E.jsxs)(`select`,{id:n,className:`h-9 w-full rounded-lg border border-border/70 bg-background/60 px-3 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,value:a,onChange:e=>{i(e.target.value)},children:[a===``&&(0,E.jsx)(`option`,{value:``,children:O(`inputs.selectPlaceholder`)}),t.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]})}return(0,E.jsx)(t,{id:n,type:`text`,value:typeof r==`string`?r:typeof e.default==`string`?e.default:``,onChange:e=>{i(e.target.value)}})},B=({job:e})=>e.steps.length===0?null:(0,E.jsx)(`div`,{className:`mt-2 ml-4 space-y-1 border-l border-border/60 pl-4`,children:e.steps.map(t=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0 text-[10px] uppercase tracking-[0.16em]`,M(t)),children:t.status===`completed`?A(t.conclusion)??O(`status.completed`):k(t.status)}),(0,E.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:t.name})]},`${e.id}-${t.number}`))}),oe=({run:e})=>{let t=N(e),n=P(e);return(0,E.jsxs)(`div`,{className:`rounded-2xl border border-border/60 bg-background/20 px-4 py-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name??`#${e.id}`}),(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0.5 text-[10px] uppercase tracking-[0.18em]`,j(e)),children:n})]}),(0,E.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t&&(0,E.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}),e.html_url&&(0,E.jsxs)(`a`,{href:e.html_url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-sky-200 hover:text-sky-100`,children:[O(`actions.openOnGithub`),(0,E.jsx)(C,{className:`h-3 w-3`})]})]})]}),e.head_branch&&(0,E.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:e.head_branch}),e.jobs.map(e=>(0,E.jsxs)(`div`,{className:`mt-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(h,{variant:`outline`,className:m(`px-2 py-0 text-[10px] uppercase tracking-[0.16em]`,j(e)),children:e.status===`completed`?A(e.conclusion)??O(`status.completed`):k(e.status)}),(0,E.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.name})]}),(0,E.jsx)(B,{job:e})]},e.id))]})},se=({tracked:e})=>{let t=e.state===`resolving`,n=e.failure?.message??O(`runs.trackingState.${e.state}`);return(0,E.jsxs)(`div`,{className:m(`flex items-start gap-2 rounded-2xl border px-4 py-3`,t?`border-border/60 bg-background/20`:`border-red-400/25 bg-red-500/8`),children:[t&&(0,E.jsx)(i,{className:`mt-0.5 h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`span`,{className:m(`block break-words text-xs`,t?`text-muted-foreground`:`text-red-200`),children:n}),(0,E.jsx)(`span`,{className:`mt-1 block text-[11px] text-muted-foreground`,children:e.ref??O(`runs.unknownRef`)})]})]})},V=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=n.get(e.id);(!t||(e.updated_at??``)>=(t.updated_at??``))&&n.set(e.id,e)}return[...n.values()]},H=(e,t)=>{let n=new Map(e.map(e=>[e.execution_run_id,e]));for(let e of t){let t=n.get(e.execution_run_id),r=t&&![`queued`,`waiting`,`running`].includes(t.execution_status),i=[`queued`,`waiting`,`running`].includes(e.execution_status);(!r||!i)&&n.set(e.execution_run_id,e)}return[...n.values()]},U=(e,t,n)=>{let r=t.filter(e=>e.run===null),i=new Set(r.map(e=>e.tracking_key));return H(e.filter(e=>i.has(e.tracking_key)||n.get(e.tracking_key)?.run===null),r.filter(e=>!n.has(e.tracking_key)))},W=e=>({ref:e??`main`}),G=({projectId:e,defaultBranch:t,onClose:c})=>{let[u,m]=(0,T.useState)([]),[h,g]=(0,T.useState)(!0),[b,x]=(0,T.useState)(null),[w,k]=(0,T.useState)([]),[A,j]=(0,T.useState)([]),[M,N]=(0,T.useState)({}),[P,L]=(0,T.useState)(null),[R,z]=(0,T.useState)(!1),[B]=(0,T.useState)(()=>W(t)),H=(0,T.useRef)({}),G=(0,T.useRef)({}),K=(0,T.useRef)(null),q=(0,T.useRef)(!1),J=(0,T.useRef)(0),Y=(0,T.useRef)(new Map),X=(0,T.useCallback)(async t=>{N(e=>{let n=e[t.id];return n?.isLoading?e:{...e,[t.id]:{inputs:n?.inputs??[],dispatchable:n?.dispatchable??!0,isLoading:!0,error:null}}});try{let n=await ee(e,t.id,t.path);return N(e=>({...e,[t.id]:{inputs:n.inputs,dispatchable:n.dispatchable,isLoading:!1,error:null}})),n}catch(e){return N(n=>({...n,[t.id]:{inputs:[],dispatchable:!0,isLoading:!1,error:e instanceof _?e.message:O(`workflows.loadError`)}})),null}},[e]),Z=(0,T.useCallback)(async()=>{g(!0),x(null);try{let t=await re(e);m(t.workflows),Promise.allSettled(t.workflows.map(e=>X(e)))}catch(e){x(e instanceof _?e.message:O(`workflows.loadError`))}finally{g(!1)}},[X,e]),Q=(0,T.useCallback)(async t=>{if(q.current)return;q.current=!0;let n=J.current;try{let r=await te(e,t);k(e=>V(e,r.runs)),j(e=>{let t=new Map([...Y.current.entries()].filter(([,e])=>e.revision>n).map(([e,t])=>[e,t.event]));return U(e,r.tracked_runs??[],t)})}catch(e){v(e)||console.warn(`[github-actions] unable to load runs`,e)}finally{q.current=!1}},[e]);(0,T.useEffect)(()=>{Z()},[Z]),(0,T.useEffect)(()=>{let e=new AbortController,t=()=>{document.visibilityState===`visible`&&Q(e.signal)};t();let r=window.setInterval(t,D),i=n(t);return()=>{e.abort(),window.clearInterval(r),i()}},[Q]);let ce=(0,T.useCallback)(async e=>{if(P?.workflow.id===e.id)return;K.current=e.id,L({workflow:e,ref:B.ref,values:{}});let t=M[e.id];if(t&&!t.isLoading&&!t.error){L(n=>!n||n.workflow.id!==e.id?n:{...n,values:F(t.inputs)});return}let n=await X(e);n&&L(t=>!t||t.workflow.id!==e.id?t:{...t,values:F(n.inputs)})},[B.ref,M,X,P]),le=(0,T.useCallback)(async()=>{if(!P)return;let t=M[P.workflow.id];if(!t||!t.dispatchable)return;z(!0);let n={};for(let e of t.inputs){let t=P.values[e.name];e.type===`boolean`?n[e.name]=typeof t==`boolean`?t:e.default===!0:typeof t==`string`&&t!==``?n[e.name]=t:typeof e.default==`string`&&e.default!==``&&(n[e.name]=e.default)}try{await ne(e,P.workflow.id,{ref:P.ref,workflowName:P.workflow.name,workflowUrl:P.workflow.url,inputs:n}),s.success(O(`messages.dispatched`)),L(null),Q()}catch(e){s.error(e instanceof _?e.message:O(`messages.dispatchError`))}finally{z(!1)}},[M,Q,e,P]);(0,T.useEffect)(()=>{let t=t=>{!t||t.project_id!==e||(J.current+=1,Y.current.set(t.tracking_key,{revision:J.current,event:t}),j(e=>{let n=e.filter(e=>e.tracking_key!==t.tracking_key);return t.run?n:[...n,t]}),t.run&&k(e=>V(e,[t.run])))};return l.on(`github-actions:updated`,t),()=>{l.off(`github-actions:updated`,t)}},[e]),(0,T.useEffect)(()=>{let e=P?.workflow.id;!e||K.current!==e||(H.current[e]?.scrollIntoView({block:`nearest`}),G.current[e]?.scrollIntoView({block:`nearest`}),K.current=null)},[P?.workflow.id]);let $=(0,T.useMemo)(()=>[...w].sort((e,t)=>{let n=e.updated_at?Date.parse(e.updated_at):0;return(t.updated_at?Date.parse(t.updated_at):0)-n}),[w]);return(0,E.jsx)(f,{open:!0,onOpenChange:e=>{e||c()},children:(0,E.jsxs)(d,{showCloseButton:!1,overlayClassName:`bg-black/70`,className:`flex h-[calc(100vh-2rem)] max-h-[58rem] w-full max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden rounded-3xl border border-[#2a2a38] bg-[#16161f] p-0 shadow-2xl sm:max-w-5xl`,onInteractOutside:e=>e.preventDefault(),children:[(0,E.jsx)(y,{className:`sr-only`,children:O(`dialog.srTitle`)}),(0,E.jsx)(p,{className:`sr-only`,children:O(`dialog.srDescription`)}),(0,E.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-border px-6 py-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-2xl border border-border/70 bg-background/60 text-violet-200`,children:(0,E.jsx)(r,{className:`h-5 w-5`})}),(0,E.jsx)(`div`,{children:(0,E.jsx)(`h2`,{className:`text-2xl font-semibold text-foreground`,children:O(`dialog.title`)})})]}),(0,E.jsx)(a,{asChild:!0,children:(0,E.jsx)(o,{type:`button`,"aria-label":O(`dialog.closeAriaLabel`),variant:`ghost`,size:`icon-sm`,className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:(0,E.jsx)(S,{className:`h-4 w-4`})})})]}),(0,E.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-0 overflow-hidden lg:grid-cols-[22rem_minmax(0,1fr)]`,children:[(0,E.jsxs)(`aside`,{"aria-label":O(`workflows.ariaLabel`),className:`flex min-h-0 flex-col gap-3 overflow-y-auto border-b border-border/70 px-4 py-4 lg:border-r lg:border-b-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,E.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:O(`workflows.title`)}),(0,E.jsx)(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>{Z(),Q()},children:O(`actions.refresh`)})]}),h&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2 px-2 text-xs text-muted-foreground`,children:[(0,E.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:O(`workflows.loading`)})]}),b&&(0,E.jsx)(`div`,{className:`rounded-2xl border border-rose-500/30 bg-rose-500/10 px-4 py-3 text-sm text-rose-200`,children:b}),!h&&u.length===0&&!b&&(0,E.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:[(0,E.jsx)(`p`,{children:O(`workflows.empty`)}),(0,E.jsx)(`p`,{className:`mt-1`,children:O(`workflows.emptyHint`)}),(0,E.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,className:`mt-2 inline-flex items-center gap-1 text-xs text-sky-200 hover:text-sky-100`,children:[O(`workflows.docsLink`),(0,E.jsx)(C,{className:`h-3 w-3`})]})]}),(0,E.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>{let t=P?.workflow.id===e.id;return(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(`div`,{ref:t=>{H.current[e.id]=t},children:(0,E.jsx)(I,{workflow:e,inputsState:M[e.id]??null,isSelected:t,onSelect:()=>{ce(e)}})}),t&&P&&(0,E.jsx)(`div`,{ref:t=>{G.current[e.id]=t},children:(0,E.jsx)(ae,{workflow:e,inputsState:M[e.id]??{inputs:[],dispatchable:!0,isLoading:!1,error:null},refValue:P.ref,onRefChange:e=>{L(t=>t&&{...t,ref:e})},values:P.values,onValueChange:(e,t)=>{L(n=>n&&{...n,values:{...n.values,[e]:t}})},isDispatching:R,onDispatch:()=>{le()},onCancel:()=>{L(null)}})})]},e.id)})})]}),(0,E.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-3 overflow-y-auto px-4 py-4`,children:[(0,E.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:O(`runs.title`)}),A.map(e=>(0,E.jsx)(se,{tracked:e},e.tracking_key)),$.map(e=>(0,E.jsx)(oe,{run:e},e.id)),$.length===0&&A.length===0&&(0,E.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:O(`runs.empty`)})]})]})]})})};export{G as GitHubActionsDialog};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,A as n,B as r,D as i,F as a,G as o,I as s,J as c,K as l,L as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,V as y,W as ee,X as b,Y as x,Z as S,_ as C,_t as w,a as te,at as T,b as E,c as ne,d as re,dt as ie,et as ae,f as D,ft as O,g as k,gt as A,h as j,ht as M,i as N,it as oe,j as se,k as P,m as ce,mt as le,n as ue,nt as de,o as fe,ot as pe,p as me,pt as F,q as he,rt as ge,s as _e,t as ve,tt as ye,v as I,vt as L,w as be,y as xe}from"./index-DBzMRUJD.js";var R=e(L(),1),z=ie(),Se=({title:e,children:t,defaultOpen:n=!1})=>(0,z.jsxs)(C,{defaultOpen:n,className:`mt-5 rounded-2xl border border-border/70 bg-background/25`,children:[(0,z.jsx)(xe,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"aria-label":e,className:`group flex w-full items-center gap-2 rounded-2xl px-4 py-3 text-left outline-none transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring/60`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-semibold text-foreground`,children:e}),(0,z.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,z.jsx)(I,{className:`border-t border-border/60 px-4 py-3`,children:t})]}),B=e=>{if(!e.file_path)return null;if(!e.start_line)return e.file_path;let t=`${e.start_line}${e.start_column?`:${e.start_column}`:``}`,n=e.end_line?`-${e.end_line}${e.end_column?`:${e.end_column}`:``}`:``;return`${e.file_path}:${t}${n}`},V=[`error`,`warning`,`info`,`unknown`],H=e=>{let t={error:0,warning:0,info:0,unknown:0};return e.forEach(e=>{t[e.severity]+=1}),t},U=({counts:e,totalCount:t})=>{let{t:n}=w(`common`,{keyPrefix:`checksDialog.diagnostics`}),r=V.filter(t=>e[t]>0);return(0,z.jsxs)(`div`,{"aria-label":n(`severitySummaryLabel`),className:`mt-3 flex flex-wrap items-center gap-2`,children:[r.map(t=>(0,z.jsx)(`span`,{className:`rounded-full border border-border/70 bg-background/45 px-2 py-1 text-[11px] text-muted-foreground`,children:n(`severityCount`,{count:e[t],severity:n(`severity.${t}`)})},t)),t>0&&t!==r.reduce((t,n)=>t+e[n],0)&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`totalAvailable`,{count:t})})]})},Ce=({attempt:e,parser:t,repair:n,ticketRequired:r,selectedTicketId:i,onSelectedTicketChange:a})=>{let{t:o}=w(`common`,{keyPrefix:`checksDialog.diagnostics`}),s=e.currency??`unavailable`;return(0,z.jsxs)(C,{className:`mt-4 rounded-xl border border-border/60 bg-background/25`,children:[(0,z.jsx)(xe,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"aria-label":o(`technicalDetails`),className:`group flex w-full items-center gap-2 rounded-xl px-3 py-2.5 text-left outline-none transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring/60`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:o(`technicalDetails`)}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:o(`technicalDetailsHint`)}),(0,z.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,z.jsxs)(I,{className:`border-t border-border/60 px-3 py-3`,children:[(0,z.jsxs)(`dl`,{className:`grid gap-3 text-xs sm:grid-cols-2`,children:[t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`parserLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`parser.${t.parser_kind}`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`parserStateLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`state.${t.status}`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`parserRetentionLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`retentionState.${t.retention_state}`)})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`outputRetentionLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`retentionState.${e.output_retention_state}`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`applicabilityLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`applicability`,{state:o(`applicabilityState.${s}`)})})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`sourceLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 break-words text-foreground`,children:e.command_snapshot.name})]}),n&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`destinationTitle`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`destination.${n.destination}`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-muted-foreground`,children:o(`destinationHint`)})]})]}),r&&n&&(0,z.jsxs)(`label`,{className:`mt-3 block text-xs text-muted-foreground`,children:[o(`ticketLabel`),(0,z.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`mt-1 h-10 w-full rounded-xl border border-border bg-card px-3 text-sm text-foreground`,children:[(0,z.jsx)(`option`,{value:``,children:o(`ticketPlaceholder`)}),n.candidate_tickets.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]})]})]})},W=({attempt:e,diagnostics:t,repair:n,selectedDiagnosticIds:r,selectedRawOutputAttemptRunIds:i,selectedAttemptRunIds:a,selectedTicketId:o,pending:s,activeRepair:l,autoFix:u,onSelectedTicketChange:d,onToggleDiagnostic:f,onToggleRawOutput:p,onStartRepair:m,onStopRepair:h})=>{let{t:g}=w(`common`,{keyPrefix:`checksDialog.diagnostics`}),{t:_}=w(`common`,{keyPrefix:`checksDialog`});if(e.execution_status!==`failed`)return null;let v=t?.parser??null,y=t?.diagnostics??[],ee=H(y),b=!!(u&&!u.terminal_reason),x=u?.attempts[u.attempts.length-1]??null,S=l?.terminal_result===null||b,C=!!(n?.eligibility.eligible&&n.eligible_attempt_run_ids.includes(e.execution_run_id)&&v?.status===`complete`&&v.retention_state===`retained`),te=!!(n?.eligibility.eligible&&n.eligible_raw_output_attempt_run_ids.includes(e.execution_run_id)&&e.output_retention_state===`retained`&&e.retained_output),T=i.has(e.execution_run_id),E=r.size,ne=E>=32,re=a.size>=8&&!a.has(e.execution_run_id),ie=ne?g(`diagnosticLimit`,{count:32}):re?g(`attemptLimit`,{count:8}):null,ae=!!(n?.accepts_ticket_id&&n.candidate_tickets.length>1),D=E+i.size,O=D>0&&(!ae||o!==``),k=n&&!n.eligibility.eligible?g(`disabled.${n.eligibility.reason}`):null,A=v&&t&&(v.status===`interrupted`||y.length===0&&[`unsupported`,`malformed`].includes(v.status))?v.status:null,j=!!(v&&t&&y.length===0&&v.status===`complete`&&v.retention_state===`retained`&&v.diagnostic_count===0),M=!!(v&&t&&y.length===0&&v.status===`complete`&&v.retention_state===`retained`&&v.diagnostic_count>0),N=v?.diagnostic_count??y.length;return(0,z.jsxs)(`section`,{"aria-labelledby":`diagnostics-${e.execution_run_id}`,className:`mt-5 rounded-2xl border border-border/70 bg-background/25 p-4`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{id:`diagnostics-${e.execution_run_id}`,className:`text-sm font-semibold text-foreground`,children:g(`title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:v&&v.status===`pending`?g(`loading`):v&&N>0?M||v.retention_state===`expired`?g(`totalAvailable`,{count:N}):g(`availableCount`,{count:N}):g(t?`noneAvailable`:`loading`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:g(`failureOutcome`,{outcome:e.outcome?_(`outcomeValue.${e.outcome}`):_(`status.${e.execution_status}`)})}),t&&y.length>0&&(0,z.jsx)(U,{counts:ee,totalCount:N})]})}),v?.retention_state===`expired`&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-amber-200`,children:g(`expired`)}),v?.truncated&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-amber-200`,children:g(`truncated`)}),A&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:g(`fallback.${A}`)}),j&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:g(`noStructuredDiagnostics`)}),M&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:g(`structuredDetailsUnavailable`)}),te&&(0,z.jsxs)(`label`,{className:`mt-4 flex items-start gap-3 rounded-xl border border-amber-400/25 bg-amber-500/5 p-3`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4 accent-primary`,"aria-label":g(`rawOutputSelect`),checked:T,disabled:S||!T&&re,onChange:e=>p(e.target.checked)}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:g(`rawOutputSelect`)}),(0,z.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:g(`rawOutputHint`)}),e.retained_start_offset>0&&(0,z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-200`,children:g(`rawOutputTruncated`)})]})]}),t&&y.length>0&&(0,z.jsxs)(`fieldset`,{className:`mt-4`,children:[(0,z.jsx)(`legend`,{className:`text-xs font-medium text-muted-foreground`,children:g(`selectLegend`)}),(0,z.jsx)(`ul`,{className:`mt-2 space-y-2`,children:y.map(e=>{let t=B(e),n=r.has(e.id);return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-border/60 bg-background/35 p-3`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4 accent-primary`,checked:n,disabled:!C||S||!n&&ie!==null,onChange:t=>f(e.id,t.target.checked)}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-semibold uppercase text-foreground`,children:g(`severity.${e.severity}`)}),e.code&&(0,z.jsx)(`code`,{children:e.code})]}),(0,z.jsx)(`span`,{className:`mt-1 block break-words text-sm text-foreground`,children:e.message}),t&&(0,z.jsx)(`span`,{className:`mt-1 block break-all font-mono text-xs text-muted-foreground`,children:t})]})]})},e.id)})})]}),k&&(0,z.jsx)(`p`,{className:`mt-3 text-xs text-amber-200`,children:k}),ie&&(0,z.jsx)(`p`,{className:`mt-3 text-xs text-amber-200`,children:ie}),l&&(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-sky-400/25 bg-sky-500/10 p-3 text-sm`,children:[(0,z.jsx)(`p`,{className:`font-medium text-sky-100`,children:g(l.terminal_result?`repairResult.${l.terminal_result}`:`repairRunning`)}),l.terminal_message&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-sky-100/80`,children:l.terminal_message})]}),u&&(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-sky-400/25 bg-sky-500/10 p-3 text-sm`,role:`status`,children:[(0,z.jsx)(`p`,{className:`font-medium text-sky-100`,children:u.terminal_reason?g(`autoFix.terminal.${u.terminal_reason}`):x?.fallback_used?g(`autoFix.phase.fallback`):g(`autoFix.phase.${u.phase}`)}),!u.terminal_reason&&u.attempt_count>0&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-sky-100/80`,children:g(`autoFix.attempt`,{current:u.attempt_count,total:u.max_attempts})})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`selectedEvidence`,{count:D})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(c,{type:`button`,size:`sm`,disabled:n?.eligibility.eligible!==!0||!O||s||S,title:k??void 0,onClick:m,children:s?g(`starting`):g(`repairSelectedEvidence`,{count:D})}),S&&(0,z.jsx)(c,{type:`button`,variant:`destructive`,size:`sm`,disabled:s||u?.phase===`stopping`,onClick:h,children:g(b?`autoFix.stop`:`stopRepair`)})]})]}),(0,z.jsx)(Ce,{attempt:e,parser:v,repair:n,ticketRequired:ae,selectedTicketId:o,onSelectedTicketChange:d})]})},G=({attempt:e})=>{let{t}=w(`common`,{keyPrefix:`checksDialog`}),n=e.retained_output?N(e.retained_output):``;return(0,z.jsxs)(Se,{title:t(`rawOutput`),defaultOpen:!0,children:[e.output_retention_state===`expired`&&(0,z.jsx)(`p`,{className:`rounded-xl border border-border bg-background/30 p-4 text-sm text-muted-foreground`,children:t(`outputExpired`)}),e.output_retention_state===`retained`&&!n&&(0,z.jsx)(`p`,{className:`rounded-xl border border-border bg-background/30 p-4 text-sm text-muted-foreground`,children:t(`outputEmpty`)}),e.output_retention_state===`retained`&&n&&(0,z.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-xl border border-border bg-[#090b12] p-4 font-mono text-xs text-slate-200`,children:n}),e.retained_start_offset>0&&(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:t(`outputTruncated`)})]})},K=({definition:e,policy:t})=>{let{t:n}=w(`common`,{keyPrefix:`checksDialog`});return(0,z.jsxs)(`article`,{"aria-labelledby":`configured-check-${e.id}`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{id:`configured-check-${e.id}`,className:`text-lg font-semibold text-foreground`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:n(`status.notRun`)})]})}),(0,z.jsx)(`p`,{className:`mt-4 rounded-xl border border-dashed border-border px-3 py-2 text-sm text-muted-foreground`,children:n(`notRunDescription`)}),(0,z.jsxs)(`dl`,{className:`mt-4 grid gap-3 text-sm sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n(`command`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 break-words font-mono text-xs text-foreground`,children:e.command})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n(`directory`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:e.cwd??n(`targetRoot`)})]}),t&&(0,z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n(`policyLabel`)}),(0,z.jsxs)(`dd`,{className:`mt-0.5 break-words text-foreground`,children:[n(t.required?`required`:`optional`),` · `,n(t.preReview?`preReview`:`finalOnly`)]})]})]})]})},we=({attempt:e,definition:t,diagnostics:n,repair:r,selectedDiagnosticIds:i,selectedRawOutputAttemptRunIds:a,selectedAttemptRunIds:o,selectedTicketId:s,pending:c,activeRepair:l,autoFix:u,onSelectedTicketChange:d,onToggleDiagnostic:f,onToggleRawOutput:p,onStartRepair:m,onStopRepair:h,policy:g})=>{let{t:_}=w(`common`,{keyPrefix:`checksDialog`}),{t:v}=w(`common`,{keyPrefix:`activityView`});return e?(0,z.jsxs)(`article`,{"aria-labelledby":`selected-check-${e.execution_run_id}`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{id:`selected-check-${e.execution_run_id}`,className:`text-lg font-semibold text-foreground`,children:e.command_snapshot.name}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:_(`status.${e.execution_status}`)})]}),e.outcome&&(0,z.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:_(`outcomeValue.${e.outcome}`)})]}),(0,z.jsxs)(`dl`,{className:`mt-4 grid gap-3 text-sm sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`command`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 break-words font-mono text-xs text-foreground`,children:e.command_snapshot.command})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`directory`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:e.command_snapshot.cwd??_(`targetRoot`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`outcome`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:e.outcome?_(`outcomeValue.${e.outcome}`):_(`status.${e.execution_status}`)})]}),e.currency&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`currencyLabel`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:v(`currency.${e.currency}`)})]}),g&&(0,z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`policyLabel`)}),(0,z.jsxs)(`dd`,{className:`mt-0.5 break-words text-foreground`,children:[_(g.required?`required`:`optional`),` · `,_(g.preReview?`preReview`:`finalOnly`)]})]})]}),e.execution_status===`failed`&&(0,z.jsx)(W,{attempt:e,diagnostics:n,repair:r,selectedDiagnosticIds:i,selectedRawOutputAttemptRunIds:a,selectedAttemptRunIds:o,selectedTicketId:s,pending:c,activeRepair:l,autoFix:u,onSelectedTicketChange:d,onToggleDiagnostic:f,onToggleRawOutput:p,onStartRepair:m,onStopRepair:h}),(0,z.jsx)(G,{attempt:e},e.execution_run_id)]}):t?(0,z.jsx)(K,{definition:t,policy:g}):(0,z.jsxs)(`section`,{"aria-labelledby":`selected-check-heading`,className:`rounded-2xl border border-dashed border-border p-6`,children:[(0,z.jsx)(`h2`,{id:`selected-check-heading`,className:`font-medium text-foreground`,children:_(`selectAttemptTitle`)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:_(`selectAttemptDescription`)})]})},q={current:`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`,stale:`border-amber-400/30 bg-amber-500/10 text-amber-200`,failed:`border-red-400/30 bg-red-500/10 text-red-200`,missing:`border-border bg-muted/40 text-muted-foreground`,interrupted:`border-orange-400/30 bg-orange-500/10 text-orange-200`,blocked:`border-amber-400/30 bg-amber-500/10 text-amber-200`},Te=(e,t)=>e.presentApplicability.appliesToCurrentState===!1?`stale`:t?t.execution_status===`interrupted`||t.execution_status===`cancelled`?`interrupted`:t.execution_status===`failed`?`failed`:t.currency===`stale`?`stale`:t.outcome&&t.outcome!==`passed`?`failed`:t.outcome===`passed`&&t.currency===`current`?`current`:e.decision===`blocked`?`blocked`:`current`:`missing`,Ee=e=>e===!0?`gateApplicability.overallCurrent`:e===!1?`gateApplicability.overallStale`:`gateApplicability.overallUnverifiable`,De=({evaluation:e})=>{let{t}=w(`common`,{keyPrefix:`checksDialog`}),n=e.presentApplicability.appliesToCurrentState===!1?`gateStale`:e.presentApplicability.appliesToCurrentState===null?`gateUnverifiable`:e.decision===`passed`?`gatePassed`:`gateBlocked`,r=e.reasonCodes[0],i=r?t(`gateReasonSummary`,{reason:t(`reason.${r}`)}):e.decision===`passed`?t(`gatePassedSummary`):t(`gateBlockedSummary`);return(0,z.jsxs)(`section`,{"aria-labelledby":`automated-delivery-gate-heading`,className:`mb-5 rounded-2xl border border-border/70 bg-background/30 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{id:`automated-delivery-gate-heading`,className:`font-semibold text-foreground`,children:t(`gateTitle`)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:i})]}),(0,z.jsx)(`span`,{className:x(`shrink-0 rounded-full border px-2.5 py-1 text-xs font-medium`,e.decision===`passed`&&e.presentApplicability.appliesToCurrentState===!0?q.current:q.blocked),children:t(n)})]}),(0,z.jsx)(Se,{title:t(`gateDetails`),children:(0,z.jsxs)(`div`,{className:`space-y-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{children:t(`gateScope`)}),(0,z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,z.jsx)(`p`,{children:t(`gateBoundary.label`,{boundary:t(`gateBoundary.${e.boundaryKind}`)})}),(0,z.jsx)(`p`,{className:`break-all`,children:t(`gatePolicy`,{fingerprint:e.policy.fingerprint.slice(0,12)})}),(0,z.jsx)(`p`,{children:t(`gatePolicyStatus`,{status:t(e.policy.status===`valid`?`gatePolicyValid`:`gatePolicyInvalid`)})}),(0,z.jsx)(`p`,{className:`break-all`,children:e.sourceBatchRunId?t(`gateSourceBatch`,{batchId:e.sourceBatchRunId}):t(`gateNoBatch`)}),(0,z.jsx)(`p`,{className:`break-words`,children:t(`gateApplicability.label`,{workspace:t(`gateApplicability.${e.presentApplicability.workspace}`),policy:t(`gateApplicability.${e.presentApplicability.policy}`),overall:t(Ee(e.presentApplicability.appliesToCurrentState))})})]}),e.reasonCodes.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`font-medium text-foreground`,children:t(`gateReasonsTitle`)}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.reasonCodes.map(e=>(0,z.jsx)(`li`,{children:t(`reason.${e}`)},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`font-medium text-foreground`,children:t(`gateEvidenceTitle`)}),(0,z.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.policy.definitions.map(n=>{let r=Te(e,e.evaluatedAttempts.find(e=>e.definition_id===n.id));return(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-xl border border-border/60 p-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`break-words text-sm font-medium text-foreground`,children:n.name}),(0,z.jsx)(`code`,{className:`mt-1 block break-all text-xs text-muted-foreground`,children:n.command})]}),(0,z.jsx)(`span`,{className:x(`shrink-0 rounded-full border px-2 py-1 text-xs`,q[r]),children:t(`evidence.${r}`)})]},n.id)})})]}),e.policy.status===`invalid`&&(0,z.jsx)(`p`,{className:`break-words text-amber-200`,children:e.policy.error})]})})]})},Oe=e=>e.execution_status===`completed`?`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`:e.execution_status===`failed`||e.execution_status===`interrupted`?`border-red-400/30 bg-red-500/10 text-red-200`:e.execution_status===`running`||e.execution_status===`queued`?`border-sky-400/30 bg-sky-500/10 text-sky-200`:`border-border bg-muted/40 text-muted-foreground`,ke=e=>e.execution_status===`completed`&&e.outcome&&e.outcome!==`passed`?`outcomeValue.${e.outcome}`:`status.${e.execution_status}`,Ae=(e,t,n,r)=>((t?.attempts.find(t=>t.attempt_run_id===e.execution_run_id))?.diagnostics.filter(e=>n.has(e.id)).length??0)+ +!!r.has(e.execution_run_id),je=({definitions:e,attempts:t,requiredDefinitionIds:n,preReviewDefinitionIds:r,selectedDefinitionIds:i,selectedCheckId:a,diagnostics:o,selectedDiagnosticIds:s,selectedRawOutputAttemptRunIds:c,onToggleDefinition:l,onSelectCheck:u})=>{let{t:d}=w(`common`,{keyPrefix:`checksDialog`}),f=new Set(n),p=new Set(r),m=new Set(e.map(e=>e.id)),h=[...e.map(e=>({definition:e,attempt:t.find(t=>t.definition_id===e.id),historical:!1})),...t.filter(e=>!m.has(e.definition_id)).map(e=>({definition:e.command_snapshot,attempt:e,historical:!0}))];return(0,z.jsxs)(`section`,{"aria-labelledby":`configured-checks-heading`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(`header`,{className:`shrink-0 border-b border-border/60 px-4 py-4 sm:px-5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,z.jsx)(`h2`,{id:`configured-checks-heading`,className:`text-sm font-semibold text-foreground`,children:d(`configured`)}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d(`selectionHint`)})]}),(0,z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border/70 bg-background/35 p-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:d(`policySummary.title`)}),(0,z.jsx)(`p`,{className:`mt-1`,children:d(`policySummary.counts`,{requiredCount:n.length,preReviewCount:r.length})})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4 sm:px-5 md:max-h-none md:py-5 max-md:max-h-[min(35vh,18rem)]`,children:(0,z.jsx)(`ul`,{"aria-label":d(`configured`),className:`space-y-2`,children:h.map(({definition:e,attempt:t,historical:n})=>{let r=a===e.id,m=t?Ae(t,o,s,c):0,h=f.has(e.id),g=p.has(e.id),_=`${d(`category.${e.category}`)} · ${d(h?`required`:`optional`)} · ${d(g?`preReview`:`finalOnly`)}`;return(0,z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/30 p-2.5`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[!n&&(0,z.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4 shrink-0 accent-primary`,checked:i.has(e.id),"aria-label":d(`selectForRun`,{name:e.name}),onChange:t=>l(e.id,t.target.checked)}),t?(0,z.jsxs)(`button`,{type:`button`,className:x(`min-w-0 flex-1 cursor-pointer rounded-lg px-1.5 py-1 text-left outline-none transition-colors hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-ring/60`,r&&`bg-accent/60`),"aria-label":d(`inspectAttempt`,{name:e.name,status:d(ke(t))}),"aria-pressed":r,"aria-current":r?`true`:void 0,onClick:()=>u(e.id),children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:x(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium`,Oe(t)),children:d(ke(t))})]}),(0,z.jsx)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:_}),m>0&&(0,z.jsx)(`span`,{"data-evidence-selected":`true`,className:`mt-1.5 inline-flex rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[11px] text-amber-200`,children:d(`evidenceSelected`,{count:m})})]}):(0,z.jsxs)(`button`,{type:`button`,className:x(`min-w-0 flex-1 cursor-pointer rounded-lg px-1.5 py-1 text-left outline-none transition-colors hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-ring/60`,r&&`bg-accent/60`),"aria-label":d(`inspectAttempt`,{name:e.name,status:d(`status.notRun`)}),"aria-pressed":r,"aria-current":r?`true`:void 0,onClick:()=>u(e.id),children:[(0,z.jsx)(`span`,{className:`flex min-w-0 items-center justify-between gap-2`,children:(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,children:e.name})}),(0,z.jsx)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:_})]})]})},t?.execution_run_id??e.id)})})})]})},Me=(e,t)=>{let n=new Set(t?.attempts.filter(e=>e.parser.status===`complete`&&e.parser.retention_state===`retained`&&e.diagnostics.length>0).map(e=>e.attempt_run_id)??[]);return e.find(e=>e.execution_status===`failed`&&n.has(e.execution_run_id))??e.find(e=>e.execution_status===`failed`)??e.find(e=>e.execution_status===`running`)??e[0]??null},Ne=new Set([`queued`,`running`,`waiting`]),Pe=75,Fe=32,Ie=64,Le=3,Re=32,ze=8,J=(e,t)=>e instanceof O?e.message:t,Be=e=>{let t=new Set(e.repair.eligibility.eligible?e.repair.eligible_attempt_run_ids:[]);return new Set(e.attempts.filter(e=>t.has(e.attempt_run_id)).flatMap(e=>e.diagnostics.map(e=>e.id)))},Ve=e=>new Set(e.repair.eligibility.eligible?e.repair.eligible_raw_output_attempt_run_ids:[]),He=({projectId:e,targetKind:n,targetBundleId:r,definitions:i,requiredDefinitionIds:a=[],preReviewDefinitionIds:o=[],gateEvaluationId:s=null,directBatchRunId:l=null,directAttemptRunId:u=null,onSelectionChange:d,onUnavailable:f,onStatusChange:p})=>{let{t:h}=w(`common`,{keyPrefix:`checksDialog`}),g=ne(),[_,v]=(0,R.useState)(()=>new Set(i.map(e=>e.id))),[y,ee]=(0,R.useState)(null),[b,x]=(0,R.useState)(null),[C,E]=(0,R.useState)(null),[re,ie]=(0,R.useState)(null),[D,k]=(0,R.useState)(!0),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(null),[se,P]=(0,R.useState)(new Set),[ce,ue]=(0,R.useState)(new Set),[me,F]=(0,R.useState)(``),[he,ve]=(0,R.useState)(null),[I,L]=(0,R.useState)(!1),[be,xe]=(0,R.useState)(0),[Se,B]=(0,R.useState)(null),V=(0,R.useRef)(y),H=(0,R.useRef)(null),U=(0,R.useRef)(new Set),Ce=(0,R.useRef)(new Map),W=(0,R.useRef)(0),G=(0,R.useRef)(0),K=(0,R.useRef)(null),q=(0,R.useRef)(!1),Te=(0,R.useRef)(!0),Ee=(0,R.useRef)(null),Oe=(0,R.useRef)(`automatic`),ke=(0,R.useRef)(null),Ae=(0,R.useRef)(async()=>void 0),He=(0,R.useRef)(async()=>void 0),Ue=(0,R.useRef)(()=>void 0),We=(0,R.useRef)(0),Ge=(0,R.useRef)(M);V.current=y,Ge.current=M,Te.current=D||A!==null;let Y=(0,R.useCallback)((e,t)=>{Ee.current=e,Oe.current=t,E(e)},[]),Ke=(0,R.useCallback)(e=>{N(e),ve(e.latest_repair?.source_batch_run_id===e.batch_run_id?e.latest_repair:null),P(t=>{let n=Be(e);return new Set([...t].filter(e=>n.has(e)))}),ue(t=>{let n=Ve(e);return new Set([...t].filter(e=>n.has(e)))}),F(t=>e.repair.candidate_tickets.some(e=>e.id===t)?t:e.repair.candidate_tickets.length===1&&e.repair.accepts_ticket_id?e.repair.candidate_tickets[0].id:``);let t=V.current;Oe.current===`automatic`&&t?.batch.execution_run_id===e.batch_run_id&&Y(Me(t.attempts,e)?.execution_run_id??null,`automatic`)},[Y]),qe=(0,R.useCallback)(e=>{let t=Ce.current;if(!t.has(e.attempt_run_id)&&t.size>=Fe){let e=t.keys().next().value;e&&(t.delete(e),U.current.delete(e))}let n=t.get(e.attempt_run_id)??[];t.set(e.attempt_run_id,[...n.slice(-(Ie-1)),e])},[]),Je=(0,R.useCallback)((e,t,n=`route`)=>{let r=V.current?.batch.execution_run_id===e.batch.execution_run_id?V.current:null,i=!1,a=new Set(e.attempts.map(e=>e.execution_run_id));for(let e of Ce.current.keys())a.has(e)||(Ce.current.delete(e),U.current.delete(e));let o=e.attempts.map(e=>{let t=!1,n=r?.attempts.find(t=>t.execution_run_id===e.execution_run_id),a=n&&n.output_revision>e.output_revision?n:e,o=Ce.current.get(e.execution_run_id)??[];for(let e of[...o].sort((e,t)=>e.revision-t.revision)){let n=fe(te(a),e);if(n.status===`refetch`){t=!0,i=!0;continue}n.status===`applied`&&(a={...a,output_revision:n.snapshot.revision,retained_start_offset:n.snapshot.retainedStartOffset,retained_end_offset:n.snapshot.totalByteCount,total_persisted_bytes:n.snapshot.totalByteCount,retained_output:n.snapshot.retainedText})}return t?U.current.add(e.execution_run_id):(U.current.delete(e.execution_run_id),Ce.current.delete(e.execution_run_id)),a}),s={...e,attempts:o};K.current=e.batch.execution_run_id,V.current=s,ee(s);let c=t?s.attempts.find(e=>e.execution_run_id===t):null,l=Ee.current,u=Oe.current,p=!!(l&&s.attempts.some(e=>e.execution_run_id===l)),m=Me(s.attempts,Ge.current?.batch_run_id===s.batch.execution_run_id?Ge.current:null),g=ke.current,_=!!(g&&g.batchRunId===s.batch.execution_run_id&&g.attemptRunId===t),v=!!(g&&g.previousBatchRunId===s.batch.execution_run_id&&g.previousAttemptRunId===t);if(n===`reset`)Y(m?.execution_run_id??null,`automatic`);else if(t)if(c)if(_)Y(c.execution_run_id,`manual`);else if(v&&u===`manual`)Y(p?l:m?.execution_run_id??null,p?`manual`:`automatic`);else{let e=u!==`external`||l!==c.execution_run_id;Y(c.execution_run_id,`external`),e&&d?.(s.batch.execution_run_id,c.execution_run_id)}else _||v?u===`manual`&&p?Y(l,`manual`):Y(m?.execution_run_id??null,`automatic`):(Y(t,`external`),f?.());else n===`preserve`?u===`external`&&l?p?Y(l,`external`):(Y(l,`external`),f?.()):u===`manual`&&p?Y(l,`manual`):Y(u===`automatic`&&p?l:m?.execution_run_id??null,`automatic`):u===`manual`&&p?Y(l,`manual`):Y(m?.execution_run_id??null,`automatic`);i?Ue.current(e.batch.execution_run_id):We.current=0,q.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe))},[d,f,h,Y]),X=(0,R.useCallback)(async(t,n)=>{let r=++W.current,i=await S(e,t,n);if(r!==W.current||i.batch.execution_run_id!==t||K.current!==null&&K.current!==t){i.batch.execution_run_id!==t&&f?.();return}Je(i,t===l?u:null)},[u,l,Je,f,e]);Ae.current=X,Ue.current=(0,R.useCallback)(e=>{if(H.current)return;if(We.current>=Le){We.current=0,U.current.clear(),Ce.current.clear();return}let t=Pe*2**We.current;H.current=setTimeout(()=>{H.current=null,We.current+=1,Ae.current(e).catch(t=>{B(J(t,h(`errors.load`))),U.current.size>0&&Ue.current(e)})},t)},[h]);let Z=(0,R.useCallback)(async t=>{let i=++W.current,a=await ye(e,n,r,t);if(i===W.current){if(a.batch_run_id){K.current=a.batch_run_id,await X(a.batch_run_id,t);return}!t?.aborted&&i===W.current&&(K.current=null,V.current=null,ee(null),Y(null,`automatic`))}},[X,e,r,n,Y]),Ye=(0,R.useCallback)(async()=>{if(s||l){let e=K.current;e&&await X(e);return}await Z()},[l,s,X,Z]);He.current=Ye;let Xe=(0,R.useCallback)(e=>{H.current||=setTimeout(()=>{H.current=null,X(e).catch(e=>B(J(e,h(`errors.load`))))},Pe)},[X,h]);(0,R.useEffect)(()=>{let n=new AbortController;return k(!0),B(null),(async()=>{if(l){if(x(null),u){let t=await _e(e,u,n.signal);if(t.run.kind!==`check_attempt`||t.details.kind!==`check_attempt`||!t.details.available||!t.details.attempt||t.details.attempt.batch_run_id!==l){f?.();return}}K.current=l,await X(l,n.signal);return}if(!s){x(null),await Z(n.signal);return}let r=await t(e,s,n.signal);if(x(r),r.sourceBatchRunId){K.current=r.sourceBatchRunId,await X(r.sourceBatchRunId,n.signal);return}K.current=null,V.current=null,ee(null),Y(null,`automatic`)})().catch(e=>{le(e)||(e instanceof O&&e.status===404&&f?.(),B(J(e,h(`errors.load`))))}).finally(()=>{n.signal.aborted||(k(!1),Te.current=!1,q.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe)))}),()=>n.abort()},[u,l,s,X,Z,f,e,h,Y]),(0,R.useEffect)(()=>{let t=y?.batch.execution_run_id;if(!t){G.current+=1,N(null),P(new Set),ue(new Set),F(``),ve(null);return}Ge.current?.batch_run_id!==t&&(N(null),P(new Set),ue(new Set),F(``),ve(null));let n=++G.current,r=new AbortController;return m(e,t,r.signal).then(e=>{n===G.current&&e.batch_run_id===t&&K.current===t&&Ke(e)}).catch(e=>{le(e)||B(J(e,h(`errors.diagnostics`)))}),()=>r.abort()},[y?.batch.execution_run_id,be,Ke,e,h]),(0,R.useEffect)(()=>{let t=t=>{if(t.project_id!==e)return;let n=K.current;if(n!==null&&t.batch_run_id!==n)return;let r=V.current;if(!r||U.current.has(t.attempt_run_id)){qe(t),r&&U.current.has(t.attempt_run_id)&&Ue.current(r.batch.execution_run_id);return}let i=r.attempts.findIndex(e=>e.execution_run_id===t.attempt_run_id);if(i<0){qe(t),Xe(r.batch.execution_run_id);return}let a=r.attempts[i],o=fe(te(a),t);if(o.status===`ignored`)return;if(o.status===`refetch`){U.current.add(t.attempt_run_id),qe(t),Ue.current(r.batch.execution_run_id);return}let s=[...r.attempts];s[i]={...a,output_revision:o.snapshot.revision,retained_start_offset:o.snapshot.retainedStartOffset,retained_end_offset:o.snapshot.totalByteCount,total_persisted_bytes:o.snapshot.totalByteCount,retained_output:o.snapshot.retainedText};let c={...r,attempts:s};V.current=c,ee(c)},n=t=>{if(t.project_id&&t.project_id!==e)return;if(Te.current){q.current=!0;return}let n=V.current,r=t.execution_run_id??t.id;if(xe(e=>e+1),he&&r===he.execution_run_id&&he.source_batch_run_id===K.current&&ae(e,he.execution_run_id).then(ve).catch(()=>void 0),n&&(r===n.batch.execution_run_id||n.attempts.some(e=>e.execution_run_id===r))){W.current+=1,Xe(n.batch.execution_run_id);return}q.current=!0,!Te.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe))},r=()=>{xe(e=>e+1),Ye().catch(e=>B(J(e,h(`errors.load`))))};return g.on(`check-attempt:output`,t),g.on(`execution-run:updated`,n),g.on(`lifecycle-event:created`,n),g.on(`connect`,r),()=>{g.off(`check-attempt:output`,t),g.off(`execution-run:updated`,n),g.off(`lifecycle-event:created`,n),g.off(`connect`,r)}},[he,qe,e,Ye,Xe,g,h]),(0,R.useEffect)(()=>()=>{H.current&&clearTimeout(H.current),U.current.clear(),Ce.current.clear()},[]);let Ze=(e,t)=>{W.current+=1,K.current=e.batch.execution_run_id,Je(e,null,t)},Qe=async(e,t)=>{W.current+=1,Te.current=!0,j(e),B(null);try{let n=await t();e!==`stop`&&(ke.current=null),Ze(n,e===`stop`?`preserve`:`reset`),e!==`stop`&&d?.(n.batch.execution_run_id,void 0)}catch(t){B(J(t,h(`errors.${e}`))),t instanceof O&&t.status===409&&await Ye().catch(()=>void 0)}finally{j(null),Te.current=D,q.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe))}},$e=y?Ne.has(y.batch.execution_status):!1,et=y?$e?`running`:y.batch.execution_status===`completed`?`finished`:y.batch.execution_status===`cancelled`||y.batch.execution_status===`interrupted`?`interrupted`:`error`:`inactive`,tt=y?.batch.execution_run_id??null,Q=M?.batch_run_id===tt?M:null,nt=he?.source_batch_run_id===tt?he:null,$=Q?.auto_fix??null,rt=!!($&&!$.terminal_reason),it=Q?Be(Q):new Set,at=Q?Ve(Q):new Set,ot=new Set([...se].filter(e=>it.has(e))),st=new Set([...ce].filter(e=>at.has(e))),ct=[..._],lt=y?.attempts.filter(e=>e.execution_status!==`completed`).length??0,ut=async()=>{let t=[...ot],n=[...st];if(!(!Q||!tt||K.current!==tt||Q.repair.eligibility.eligible!==!0||nt?.terminal_result===null||$&&!$.terminal_reason||t.length===0&&n.length===0)){L(!0),B(null);try{let r=await oe(e,t,n,Q.repair.accepts_ticket_id?Q.repair.candidate_tickets.some(e=>e.id===me)?me:Q.repair.candidate_tickets[0]?.id||null:null);ve(r.source_batch_run_id===tt?r:null)}catch(t){if(B(J(t,h(`errors.repair`))),t instanceof O&&t.status===409&&y){let t=y.batch.execution_run_id,n=++G.current;m(e,t).then(e=>{n===G.current&&e.batch_run_id===t&&K.current===t&&Ke(e)}).catch(()=>void 0)}}finally{L(!1)}}},dt=async()=>{let t=$&&!$.terminal_reason?$.execution_run_id:nt?.execution_run_id;if(t){L(!0),B(null);try{let n=await pe(e,t);`source_batch_run_id`in n&&ve(n),xe(e=>e+1)}catch(e){B(J(e,h(`errors.repairStop`)))}finally{L(!1)}}},ft=new Set([...Q?.attempts.filter(e=>e.diagnostics.some(e=>ot.has(e.id))).map(e=>e.attempt_run_id)??[],...st]),pt=(e,t,n)=>{P(r=>{let i=new Set(r);if(!n)return i.delete(t),i;if(i.size>=Re||!Q||!it.has(t))return r;let a=new Set(Q.attempts.filter(e=>e.diagnostics.some(e=>i.has(e.id))).map(e=>e.attempt_run_id)??[]);return!a.has(e)&&a.size>=ze?r:(i.add(t),i)})},mt=(e,t)=>{ue(n=>{let r=new Set(n);return t?!ft.has(e)&&ft.size>=ze||!at.has(e)?n:(r.add(e),r):(r.delete(e),r)})},ht=(e,t)=>{v(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},gt=e=>{y&&(ie(null),ke.current={batchRunId:y.batch.execution_run_id,attemptRunId:e,previousBatchRunId:l===y.batch.execution_run_id?l:null,previousAttemptRunId:l===y.batch.execution_run_id?u:null},Y(e,`manual`),d?.(y.batch.execution_run_id,e))},_t=e=>{let t=y?.attempts.find(t=>t.definition_id===e);if(t){gt(t.execution_run_id);return}ie(e)},vt=re?y?.attempts.find(e=>e.definition_id===re)??null:y?.attempts.find(e=>e.execution_run_id===C)??null,yt=vt?.command_snapshot??i.find(e=>e.id===re)??null,bt=re??vt?.definition_id??null,xt=yt?{required:a.includes(yt.id),preReview:o.includes(yt.id)}:null;return(0,R.useEffect)(()=>{p?.(et)},[et,p]),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[Se&&(0,z.jsx)(`p`,{role:`alert`,className:`mx-4 mt-3 rounded-xl border border-red-400/25 bg-red-500/10 px-3 py-2 text-sm text-red-200 sm:mx-6`,children:Se}),(0,z.jsxs)(`div`,{role:`toolbar`,"aria-label":h(`runActions`),className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-y border-border/70 bg-background/30 px-4 py-3 sm:px-6`,children:[(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:h(`runActions`)})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(c,{type:`button`,size:`sm`,disabled:ct.length===0||$e||rt||A!==null,onClick:()=>void Qe(`run`,()=>ge(e,{targetKind:n,targetBundleId:r,definitionIds:ct})),children:h(A===`run`?`starting`:`runSelected`)}),y&&$e&&(0,z.jsx)(c,{type:`button`,variant:`destructive`,size:`sm`,disabled:A!==null||I,onClick:()=>void(rt?dt():Qe(`stop`,()=>T(e,y.batch.execution_run_id))),children:h(A===`stop`||I?`stopping`:`stop`)}),y&&!$e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(c,{type:`button`,variant:`outline`,size:`xs`,disabled:rt||A!==null,onClick:()=>void Qe(`rerun`,()=>de(e,y.batch.execution_run_id,{mode:`all`})),children:h(`rerunAll`)}),(0,z.jsx)(c,{type:`button`,variant:`outline`,size:`xs`,disabled:rt||A!==null||lt===0,onClick:()=>void Qe(`rerun`,()=>de(e,y.batch.execution_run_id,{mode:`failed_only`})),children:h(`rerunFailed`)})]})]})]}),(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,auto)_minmax(0,1fr)] overflow-hidden md:grid-cols-[19rem_minmax(0,1fr)] md:grid-rows-1`,children:[(0,z.jsx)(`aside`,{className:`flex min-h-0 flex-col border-b border-border/70 md:border-r md:border-b-0`,children:(0,z.jsx)(je,{definitions:i,attempts:y?.attempts??[],requiredDefinitionIds:a,preReviewDefinitionIds:o,selectedDefinitionIds:_,selectedCheckId:bt,diagnostics:Q,selectedDiagnosticIds:ot,selectedRawOutputAttemptRunIds:st,onToggleDefinition:ht,onSelectCheck:_t})}),(0,z.jsxs)(`main`,{className:`min-h-0 overflow-y-auto p-4 sm:p-6`,children:[s&&!b&&D&&(0,z.jsx)(`p`,{role:`status`,className:`mb-4 text-sm text-muted-foreground`,children:h(`gateLoading`)}),b&&(0,z.jsx)(De,{evaluation:b}),D&&(0,z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:h(`loading`)}),!D&&!y&&!yt&&(0,z.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border p-6 text-center`,children:[(0,z.jsx)(`h2`,{className:`font-medium text-foreground`,children:h(`emptyTitle`)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:h(`emptyDescription`)})]}),y&&(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:h(`status.${y.batch.execution_status}`)}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:h(`summary`,{passed:y.batch.passed_count,failed:y.batch.failed_count,running:y.batch.running_count,queued:y.batch.queued_count})}),y.batch.stop_requested&&(0,z.jsx)(`span`,{className:`text-xs text-amber-200`,children:h(`stopRequested`)})]})}),(y||yt)&&(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(we,{attempt:vt,definition:yt,diagnostics:Q?.attempts.find(e=>e.attempt_run_id===vt?.execution_run_id)??null,repair:Q?.repair??null,selectedDiagnosticIds:ot,selectedRawOutputAttemptRunIds:st,selectedAttemptRunIds:ft,selectedTicketId:me,pending:I,activeRepair:nt,autoFix:$,policy:xt,onSelectedTicketChange:F,onToggleDiagnostic:(e,t)=>vt&&pt(vt.execution_run_id,e,t),onToggleRawOutput:e=>vt&&mt(vt.execution_run_id,e),onStartRepair:()=>void ut(),onStopRepair:()=>void dt()})})]})]})]})},Ue=(e,t)=>A(F(`/projects/${e}/test-sessions`),{method:`POST`,body:t,fallbackErrorMessage:`Unable to open the test runner right now.`}),We=(e,t)=>A(F(`/tickets/${e}/test-sessions${t?`?project_id=${encodeURIComponent(t)}`:``}`),{method:`POST`,fallbackErrorMessage:`Unable to open the test runner right now.`}),Ge=(e,t={})=>A(F(`/test-sessions/${e}/discovery${t.commandId?`?command_id=${encodeURIComponent(t.commandId)}`:``}`),{signal:t.signal,fallbackErrorMessage:`Unable to discover tests right now.`}),Y=(e,t)=>A(F(`/test-sessions/${e}/run`),{method:`POST`,body:t,fallbackErrorMessage:`Unable to start the selected tests right now.`}),Ke=e=>A(F(`/test-sessions/${e}/stop`),{method:`POST`,fallbackErrorMessage:`Unable to stop the test run right now.`}),qe=e=>M(F(`/test-sessions/${e}`),{method:`DELETE`,fallbackErrorMessage:`Unable to close the test runner right now.`}),Je=256*1024,X=24,Z=(e,t)=>_.t(`common:testsDialog.${e}`,t),Ye=(e,t)=>{let n=`${e}${t}`;return n.length<=Je?n:n.slice(-Je)},Xe=(e,t)=>e?e.run_id&&t.run_id&&e.run_id!==t.run_id?e.status===`running`||t.status!==`running`?e:t:e.status!==`idle`&&e.status!==`running`&&t.status===`running`?e:e.run_id===t.run_id&&e.output.length>t.output.length?{...t,output:e.output,output_truncated:e.output_truncated||t.output_truncated}:t:t,Ze=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=X,Qe=e=>{e.scrollTop=e.scrollHeight},$e=(e,t=!1)=>{Qe(e);let n=0,r=0;return n=window.requestAnimationFrame(()=>{Qe(e),t&&(r=window.requestAnimationFrame(()=>{Qe(e)}))}),()=>{window.cancelAnimationFrame(n),r!==0&&window.cancelAnimationFrame(r)}},et=e=>e===`running`?`border-sky-400/40 bg-sky-500/10 text-sky-200`:e===`passed`?`border-emerald-400/40 bg-emerald-500/10 text-emerald-200`:e===`failed`||e===`error`?`border-rose-400/40 bg-rose-500/10 text-rose-200`:e===`stopped`?`border-amber-400/40 bg-amber-500/10 text-amber-200`:`border-border/70 bg-background/60 text-muted-foreground`,tt=e=>{if(e==null)return null;if(e<1e3)return`${e} ms`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${(e/1e3).toFixed(e>=1e4?0:1)} s`},Q=e=>{let t=e.split(`/`);return t[t.length-1]||e},nt=e=>e.toLowerCase().trim().split(/\s+/).filter(Boolean),$=(e,t)=>e.length===0?!0:e.every(e=>t.some(t=>t.includes(e))),rt=(e,t)=>{let n=nt(t);return n.length===0?e:e.flatMap(e=>{let t=Q(e.path);if($(n,[t.toLowerCase(),e.path.toLowerCase()]))return[e];let r=e.cases.filter(r=>$(n,[t.toLowerCase(),e.path.toLowerCase(),r.name.toLowerCase()]));return r.length===0?[]:[{...e,cases:r}]})},it=e=>Z(e===`passed`?`status.passed`:e===`failed`?`status.failed`:e===`running`?`status.running`:e===`error`?`status.error`:e===`stopped`?`status.stopped`:`status.idle`),at=e=>e?.selection?e.selection.kind===`all`?Z(`selection.allTests`):e.selection.kind===`case`?e.selection.name:Q(e.selection.path):Z(`selection.noRunYet`),ot=e=>/(^|\s)(?:FAIL|✗)(\s|$)|\b(?:failed|error|stderr|Expected:|Received:)\b/i.test(e)?`failure`:/(^|\s)(?:PASS|✓)(\s|$)|\bpassed\b/i.test(e)?`success`:/\b(?:WARN|warning|skipped|todo|pending)\b/i.test(e)?`warning`:`default`,st=e=>e===`failure`?`text-rose-200`:e===`success`?`text-emerald-200`:e===`warning`?`text-amber-200`:`text-slate-200`,ct=(e,t)=>e===t?!0:e.length===t.length?e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.name===r.name&&e.command===r.command&&e.cwd===r.cwd&&e.runner===r.runner}):!1,lt=`min-w-24 justify-center shadow-none transition-none disabled:opacity-100`,ut=({line:e,tone:t})=>(0,z.jsx)(`div`,{"data-tone":t,className:x(`whitespace-pre-wrap break-words`,st(t)),children:e===``?` `:e}),dt=(0,R.memo)(({canRunGranular:e,filePath:t,isActive:n,name:r,onRunCase:i})=>(0,z.jsxs)(`button`,{type:`button`,"aria-label":Z(`caseRow.runAriaLabel`,{name:r}),title:r,className:x(`flex w-full min-w-0 items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,e?`cursor-pointer hover:bg-sky-500/10`:`cursor-not-allowed opacity-60`,n&&`bg-sky-500/10`),disabled:!e,onClick:()=>{i(t,r)},children:[(0,z.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-sky-300/80`}),(0,z.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:r})]}));dt.displayName=`TestCaseRow`;var ft=(0,R.memo)(({activeSelectionKind:e,activeSelectionName:t,activeSelectionPath:n,canRunGranular:r,file:i,isExpanded:a,onRunCase:o,onRunFile:l,onToggleFile:u})=>{let d=e===`file`&&n===i.path,f=e===`case`&&n===i.path;return(0,z.jsx)(C,{open:a,onOpenChange:e=>{u(i.path,e)},children:(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(xe,{asChild:!0,children:(0,z.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":Z(a?`fileRow.collapseAriaLabel`:`fileRow.expandAriaLabel`,{path:i.path}),className:`mt-1 shrink-0 text-muted-foreground hover:text-foreground`,children:(0,z.jsx)(h,{className:x(`h-4 w-4 transition-transform`,a&&`rotate-180`)})})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Z(`fileRow.runAriaLabel`,{path:i.path}),className:x(`min-w-0 flex-1 rounded-xl border border-border/60 bg-background/20 px-2.5 py-2 text-left transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,r?`cursor-pointer hover:border-sky-400/35 hover:bg-sky-500/10`:`cursor-not-allowed opacity-60`,(d||f)&&`border-sky-400/45 bg-sky-500/10`),disabled:!r,onClick:()=>{l(i.path)},children:(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,z.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background/60 text-sky-200`,children:(0,z.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-xs font-medium text-foreground`,children:Q(i.path)}),(0,z.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-muted-foreground`,children:i.path})]}),(0,z.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:Z(`fileRow.testCount`,{count:i.cases.length})})]})]})})]}),(0,z.jsx)(I,{children:(0,z.jsx)(`div`,{className:`ml-4 border-l border-border/60 pl-6`,children:i.cases.length===0?(0,z.jsx)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:Z(`fileRow.noNamedTests`)}):(0,z.jsx)(`div`,{className:`space-y-1`,children:i.cases.map(a=>{let s=e===`case`&&n===i.path&&t===a.name;return(0,z.jsx)(dt,{canRunGranular:r,filePath:i.path,isActive:s,name:a.name,onRunCase:o},a.id)})})})})]})})});ft.displayName=`DiscoveryFileRow`;var pt=(0,R.memo)(({activeSelectionKind:e,activeSelectionName:t,activeSelectionPath:i,availableCommands:o,canRunGranular:s,discovery:l,expandedFiles:u,fullSuiteOnlyNotice:d,isLoading:p,selectedCommandId:m,selectedCommandName:g,sessionError:_,sessionStatus:v,shouldShowCommandSelector:y,onRunCase:ee,onRunFile:b,onSelectCommand:S,onToggleFile:C})=>{let[w,te]=(0,R.useState)(``),T=(0,R.useMemo)(()=>rt(l,w),[l,w]),E=(0,R.useMemo)(()=>T.reduce((e,t)=>e+t.cases.length,0),[T]),ne=nt(w).length>0;return(0,z.jsx)(`aside`,{className:`min-h-0 border-b border-border/70 px-4 py-4 lg:border-r lg:border-b-0`,children:(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[y&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:Z(`scope.label`)}),(0,z.jsxs)(f,{children:[(0,z.jsx)(se,{asChild:!0,children:(0,z.jsxs)(c,{type:`button`,variant:`outline`,className:`w-full justify-between rounded-xl border-border/70 bg-background/60`,"aria-label":Z(`scope.selectedCommandAriaLabel`),disabled:o.length===0||v===`running`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:g??Z(`scope.selectTestScope`)}),(0,z.jsx)(h,{className:`h-4 w-4 text-muted-foreground`})]})}),(0,z.jsx)(P,{align:`start`,className:`w-72`,children:o.map(e=>(0,z.jsx)(n,{className:x(m===e.id&&`bg-accent text-accent-foreground`),onSelect:()=>{S(e.id)},children:(0,z.jsx)(`span`,{className:`truncate`,children:e.name})},e.id))})]})]}),d&&(0,z.jsx)(`div`,{className:`rounded-2xl border border-border/70 bg-background/30 px-4 py-3 text-sm text-muted-foreground`,children:d}),(l.length>0||w.length>0)&&(0,z.jsxs)(`div`,{className:`relative mt-1 shrink-0`,children:[(0,z.jsx)(r,{type:`search`,value:w,onChange:e=>{te(e.target.value)},placeholder:Z(`filter.placeholder`),"aria-label":Z(`filter.ariaLabel`),className:`pr-10`}),w.length>0&&(0,z.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":Z(`filter.clearAriaLabel`),className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{te(``)},children:(0,z.jsx)(be,{className:`size-4`})})]}),!o.length&&(0,z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-4 text-sm text-muted-foreground`,children:Z(`discovery.noCommands`)}),_&&(0,z.jsx)(`div`,{className:`rounded-2xl border border-rose-500/30 bg-rose-500/10 px-4 py-3 text-sm text-rose-200`,children:_}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden rounded-2xl border border-border/70 bg-background/20 p-4`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 flex items-start justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[Z(`discovery.fileCount`,{count:T.length}),`, `,Z(`discovery.caseCount`,{count:E})]})}),p&&(0,z.jsx)(a,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto pr-1`,children:l.length===0&&!p?(0,z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:Z(`discovery.noFilesDetected`)}):T.length===0?(0,z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:Z(`discovery.noFilterMatches`)}):T.map(n=>(0,z.jsx)(ft,{activeSelectionKind:e,activeSelectionName:t,activeSelectionPath:i,canRunGranular:s,file:n,isExpanded:ne||(u[n.path]??!1),onRunCase:ee,onRunFile:b,onToggleFile:C},n.path))})]})]})})});pt.displayName=`DiscoveryPane`;var mt=(0,R.memo)(({durationMs:e,output:t,outputTruncated:n,selectionLabel:r,status:i,summaryCounts:a,viewportRef:o,onScroll:s})=>{let c=(0,R.useMemo)(()=>t?N(t).replace(/\r\n/g,`
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,A as n,B as r,D as i,F as a,G as o,I as s,J as c,K as l,L as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,V as y,W as ee,X as b,Y as x,Z as S,_ as C,_t as w,a as te,at as T,b as E,c as ne,d as re,dt as ie,et as ae,f as D,ft as O,g as k,gt as A,h as j,ht as M,i as N,it as oe,j as se,k as P,m as ce,mt as le,n as ue,nt as de,o as fe,ot as pe,p as me,pt as F,q as he,rt as ge,s as _e,t as ve,tt as ye,v as I,vt as L,w as be,y as xe}from"./index-Ci2Or91O.js";var R=e(L(),1),z=ie(),Se=({title:e,children:t,defaultOpen:n=!1})=>(0,z.jsxs)(C,{defaultOpen:n,className:`mt-5 rounded-2xl border border-border/70 bg-background/25`,children:[(0,z.jsx)(xe,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"aria-label":e,className:`group flex w-full items-center gap-2 rounded-2xl px-4 py-3 text-left outline-none transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring/60`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-semibold text-foreground`,children:e}),(0,z.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,z.jsx)(I,{className:`border-t border-border/60 px-4 py-3`,children:t})]}),B=e=>{if(!e.file_path)return null;if(!e.start_line)return e.file_path;let t=`${e.start_line}${e.start_column?`:${e.start_column}`:``}`,n=e.end_line?`-${e.end_line}${e.end_column?`:${e.end_column}`:``}`:``;return`${e.file_path}:${t}${n}`},V=[`error`,`warning`,`info`,`unknown`],H=e=>{let t={error:0,warning:0,info:0,unknown:0};return e.forEach(e=>{t[e.severity]+=1}),t},U=({counts:e,totalCount:t})=>{let{t:n}=w(`common`,{keyPrefix:`checksDialog.diagnostics`}),r=V.filter(t=>e[t]>0);return(0,z.jsxs)(`div`,{"aria-label":n(`severitySummaryLabel`),className:`mt-3 flex flex-wrap items-center gap-2`,children:[r.map(t=>(0,z.jsx)(`span`,{className:`rounded-full border border-border/70 bg-background/45 px-2 py-1 text-[11px] text-muted-foreground`,children:n(`severityCount`,{count:e[t],severity:n(`severity.${t}`)})},t)),t>0&&t!==r.reduce((t,n)=>t+e[n],0)&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`totalAvailable`,{count:t})})]})},Ce=({attempt:e,parser:t,repair:n,ticketRequired:r,selectedTicketId:i,onSelectedTicketChange:a})=>{let{t:o}=w(`common`,{keyPrefix:`checksDialog.diagnostics`}),s=e.currency??`unavailable`;return(0,z.jsxs)(C,{className:`mt-4 rounded-xl border border-border/60 bg-background/25`,children:[(0,z.jsx)(xe,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"aria-label":o(`technicalDetails`),className:`group flex w-full items-center gap-2 rounded-xl px-3 py-2.5 text-left outline-none transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring/60`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:o(`technicalDetails`)}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:o(`technicalDetailsHint`)}),(0,z.jsx)(h,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,z.jsxs)(I,{className:`border-t border-border/60 px-3 py-3`,children:[(0,z.jsxs)(`dl`,{className:`grid gap-3 text-xs sm:grid-cols-2`,children:[t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`parserLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`parser.${t.parser_kind}`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`parserStateLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`state.${t.status}`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`parserRetentionLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`retentionState.${t.retention_state}`)})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`outputRetentionLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`retentionState.${e.output_retention_state}`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`applicabilityLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`applicability`,{state:o(`applicabilityState.${s}`)})})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`sourceLabel`)}),(0,z.jsx)(`dd`,{className:`mt-1 break-words text-foreground`,children:e.command_snapshot.name})]}),n&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:o(`destinationTitle`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-foreground`,children:o(`destination.${n.destination}`)}),(0,z.jsx)(`dd`,{className:`mt-1 text-muted-foreground`,children:o(`destinationHint`)})]})]}),r&&n&&(0,z.jsxs)(`label`,{className:`mt-3 block text-xs text-muted-foreground`,children:[o(`ticketLabel`),(0,z.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`mt-1 h-10 w-full rounded-xl border border-border bg-card px-3 text-sm text-foreground`,children:[(0,z.jsx)(`option`,{value:``,children:o(`ticketPlaceholder`)}),n.candidate_tickets.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]})]})]})},W=({attempt:e,diagnostics:t,repair:n,selectedDiagnosticIds:r,selectedRawOutputAttemptRunIds:i,selectedAttemptRunIds:a,selectedTicketId:o,pending:s,activeRepair:l,autoFix:u,onSelectedTicketChange:d,onToggleDiagnostic:f,onToggleRawOutput:p,onStartRepair:m,onStopRepair:h})=>{let{t:g}=w(`common`,{keyPrefix:`checksDialog.diagnostics`}),{t:_}=w(`common`,{keyPrefix:`checksDialog`});if(e.execution_status!==`failed`)return null;let v=t?.parser??null,y=t?.diagnostics??[],ee=H(y),b=!!(u&&!u.terminal_reason),x=u?.attempts[u.attempts.length-1]??null,S=l?.terminal_result===null||b,C=!!(n?.eligibility.eligible&&n.eligible_attempt_run_ids.includes(e.execution_run_id)&&v?.status===`complete`&&v.retention_state===`retained`),te=!!(n?.eligibility.eligible&&n.eligible_raw_output_attempt_run_ids.includes(e.execution_run_id)&&e.output_retention_state===`retained`&&e.retained_output),T=i.has(e.execution_run_id),E=r.size,ne=E>=32,re=a.size>=8&&!a.has(e.execution_run_id),ie=ne?g(`diagnosticLimit`,{count:32}):re?g(`attemptLimit`,{count:8}):null,ae=!!(n?.accepts_ticket_id&&n.candidate_tickets.length>1),D=E+i.size,O=D>0&&(!ae||o!==``),k=n&&!n.eligibility.eligible?g(`disabled.${n.eligibility.reason}`):null,A=v&&t&&(v.status===`interrupted`||y.length===0&&[`unsupported`,`malformed`].includes(v.status))?v.status:null,j=!!(v&&t&&y.length===0&&v.status===`complete`&&v.retention_state===`retained`&&v.diagnostic_count===0),M=!!(v&&t&&y.length===0&&v.status===`complete`&&v.retention_state===`retained`&&v.diagnostic_count>0),N=v?.diagnostic_count??y.length;return(0,z.jsxs)(`section`,{"aria-labelledby":`diagnostics-${e.execution_run_id}`,className:`mt-5 rounded-2xl border border-border/70 bg-background/25 p-4`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{id:`diagnostics-${e.execution_run_id}`,className:`text-sm font-semibold text-foreground`,children:g(`title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:v&&v.status===`pending`?g(`loading`):v&&N>0?M||v.retention_state===`expired`?g(`totalAvailable`,{count:N}):g(`availableCount`,{count:N}):g(t?`noneAvailable`:`loading`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:g(`failureOutcome`,{outcome:e.outcome?_(`outcomeValue.${e.outcome}`):_(`status.${e.execution_status}`)})}),t&&y.length>0&&(0,z.jsx)(U,{counts:ee,totalCount:N})]})}),v?.retention_state===`expired`&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-amber-200`,children:g(`expired`)}),v?.truncated&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-amber-200`,children:g(`truncated`)}),A&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:g(`fallback.${A}`)}),j&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:g(`noStructuredDiagnostics`)}),M&&(0,z.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:g(`structuredDetailsUnavailable`)}),te&&(0,z.jsxs)(`label`,{className:`mt-4 flex items-start gap-3 rounded-xl border border-amber-400/25 bg-amber-500/5 p-3`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4 accent-primary`,"aria-label":g(`rawOutputSelect`),checked:T,disabled:S||!T&&re,onChange:e=>p(e.target.checked)}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:g(`rawOutputSelect`)}),(0,z.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:g(`rawOutputHint`)}),e.retained_start_offset>0&&(0,z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-200`,children:g(`rawOutputTruncated`)})]})]}),t&&y.length>0&&(0,z.jsxs)(`fieldset`,{className:`mt-4`,children:[(0,z.jsx)(`legend`,{className:`text-xs font-medium text-muted-foreground`,children:g(`selectLegend`)}),(0,z.jsx)(`ul`,{className:`mt-2 space-y-2`,children:y.map(e=>{let t=B(e),n=r.has(e.id);return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-border/60 bg-background/35 p-3`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4 accent-primary`,checked:n,disabled:!C||S||!n&&ie!==null,onChange:t=>f(e.id,t.target.checked)}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-semibold uppercase text-foreground`,children:g(`severity.${e.severity}`)}),e.code&&(0,z.jsx)(`code`,{children:e.code})]}),(0,z.jsx)(`span`,{className:`mt-1 block break-words text-sm text-foreground`,children:e.message}),t&&(0,z.jsx)(`span`,{className:`mt-1 block break-all font-mono text-xs text-muted-foreground`,children:t})]})]})},e.id)})})]}),k&&(0,z.jsx)(`p`,{className:`mt-3 text-xs text-amber-200`,children:k}),ie&&(0,z.jsx)(`p`,{className:`mt-3 text-xs text-amber-200`,children:ie}),l&&(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-sky-400/25 bg-sky-500/10 p-3 text-sm`,children:[(0,z.jsx)(`p`,{className:`font-medium text-sky-100`,children:g(l.terminal_result?`repairResult.${l.terminal_result}`:`repairRunning`)}),l.terminal_message&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-sky-100/80`,children:l.terminal_message})]}),u&&(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-sky-400/25 bg-sky-500/10 p-3 text-sm`,role:`status`,children:[(0,z.jsx)(`p`,{className:`font-medium text-sky-100`,children:u.terminal_reason?g(`autoFix.terminal.${u.terminal_reason}`):x?.fallback_used?g(`autoFix.phase.fallback`):g(`autoFix.phase.${u.phase}`)}),!u.terminal_reason&&u.attempt_count>0&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-sky-100/80`,children:g(`autoFix.attempt`,{current:u.attempt_count,total:u.max_attempts})})]}),(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`selectedEvidence`,{count:D})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(c,{type:`button`,size:`sm`,disabled:n?.eligibility.eligible!==!0||!O||s||S,title:k??void 0,onClick:m,children:s?g(`starting`):g(`repairSelectedEvidence`,{count:D})}),S&&(0,z.jsx)(c,{type:`button`,variant:`destructive`,size:`sm`,disabled:s||u?.phase===`stopping`,onClick:h,children:g(b?`autoFix.stop`:`stopRepair`)})]})]}),(0,z.jsx)(Ce,{attempt:e,parser:v,repair:n,ticketRequired:ae,selectedTicketId:o,onSelectedTicketChange:d})]})},G=({attempt:e})=>{let{t}=w(`common`,{keyPrefix:`checksDialog`}),n=e.retained_output?N(e.retained_output):``;return(0,z.jsxs)(Se,{title:t(`rawOutput`),defaultOpen:!0,children:[e.output_retention_state===`expired`&&(0,z.jsx)(`p`,{className:`rounded-xl border border-border bg-background/30 p-4 text-sm text-muted-foreground`,children:t(`outputExpired`)}),e.output_retention_state===`retained`&&!n&&(0,z.jsx)(`p`,{className:`rounded-xl border border-border bg-background/30 p-4 text-sm text-muted-foreground`,children:t(`outputEmpty`)}),e.output_retention_state===`retained`&&n&&(0,z.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-xl border border-border bg-[#090b12] p-4 font-mono text-xs text-slate-200`,children:n}),e.retained_start_offset>0&&(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:t(`outputTruncated`)})]})},K=({definition:e,policy:t})=>{let{t:n}=w(`common`,{keyPrefix:`checksDialog`});return(0,z.jsxs)(`article`,{"aria-labelledby":`configured-check-${e.id}`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{id:`configured-check-${e.id}`,className:`text-lg font-semibold text-foreground`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:n(`status.notRun`)})]})}),(0,z.jsx)(`p`,{className:`mt-4 rounded-xl border border-dashed border-border px-3 py-2 text-sm text-muted-foreground`,children:n(`notRunDescription`)}),(0,z.jsxs)(`dl`,{className:`mt-4 grid gap-3 text-sm sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n(`command`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 break-words font-mono text-xs text-foreground`,children:e.command})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n(`directory`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:e.cwd??n(`targetRoot`)})]}),t&&(0,z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:n(`policyLabel`)}),(0,z.jsxs)(`dd`,{className:`mt-0.5 break-words text-foreground`,children:[n(t.required?`required`:`optional`),` · `,n(t.preReview?`preReview`:`finalOnly`)]})]})]})]})},we=({attempt:e,definition:t,diagnostics:n,repair:r,selectedDiagnosticIds:i,selectedRawOutputAttemptRunIds:a,selectedAttemptRunIds:o,selectedTicketId:s,pending:c,activeRepair:l,autoFix:u,onSelectedTicketChange:d,onToggleDiagnostic:f,onToggleRawOutput:p,onStartRepair:m,onStopRepair:h,policy:g})=>{let{t:_}=w(`common`,{keyPrefix:`checksDialog`}),{t:v}=w(`common`,{keyPrefix:`activityView`});return e?(0,z.jsxs)(`article`,{"aria-labelledby":`selected-check-${e.execution_run_id}`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{id:`selected-check-${e.execution_run_id}`,className:`text-lg font-semibold text-foreground`,children:e.command_snapshot.name}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:_(`status.${e.execution_status}`)})]}),e.outcome&&(0,z.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:_(`outcomeValue.${e.outcome}`)})]}),(0,z.jsxs)(`dl`,{className:`mt-4 grid gap-3 text-sm sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`command`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 break-words font-mono text-xs text-foreground`,children:e.command_snapshot.command})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`directory`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:e.command_snapshot.cwd??_(`targetRoot`)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`outcome`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:e.outcome?_(`outcomeValue.${e.outcome}`):_(`status.${e.execution_status}`)})]}),e.currency&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`currencyLabel`)}),(0,z.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:v(`currency.${e.currency}`)})]}),g&&(0,z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:_(`policyLabel`)}),(0,z.jsxs)(`dd`,{className:`mt-0.5 break-words text-foreground`,children:[_(g.required?`required`:`optional`),` · `,_(g.preReview?`preReview`:`finalOnly`)]})]})]}),e.execution_status===`failed`&&(0,z.jsx)(W,{attempt:e,diagnostics:n,repair:r,selectedDiagnosticIds:i,selectedRawOutputAttemptRunIds:a,selectedAttemptRunIds:o,selectedTicketId:s,pending:c,activeRepair:l,autoFix:u,onSelectedTicketChange:d,onToggleDiagnostic:f,onToggleRawOutput:p,onStartRepair:m,onStopRepair:h}),(0,z.jsx)(G,{attempt:e},e.execution_run_id)]}):t?(0,z.jsx)(K,{definition:t,policy:g}):(0,z.jsxs)(`section`,{"aria-labelledby":`selected-check-heading`,className:`rounded-2xl border border-dashed border-border p-6`,children:[(0,z.jsx)(`h2`,{id:`selected-check-heading`,className:`font-medium text-foreground`,children:_(`selectAttemptTitle`)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:_(`selectAttemptDescription`)})]})},q={current:`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`,stale:`border-amber-400/30 bg-amber-500/10 text-amber-200`,failed:`border-red-400/30 bg-red-500/10 text-red-200`,missing:`border-border bg-muted/40 text-muted-foreground`,interrupted:`border-orange-400/30 bg-orange-500/10 text-orange-200`,blocked:`border-amber-400/30 bg-amber-500/10 text-amber-200`},Te=(e,t)=>e.presentApplicability.appliesToCurrentState===!1?`stale`:t?t.execution_status===`interrupted`||t.execution_status===`cancelled`?`interrupted`:t.execution_status===`failed`?`failed`:t.currency===`stale`?`stale`:t.outcome&&t.outcome!==`passed`?`failed`:t.outcome===`passed`&&t.currency===`current`?`current`:e.decision===`blocked`?`blocked`:`current`:`missing`,Ee=e=>e===!0?`gateApplicability.overallCurrent`:e===!1?`gateApplicability.overallStale`:`gateApplicability.overallUnverifiable`,De=({evaluation:e})=>{let{t}=w(`common`,{keyPrefix:`checksDialog`}),n=e.presentApplicability.appliesToCurrentState===!1?`gateStale`:e.presentApplicability.appliesToCurrentState===null?`gateUnverifiable`:e.decision===`passed`?`gatePassed`:`gateBlocked`,r=e.reasonCodes[0],i=r?t(`gateReasonSummary`,{reason:t(`reason.${r}`)}):e.decision===`passed`?t(`gatePassedSummary`):t(`gateBlockedSummary`);return(0,z.jsxs)(`section`,{"aria-labelledby":`automated-delivery-gate-heading`,className:`mb-5 rounded-2xl border border-border/70 bg-background/30 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{id:`automated-delivery-gate-heading`,className:`font-semibold text-foreground`,children:t(`gateTitle`)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:i})]}),(0,z.jsx)(`span`,{className:x(`shrink-0 rounded-full border px-2.5 py-1 text-xs font-medium`,e.decision===`passed`&&e.presentApplicability.appliesToCurrentState===!0?q.current:q.blocked),children:t(n)})]}),(0,z.jsx)(Se,{title:t(`gateDetails`),children:(0,z.jsxs)(`div`,{className:`space-y-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{children:t(`gateScope`)}),(0,z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,z.jsx)(`p`,{children:t(`gateBoundary.label`,{boundary:t(`gateBoundary.${e.boundaryKind}`)})}),(0,z.jsx)(`p`,{className:`break-all`,children:t(`gatePolicy`,{fingerprint:e.policy.fingerprint.slice(0,12)})}),(0,z.jsx)(`p`,{children:t(`gatePolicyStatus`,{status:t(e.policy.status===`valid`?`gatePolicyValid`:`gatePolicyInvalid`)})}),(0,z.jsx)(`p`,{className:`break-all`,children:e.sourceBatchRunId?t(`gateSourceBatch`,{batchId:e.sourceBatchRunId}):t(`gateNoBatch`)}),(0,z.jsx)(`p`,{className:`break-words`,children:t(`gateApplicability.label`,{workspace:t(`gateApplicability.${e.presentApplicability.workspace}`),policy:t(`gateApplicability.${e.presentApplicability.policy}`),overall:t(Ee(e.presentApplicability.appliesToCurrentState))})})]}),e.reasonCodes.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`font-medium text-foreground`,children:t(`gateReasonsTitle`)}),(0,z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.reasonCodes.map(e=>(0,z.jsx)(`li`,{children:t(`reason.${e}`)},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`font-medium text-foreground`,children:t(`gateEvidenceTitle`)}),(0,z.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.policy.definitions.map(n=>{let r=Te(e,e.evaluatedAttempts.find(e=>e.definition_id===n.id));return(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-xl border border-border/60 p-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`break-words text-sm font-medium text-foreground`,children:n.name}),(0,z.jsx)(`code`,{className:`mt-1 block break-all text-xs text-muted-foreground`,children:n.command})]}),(0,z.jsx)(`span`,{className:x(`shrink-0 rounded-full border px-2 py-1 text-xs`,q[r]),children:t(`evidence.${r}`)})]},n.id)})})]}),e.policy.status===`invalid`&&(0,z.jsx)(`p`,{className:`break-words text-amber-200`,children:e.policy.error})]})})]})},Oe=e=>e.execution_status===`completed`?`border-emerald-400/30 bg-emerald-500/10 text-emerald-200`:e.execution_status===`failed`||e.execution_status===`interrupted`?`border-red-400/30 bg-red-500/10 text-red-200`:e.execution_status===`running`||e.execution_status===`queued`?`border-sky-400/30 bg-sky-500/10 text-sky-200`:`border-border bg-muted/40 text-muted-foreground`,ke=e=>e.execution_status===`completed`&&e.outcome&&e.outcome!==`passed`?`outcomeValue.${e.outcome}`:`status.${e.execution_status}`,Ae=(e,t,n,r)=>((t?.attempts.find(t=>t.attempt_run_id===e.execution_run_id))?.diagnostics.filter(e=>n.has(e.id)).length??0)+ +!!r.has(e.execution_run_id),je=({definitions:e,attempts:t,requiredDefinitionIds:n,preReviewDefinitionIds:r,selectedDefinitionIds:i,selectedCheckId:a,diagnostics:o,selectedDiagnosticIds:s,selectedRawOutputAttemptRunIds:c,onToggleDefinition:l,onSelectCheck:u})=>{let{t:d}=w(`common`,{keyPrefix:`checksDialog`}),f=new Set(n),p=new Set(r),m=new Set(e.map(e=>e.id)),h=[...e.map(e=>({definition:e,attempt:t.find(t=>t.definition_id===e.id),historical:!1})),...t.filter(e=>!m.has(e.definition_id)).map(e=>({definition:e.command_snapshot,attempt:e,historical:!0}))];return(0,z.jsxs)(`section`,{"aria-labelledby":`configured-checks-heading`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(`header`,{className:`shrink-0 border-b border-border/60 px-4 py-4 sm:px-5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,z.jsx)(`h2`,{id:`configured-checks-heading`,className:`text-sm font-semibold text-foreground`,children:d(`configured`)}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d(`selectionHint`)})]}),(0,z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border/70 bg-background/35 p-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:d(`policySummary.title`)}),(0,z.jsx)(`p`,{className:`mt-1`,children:d(`policySummary.counts`,{requiredCount:n.length,preReviewCount:r.length})})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4 sm:px-5 md:max-h-none md:py-5 max-md:max-h-[min(35vh,18rem)]`,children:(0,z.jsx)(`ul`,{"aria-label":d(`configured`),className:`space-y-2`,children:h.map(({definition:e,attempt:t,historical:n})=>{let r=a===e.id,m=t?Ae(t,o,s,c):0,h=f.has(e.id),g=p.has(e.id),_=`${d(`category.${e.category}`)} · ${d(h?`required`:`optional`)} · ${d(g?`preReview`:`finalOnly`)}`;return(0,z.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-background/30 p-2.5`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[!n&&(0,z.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4 shrink-0 accent-primary`,checked:i.has(e.id),"aria-label":d(`selectForRun`,{name:e.name}),onChange:t=>l(e.id,t.target.checked)}),t?(0,z.jsxs)(`button`,{type:`button`,className:x(`min-w-0 flex-1 cursor-pointer rounded-lg px-1.5 py-1 text-left outline-none transition-colors hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-ring/60`,r&&`bg-accent/60`),"aria-label":d(`inspectAttempt`,{name:e.name,status:d(ke(t))}),"aria-pressed":r,"aria-current":r?`true`:void 0,onClick:()=>u(e.id),children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:x(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium`,Oe(t)),children:d(ke(t))})]}),(0,z.jsx)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:_}),m>0&&(0,z.jsx)(`span`,{"data-evidence-selected":`true`,className:`mt-1.5 inline-flex rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[11px] text-amber-200`,children:d(`evidenceSelected`,{count:m})})]}):(0,z.jsxs)(`button`,{type:`button`,className:x(`min-w-0 flex-1 cursor-pointer rounded-lg px-1.5 py-1 text-left outline-none transition-colors hover:bg-accent/60 focus-visible:ring-2 focus-visible:ring-ring/60`,r&&`bg-accent/60`),"aria-label":d(`inspectAttempt`,{name:e.name,status:d(`status.notRun`)}),"aria-pressed":r,"aria-current":r?`true`:void 0,onClick:()=>u(e.id),children:[(0,z.jsx)(`span`,{className:`flex min-w-0 items-center justify-between gap-2`,children:(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,children:e.name})}),(0,z.jsx)(`span`,{className:`mt-1 block truncate text-[11px] text-muted-foreground`,children:_})]})]})},t?.execution_run_id??e.id)})})})]})},Me=(e,t)=>{let n=new Set(t?.attempts.filter(e=>e.parser.status===`complete`&&e.parser.retention_state===`retained`&&e.diagnostics.length>0).map(e=>e.attempt_run_id)??[]);return e.find(e=>e.execution_status===`failed`&&n.has(e.execution_run_id))??e.find(e=>e.execution_status===`failed`)??e.find(e=>e.execution_status===`running`)??e[0]??null},Ne=new Set([`queued`,`running`,`waiting`]),Pe=75,Fe=32,Ie=64,Le=3,Re=32,ze=8,J=(e,t)=>e instanceof O?e.message:t,Be=e=>{let t=new Set(e.repair.eligibility.eligible?e.repair.eligible_attempt_run_ids:[]);return new Set(e.attempts.filter(e=>t.has(e.attempt_run_id)).flatMap(e=>e.diagnostics.map(e=>e.id)))},Ve=e=>new Set(e.repair.eligibility.eligible?e.repair.eligible_raw_output_attempt_run_ids:[]),He=({projectId:e,targetKind:n,targetBundleId:r,definitions:i,requiredDefinitionIds:a=[],preReviewDefinitionIds:o=[],gateEvaluationId:s=null,directBatchRunId:l=null,directAttemptRunId:u=null,onSelectionChange:d,onUnavailable:f,onStatusChange:p})=>{let{t:h}=w(`common`,{keyPrefix:`checksDialog`}),g=ne(),[_,v]=(0,R.useState)(()=>new Set(i.map(e=>e.id))),[y,ee]=(0,R.useState)(null),[b,x]=(0,R.useState)(null),[C,E]=(0,R.useState)(null),[re,ie]=(0,R.useState)(null),[D,k]=(0,R.useState)(!0),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(null),[se,P]=(0,R.useState)(new Set),[ce,ue]=(0,R.useState)(new Set),[me,F]=(0,R.useState)(``),[he,ve]=(0,R.useState)(null),[I,L]=(0,R.useState)(!1),[be,xe]=(0,R.useState)(0),[Se,B]=(0,R.useState)(null),V=(0,R.useRef)(y),H=(0,R.useRef)(null),U=(0,R.useRef)(new Set),Ce=(0,R.useRef)(new Map),W=(0,R.useRef)(0),G=(0,R.useRef)(0),K=(0,R.useRef)(null),q=(0,R.useRef)(!1),Te=(0,R.useRef)(!0),Ee=(0,R.useRef)(null),Oe=(0,R.useRef)(`automatic`),ke=(0,R.useRef)(null),Ae=(0,R.useRef)(async()=>void 0),He=(0,R.useRef)(async()=>void 0),Ue=(0,R.useRef)(()=>void 0),We=(0,R.useRef)(0),Ge=(0,R.useRef)(M);V.current=y,Ge.current=M,Te.current=D||A!==null;let Y=(0,R.useCallback)((e,t)=>{Ee.current=e,Oe.current=t,E(e)},[]),Ke=(0,R.useCallback)(e=>{N(e),ve(e.latest_repair?.source_batch_run_id===e.batch_run_id?e.latest_repair:null),P(t=>{let n=Be(e);return new Set([...t].filter(e=>n.has(e)))}),ue(t=>{let n=Ve(e);return new Set([...t].filter(e=>n.has(e)))}),F(t=>e.repair.candidate_tickets.some(e=>e.id===t)?t:e.repair.candidate_tickets.length===1&&e.repair.accepts_ticket_id?e.repair.candidate_tickets[0].id:``);let t=V.current;Oe.current===`automatic`&&t?.batch.execution_run_id===e.batch_run_id&&Y(Me(t.attempts,e)?.execution_run_id??null,`automatic`)},[Y]),qe=(0,R.useCallback)(e=>{let t=Ce.current;if(!t.has(e.attempt_run_id)&&t.size>=Fe){let e=t.keys().next().value;e&&(t.delete(e),U.current.delete(e))}let n=t.get(e.attempt_run_id)??[];t.set(e.attempt_run_id,[...n.slice(-(Ie-1)),e])},[]),Je=(0,R.useCallback)((e,t,n=`route`)=>{let r=V.current?.batch.execution_run_id===e.batch.execution_run_id?V.current:null,i=!1,a=new Set(e.attempts.map(e=>e.execution_run_id));for(let e of Ce.current.keys())a.has(e)||(Ce.current.delete(e),U.current.delete(e));let o=e.attempts.map(e=>{let t=!1,n=r?.attempts.find(t=>t.execution_run_id===e.execution_run_id),a=n&&n.output_revision>e.output_revision?n:e,o=Ce.current.get(e.execution_run_id)??[];for(let e of[...o].sort((e,t)=>e.revision-t.revision)){let n=fe(te(a),e);if(n.status===`refetch`){t=!0,i=!0;continue}n.status===`applied`&&(a={...a,output_revision:n.snapshot.revision,retained_start_offset:n.snapshot.retainedStartOffset,retained_end_offset:n.snapshot.totalByteCount,total_persisted_bytes:n.snapshot.totalByteCount,retained_output:n.snapshot.retainedText})}return t?U.current.add(e.execution_run_id):(U.current.delete(e.execution_run_id),Ce.current.delete(e.execution_run_id)),a}),s={...e,attempts:o};K.current=e.batch.execution_run_id,V.current=s,ee(s);let c=t?s.attempts.find(e=>e.execution_run_id===t):null,l=Ee.current,u=Oe.current,p=!!(l&&s.attempts.some(e=>e.execution_run_id===l)),m=Me(s.attempts,Ge.current?.batch_run_id===s.batch.execution_run_id?Ge.current:null),g=ke.current,_=!!(g&&g.batchRunId===s.batch.execution_run_id&&g.attemptRunId===t),v=!!(g&&g.previousBatchRunId===s.batch.execution_run_id&&g.previousAttemptRunId===t);if(n===`reset`)Y(m?.execution_run_id??null,`automatic`);else if(t)if(c)if(_)Y(c.execution_run_id,`manual`);else if(v&&u===`manual`)Y(p?l:m?.execution_run_id??null,p?`manual`:`automatic`);else{let e=u!==`external`||l!==c.execution_run_id;Y(c.execution_run_id,`external`),e&&d?.(s.batch.execution_run_id,c.execution_run_id)}else _||v?u===`manual`&&p?Y(l,`manual`):Y(m?.execution_run_id??null,`automatic`):(Y(t,`external`),f?.());else n===`preserve`?u===`external`&&l?p?Y(l,`external`):(Y(l,`external`),f?.()):u===`manual`&&p?Y(l,`manual`):Y(u===`automatic`&&p?l:m?.execution_run_id??null,`automatic`):u===`manual`&&p?Y(l,`manual`):Y(m?.execution_run_id??null,`automatic`);i?Ue.current(e.batch.execution_run_id):We.current=0,q.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe))},[d,f,h,Y]),X=(0,R.useCallback)(async(t,n)=>{let r=++W.current,i=await S(e,t,n);if(r!==W.current||i.batch.execution_run_id!==t||K.current!==null&&K.current!==t){i.batch.execution_run_id!==t&&f?.();return}Je(i,t===l?u:null)},[u,l,Je,f,e]);Ae.current=X,Ue.current=(0,R.useCallback)(e=>{if(H.current)return;if(We.current>=Le){We.current=0,U.current.clear(),Ce.current.clear();return}let t=Pe*2**We.current;H.current=setTimeout(()=>{H.current=null,We.current+=1,Ae.current(e).catch(t=>{B(J(t,h(`errors.load`))),U.current.size>0&&Ue.current(e)})},t)},[h]);let Z=(0,R.useCallback)(async t=>{let i=++W.current,a=await ye(e,n,r,t);if(i===W.current){if(a.batch_run_id){K.current=a.batch_run_id,await X(a.batch_run_id,t);return}!t?.aborted&&i===W.current&&(K.current=null,V.current=null,ee(null),Y(null,`automatic`))}},[X,e,r,n,Y]),Ye=(0,R.useCallback)(async()=>{if(s||l){let e=K.current;e&&await X(e);return}await Z()},[l,s,X,Z]);He.current=Ye;let Xe=(0,R.useCallback)(e=>{H.current||=setTimeout(()=>{H.current=null,X(e).catch(e=>B(J(e,h(`errors.load`))))},Pe)},[X,h]);(0,R.useEffect)(()=>{let n=new AbortController;return k(!0),B(null),(async()=>{if(l){if(x(null),u){let t=await _e(e,u,n.signal);if(t.run.kind!==`check_attempt`||t.details.kind!==`check_attempt`||!t.details.available||!t.details.attempt||t.details.attempt.batch_run_id!==l){f?.();return}}K.current=l,await X(l,n.signal);return}if(!s){x(null),await Z(n.signal);return}let r=await t(e,s,n.signal);if(x(r),r.sourceBatchRunId){K.current=r.sourceBatchRunId,await X(r.sourceBatchRunId,n.signal);return}K.current=null,V.current=null,ee(null),Y(null,`automatic`)})().catch(e=>{le(e)||(e instanceof O&&e.status===404&&f?.(),B(J(e,h(`errors.load`))))}).finally(()=>{n.signal.aborted||(k(!1),Te.current=!1,q.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe)))}),()=>n.abort()},[u,l,s,X,Z,f,e,h,Y]),(0,R.useEffect)(()=>{let t=y?.batch.execution_run_id;if(!t){G.current+=1,N(null),P(new Set),ue(new Set),F(``),ve(null);return}Ge.current?.batch_run_id!==t&&(N(null),P(new Set),ue(new Set),F(``),ve(null));let n=++G.current,r=new AbortController;return m(e,t,r.signal).then(e=>{n===G.current&&e.batch_run_id===t&&K.current===t&&Ke(e)}).catch(e=>{le(e)||B(J(e,h(`errors.diagnostics`)))}),()=>r.abort()},[y?.batch.execution_run_id,be,Ke,e,h]),(0,R.useEffect)(()=>{let t=t=>{if(t.project_id!==e)return;let n=K.current;if(n!==null&&t.batch_run_id!==n)return;let r=V.current;if(!r||U.current.has(t.attempt_run_id)){qe(t),r&&U.current.has(t.attempt_run_id)&&Ue.current(r.batch.execution_run_id);return}let i=r.attempts.findIndex(e=>e.execution_run_id===t.attempt_run_id);if(i<0){qe(t),Xe(r.batch.execution_run_id);return}let a=r.attempts[i],o=fe(te(a),t);if(o.status===`ignored`)return;if(o.status===`refetch`){U.current.add(t.attempt_run_id),qe(t),Ue.current(r.batch.execution_run_id);return}let s=[...r.attempts];s[i]={...a,output_revision:o.snapshot.revision,retained_start_offset:o.snapshot.retainedStartOffset,retained_end_offset:o.snapshot.totalByteCount,total_persisted_bytes:o.snapshot.totalByteCount,retained_output:o.snapshot.retainedText};let c={...r,attempts:s};V.current=c,ee(c)},n=t=>{if(t.project_id&&t.project_id!==e)return;if(Te.current){q.current=!0;return}let n=V.current,r=t.execution_run_id??t.id;if(xe(e=>e+1),he&&r===he.execution_run_id&&he.source_batch_run_id===K.current&&ae(e,he.execution_run_id).then(ve).catch(()=>void 0),n&&(r===n.batch.execution_run_id||n.attempts.some(e=>e.execution_run_id===r))){W.current+=1,Xe(n.batch.execution_run_id);return}q.current=!0,!Te.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe))},r=()=>{xe(e=>e+1),Ye().catch(e=>B(J(e,h(`errors.load`))))};return g.on(`check-attempt:output`,t),g.on(`execution-run:updated`,n),g.on(`lifecycle-event:created`,n),g.on(`connect`,r),()=>{g.off(`check-attempt:output`,t),g.off(`execution-run:updated`,n),g.off(`lifecycle-event:created`,n),g.off(`connect`,r)}},[he,qe,e,Ye,Xe,g,h]),(0,R.useEffect)(()=>()=>{H.current&&clearTimeout(H.current),U.current.clear(),Ce.current.clear()},[]);let Ze=(e,t)=>{W.current+=1,K.current=e.batch.execution_run_id,Je(e,null,t)},Qe=async(e,t)=>{W.current+=1,Te.current=!0,j(e),B(null);try{let n=await t();e!==`stop`&&(ke.current=null),Ze(n,e===`stop`?`preserve`:`reset`),e!==`stop`&&d?.(n.batch.execution_run_id,void 0)}catch(t){B(J(t,h(`errors.${e}`))),t instanceof O&&t.status===409&&await Ye().catch(()=>void 0)}finally{j(null),Te.current=D,q.current&&!H.current&&(q.current=!1,H.current=setTimeout(()=>{H.current=null,He.current().catch(e=>B(J(e,h(`errors.load`))))},Pe))}},$e=y?Ne.has(y.batch.execution_status):!1,et=y?$e?`running`:y.batch.execution_status===`completed`?`finished`:y.batch.execution_status===`cancelled`||y.batch.execution_status===`interrupted`?`interrupted`:`error`:`inactive`,tt=y?.batch.execution_run_id??null,Q=M?.batch_run_id===tt?M:null,nt=he?.source_batch_run_id===tt?he:null,$=Q?.auto_fix??null,rt=!!($&&!$.terminal_reason),it=Q?Be(Q):new Set,at=Q?Ve(Q):new Set,ot=new Set([...se].filter(e=>it.has(e))),st=new Set([...ce].filter(e=>at.has(e))),ct=[..._],lt=y?.attempts.filter(e=>e.execution_status!==`completed`).length??0,ut=async()=>{let t=[...ot],n=[...st];if(!(!Q||!tt||K.current!==tt||Q.repair.eligibility.eligible!==!0||nt?.terminal_result===null||$&&!$.terminal_reason||t.length===0&&n.length===0)){L(!0),B(null);try{let r=await oe(e,t,n,Q.repair.accepts_ticket_id?Q.repair.candidate_tickets.some(e=>e.id===me)?me:Q.repair.candidate_tickets[0]?.id||null:null);ve(r.source_batch_run_id===tt?r:null)}catch(t){if(B(J(t,h(`errors.repair`))),t instanceof O&&t.status===409&&y){let t=y.batch.execution_run_id,n=++G.current;m(e,t).then(e=>{n===G.current&&e.batch_run_id===t&&K.current===t&&Ke(e)}).catch(()=>void 0)}}finally{L(!1)}}},dt=async()=>{let t=$&&!$.terminal_reason?$.execution_run_id:nt?.execution_run_id;if(t){L(!0),B(null);try{let n=await pe(e,t);`source_batch_run_id`in n&&ve(n),xe(e=>e+1)}catch(e){B(J(e,h(`errors.repairStop`)))}finally{L(!1)}}},ft=new Set([...Q?.attempts.filter(e=>e.diagnostics.some(e=>ot.has(e.id))).map(e=>e.attempt_run_id)??[],...st]),pt=(e,t,n)=>{P(r=>{let i=new Set(r);if(!n)return i.delete(t),i;if(i.size>=Re||!Q||!it.has(t))return r;let a=new Set(Q.attempts.filter(e=>e.diagnostics.some(e=>i.has(e.id))).map(e=>e.attempt_run_id)??[]);return!a.has(e)&&a.size>=ze?r:(i.add(t),i)})},mt=(e,t)=>{ue(n=>{let r=new Set(n);return t?!ft.has(e)&&ft.size>=ze||!at.has(e)?n:(r.add(e),r):(r.delete(e),r)})},ht=(e,t)=>{v(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},gt=e=>{y&&(ie(null),ke.current={batchRunId:y.batch.execution_run_id,attemptRunId:e,previousBatchRunId:l===y.batch.execution_run_id?l:null,previousAttemptRunId:l===y.batch.execution_run_id?u:null},Y(e,`manual`),d?.(y.batch.execution_run_id,e))},_t=e=>{let t=y?.attempts.find(t=>t.definition_id===e);if(t){gt(t.execution_run_id);return}ie(e)},vt=re?y?.attempts.find(e=>e.definition_id===re)??null:y?.attempts.find(e=>e.execution_run_id===C)??null,yt=vt?.command_snapshot??i.find(e=>e.id===re)??null,bt=re??vt?.definition_id??null,xt=yt?{required:a.includes(yt.id),preReview:o.includes(yt.id)}:null;return(0,R.useEffect)(()=>{p?.(et)},[et,p]),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[Se&&(0,z.jsx)(`p`,{role:`alert`,className:`mx-4 mt-3 rounded-xl border border-red-400/25 bg-red-500/10 px-3 py-2 text-sm text-red-200 sm:mx-6`,children:Se}),(0,z.jsxs)(`div`,{role:`toolbar`,"aria-label":h(`runActions`),className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-y border-border/70 bg-background/30 px-4 py-3 sm:px-6`,children:[(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:h(`runActions`)})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(c,{type:`button`,size:`sm`,disabled:ct.length===0||$e||rt||A!==null,onClick:()=>void Qe(`run`,()=>ge(e,{targetKind:n,targetBundleId:r,definitionIds:ct})),children:h(A===`run`?`starting`:`runSelected`)}),y&&$e&&(0,z.jsx)(c,{type:`button`,variant:`destructive`,size:`sm`,disabled:A!==null||I,onClick:()=>void(rt?dt():Qe(`stop`,()=>T(e,y.batch.execution_run_id))),children:h(A===`stop`||I?`stopping`:`stop`)}),y&&!$e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(c,{type:`button`,variant:`outline`,size:`xs`,disabled:rt||A!==null,onClick:()=>void Qe(`rerun`,()=>de(e,y.batch.execution_run_id,{mode:`all`})),children:h(`rerunAll`)}),(0,z.jsx)(c,{type:`button`,variant:`outline`,size:`xs`,disabled:rt||A!==null||lt===0,onClick:()=>void Qe(`rerun`,()=>de(e,y.batch.execution_run_id,{mode:`failed_only`})),children:h(`rerunFailed`)})]})]})]}),(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,auto)_minmax(0,1fr)] overflow-hidden md:grid-cols-[19rem_minmax(0,1fr)] md:grid-rows-1`,children:[(0,z.jsx)(`aside`,{className:`flex min-h-0 flex-col border-b border-border/70 md:border-r md:border-b-0`,children:(0,z.jsx)(je,{definitions:i,attempts:y?.attempts??[],requiredDefinitionIds:a,preReviewDefinitionIds:o,selectedDefinitionIds:_,selectedCheckId:bt,diagnostics:Q,selectedDiagnosticIds:ot,selectedRawOutputAttemptRunIds:st,onToggleDefinition:ht,onSelectCheck:_t})}),(0,z.jsxs)(`main`,{className:`min-h-0 overflow-y-auto p-4 sm:p-6`,children:[s&&!b&&D&&(0,z.jsx)(`p`,{role:`status`,className:`mb-4 text-sm text-muted-foreground`,children:h(`gateLoading`)}),b&&(0,z.jsx)(De,{evaluation:b}),D&&(0,z.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:h(`loading`)}),!D&&!y&&!yt&&(0,z.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border p-6 text-center`,children:[(0,z.jsx)(`h2`,{className:`font-medium text-foreground`,children:h(`emptyTitle`)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:h(`emptyDescription`)})]}),y&&(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:h(`status.${y.batch.execution_status}`)}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:h(`summary`,{passed:y.batch.passed_count,failed:y.batch.failed_count,running:y.batch.running_count,queued:y.batch.queued_count})}),y.batch.stop_requested&&(0,z.jsx)(`span`,{className:`text-xs text-amber-200`,children:h(`stopRequested`)})]})}),(y||yt)&&(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(we,{attempt:vt,definition:yt,diagnostics:Q?.attempts.find(e=>e.attempt_run_id===vt?.execution_run_id)??null,repair:Q?.repair??null,selectedDiagnosticIds:ot,selectedRawOutputAttemptRunIds:st,selectedAttemptRunIds:ft,selectedTicketId:me,pending:I,activeRepair:nt,autoFix:$,policy:xt,onSelectedTicketChange:F,onToggleDiagnostic:(e,t)=>vt&&pt(vt.execution_run_id,e,t),onToggleRawOutput:e=>vt&&mt(vt.execution_run_id,e),onStartRepair:()=>void ut(),onStopRepair:()=>void dt()})})]})]})]})},Ue=(e,t)=>A(F(`/projects/${e}/test-sessions`),{method:`POST`,body:t,fallbackErrorMessage:`Unable to open the test runner right now.`}),We=(e,t)=>A(F(`/tickets/${e}/test-sessions${t?`?project_id=${encodeURIComponent(t)}`:``}`),{method:`POST`,fallbackErrorMessage:`Unable to open the test runner right now.`}),Ge=(e,t={})=>A(F(`/test-sessions/${e}/discovery${t.commandId?`?command_id=${encodeURIComponent(t.commandId)}`:``}`),{signal:t.signal,fallbackErrorMessage:`Unable to discover tests right now.`}),Y=(e,t)=>A(F(`/test-sessions/${e}/run`),{method:`POST`,body:t,fallbackErrorMessage:`Unable to start the selected tests right now.`}),Ke=e=>A(F(`/test-sessions/${e}/stop`),{method:`POST`,fallbackErrorMessage:`Unable to stop the test run right now.`}),qe=e=>M(F(`/test-sessions/${e}`),{method:`DELETE`,fallbackErrorMessage:`Unable to close the test runner right now.`}),Je=256*1024,X=24,Z=(e,t)=>_.t(`common:testsDialog.${e}`,t),Ye=(e,t)=>{let n=`${e}${t}`;return n.length<=Je?n:n.slice(-Je)},Xe=(e,t)=>e?e.run_id&&t.run_id&&e.run_id!==t.run_id?e.status===`running`||t.status!==`running`?e:t:e.status!==`idle`&&e.status!==`running`&&t.status===`running`?e:e.run_id===t.run_id&&e.output.length>t.output.length?{...t,output:e.output,output_truncated:e.output_truncated||t.output_truncated}:t:t,Ze=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=X,Qe=e=>{e.scrollTop=e.scrollHeight},$e=(e,t=!1)=>{Qe(e);let n=0,r=0;return n=window.requestAnimationFrame(()=>{Qe(e),t&&(r=window.requestAnimationFrame(()=>{Qe(e)}))}),()=>{window.cancelAnimationFrame(n),r!==0&&window.cancelAnimationFrame(r)}},et=e=>e===`running`?`border-sky-400/40 bg-sky-500/10 text-sky-200`:e===`passed`?`border-emerald-400/40 bg-emerald-500/10 text-emerald-200`:e===`failed`||e===`error`?`border-rose-400/40 bg-rose-500/10 text-rose-200`:e===`stopped`?`border-amber-400/40 bg-amber-500/10 text-amber-200`:`border-border/70 bg-background/60 text-muted-foreground`,tt=e=>{if(e==null)return null;if(e<1e3)return`${e} ms`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${(e/1e3).toFixed(e>=1e4?0:1)} s`},Q=e=>{let t=e.split(`/`);return t[t.length-1]||e},nt=e=>e.toLowerCase().trim().split(/\s+/).filter(Boolean),$=(e,t)=>e.length===0?!0:e.every(e=>t.some(t=>t.includes(e))),rt=(e,t)=>{let n=nt(t);return n.length===0?e:e.flatMap(e=>{let t=Q(e.path);if($(n,[t.toLowerCase(),e.path.toLowerCase()]))return[e];let r=e.cases.filter(r=>$(n,[t.toLowerCase(),e.path.toLowerCase(),r.name.toLowerCase()]));return r.length===0?[]:[{...e,cases:r}]})},it=e=>Z(e===`passed`?`status.passed`:e===`failed`?`status.failed`:e===`running`?`status.running`:e===`error`?`status.error`:e===`stopped`?`status.stopped`:`status.idle`),at=e=>e?.selection?e.selection.kind===`all`?Z(`selection.allTests`):e.selection.kind===`case`?e.selection.name:Q(e.selection.path):Z(`selection.noRunYet`),ot=e=>/(^|\s)(?:FAIL|✗)(\s|$)|\b(?:failed|error|stderr|Expected:|Received:)\b/i.test(e)?`failure`:/(^|\s)(?:PASS|✓)(\s|$)|\bpassed\b/i.test(e)?`success`:/\b(?:WARN|warning|skipped|todo|pending)\b/i.test(e)?`warning`:`default`,st=e=>e===`failure`?`text-rose-200`:e===`success`?`text-emerald-200`:e===`warning`?`text-amber-200`:`text-slate-200`,ct=(e,t)=>e===t?!0:e.length===t.length?e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.name===r.name&&e.command===r.command&&e.cwd===r.cwd&&e.runner===r.runner}):!1,lt=`min-w-24 justify-center shadow-none transition-none disabled:opacity-100`,ut=({line:e,tone:t})=>(0,z.jsx)(`div`,{"data-tone":t,className:x(`whitespace-pre-wrap break-words`,st(t)),children:e===``?` `:e}),dt=(0,R.memo)(({canRunGranular:e,filePath:t,isActive:n,name:r,onRunCase:i})=>(0,z.jsxs)(`button`,{type:`button`,"aria-label":Z(`caseRow.runAriaLabel`,{name:r}),title:r,className:x(`flex w-full min-w-0 items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,e?`cursor-pointer hover:bg-sky-500/10`:`cursor-not-allowed opacity-60`,n&&`bg-sky-500/10`),disabled:!e,onClick:()=>{i(t,r)},children:[(0,z.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-sky-300/80`}),(0,z.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:r})]}));dt.displayName=`TestCaseRow`;var ft=(0,R.memo)(({activeSelectionKind:e,activeSelectionName:t,activeSelectionPath:n,canRunGranular:r,file:i,isExpanded:a,onRunCase:o,onRunFile:l,onToggleFile:u})=>{let d=e===`file`&&n===i.path,f=e===`case`&&n===i.path;return(0,z.jsx)(C,{open:a,onOpenChange:e=>{u(i.path,e)},children:(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(xe,{asChild:!0,children:(0,z.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":Z(a?`fileRow.collapseAriaLabel`:`fileRow.expandAriaLabel`,{path:i.path}),className:`mt-1 shrink-0 text-muted-foreground hover:text-foreground`,children:(0,z.jsx)(h,{className:x(`h-4 w-4 transition-transform`,a&&`rotate-180`)})})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Z(`fileRow.runAriaLabel`,{path:i.path}),className:x(`min-w-0 flex-1 rounded-xl border border-border/60 bg-background/20 px-2.5 py-2 text-left transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,r?`cursor-pointer hover:border-sky-400/35 hover:bg-sky-500/10`:`cursor-not-allowed opacity-60`,(d||f)&&`border-sky-400/45 bg-sky-500/10`),disabled:!r,onClick:()=>{l(i.path)},children:(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,z.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-md border border-border/70 bg-background/60 text-sky-200`,children:(0,z.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-start justify-between gap-3`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-xs font-medium text-foreground`,children:Q(i.path)}),(0,z.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-muted-foreground`,children:i.path})]}),(0,z.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:Z(`fileRow.testCount`,{count:i.cases.length})})]})]})})]}),(0,z.jsx)(I,{children:(0,z.jsx)(`div`,{className:`ml-4 border-l border-border/60 pl-6`,children:i.cases.length===0?(0,z.jsx)(`p`,{className:`px-2.5 py-1.5 text-xs text-muted-foreground`,children:Z(`fileRow.noNamedTests`)}):(0,z.jsx)(`div`,{className:`space-y-1`,children:i.cases.map(a=>{let s=e===`case`&&n===i.path&&t===a.name;return(0,z.jsx)(dt,{canRunGranular:r,filePath:i.path,isActive:s,name:a.name,onRunCase:o},a.id)})})})})]})})});ft.displayName=`DiscoveryFileRow`;var pt=(0,R.memo)(({activeSelectionKind:e,activeSelectionName:t,activeSelectionPath:i,availableCommands:o,canRunGranular:s,discovery:l,expandedFiles:u,fullSuiteOnlyNotice:d,isLoading:p,selectedCommandId:m,selectedCommandName:g,sessionError:_,sessionStatus:v,shouldShowCommandSelector:y,onRunCase:ee,onRunFile:b,onSelectCommand:S,onToggleFile:C})=>{let[w,te]=(0,R.useState)(``),T=(0,R.useMemo)(()=>rt(l,w),[l,w]),E=(0,R.useMemo)(()=>T.reduce((e,t)=>e+t.cases.length,0),[T]),ne=nt(w).length>0;return(0,z.jsx)(`aside`,{className:`min-h-0 border-b border-border/70 px-4 py-4 lg:border-r lg:border-b-0`,children:(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[y&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-xs uppercase tracking-[0.22em] text-muted-foreground`,children:Z(`scope.label`)}),(0,z.jsxs)(f,{children:[(0,z.jsx)(se,{asChild:!0,children:(0,z.jsxs)(c,{type:`button`,variant:`outline`,className:`w-full justify-between rounded-xl border-border/70 bg-background/60`,"aria-label":Z(`scope.selectedCommandAriaLabel`),disabled:o.length===0||v===`running`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:g??Z(`scope.selectTestScope`)}),(0,z.jsx)(h,{className:`h-4 w-4 text-muted-foreground`})]})}),(0,z.jsx)(P,{align:`start`,className:`w-72`,children:o.map(e=>(0,z.jsx)(n,{className:x(m===e.id&&`bg-accent text-accent-foreground`),onSelect:()=>{S(e.id)},children:(0,z.jsx)(`span`,{className:`truncate`,children:e.name})},e.id))})]})]}),d&&(0,z.jsx)(`div`,{className:`rounded-2xl border border-border/70 bg-background/30 px-4 py-3 text-sm text-muted-foreground`,children:d}),(l.length>0||w.length>0)&&(0,z.jsxs)(`div`,{className:`relative mt-1 shrink-0`,children:[(0,z.jsx)(r,{type:`search`,value:w,onChange:e=>{te(e.target.value)},placeholder:Z(`filter.placeholder`),"aria-label":Z(`filter.ariaLabel`),className:`pr-10`}),w.length>0&&(0,z.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":Z(`filter.clearAriaLabel`),className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>{te(``)},children:(0,z.jsx)(be,{className:`size-4`})})]}),!o.length&&(0,z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-4 text-sm text-muted-foreground`,children:Z(`discovery.noCommands`)}),_&&(0,z.jsx)(`div`,{className:`rounded-2xl border border-rose-500/30 bg-rose-500/10 px-4 py-3 text-sm text-rose-200`,children:_}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden rounded-2xl border border-border/70 bg-background/20 p-4`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 flex items-start justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[Z(`discovery.fileCount`,{count:T.length}),`, `,Z(`discovery.caseCount`,{count:E})]})}),p&&(0,z.jsx)(a,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto pr-1`,children:l.length===0&&!p?(0,z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:Z(`discovery.noFilesDetected`)}):T.length===0?(0,z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-background/20 px-4 py-5 text-sm text-muted-foreground`,children:Z(`discovery.noFilterMatches`)}):T.map(n=>(0,z.jsx)(ft,{activeSelectionKind:e,activeSelectionName:t,activeSelectionPath:i,canRunGranular:s,file:n,isExpanded:ne||(u[n.path]??!1),onRunCase:ee,onRunFile:b,onToggleFile:C},n.path))})]})]})})});pt.displayName=`DiscoveryPane`;var mt=(0,R.memo)(({durationMs:e,output:t,outputTruncated:n,selectionLabel:r,status:i,summaryCounts:a,viewportRef:o,onScroll:s})=>{let c=(0,R.useMemo)(()=>t?N(t).replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `).split(`
4
4
  `).map(e=>({line:e,tone:ot(e)})):[],[t]);return(0,z.jsx)(`section`,{className:`min-h-0 px-4 py-4`,children:(0,z.jsxs)(`div`,{className:`flex h-full flex-col gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),i&&(0,z.jsx)(E,{variant:`outline`,className:x(`px-3 py-1 text-xs uppercase tracking-[0.2em]`,et(i)),children:it(i)}),a&&(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-xs font-medium uppercase tracking-[0.18em]`,children:[(0,z.jsxs)(`span`,{className:`text-rose-200`,children:[a.failed.count,` `,a.failed.label]}),(0,z.jsxs)(`span`,{className:`text-emerald-200`,children:[a.passed.count,` `,a.passed.label]})]}),e!=null&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:tt(e)}),n&&(0,z.jsx)(E,{variant:`outline`,className:`border-amber-400/30 bg-amber-500/10 text-amber-200`,children:Z(`output.trimmed`)})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-2xl border border-border/70 bg-[#0d1017]`,children:(0,z.jsx)(`div`,{ref:o,"aria-label":Z(`output.ariaLabel`),className:`h-full overflow-auto px-4 py-4`,onScroll:s,children:(0,z.jsx)(`div`,{className:`font-mono text-xs leading-5`,children:c.length>0?c.map((e,t)=>(0,z.jsx)(ut,{line:e.line,tone:e.tone},`${t}:${e.line}`)):(0,z.jsx)(`div`,{className:`text-slate-200`,children:Z(`output.empty`)})})})})]})})});mt.displayName=`OutputPane`;var ht=(0,R.forwardRef)(({testCommands:e,onStatusChange:t,onTargetLabelChange:n,onClose:r,...i},a)=>{let s=i.scope,u=i.projectId,f=i.scope===`ticket`?i.ticketId:null,m=i.scope===`project`?i.targetKind:null,h=i.scope===`project`?i.targetBundleId:null,[_,x]=(0,R.useState)(e),[S,C]=(0,R.useState)(null),[w,te]=(0,R.useState)([]),[T,E]=(0,R.useState)(``),[ne,ie]=(0,R.useState)({}),[ae,D]=(0,R.useState)(!0),[k,A]=(0,R.useState)(!1),[j,M]=(0,R.useState)(!1),[N,oe]=(0,R.useState)(null),[se,P]=(0,R.useState)(!1),[ce,le]=(0,R.useState)(!1),de=(0,R.useRef)(null),fe=(0,R.useRef)(!1),pe=(0,R.useRef)(null),me=(0,R.useRef)(!0),F=(0,R.useRef)(null),ge=(0,R.useRef)(null),_e=S?.selection?.kind??null,ve=S?.selection?.kind===`all`?null:S?.selection?.path??null,ye=S?.selection?.kind===`case`?S.selection.name:null,I=S?.id??null,L=S?.status??null,be=(0,R.useMemo)(()=>_.find(e=>e.id===T)??null,[_,T]),xe=(0,R.useMemo)(()=>{if(S?.summary?.failed_count==null&&S?.summary?.passed_count==null&&S?.summary?.failed_file_count==null&&S?.summary?.passed_file_count==null)return null;let e=S?.summary?.failed_count==null&&S?.summary?.passed_count==null;return{failed:L===`failed`&&S?.summary?.failed_count==null&&S?.summary?.failed_file_count!=null||e?{count:S?.summary?.failed_file_count??0,label:Z(`summaryCounts.filesFailed`)}:{count:S?.summary?.failed_count??0,label:Z(`summaryCounts.failed`)},passed:e?{count:S?.summary?.passed_file_count??0,label:Z(`summaryCounts.filesPassed`)}:{count:S?.summary?.passed_count??S?.summary?.passed_file_count??0,label:Z(`summaryCounts.passed`)}}},[S?.summary?.failed_count,S?.summary?.passed_count,S?.summary?.failed_file_count,S?.summary?.passed_file_count,L]),Se=be?.runner===`unknown`?Z(`scope.fullSuiteOnlyNotice`):null,B=!!(be&&S?.status!==`running`&&!k&&!j),V=B,H=B&&ce,U=_.length>1,{runs:Ce}=ue(u),W=S?.run_id?Ce.find(e=>e.id===S.run_id)??null:null;(0,R.useEffect)(()=>{T||_.length===0||E(_[0]?.id??``)},[_,T]),(0,R.useEffect)(()=>{e.length>0&&x(t=>ct(t,e)?t:e)},[e]),(0,R.useEffect)(()=>{if(_.length>0||!u)return;let e=new AbortController;return b(e.signal).then(e=>{let t=e.find(e=>e.id===u);t&&x(e=>{let n=re(t);return ct(e,n)?e:n})}).catch(()=>{}),()=>{e.abort()}},[_.length,u]),(0,R.useEffect)(()=>{let e=e=>{!e||e.id!==de.current||C(t=>Xe(t,e))},t=e=>{!e||e.session_id!==de.current||C(t=>!t||t.id!==e.session_id||e.run_id&&t.run_id&&e.run_id!==t.run_id?t:{...t,output:Ye(t.output,e.chunk),output_truncated:e.output_truncated})};return g.on(`test-session:updated`,e),g.on(`test-session:output`,t),()=>{g.off(`test-session:updated`,e),g.off(`test-session:output`,t)}},[]),(0,R.useEffect)(()=>{let e=pe.current;if(!e){F.current=S?.output??null,ge.current=S?.status??null;return}let t=F.current!==(S?.output??null),n=ge.current!==`running`&&S?.status===`running`,r=ge.current===`running`&&S?.status!==`running`;if(n&&(me.current=!0),n||t&&S?.status===`running`&&me.current||r&&me.current){let t=$e(e,r);return F.current=S?.output??null,ge.current=S?.status??null,t}F.current=S?.output??null,ge.current=S?.status??null},[S?.output,S?.status]),(0,R.useEffect)(()=>{let e=!1;return(async()=>{try{let t;if(s===`project`){if(!u)return;t=await Ue(u,{target_kind:m??`repo_root`,target_bundle_id:h??null})}else t=await We(f??``,u);if(e){qe(t.id).catch(()=>{});return}de.current=t.id,C(t)}catch(t){e||oe(t instanceof O?t.message:Z(`messages.loadRunnerError`))}finally{!e&&de.current==null&&D(!1)}})(),()=>{e=!0}},[u,s,h,m,f]),(0,R.useEffect)(()=>{W&&C(e=>{if(!e||e.run_id!==W.id)return e;let t=W.status===`completed`?`passed`:W.status===`failed`?`failed`:W.status===`cancelled`||W.status===`interrupted`?`stopped`:`running`;return e.status===t&&e.error===(W.failure?.message??e.error)?e:{...e,status:t,error:W.failure?.message??e.error,started_at:W.started_at??e.started_at,completed_at:W.completed_at??e.completed_at}})},[W]),(0,R.useEffect)(()=>{if(!S?.id){le(!1);return}if(_.length>0&&!T){le(!1);return}let e=new AbortController,t=!1;return D(!0),le(!1),Ge(S.id,{commandId:T||null,signal:e.signal}).then(e=>{t||(te(e.files),le(e.supports_granular_selection))}).catch(n=>{t||e.signal.aborted||oe(n instanceof O?n.message:Z(`messages.discoverError`))}).finally(()=>{t||D(!1)}),()=>{t=!0,e.abort()}},[_.length,T,S?.id]),(0,R.useEffect)(()=>()=>{let e=de.current;!e||fe.current||(fe.current=!0,qe(e).catch(()=>{}))},[]);let G=(0,R.useCallback)(async e=>{if(!(!I||L===`running`||!be||k||j)){oe(null),A(!0);try{let t=await Y(I,{command_id:be.id,selection:e});C(e=>Xe(e,t))}catch(e){oe(e instanceof O?e.message:Z(`messages.startError`))}finally{A(!1)}}},[k,j,be,I,L]),K=(0,R.useCallback)(async()=>{if(!(!I||L!==`running`||j)){oe(null),M(!0);try{let e=await Ke(I);C(t=>Xe(t,e))}catch(e){oe(e instanceof O?e.message:Z(`messages.stopError`))}finally{M(!1)}}},[j,I,L]),we=(0,R.useCallback)(()=>{let e=de.current;if(!e||fe.current){r();return}fe.current=!0,r(),qe(e).catch(()=>{})},[r]),q=(0,R.useCallback)(()=>{if(L===`running`){P(!0);return}we()},[we,L]);(0,R.useImperativeHandle)(a,()=>({requestClose:q}),[q]),(0,R.useEffect)(()=>{t?.(L===`running`?`running`:L===`passed`?`finished`:L===`failed`||L===`error`?`error`:L===`stopped`?`interrupted`:`inactive`)},[t,L]),(0,R.useEffect)(()=>{S?.target_label&&n?.(S.target_label)},[n,S?.target_label]);let Te=(0,R.useCallback)(()=>{let e=pe.current;e&&(me.current=Ze(e))},[]),Ee=(0,R.useCallback)(e=>{E(e)},[]),De=(0,R.useCallback)((e,t)=>{ie(n=>(n[e]??!1)===t?n:{...n,[e]:t})},[]),Oe=(0,R.useCallback)(e=>{G({kind:`file`,path:e})},[G]),ke=(0,R.useCallback)((e,t)=>{G({kind:`case`,path:e,name:t})},[G]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,"data-testid":`tests-panel-layout`,children:[(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-0 lg:grid-cols-[22rem_minmax(0,1fr)] lg:grid-rows-1`,children:[(0,z.jsx)(pt,{activeSelectionKind:_e,activeSelectionName:ye,activeSelectionPath:ve,availableCommands:_,canRunGranular:H,discovery:w,expandedFiles:ne,fullSuiteOnlyNotice:Se,isLoading:ae,selectedCommandId:T,selectedCommandName:be?.name??null,sessionError:N,sessionStatus:L,shouldShowCommandSelector:U,onRunCase:ke,onRunFile:Oe,onSelectCommand:Ee,onToggleFile:De}),(0,z.jsx)(mt,{durationMs:S?.duration_ms??null,output:S?.output??``,outputTruncated:S?.output_truncated??!1,selectionLabel:at(S),status:L,summaryCounts:xe,viewportRef:pe,onScroll:Te})]}),(0,z.jsx)(o,{className:`shrink-0 border-t border-border/70 px-6 py-4 sm:flex-row sm:items-center sm:justify-end`,children:(0,z.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:S?.status===`running`?(0,z.jsxs)(c,{type:`button`,variant:`destructive`,className:lt,onClick:()=>{K()},disabled:j,children:[(0,z.jsx)(d,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Z(`actions.stop`)})]}):(0,z.jsxs)(c,{type:`button`,variant:`success`,className:lt,disabled:!V,onClick:()=>{G({kind:`all`})},children:[(0,z.jsx)(p,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Z(`actions.run`)})]})})})]}),(0,z.jsx)(y,{open:se,onOpenChange:P,children:(0,z.jsxs)(v,{showCloseButton:!1,overlayClassName:`z-[60] bg-black/60`,className:`z-[60] max-w-md rounded-2xl border border-border bg-card p-6 shadow-2xl`,children:[(0,z.jsxs)(l,{children:[(0,z.jsx)(he,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:Z(`closeConfirmation.title`)}),(0,z.jsx)(ee,{className:`text-sm text-foreground whitespace-pre-line`,children:Z(`closeConfirmation.description`)})]}),(0,z.jsxs)(o,{className:`sm:flex-row sm:justify-end`,children:[(0,z.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>P(!1),children:Z(`closeConfirmation.keepRunning`)}),(0,z.jsx)(c,{type:`button`,variant:`destructive`,onClick:()=>{P(!1),we()},children:Z(`closeConfirmation.stopAndClose`)})]})]})})]})});ht.displayName=`TestsPanel`;var gt=`archon.verification-tab`,_t=()=>{try{let e=window.localStorage.getItem(gt);return e===`checks`||e===`tests`?e:null}catch{return null}},vt=e=>{try{window.localStorage.setItem(gt,e)}catch{}},yt=({targetLabel:e,definitions:t,requiredDefinitionIds:n=[],preReviewDefinitionIds:r=[],checksTarget:a,testsTarget:o,onClose:s,onOpenActivity:l,requestedInitialTab:d,directBatchRunId:f,directAttemptRunId:p,onCheckSelectionChange:m,onUnavailable:h})=>{let{t:g}=w(`common`,{keyPrefix:`verificationDialog`}),_=D(t),b=a!==null&&(t.length>0||!!a.gateEvaluationId||!!f),x=o!==null&&_.length>0,[S,C]=(0,R.useState)(()=>{if(d===`checks`&&b||d===`tests`&&x)return d;let e=_t();return e===`checks`&&b||e===`tests`&&x?e:b?`checks`:`tests`}),[te,T]=(0,R.useState)(()=>new Set([S])),[E,ne]=(0,R.useState)(`inactive`),[re,ie]=(0,R.useState)(`inactive`),ae=(0,R.useRef)(null),O=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(S===`checks`&&!b||S===`tests`&&!x){let e=b?`checks`:`tests`;C(e),T(t=>new Set(t).add(e))}},[S,b,x]);let A=e=>{if(O.current=e??null,o){let e=ae.current;if(e){e.requestClose();return}}(e??s)()},M=()=>{let e=O.current??s;O.current=null,e()};return(0,z.jsx)(y,{open:!0,onOpenChange:e=>{e||A()},children:(0,z.jsxs)(v,{showCloseButton:!1,className:`flex h-[calc(100vh-1rem)] max-h-[58rem] w-full max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden rounded-3xl p-0 sm:h-[calc(100vh-2rem)] sm:max-w-7xl`,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.stopPropagation(),children:[(0,z.jsx)(he,{className:`sr-only`,children:g(`title`)}),(0,z.jsx)(ee,{className:`sr-only`,children:g(`description`)}),(0,z.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-border/70 px-4 py-4 sm:px-6`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,z.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-2xl border border-border bg-background/60 text-sky-200`,children:(0,z.jsx)(u,{className:`size-5`})}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:g(`title`)}),(0,z.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:e})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l&&(0,z.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>A(l),children:g(`openActivity`)}),(0,z.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":g(`close`),onClick:()=>A(),children:(0,z.jsx)(be,{className:`size-4`})})]})]}),(0,z.jsxs)(me,{value:S,onValueChange:e=>{e!==`checks`&&e!==`tests`||(C(e),T(t=>new Set(t).add(e)),vt(e))},className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-3 sm:px-6`,children:[(0,z.jsxs)(j,{"aria-label":g(`tabsAriaLabel`),children:[b&&(0,z.jsxs)(k,{value:`checks`,className:`gap-2`,children:[(0,z.jsx)(u,{className:`size-4`}),(0,z.jsx)(`span`,{children:g(`tabs.checks.label`)}),(0,z.jsx)(`span`,{className:`inline-flex shrink-0`,role:`status`,"aria-label":g(`status.checks.${E}`),children:(0,z.jsx)(i,{state:E})})]}),x&&(0,z.jsxs)(k,{value:`tests`,className:`gap-2`,children:[(0,z.jsx)(ve,{className:`size-4`}),(0,z.jsx)(`span`,{children:g(`tabs.tests.label`)}),(0,z.jsx)(`span`,{className:`inline-flex shrink-0`,role:`status`,"aria-label":g(`status.tests.${re}`),children:(0,z.jsx)(i,{state:re})})]})]}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:g(`tabs.${S}.description`)})]}),b&&a&&te.has(`checks`)&&(0,z.jsx)(ce,{value:`checks`,forceMount:!0,className:`mt-0 flex min-h-0 flex-1 flex-col overflow-hidden data-[state=inactive]:hidden`,children:(0,z.jsx)(He,{...a,definitions:t,requiredDefinitionIds:n,preReviewDefinitionIds:r,directBatchRunId:f,directAttemptRunId:p,onSelectionChange:S===`checks`?m:void 0,onUnavailable:h,onStatusChange:ne})}),o&&_.length>0&&te.has(`tests`)&&(0,z.jsx)(ce,{value:`tests`,forceMount:!0,className:`mt-0 flex min-h-0 flex-1 flex-col overflow-hidden data-[state=inactive]:hidden`,children:(0,z.jsx)(ht,{ref:ae,...o,testCommands:_,onStatusChange:ie,onClose:M})})]})]})})};export{yt as VerificationDialog};