@open-mercato/cezar 0.16.2 → 0.16.3

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 (111) hide show
  1. package/dist/api-origin.d.ts +6 -0
  2. package/dist/api-origin.js +32 -0
  3. package/dist/api-origin.js.map +1 -0
  4. package/dist/automations/schedule-runner.d.ts +1 -0
  5. package/dist/automations/schedule-runner.js +2 -2
  6. package/dist/automations/schedule-runner.js.map +1 -1
  7. package/dist/core/agent-errors.d.ts +5 -0
  8. package/dist/core/agent-errors.js +49 -0
  9. package/dist/core/agent-errors.js.map +1 -1
  10. package/dist/core/claude-cli-runner.d.ts +3 -0
  11. package/dist/core/claude-cli-runner.js +20 -4
  12. package/dist/core/claude-cli-runner.js.map +1 -1
  13. package/dist/core/codex-ui-mapper.js +4 -1
  14. package/dist/core/codex-ui-mapper.js.map +1 -1
  15. package/dist/core/copilot-acp-runner.d.ts +1 -1
  16. package/dist/core/copilot-acp-runner.js +26 -5
  17. package/dist/core/copilot-acp-runner.js.map +1 -1
  18. package/dist/core/model-presets.d.ts +11 -0
  19. package/dist/core/model-presets.js +35 -1
  20. package/dist/core/model-presets.js.map +1 -1
  21. package/dist/core/opencode-model-catalog.js +3 -0
  22. package/dist/core/opencode-model-catalog.js.map +1 -1
  23. package/dist/core/opencode-server-runner.d.ts +7 -0
  24. package/dist/core/opencode-server-runner.js +36 -1
  25. package/dist/core/opencode-server-runner.js.map +1 -1
  26. package/dist/core/pi-runner.js +2 -0
  27. package/dist/core/pi-runner.js.map +1 -1
  28. package/dist/core/provider-auth.d.ts +6 -0
  29. package/dist/core/provider-auth.js +59 -13
  30. package/dist/core/provider-auth.js.map +1 -1
  31. package/dist/core/usage-limit.js +8 -2
  32. package/dist/core/usage-limit.js.map +1 -1
  33. package/dist/index.js +3 -19
  34. package/dist/index.js.map +1 -1
  35. package/dist/release/bump.d.ts +1 -1
  36. package/dist/release/bump.js +1 -1
  37. package/dist/release/stable.d.ts +21 -4
  38. package/dist/release/stable.js +48 -15
  39. package/dist/release/stable.js.map +1 -1
  40. package/dist/runs/agent-error-telemetry.js +4 -2
  41. package/dist/runs/agent-error-telemetry.js.map +1 -1
  42. package/dist/runs/store.d.ts +1 -1
  43. package/dist/runs/store.js +31 -4
  44. package/dist/runs/store.js.map +1 -1
  45. package/dist/server/git-changes.d.ts +22 -0
  46. package/dist/server/git-changes.js +19 -1
  47. package/dist/server/git-changes.js.map +1 -1
  48. package/dist/server/open-in-app.js +14 -3
  49. package/dist/server/open-in-app.js.map +1 -1
  50. package/dist/server/preview/location-reporter.d.ts +12 -0
  51. package/dist/server/preview/location-reporter.js +45 -0
  52. package/dist/server/preview/location-reporter.js.map +1 -0
  53. package/dist/server/preview/picker-script.d.ts +0 -22
  54. package/dist/server/preview/picker-script.js +3 -1
  55. package/dist/server/preview/picker-script.js.map +1 -1
  56. package/dist/server/provider-telemetry.d.ts +3 -1
  57. package/dist/server/provider-telemetry.js +4 -2
  58. package/dist/server/provider-telemetry.js.map +1 -1
  59. package/dist/server/repo-sync.js +5 -10
  60. package/dist/server/repo-sync.js.map +1 -1
  61. package/dist/server/server.d.ts +1854 -1854
  62. package/dist/server/server.js +7 -2
  63. package/dist/server/server.js.map +1 -1
  64. package/dist/server/worktree-lifecycle.d.ts +8 -8
  65. package/dist/telemetry.js +3 -1
  66. package/dist/telemetry.js.map +1 -1
  67. package/dist/workflows/continuation-context.d.ts +3 -1
  68. package/dist/workflows/continuation-context.js +22 -3
  69. package/dist/workflows/continuation-context.js.map +1 -1
  70. package/dist/workflows/run.d.ts +20 -9
  71. package/dist/workflows/run.js +49 -11
  72. package/dist/workflows/run.js.map +1 -1
  73. package/package.json +3 -3
  74. package/scripts/mock-copilot-acp.mjs +4 -0
  75. package/web/dist/assets/{agent-task-pickers-DEW3Vgdv.js → agent-task-pickers-CNuwgeJL.js} +1 -1
  76. package/web/dist/assets/{automations-route-Cx7mzYhD.js → automations-route-Cs1tsu1W.js} +1 -1
  77. package/web/dist/assets/{commit-list-xMdmPYbz.js → commit-list-Ti2arrt8.js} +1 -1
  78. package/web/dist/assets/{compare-variants-B6ja1M4D.js → compare-variants-CdchlJMs.js} +1 -1
  79. package/web/dist/assets/{dashboard-ClEGBFFq.js → dashboard-wi0EQack.js} +2 -2
  80. package/web/dist/assets/{file-preview-iucr8WDo.js → file-preview-pS9i9ZDR.js} +1 -1
  81. package/web/dist/assets/git-tab-loading-BC6WP7W4.js +1 -0
  82. package/web/dist/assets/{git-toolbar-DU5Ca6RI.js → git-toolbar-Dra1QlHb.js} +1 -1
  83. package/web/dist/assets/github-DZcdhMzw.js +1 -0
  84. package/web/dist/assets/{host-usage-DjDYDU0A.js → host-usage-DnkXF0CT.js} +1 -1
  85. package/web/dist/assets/index-qeFtKZ4e.js +22 -0
  86. package/web/dist/assets/{layout-cards-Sur4EWtx.js → layout-cards-CXMlrDUf.js} +1 -1
  87. package/web/dist/assets/{project-router-DZsR9P9C.js → project-router-CZzr7lzN.js} +2 -2
  88. package/web/dist/assets/queries-Bn7zl9OU.js +1 -0
  89. package/web/dist/assets/{reference-chip-DnemrSPW.js → reference-chip-CScP5y_O.js} +1 -1
  90. package/web/dist/assets/repo-git-CV-yXaSx.js +1 -0
  91. package/web/dist/assets/{run-diff-BPZ85gAE.js → run-diff-GHEaeAio.js} +2 -2
  92. package/web/dist/assets/{skills-BgCN1gTp.js → skills-DuSNv5op.js} +1 -1
  93. package/web/dist/assets/{task-commits-W1ZZiEt4.js → task-commits-D_gLpFQo.js} +1 -1
  94. package/web/dist/assets/{task-graph-DI2fn5M8.js → task-graph-BgHk8Y3v.js} +1 -1
  95. package/web/dist/assets/{task-notes-lmvd1UM7.js → task-notes-BBp0rdzM.js} +1 -1
  96. package/web/dist/assets/task-workspace-Cr9AjTxP.js +27 -0
  97. package/web/dist/assets/{terminal-drawer-DAkquqSe.js → terminal-drawer-CcPOjWwP.js} +2 -2
  98. package/web/dist/assets/{tracker-Cqdpt9RN.js → tracker-BHwMGsDY.js} +2 -2
  99. package/web/dist/assets/use-automations-Dh3Wj-79.js +5 -0
  100. package/web/dist/assets/{use-now-pBdvhv13.js → use-now-BB7W0F--.js} +1 -1
  101. package/web/dist/assets/{workflow-graph-l7O50dsV.js → workflow-graph-CcOTCItr.js} +3 -3
  102. package/web/dist/assets/worktree-lifecycle-operation-vTgExKUM.js +18 -0
  103. package/web/dist/index.html +10 -10
  104. package/web/dist/assets/git-tab-loading-BfC2ir8N.js +0 -1
  105. package/web/dist/assets/github-CELdSmld.js +0 -1
  106. package/web/dist/assets/index-BBND6Sg3.js +0 -22
  107. package/web/dist/assets/queries-CI0EmEcH.js +0 -1
  108. package/web/dist/assets/repo-git-Bj0PBOjX.js +0 -1
  109. package/web/dist/assets/task-workspace-B8Fpho3e.js +0 -27
  110. package/web/dist/assets/use-automations-v77gHYDG.js +0 -5
  111. package/web/dist/assets/worktree-lifecycle-operation-DOTiqQFx.js +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cezar",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -54,8 +54,8 @@
54
54
  "zod": "^4.4.3"
55
55
  },
56
56
  "devDependencies": {
57
- "@open-mercato/cezar-api-client": "^0.16.2",
58
- "@open-mercato/cezar-contract": "^0.16.2",
57
+ "@open-mercato/cezar-api-client": "^0.16.3",
58
+ "@open-mercato/cezar-contract": "^0.16.3",
59
59
  "@types/node": "^20.14.0",
60
60
  "@types/proper-lockfile": "4.1.4",
61
61
  "@types/ws": "^8.18.1",
@@ -96,6 +96,10 @@ async function handle(frame) {
96
96
  }
97
97
 
98
98
  if (method === 'session/prompt') {
99
+ // The CLI quitting cleanly with a prompt unanswered (telemetry 2e3b122d).
100
+ if (process.env.CEZ_MOCK_COPILOT_EXIT_MID_TURN === '1') process.exit(0);
101
+ // A turn that never ends on its own: only stdin EOF (exit 0) or a signal stops it.
102
+ if (process.env.CEZ_MOCK_COPILOT_PROMPT_HANGS === '1') return;
99
103
  turn += 1;
100
104
  cancelled = false;
101
105
  const sessionId = params?.sessionId ?? SESSION_ID;
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-Clwd6u4_.js";import{t as i}from"./project-router-DZsR9P9C.js";import{a,o,r as s}from"./reference-chip-DnemrSPW.js";import{d as c,f as l,h as u,l as d,m as f,p}from"./use-now-pBdvhv13.js";import{bn as m,x as h}from"./git-tab-loading-BfC2ir8N.js";import{B as g,L as _,N as v,V as y,z as b}from"./worktree-lifecycle-operation-DOTiqQFx.js";import{n as x}from"./textarea-ewNKsXDa.js";import{t as S}from"./check-Dt8U0Zvm.js";import{f as C}from"./tooltip-B628Gs7C.js";import{m as w}from"./git-toolbar-DU5Ca6RI.js";import{c as T}from"./index-BBND6Sg3.js";var E=n();function D({name:e,route:t,selected:n,list:i,detail:a}){return(0,E.jsxs)(`div`,{"data-route":t,className:`flex h-full min-h-0 items-stretch`,children:[(0,E.jsx)(`section`,{"data-slot":`${e}-list`,className:r(`w-full min-h-0 flex-col overflow-y-auto overscroll-contain border-border md:flex md:w-[360px] md:shrink-0 md:border-r`,n?`hidden`:`flex`),children:i}),(0,E.jsx)(`section`,{"data-slot":`${e}-detail`,className:r(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n?`flex`:`hidden md:flex`),children:a})]})}function O(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function k(e,t=[]){let n=O(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=A(t)),n}function A(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function j(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function M(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function N(e,t,n){let r=(n??``).trim();if(!r)return k(e,t);let i=O(e),a=r.startsWith(i)?i+j(r.slice(i.length),e):j(r,e),o=M(a,e)?a:`${i}\n\n${a}`;return t.length?o+A(t):o}function P(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function F(e,t,n,r,i={}){return t?{...i,workflow:t,task:N(e,n,r)}:n.length?{...i,steps:P(n),task:N(e,[],r)}:{...i,workflow:`quick-task`,task:N(e,[],r)}}function I({resolved:e,dataSlot:t}){return e.providerPending||e.canRun?null:(0,E.jsxs)(`span`,{"data-slot":t,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[e.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,E.jsx)(i,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]})}var L=e(t(),1);function R({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[m,_]=(0,L.useState)(!1),[v,b]=(0,L.useState)(``),w=(0,L.useRef)(null),T=g(e,v);return(0,E.jsxs)(s,{open:m,onOpenChange:e=>{_(e),e||b(``)},children:[(0,E.jsx)(o,{asChild:!0,children:(0,E.jsxs)(`button`,{type:`button`,"data-slot":`${i}-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(h,t&&`border-foreground/60 font-mono text-[11.5px] font-semibold text-foreground`),children:[(0,E.jsx)(x,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,E.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,E.jsx)(C,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,E.jsx)(a,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,E.jsxs)(d,{label:`Choose a workflow`,shouldFilter:!1,children:[(0,E.jsx)(p,{placeholder:`search workflows…`,value:v,onValueChange:b,onInput:()=>w.current?.scrollTo(0,0)}),(0,E.jsxs)(u,{ref:w,"data-slot":`${i}-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[T.length===0?(0,E.jsx)(c,{children:`Nothing matches.`}):null,(0,E.jsx)(l,{children:T.map(e=>{let r=t===e.name;return(0,E.jsxs)(f,{value:`workflow ${e.name}`,keywords:y(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),_(!1)},children:[(0,E.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,E.jsx)(S,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function z({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:g,slotPrefix:x=`gh`}){let[D,O]=(0,L.useState)(!1),[k,A]=(0,L.useState)(``),[j,M]=(0,L.useState)(null),N=(0,L.useRef)(null),{mostUsed:P,project:F,global:I}=_(b(e,k,t),t),R=(e,t)=>{let a=n.includes(e.name);return(0,E.jsxs)(f,{value:`skill ${e.name} ${e.path}`,keywords:y(e.name,e.description),"data-slot":`${x}-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,disabled:!a&&g!==void 0&&n.length>=g,onSelect:()=>i(e.name),children:[(0,E.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,E.jsx)(`button`,{type:`button`,"data-slot":`${x}-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),M(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,E.jsx)(w,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,E.jsx)(S,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(T,{skill:j,onClose:()=>M(null)}),(0,E.jsxs)(s,{open:D,onOpenChange:e=>{O(e),e||A(``)},children:[(0,E.jsx)(o,{asChild:!0,children:(0,E.jsxs)(`button`,{type:`button`,"data-slot":`${x}-skills-trigger`,"aria-label":`Choose skills`,className:r(h,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,E.jsx)(m,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,E.jsx)(C,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,E.jsx)(a,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,E.jsxs)(d,{label:`Choose skills`,shouldFilter:!1,children:[(0,E.jsx)(p,{placeholder:`search skills…`,value:k,onValueChange:A,onInput:()=>N.current?.scrollTo(0,0)}),(0,E.jsxs)(u,{ref:N,"data-slot":`${x}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[P.length===0&&F.length===0&&I.length===0?(0,E.jsx)(c,{children:`Nothing matches.`}):null,P.length>0?(0,E.jsx)(l,{heading:`Most used`,children:P.map(e=>R(e,v(e)))}):null,F.length>0?(0,E.jsx)(l,{heading:`Project skills`,children:F.map(e=>R(e,!0))}):null,I.length>0?(0,E.jsx)(l,{heading:`Global`,children:I.map(e=>R(e,!1))}):null]})]})})]})]})}export{k as a,D as c,F as i,R as n,O as o,I as r,P as s,z as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-Clwd6u4_.js";import{t as i}from"./project-router-CZzr7lzN.js";import{a,o,r as s}from"./reference-chip-CScP5y_O.js";import{d as c,f as l,h as u,l as d,m as f,p}from"./use-now-BB7W0F--.js";import{bn as m,x as h}from"./git-tab-loading-BC6WP7W4.js";import{B as g,L as _,N as v,V as y,z as b}from"./worktree-lifecycle-operation-vTgExKUM.js";import{n as x}from"./textarea-ewNKsXDa.js";import{t as S}from"./check-Dt8U0Zvm.js";import{f as C}from"./tooltip-B628Gs7C.js";import{m as w}from"./git-toolbar-Dra1QlHb.js";import{c as T}from"./index-qeFtKZ4e.js";var E=n();function D({name:e,route:t,selected:n,list:i,detail:a}){return(0,E.jsxs)(`div`,{"data-route":t,className:`flex h-full min-h-0 items-stretch`,children:[(0,E.jsx)(`section`,{"data-slot":`${e}-list`,className:r(`w-full min-h-0 flex-col overflow-y-auto overscroll-contain border-border md:flex md:w-[360px] md:shrink-0 md:border-r`,n?`hidden`:`flex`),children:i}),(0,E.jsx)(`section`,{"data-slot":`${e}-detail`,className:r(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n?`flex`:`hidden md:flex`),children:a})]})}function O(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function k(e,t=[]){let n=O(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=A(t)),n}function A(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function j(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function M(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function N(e,t,n){let r=(n??``).trim();if(!r)return k(e,t);let i=O(e),a=r.startsWith(i)?i+j(r.slice(i.length),e):j(r,e),o=M(a,e)?a:`${i}\n\n${a}`;return t.length?o+A(t):o}function P(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function F(e,t,n,r,i={}){return t?{...i,workflow:t,task:N(e,n,r)}:n.length?{...i,steps:P(n),task:N(e,[],r)}:{...i,workflow:`quick-task`,task:N(e,[],r)}}function I({resolved:e,dataSlot:t}){return e.providerPending||e.canRun?null:(0,E.jsxs)(`span`,{"data-slot":t,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[e.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,E.jsx)(i,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]})}var L=e(t(),1);function R({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[m,_]=(0,L.useState)(!1),[v,b]=(0,L.useState)(``),w=(0,L.useRef)(null),T=g(e,v);return(0,E.jsxs)(s,{open:m,onOpenChange:e=>{_(e),e||b(``)},children:[(0,E.jsx)(o,{asChild:!0,children:(0,E.jsxs)(`button`,{type:`button`,"data-slot":`${i}-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(h,t&&`border-foreground/60 font-mono text-[11.5px] font-semibold text-foreground`),children:[(0,E.jsx)(x,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,E.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,E.jsx)(C,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,E.jsx)(a,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,E.jsxs)(d,{label:`Choose a workflow`,shouldFilter:!1,children:[(0,E.jsx)(p,{placeholder:`search workflows…`,value:v,onValueChange:b,onInput:()=>w.current?.scrollTo(0,0)}),(0,E.jsxs)(u,{ref:w,"data-slot":`${i}-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[T.length===0?(0,E.jsx)(c,{children:`Nothing matches.`}):null,(0,E.jsx)(l,{children:T.map(e=>{let r=t===e.name;return(0,E.jsxs)(f,{value:`workflow ${e.name}`,keywords:y(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),_(!1)},children:[(0,E.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,E.jsx)(S,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function z({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:g,slotPrefix:x=`gh`}){let[D,O]=(0,L.useState)(!1),[k,A]=(0,L.useState)(``),[j,M]=(0,L.useState)(null),N=(0,L.useRef)(null),{mostUsed:P,project:F,global:I}=_(b(e,k,t),t),R=(e,t)=>{let a=n.includes(e.name);return(0,E.jsxs)(f,{value:`skill ${e.name} ${e.path}`,keywords:y(e.name,e.description),"data-slot":`${x}-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,disabled:!a&&g!==void 0&&n.length>=g,onSelect:()=>i(e.name),children:[(0,E.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,E.jsx)(`button`,{type:`button`,"data-slot":`${x}-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),M(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,E.jsx)(w,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,E.jsx)(S,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(T,{skill:j,onClose:()=>M(null)}),(0,E.jsxs)(s,{open:D,onOpenChange:e=>{O(e),e||A(``)},children:[(0,E.jsx)(o,{asChild:!0,children:(0,E.jsxs)(`button`,{type:`button`,"data-slot":`${x}-skills-trigger`,"aria-label":`Choose skills`,className:r(h,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,E.jsx)(m,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,E.jsx)(C,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,E.jsx)(a,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,E.jsxs)(d,{label:`Choose skills`,shouldFilter:!1,children:[(0,E.jsx)(p,{placeholder:`search skills…`,value:k,onValueChange:A,onInput:()=>N.current?.scrollTo(0,0)}),(0,E.jsxs)(u,{ref:N,"data-slot":`${x}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[P.length===0&&F.length===0&&I.length===0?(0,E.jsx)(c,{children:`Nothing matches.`}):null,P.length>0?(0,E.jsx)(l,{heading:`Most used`,children:P.map(e=>R(e,v(e)))}):null,F.length>0?(0,E.jsx)(l,{heading:`Project skills`,children:F.map(e=>R(e,!0))}):null,I.length>0?(0,E.jsx)(l,{heading:`Global`,children:I.map(e=>R(e,!1))}):null]})]})})]})]})}export{k as a,D as c,F as i,R as n,O as o,I as r,P as s,z as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Er as r,Ii as i,Nt as a,Sa as o,Tr as s,Ut as c,Yn as l,Yr as u,Zr as d,ba as f,dr as p,it as ee,j as m,qt as h,ta as g,va as _,ya as te}from"./queries-CI0EmEcH.js";import{B as v,F as y,at as b,ct as x,dt as S,lt as ne,mt as re,ot as ie,pt as C,r as w,st as T,t as E,ut as D}from"./button-Clwd6u4_.js";import{T as ae,c as O,f as oe,s as se,t as k,w as ce}from"./project-router-DZsR9P9C.js";import{S as A}from"./reference-chip-DnemrSPW.js";import{O as le,a as ue,i as de,n as fe,o as pe,r as me,t as he,u as ge}from"./use-automations-v77gHYDG.js";import{a as _e,i as ve,n as ye,o as be,s as xe,t as Se}from"./use-now-pBdvhv13.js";import{An as j,Dn as Ce,P as we,_ as Te,vn as M,y as N}from"./git-tab-loading-BfC2ir8N.js";import{t as Ee}from"./arrow-left-BELOeFyX.js";import{I as De,c as Oe,d as ke,l as Ae}from"./worktree-lifecycle-operation-DOTiqQFx.js";import{r as je,t as Me}from"./textarea-ewNKsXDa.js";import{a as Ne,c as Pe,d as Fe,f as P,i as Ie,l as Le,n as Re,o as ze,p as Be,r as Ve,s as He,t as Ue,u as We}from"./automation-format-BL4n19a2.js";import{t as Ge}from"./chevron-left-Df5IsPem.js";import{f as Ke}from"./tooltip-B628Gs7C.js";import{t as qe}from"./chevron-right-VbYrJ_st.js";import{c as Je,i as F,n as Ye,r as Xe,u as Ze}from"./icon-tooltip-YXzUubMO.js";import{t as Qe}from"./terminal-F3ZJ5fI8.js";import{m as $e}from"./git-toolbar-DU5Ca6RI.js";import{t as et}from"./file-text-DmMQx3hx.js";import{n as tt,t as nt}from"./settings-2-COky68xN.js";import{r as rt}from"./use-submit-shortcut-hAaAH4HY.js";import{n as it}from"./square-8OFxLPoA.js";import{t as at}from"./plus-CBVm02wz.js";import{n as ot,o as I,r as st,t as ct}from"./collapsible-Bdyuw-he.js";import{a as lt,c as ut,i as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./alert-dialog-DvPnvVvK.js";import{t as L}from"./input-DIWTlsx6.js";import{i as R,r as _t}from"./token-metrics-Dk2ZNHb_.js";import{t as vt}from"./centered-state-nM7v9xtl.js";import{C as z,D as yt,E as bt,F as xt,O as B,P as St,S as V,T as H,d as Ct,o as wt,r as Tt,w as U,x as W}from"./index-BBND6Sg3.js";var Et=y(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Dt=y(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Ot=y(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),kt=y(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),G=e(t(),1),K=n();function At({association:e,selected:t,onSelect:n,onRemove:r}){let i=_({queryKey:[`tracker`,v(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>d({association:e,state:`all`,limit:50,cursor:t},{signal:n}),getNextPageParam:e=>e.available&&e.truncated?e.nextCursor:void 0,retry:!1,staleTime:6e4}),a=i.data?.pages??[],o=a.at(-1),s=a.find(e=>!e.available),c=i.isError||!!s,l=[...new Set([...t,...c?[]:a.flatMap(e=>e.available?e.items.flatMap(e=>e.labels):[])])].filter(e=>t.includes(e)||e.length>0&&e.length<=200).sort((e,t)=>e.localeCompare(t));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,K.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,K.jsx)(N,{active:t.includes(e),"aria-pressed":t.includes(e),disabled:!t.includes(e)&&t.length>=100,onClick:()=>t.includes(e)?r(e):n(e),children:e},e))}),i.isFetching?(0,K.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,c?(0,K.jsxs)(`div`,{role:`alert`,children:[(0,K.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,K.jsx)(E,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,K.jsxs)(K.Fragment,{children:[!i.isPending&&!i.isFetching&&l.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,K.jsx)(E,{type:`button`,variant:`outline`,size:`sm`,disabled:i.isFetching,onClick:()=>void i.fetchNextPage(),children:`Load labels from more tasks`}):null,!i.hasNextPage&&o?.available&&o.truncated?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var jt=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`,`pull_request.closed`,`pull_request.merged`];function Mt(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function Nt(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function Pt(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function Ft(e){return e?.source===`skill`?{skill:e.ref,workflow:we,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var It=[2,5,10,15,30,60],Lt=[1,2,4,6,8],Rt={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},zt={type:`daily`,hour:4,minute:0};function Bt(){return{name:``,kind:`schedule`,schedule:{...zt},events:[`issue.opened`],intervalSeconds:300,filters:{...Rt},prompt:``,workflow:we,skill:null,customSteps:null,runner:null,account:null,model:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var q=e=>(e??[]).join(`, `);function Vt(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Ht(e){return{authors:q(e.authors),assignees:q(e.assignees),anyLabels:q(e.anyLabels),allLabels:q(e.allLabels),excludeLabels:q(e.excludeLabels),changedLabels:q(e.changedLabels),reviewers:q(e.reviewers),lookbackDays:e.lookbackDays,maxRecords:e.maxRecords}}function Ut(e){let t=Bt(),{task:n,filters:r}=e,i=Nt(n.steps);return{...t,name:e.name,kind:e.kind,trackerTrigger:e.trackerTrigger,schedule:e.schedule?{...e.schedule}:t.schedule,events:e.events?.length?[...e.events]:t.events,intervalSeconds:e.intervalSeconds??t.intervalSeconds,filters:r?Ht(r):t.filters,prompt:n.prompt,workflow:n.workflow??t.workflow,skill:i,customSteps:n.steps&&!i?n.steps:null,runner:n.runner??null,account:n.agentProfile??null,model:n.model??null,autonomous:n.autonomous??!1,dispatch:n.dispatch!==void 0,maxSubtasks:n.dispatch?.maxSubtasks??t.maxSubtasks,reviewChild:n.dispatch?.reviewChild??t.reviewChild,enabled:e.enabled,...n.checkout===void 0?{}:{checkout:n.checkout},...n.allowForkHeads===void 0?{}:{allowForkHeads:n.allowForkHeads}}}function Wt(e){return{name:e.name,kind:e.kind,...e.schedule?{schedule:e.schedule}:{},...e.events?{events:e.events}:{},...e.intervalSeconds===void 0?{}:{intervalSeconds:e.intervalSeconds},...e.filters?{filters:e.filters}:{},prompt:e.task.prompt,...e.task.workflow?{workflow:e.task.workflow}:{},...e.task.steps?{steps:e.task.steps}:{},...e.task.runner?{runner:e.task.runner}:{},...e.task.model===void 0?{}:{model:e.task.model},...e.task.autonomous===void 0?{}:{autonomous:e.task.autonomous},...e.task.dispatch?{dispatch:e.task.dispatch}:{},...e.task.checkout?{checkout:e.task.checkout}:{},...e.task.allowForkHeads===void 0?{}:{allowForkHeads:e.task.allowForkHeads}}}var Gt=e=>e===`claude`||e===`codex`||e===`junie`||e===`opencode`||e===`cursor`||e===`pi`||e===`copilot`;function Kt(e,t){let n=Nt(t.steps);return{...e,name:t.name,kind:t.kind,schedule:t.schedule?{...t.schedule}:e.schedule,events:t.events?.length?[...t.events]:e.events,intervalSeconds:t.intervalSeconds??e.intervalSeconds,filters:t.filters?Ht(t.filters):{...Rt},prompt:t.prompt,...t.steps?{skill:n,customSteps:n?null:t.steps,workflow:we}:Ft(t.workflow?{source:`workflow`,ref:t.workflow}:null),checkout:t.checkout,allowForkHeads:t.allowForkHeads,runner:t.runner!==void 0&&Gt(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&Gt(t.runner)?null:e.account,model:t.model??e.model,autonomous:t.autonomous??e.autonomous,dispatch:t.dispatch!==void 0,maxSubtasks:t.dispatch?.maxSubtasks??e.maxSubtasks,reviewChild:t.dispatch?.reviewChild??e.reviewChild}}function qt(e){let t=D(e);switch(t.type){case`hours`:return{type:`hours`,every:t.every};case`weekly`:return{type:`weekly`,hour:t.hour,minute:t.minute,day:t.day};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function Jt(e){let t={prompt:e.prompt,...e.skill?{steps:Mt(e.skill)}:e.customSteps?{steps:e.customSteps}:e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.account?{agentProfile:e.account}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.dispatch?{dispatch:{maxSubtasks:e.maxSubtasks,reviewChild:e.reviewChild}}:{}};if(e.kind===`schedule`)return{name:e.name.trim(),kind:`schedule`,schedule:qt(e.schedule),task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:J(e.filters.lookbackDays,1,90),maxRecords:J(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Vt(e);return n.length>0?{[t]:n}:{}};return{name:e.name.trim(),kind:`github`,events:[...e.events],intervalSeconds:e.intervalSeconds,filters:{...r(n.authors,`authors`),...r(n.assignees,`assignees`),...r(n.anyLabels,`anyLabels`),...r(n.allLabels,`allLabels`),...r(n.excludeLabels,`excludeLabels`),...r(n.changedLabels,`changedLabels`),...r(n.reviewers,`reviewers`),lookbackDays:J(n.lookbackDays,1,90),maxRecords:J(n.maxRecords,1,100)},task:{...t,...e.checkout===void 0?{}:{checkout:e.checkout},...e.allowForkHeads===void 0?{}:{allowForkHeads:e.allowForkHeads}}}}function J(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Yt(e){let t=Jt(e);return{name:t.name,kind:e.kind,...t.trackerTrigger?{trackerTrigger:t.trackerTrigger}:{},...t.schedule?{schedule:t.schedule}:{},...t.events?{events:t.events}:{},...t.intervalSeconds===void 0?{}:{intervalSeconds:t.intervalSeconds},...t.filters?{filters:t.filters}:{},task:t.task,...e.enabled?{enable:!0}:{}}}var Xt=`([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})`,Zt=RegExp(`\\b(?:user|author|by)\\s+(?:\`@?${Xt}\`|@${Xt}(?![\\w/-]))`,`gi`);function Qt(e){if(e.kind!==`github`)return[];let t=new Set([e.filters.authors,e.filters.assignees,e.filters.reviewers].flatMap(Vt).map(e=>e.replace(/^@/,``).toLowerCase())),n=new Map;for(let r of e.prompt.matchAll(Zt)){let e=r[1]??r[2];e&&!t.has(e.toLowerCase())&&!n.has(e.toLowerCase())&&n.set(e.toLowerCase(),e)}return[...n.values()]}function $t(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var en=e=>[1,2,3,4,6,8,12].includes(e);function tn({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,a]=(0,G.useState)(``),o=v(),s=_({queryKey:[`tracker`,o,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>u({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),c=_({queryKey:[`tracker`,o,`automation-options`,i],enabled:!!i&&s.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>u({...i?{search:i}:{},...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),l=i?c:s,d=s.data?.pages[0],f=d?.available?d:void 0,p=!!f&&!!e&&JSON.stringify(f.association)===JSON.stringify(e.association),ee=p&&!!e?.events.length&&e.events.every(e=>f?.events.includes(e))&&(e.requiredLabels?.length??0)<=100&&(e.requiredLabels??[]).every(e=>e.length>0&&e.length<=200)&&(!e.events.includes(`issue.status_changed`)||!!e.targetStatusIds?.length)&&(!(e.events.includes(`issue.labeled`)||e.events.includes(`issue.unlabeled`))||!!e.changedLabelIds?.length);(0,G.useEffect)(()=>(r(ee),()=>r(!1)),[ee,r]);let m=l.data?.pages.flatMap(e=>e.available?[e]:[])??[],h=[...new Map(m.flatMap(e=>e.statuses).map(e=>[e.id,e])).values()],g=new Map((s.data?.pages.flatMap(e=>e.available?e.statuses:[])??[]).map(e=>[e.id,e.name])),te=(e?.targetStatusIds??[]).filter(e=>!h.some(t=>t.id===e)),y=[...new Map(m.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],b=e?.events.includes(`issue.status_changed`),x=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),S=b&&x?`Search tracker statuses and labels`:x?`Search tracker labels`:`Search tracker statuses`;return(0,K.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[s.isPending?(0,K.jsx)(`p`,{children:`Loading tracker events…`}):null,s.isError||d&&!d.available?(0,K.jsxs)(`div`,{role:`alert`,children:[(0,K.jsxs)(`p`,{children:[d&&!d.available?d.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,K.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void s.refetch(),children:`Retry`})]}):null,f?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{children:[f.association.kind===`jira`?`Jira`:`Linear`,` · `,f.association.externalName]}),e&&!p?(0,K.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,K.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,K.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:f.events.map(t=>(0,K.jsx)(N,{active:p&&e?.events.includes(t),"aria-pressed":p&&e?.events.includes(t),onClick:()=>{let r=p?e.events:[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a={...p?e:{},association:f.association,events:i};t===`issue.status_changed`&&!i.includes(t)&&delete a.targetStatusIds,n({trackerTrigger:a,...p?{}:{enabled:!1}})},children:t},t))}),p&&e?(0,K.jsx)(At,{association:f.association,selected:e.requiredLabels??[],onRemove:t=>n({trackerTrigger:{...e,requiredLabels:(e.requiredLabels??[]).filter(e=>e!==t)}}),onSelect:t=>n({trackerTrigger:{...e,requiredLabels:[...new Set([...e.requiredLabels??[],t])]}})},JSON.stringify(f.association)):null,(0,K.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,K.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,K.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),f.limitations.map(e=>(0,K.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(L,{"aria-label":S,placeholder:S,value:i,onChange:e=>a(e.target.value)}),l.isFetching?(0,K.jsx)(`p`,{role:`status`,children:`Searching…`}):null,l.isError||l.data?.pages[0]&&!l.data.pages[0].available?(0,K.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,K.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void l.refetch(),children:`Retry search`})]}):null,!l.isFetching&&l.data?.pages[0]?.available&&b&&h.length===0?(0,K.jsx)(`p`,{children:`No matching statuses.`}):null,!l.isFetching&&l.data?.pages[0]?.available&&x&&y.length===0?(0,K.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,K.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[h.map(t=>(0,K.jsx)(N,{active:e.targetStatusIds?.includes(t.id),"aria-pressed":e.targetStatusIds?.includes(t.id),onClick:()=>{let r=e.targetStatusIds??[];n({trackerTrigger:{...e,targetStatusIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id)),te.map(t=>(0,K.jsxs)(N,{active:!0,"aria-pressed":!0,onClick:()=>{n({trackerTrigger:{...e,targetStatusIds:(e.targetStatusIds??[]).filter(e=>e!==t)}})},children:[g.get(t)??t,` (not in current results)`]},t))]}):null,e.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)?(0,K.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:y.map(t=>(0,K.jsx)(N,{active:e.changedLabelIds?.includes(t.id),"aria-pressed":e.changedLabelIds?.includes(t.id),onClick:()=>{let r=e.changedLabelIds??[];n({trackerTrigger:{...e,changedLabelIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id))}):null,l.hasNextPage?(0,K.jsx)(E,{variant:`outline`,size:`sm`,disabled:l.isFetchingNextPage,onClick:()=>void l.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,K.jsxs)(W,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,K.jsx)(U,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:It.map(e=>(0,K.jsxs)(z,{value:String(e),children:[e,` min`]},e))})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only events after enabling are eligible. Existing backlog is not launched. The workflow agent receives this project’s tracker credentials to carry out your instructions; status updates are not guaranteed by the scheduler.`})]})}function nn({definition:e}){let t=(0,G.useMemo)(()=>pe(e),[e]);return(0,K.jsxs)(P,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Copy as CLI`}),(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void fe(t),children:[(0,K.jsx)(j,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,K.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-[11.5px] leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:t}),(0,K.jsxs)(`p`,{className:`mt-2 mb-0 text-[11.5px] leading-[1.5] text-soft-foreground`,children:[`The same definition the cockpit saves — `,(0,K.jsx)(`code`,{className:`text-[11px]`,children:`cez automation schema`}),` prints its shape.`]})]})}function rn({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=Lt.includes(n)?Lt:[...Lt,n].sort((e,t)=>e-t);return(0,K.jsxs)(`div`,{"data-slot":`editor-dispatch`,"data-enabled":t?`true`:void 0,title:`Let this run start its own subtasks with cez task create — each in a worktree forked off its branch, reporting back into the parent session.`,className:`flex flex-wrap items-center gap-2.5 border-t border-border pt-3 text-[13px] text-muted-foreground`,children:[(0,K.jsxs)(B,{className:`text-[13px] font-medium text-foreground`,children:[(0,K.jsx)(tt,{"aria-hidden":`true`,className:w(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,K.jsx)(yt,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i({dispatch:e})})]}),t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,K.jsxs)(W,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-[12.5px]`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:a.map(e=>(0,K.jsx)(z,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsxs)(B,{className:`text-[13px] font-normal text-muted-foreground`,children:[(0,K.jsx)(yt,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,K.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-[11.5px] whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null]})}function an({events:e,intervalSeconds:t,filters:n,onChange:r}){let[i,a]=(0,G.useState)([`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].some(e=>n[e].trim().length>0)||n.lookbackDays!==7||n.maxRecords!==25),o=(e,t)=>r({filters:{...n,[e]:t}}),s=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:jt.filter(e=>n.includes(e))})},c=$t(e),l=c&&n.changedLabels.trim().length===0;return(0,K.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-3.5`,children:[(0,K.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:jt.map(t=>(0,K.jsx)(N,{active:e.includes(t),"aria-pressed":e.includes(t),className:`font-mono`,onClick:()=>s(t),children:t},t))}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground`,children:[`poll every`,(0,K.jsxs)(W,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Poll interval`,className:`text-[13px]`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:It.map(e=>(0,K.jsxs)(z,{value:String(e),children:[e,` min`]},e))})]}),(0,K.jsxs)(`span`,{children:[`· last `,n.lookbackDays,` days · maximum `,n.maxRecords,` records`]})]}),(0,K.jsxs)(ct,{open:i,onOpenChange:a,children:[(0,K.jsx)(st,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,K.jsx)(Ke,{"aria-hidden":`true`,className:w(`size-3 transition-transform`,i?``:`-rotate-90`)}),`Filters`,l?(0,K.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):null]})}),(0,K.jsx)(ot,{children:(0,K.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-2 sm:grid-cols-2`,children:[(0,K.jsx)(Y,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>o(`authors`,e)}),(0,K.jsx)(Y,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>o(`assignees`,e)}),(0,K.jsx)(Y,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>o(`anyLabels`,e)}),(0,K.jsx)(Y,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>o(`allLabels`,e)}),(0,K.jsx)(Y,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>o(`excludeLabels`,e)}),(0,K.jsx)(Y,{id:`filter-changed-labels`,label:c?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:l,onChange:e=>o(`changedLabels`,e)}),(0,K.jsx)(Y,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>o(`reviewers`,e)}),(0,K.jsx)(on,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>o(`lookbackDays`,e)}),(0,K.jsx)(on,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>o(`maxRecords`,e)})]})})]})]})}function Y({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(B,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,K.jsx)(L,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-[13px]`})]})}function on({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(B,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,K.jsx)(L,{id:e,type:`number`,min:r,max:i,value:n,onChange:e=>a(J(Number(e.target.value),r,i)),className:`h-8 w-28 font-mono text-[13px] tabular-nums`})]})}function sn({source:e,sourcesReady:t,skills:n,skillUsage:r,workflows:i,onSource:a,pick:o,onPick:s,baseBranch:c,autonomous:l,onAutonomous:u}){return(0,K.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(wt,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,K.jsx)(Ct,{pick:o,onChange:s,accounts:!0}),(0,K.jsx)(Te,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,K.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsxs)(B,{className:`text-[13px] font-medium`,children:[`Autonomous`,(0,K.jsx)(yt,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function cn({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`branch-chip`,className:w(`inline-block rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11.5px] leading-[1.3] font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var ln=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`]],un=e=>String(e).padStart(2,`0`);function dn({schedule:e,timeZone:t,onChange:n}){let r=D(e),i=e=>n({...r,...e});return(0,K.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,K.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:ln.map(([e,t])=>(0,K.jsx)(N,{active:r.type===e,"aria-pressed":r.type===e,onClick:()=>i({type:e}),children:t},e))}),r.type===`weekly`?(0,K.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:ie.map((e,t)=>(0,K.jsx)(N,{active:r.day===t+1,"aria-pressed":r.day===t+1,className:`px-[9px]`,onClick:()=>i({day:t+1}),children:e},e))}):null,r.type===`hours`?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`every`,(0,K.jsxs)(W,{value:String(r.every),onValueChange:e=>{let t=Number(e);en(t)&&i({every:t})},children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Every N hours`,className:`text-[13px]`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:b.map(e=>(0,K.jsxs)(z,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`at`,(0,K.jsx)(L,{"aria-label":`Hour`,inputMode:`numeric`,value:un(r.hour),onChange:e=>i({hour:Math.min(23,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),`:`,(0,K.jsx)(L,{"aria-label":`Minute`,inputMode:`numeric`,value:un(r.minute),onChange:e=>i({minute:Math.min(59,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 font-mono text-xs text-soft-foreground`,children:[(0,K.jsx)(`span`,{children:`cron`}),(0,K.jsx)(cn,{"data-slot":`editor-cron`,children:T(r)})]})]})}function fn({lastRun:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){return(0,K.jsxs)(P,{flush:!0,"data-slot":`last-run-card`,className:`px-3.5 py-3`,children:[(0,K.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Last run`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,K.jsx)(R,{tone:Pe(e.status)}),He(e.status),(0,K.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:_t(e.ts,i)}),null]}),(0,K.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,K.jsxs)(E,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,K.jsx)(it,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}),n?(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,K.jsx)(kt,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}var pn=864e5;function mn({kind:e,schedule:t,intervalSeconds:n,timeZone:r,now:i}){let[a,o]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{if(i!==void 0)return;let e=setInterval(()=>o(Date.now()),6e4);return()=>clearInterval(e)},[i]);let s=i??a,c=(0,G.useMemo)(()=>e===`schedule`?S(t,s,s+9*pn,r,5):[],[e,t,s,r]);return(0,K.jsxs)(P,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,K.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:e===`schedule`?`Next 5 runs`:`How it polls`}),e===`schedule`?c.length===0?(0,K.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:`Nothing in the next nine days.`}):c.map(e=>(0,K.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-[13px]`,children:[(0,K.jsx)(`span`,{className:`w-[82px] shrink-0 font-mono text-xs font-medium whitespace-nowrap text-foreground tabular-nums`,children:Ve(e,r)}),(0,K.jsx)(`span`,{className:`text-[11.5px] whitespace-nowrap text-soft-foreground`,children:Ne(e,s)})]},e)):(0,K.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,K.jsxs)(K.Fragment,{children:[`Checks the project tracker every `,Math.round(n/60),` min while this cockpit is open. No webhook or public URL required.`]}):(0,K.jsxs)(K.Fragment,{children:[`Checks GitHub every `,Math.round(n/60),` min while this cockpit is open, through your `,(0,K.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var hn=[{name:`Nightly dependency bump`,when:`Every day at 04:00`,kind:`schedule`,schedule:{type:`daily`,hour:4,minute:0},prompt:`Run npm outdated, bump patch and minor versions, run the test suite, open a draft PR if anything changed.`},{name:`Triage new issues`,when:`On issue.opened · every 5 min`,kind:`github`,events:[`issue.opened`],intervalSeconds:300,prompt:`Read {{github.url}}. Label it, add a repro or a clarification request. Never close it.`},{name:`Weekly changelog draft`,when:`Fridays at 16:00`,kind:`schedule`,schedule:{type:`weekly`,day:5,hour:16,minute:0},prompt:`Collect merged PRs since last week, write CHANGELOG entries, open a draft PR.`},{name:`Stale PR nudge`,when:`Every 6 hours`,kind:`schedule`,schedule:{type:`hours`,every:6},prompt:`Comment on PRs idle for 48h with what is blocking them.`},{name:`Flaky test hunt`,when:`Tuesdays at 02:00`,kind:`schedule`,schedule:{type:`weekly`,day:2,hour:2,minute:0},prompt:`Run the suite 5×, quarantine intermittent tests, open an issue per test.`,dispatch:{maxSubtasks:8,reviewChild:!0}},{name:`Security advisories`,when:`Every day at 06:00`,kind:`schedule`,schedule:{type:`daily`,hour:6,minute:0},prompt:`Run npm audit; for each high/critical advisory open a task with the upgrade path.`}],gn=e=>[v(),`automation-templates`,e??``];function _n({onPick:e}){let[t,n]=(0,G.useState)(`builtin`),i=se(),a=f({queryKey:gn(i),queryFn:({signal:e})=>r(i,{signal:e}),enabled:t===`mine`}),o=t===`builtin`?hn.map(e=>({...e,key:e.name})):(a.data?.templates??[]).map(e=>({...Wt(e),key:`${e.project.id}:${e.id}`,when:We(e),project:e.project.name}));return(0,K.jsxs)(P,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,K.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,K.jsx)(vn,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,K.jsx)(vn,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,K.jsx)(`span`,{className:`ml-auto min-w-0 overflow-hidden pb-2 text-xs text-ellipsis whitespace-nowrap text-soft-foreground`,children:t===`builtin`?`Built-in`:`Registered in ~/.cezar/config.json`})]}),t===`mine`&&a.isPending?(0,K.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`Loading…`}):t===`mine`&&a.isError?(0,K.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-xs text-danger`,children:a.error.message}):o.length===0?(0,K.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`No automations in your other projects yet.`}):(0,K.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:o.map(t=>(0,K.jsxs)(`div`,{"data-slot":`template-card`,className:`flex flex-col gap-1.5 rounded-[10px] border border-border bg-card-2 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-semibold`,children:[t.kind===`github`?(0,K.jsx)(bt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,K.jsx)(xt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,K.jsx)(cn,{className:`ml-auto`,children:t.project}):null]}),(0,K.jsx)(`div`,{className:`font-mono text-[11.5px] text-muted-foreground`,children:t.when}),(0,K.jsx)(`div`,{className:`line-clamp-2 text-xs leading-[1.45] text-soft-foreground`,children:t.prompt}),(0,K.jsx)(E,{variant:`outline`,size:`sm`,className:`mt-0.5 self-start`,"aria-label":`Use this: ${t.name}`,onClick:()=>e(t),children:`Use this`})]},t.key))})]})}function vn({active:e,onClick:t,children:n}){return(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:w(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-[13px] font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function yn(e){let t=e.toLowerCase();return/\b(events?|filters?|schedule|interval|changedlabels|changed labels|lookback|maxrecords)\b/.test(t)?`when`:/\b(prompt|workflow|runner|model|dispatch)\b/.test(t)?`what`:`top`}var bn={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`Describe the task the agent should do each time. Placeholders: {{date}}, {{project}}`,github:`Describe the task the agent should do for each match. Placeholders: {{github.url}}, {{github.title}}, {{github.number}}, {{github.labels}}`};function xn({data:e,automation:t,actions:n,onBack:r,onSaved:i,onLog:s}){let u=o(),d=O(),f=m(),_=c(),te=h(),v=a(),y=ee(),[b,x]=(0,G.useState)(()=>t?Ut(t):Bt()),[S,ne]=(0,G.useState)(!t),[re,ie]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,D]=(0,G.useState)(null),[ae,oe]=(0,G.useState)(!1),se=(0,G.useRef)(null),k=t?.revision,ce=(0,G.useRef)(k);(0,G.useEffect)(()=>{!t||k===ce.current||(ce.current=k,x(Ut(t)),oe(!1),D(null))},[t,k]);let A=e=>x(t=>({...t,...e})),le=e?.timeZone??`UTC`,ue=e?.available!==!1,de=f.data?.capabilities.dispatch===!0,fe=(0,G.useMemo)(()=>Oe(ke(_.data?.promptTemplates),f.data?.capabilities),[_.data?.promptTemplates,f.data?.capabilities]),pe=te.data?.workflows??[],me=pe.map(e=>e.name),ge=v.data,_e=(ge??[]).map(e=>e.name),ve=_.data?.skillUsage,ye=(0,G.useMemo)(()=>De(ge??[],ve),[ge,ve]),be=v.data!==void 0&&te.data!==void 0&&!_.isPending,xe=y.data?.baseBranch??y.data?.info?.branch??void 0,Se=(0,G.useMemo)(()=>Yt(b),[b]),j=(0,G.useMemo)(()=>Qt(b),[b]),Ce=b.name.trim().length>0&&b.prompt.trim().length>0&&!C&&(b.kind!==`tracker`||re),we=e=>{let t=se.current,n=t?.selectionStart??b.prompt.length,r=Ae(b.prompt,n,e);A({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},Te=async()=>{w(!0),D(null),oe(!1);try{let e=Jt(b);t?await g(t.id,{...e,enabled:b.enabled,expectedRevision:t.revision}):await p({...e,enable:b.enabled}),await u.invalidateQueries({queryKey:he()}),i()}catch(e){if(t&&e instanceof l&&e.status===409)oe(!0);else{let t=e instanceof Error?e.message:String(e);D({message:t,section:e instanceof l&&e.status===400?yn(t):`top`})}}finally{w(!1)}},M=()=>void u.invalidateQueries({queryKey:he()}),je=t?`Save changes`:b.enabled?`Save and enable`:`Save paused`;return(0,K.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,className:`flex min-h-full flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex min-h-14 shrink-0 flex-wrap items-center gap-3 border-b border-border bg-background px-5 max-md:py-2 md:h-14 md:flex-nowrap`,children:[(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,K.jsx)(Ee,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,K.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,K.jsx)(I,{dot:t.enabled?`success`:`neutral`,children:t.enabled?`enabled`:`paused`}):null,(0,K.jsx)(`span`,{className:`flex-1`}),t?null:(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,"aria-expanded":S,"aria-label":S?`Hide templates`:`Start from a template`,onClick:()=>ne(e=>!e),children:[(0,K.jsx)(Et,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(`span`,{className:`max-md:hidden`,children:S?`Hide templates`:`Start from a template`})]}),(0,K.jsx)(E,{variant:`outline`,onClick:r,children:`Cancel`}),(0,K.jsx)(E,{disabled:!Ce,onClick:()=>void Te(),children:je})]}),(0,K.jsx)(`div`,{className:`flex justify-center p-5`,children:(0,K.jsxs)(`div`,{className:`grid w-full max-w-[1080px] grid-cols-1 items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[ae?(0,K.jsxs)(`div`,{role:`alert`,"data-slot":`editor-conflict`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-[13px] text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,K.jsx)(E,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:M,children:`Reload`})]}):null,T?.section===`top`?(0,K.jsx)(Cn,{children:T.message}):null,S&&!t?(0,K.jsx)(_n,{onPick:e=>{let t=e.workflow&&me.includes(e.workflow)?e.workflow:void 0,n=e.steps?.every(e=>!e.skill||_e.includes(e.skill))?e.steps:void 0;x(r=>Kt(r,{...e,workflow:t,steps:n})),ne(!1)}}):null,(0,K.jsx)(Sn,{title:`Name`,children:(0,K.jsx)(L,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:b.name,onChange:e=>A({name:e.target.value}),className:`max-w-[420px] text-[15px] md:text-[15px]`})}),(0,K.jsxs)(Sn,{title:`When`,children:[(0,K.jsx)(wn,{value:b.kind,editing:!!t,githubAvailable:ue,githubReason:e?.reason,onChange:e=>A({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})}),b.kind===`schedule`?(0,K.jsx)(dn,{schedule:b.schedule,timeZone:le,onChange:e=>A({schedule:e})}):b.kind===`tracker`?(0,K.jsx)(tn,{trigger:b.trackerTrigger,intervalSeconds:b.intervalSeconds,onChange:A,onValid:ie}):(0,K.jsx)(an,{events:b.events,intervalSeconds:b.intervalSeconds,filters:b.filters,onChange:e=>A(e)}),T?.section===`when`?(0,K.jsx)(Cn,{children:T.message}):null]}),(0,K.jsxs)(Sn,{title:`What to run`,children:[(0,K.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,K.jsx)(et,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,fe.map(e=>(0,K.jsx)(N,{className:`h-6 text-[11.5px]`,title:e.text,onClick:()=>we(e.text),children:e.label},e.id)),(0,K.jsx)(N,{dashed:!0,className:`h-6 text-[11.5px]`,icon:(0,K.jsx)(nt,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>d(`${Tt(`project`,`instructions`)}#prompt-templates`),children:`Manage…`})]}),(0,K.jsx)(Me,{ref:se,"aria-label":`Prompt`,rows:5,placeholder:bn[b.kind],value:b.prompt,onChange:e=>A({prompt:e.target.value}),className:`min-h-[104px] text-sm leading-[1.55] md:text-sm`}),j.length>0?(0,K.jsxs)(`div`,{role:`status`,"data-slot":`editor-prompt-condition`,className:`flex flex-wrap items-center gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[12.5px] text-foreground`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`The prompt names `,j.map(e=>`@${e}`).join(`, `),`, but prompt text does not decide what launches — without a filter every matching event starts a task.`]}),(0,K.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>A({filters:{...b.filters,authors:[...Vt(b.filters.authors),...j].join(`, `)}}),children:`Add to Authors`})]}):null,(0,K.jsx)(sn,{source:Pt(b),sourcesReady:be,skills:ye,skillUsage:ve,workflows:pe,onSource:e=>A(Ft(e)),pick:{runner:b.runner,model:b.model,account:b.account},onPick:e=>A({runner:e.runner,model:e.model,account:e.account}),baseBranch:xe,autonomous:b.autonomous,onAutonomous:e=>A({autonomous:e})}),(0,K.jsx)(`p`,{className:`m-0 text-xs leading-[1.5] text-soft-foreground`,children:`Each run is an ordinary cezar task in its own worktree — it queues behind the parallel cap like anything else and never auto-merges.`}),(0,K.jsx)(rn,{available:de,enabled:b.dispatch,maxSubtasks:b.maxSubtasks,reviewChild:b.reviewChild,onChange:e=>A(e)}),T?.section===`what`?(0,K.jsx)(Cn,{children:T.message}):null]}),(0,K.jsx)(Sn,{title:`Enable`,children:(0,K.jsxs)(B,{className:`text-[13px] font-medium`,children:[(0,K.jsx)(yt,{"aria-label":`Enabled`,checked:b.enabled,onCheckedChange:e=>A({enabled:e})}),`Enabled`,b.kind===`schedule`?null:(0,K.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`— from a current-time baseline; existing matches will not launch`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 lg:sticky lg:top-[76px]`,children:[(0,K.jsx)(mn,{kind:b.kind,schedule:b.schedule,intervalSeconds:b.intervalSeconds,timeZone:le}),(0,K.jsx)(nn,{definition:Se}),t&&t.kind!==`schedule`&&n?(0,K.jsx)(E,{variant:`outline`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t?.lastRun?(0,K.jsx)(fn,{lastRun:t.lastRun,busy:n?.busy,onRunNow:()=>void n?.runNow(t),onLog:s}):null]})]})})]})}function Sn({title:e,children:t}){return(0,K.jsxs)(P,{"data-slot":`editor-section`,className:`gap-0 px-6 py-0`,children:[(0,K.jsx)(`div`,{className:`pt-4 pb-1 text-sm font-semibold`,children:e}),(0,K.jsx)(`div`,{className:`flex flex-col gap-3.5 pt-2.5 pb-5`,children:t})]})}function Cn({children:e}){return(0,K.jsx)(`p`,{role:`alert`,className:`m-0 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-[12.5px] text-danger`,children:e})}function wn({value:e,editing:t,githubAvailable:n,githubReason:r,onChange:i}){let a=`Change the kind by creating a new automation`;return(0,K.jsx)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`inline-flex flex-wrap gap-0.5 self-start rounded-md bg-muted p-[3px]`,children:[{value:`schedule`,label:`On a schedule`,disabled:t&&e!==`schedule`,...t&&e!==`schedule`?{title:a}:{}},{value:`github`,label:`When GitHub changes`,disabled:!n||t&&e!==`github`,...n?t&&e!==`github`?{title:a}:{}:{title:r??`GitHub is unavailable`}},{value:`tracker`,label:`When Jira / Linear changes`,disabled:t&&e!==`tracker`,...t&&e!==`tracker`?{title:a}:{}}].map(t=>(0,K.jsx)(`button`,{type:`button`,"data-value":t.value,"aria-pressed":t.value===e,disabled:t.disabled,title:t.title,onClick:()=>{t.value!==e&&i(t.value)},className:w(`flex h-7 items-center justify-center gap-1.5 rounded-[7px] px-3 text-[12.5px] font-medium whitespace-nowrap text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,t.value===e&&`bg-card font-semibold text-foreground shadow-xs`),children:t.label},t.value))})}function Tn({automationId:e,automation:t,timeZone:n,onBack:r}){let a=O(),c=o(),l=v(),u=(0,G.useMemo)(()=>[l,`automation-log`,e],[l,e]),d=f({queryKey:u,queryFn:({signal:t})=>s(e,{signal:t})}),[p,ee]=(0,G.useState)(`all`),[m,h]=(0,G.useState)(`all`);(0,G.useEffect)(()=>le((t,n)=>{t===`automation-change`&&n.automationId===e&&c.invalidateQueries({queryKey:u})}),[e,c,u]);let g=te({mutationFn:e=>i(e),onSuccess:()=>c.invalidateQueries({queryKey:u}),onError:e=>oe(e instanceof Error?e.message:String(e),{tone:`danger`})}),_=n??`UTC`,y=d.data?.records.filter(e=>(p===`all`||e.result===p)&&(m===`all`||e.event===m));return(0,K.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-log`,className:`flex min-h-full flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5`,children:[(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,K.jsx)(Ee,{className:`size-[15px]`})}),(0,K.jsx)(`h1`,{className:`m-0 text-base font-semibold`,children:t?t.name:`Automation`}),(0,K.jsx)(`span`,{className:`text-[13px] text-muted-foreground`,children:`· execution log`}),(0,K.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2`,children:[(0,K.jsxs)(W,{value:p,onValueChange:e=>ee(e),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Filter by result`,className:`text-[12.5px]`,children:(0,K.jsx)(H,{placeholder:`All results`})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(z,{value:`all`,children:`All results`}),En.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]}),(0,K.jsxs)(W,{value:m,onValueChange:e=>h(e),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Filter by event`,className:`text-[12.5px]`,children:(0,K.jsx)(H,{placeholder:`All events`})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(z,{value:`all`,children:`All events`}),Dn.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]})]}),(0,K.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>a(`/automations/${encodeURIComponent(e)}`),children:[(0,K.jsx)(rt,{className:`size-[13px]`}),`Edit`]})]}),(0,K.jsx)(`div`,{className:`flex justify-center p-5`,children:d.isError?(0,K.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,K.jsx)($,{text:d.error instanceof Error?d.error.message:String(d.error)})}):y===void 0?(0,K.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,K.jsx)($,{text:`Loading execution log…`})}):y.length===0?(0,K.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,K.jsx)($,{text:`No checks have run yet.`})}):(0,K.jsx)(P,{flush:!0,className:`w-full max-w-[820px]`,children:y.map((e,t)=>(0,K.jsx)(kn,{record:e,run:e.runId===void 0?void 0:d.data?.runs[e.runId],last:t===y.length-1,timeZone:_,retrying:g.isPending&&g.variables===e.receiptId,onRetry:e=>g.mutate(e)},e.seq))})})]})}var En=[`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`manual`,`catch-up`,`skipped`,`failed`],Dn=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`,`pull_request.closed`,`pull_request.merged`];function On(e){return e.result===`failed`&&e.runId===void 0?e.receiptId:void 0}function kn({record:e,run:t,last:n,timeZone:r,retrying:i,onRetry:a}){let o=ze(e.result),s=t?.children??[],c=On(e);return(0,K.jsxs)(`div`,{"data-slot":`log-row`,"data-result":e.result,className:`grid grid-cols-[90px_110px_1fr_auto] items-center gap-x-3 gap-y-2 px-4 py-3 text-[13px] ${n?``:`border-b border-border`}`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:Ie(e.ts,r)}),(0,K.jsx)(I,{dot:o,className:`w-fit`,children:e.result}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap ${o===`danger`?`text-danger`:`text-muted-foreground`}`,title:e.reason,children:e.reason??``}),null,e.runId===void 0?c===void 0?(0,K.jsx)(`span`,{}):(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a(c),children:[(0,K.jsx)(St,{className:`size-3`}),`Retry task`]}):(0,K.jsx)(E,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,K.jsxs)(k,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open task`,(0,K.jsx)(A,{className:`size-3`})]})}),s.length>0?(0,K.jsx)(`div`,{className:`col-span-full flex flex-col gap-1 pl-3.5`,children:s.map(e=>(0,K.jsxs)(`div`,{"data-slot":`log-child`,className:`grid grid-cols-[14px_70px_1fr_auto] items-center gap-2.5 text-[12.5px]`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`└`}),(0,K.jsx)(`span`,{className:`w-fit rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:e.kind??`implement`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(R,{tone:Pe(e.status)}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.title})]}),null,(0,K.jsx)(E,{variant:`ghost`,size:`sm`,className:`h-6`,asChild:!0,children:(0,K.jsxs)(k,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open`,(0,K.jsx)(A,{className:`size-[11px]`})]})})]},e.runId))}):null]})}function An({automation:e,actions:t}){let n=O(),[r,i]=(0,G.useState)(!1),a=e=>e.stopPropagation(),o=`/automations/${encodeURIComponent(e.id)}`;return(0,K.jsxs)(`span`,{"data-slot":`row-actions`,className:`inline-flex gap-0.5`,onClick:a,children:[e.kind===`schedule`?null:(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,title:`Preview matches`,"aria-label":`Preview matches`,disabled:t.busy,onClick:()=>void t.preview(e),children:(0,K.jsx)($e,{className:`size-[13px]`})}),(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,title:`Run now`,"aria-label":`Run now`,disabled:t.busy,onClick:()=>void t.runNow(e),children:(0,K.jsx)(it,{className:`size-[13px]`})}),(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,title:e.enabled?`Pause`:`Enable`,"aria-label":e.enabled?`Pause`:`Enable`,disabled:t.busy,onClick:()=>void t.toggleEnabled(e),children:e.enabled?(0,K.jsx)(Dt,{className:`size-[13px]`}):(0,K.jsx)(Ot,{className:`size-[13px]`})}),(0,K.jsxs)(Ye,{children:[(0,K.jsx)(Ze,{asChild:!0,children:(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`More`,children:(0,K.jsx)(Ce,{className:`size-3.5`})})}),(0,K.jsxs)(Xe,{align:`end`,className:`w-[200px]`,onClick:a,children:[(0,K.jsxs)(F,{onSelect:()=>n(o),children:[(0,K.jsx)(rt,{}),`Edit`]}),(0,K.jsxs)(F,{onSelect:()=>n(`${o}/log`),children:[(0,K.jsx)(kt,{}),`View log`]}),(0,K.jsxs)(F,{onSelect:()=>void t.duplicate(e),children:[(0,K.jsx)(j,{}),`Duplicate`]}),(0,K.jsxs)(F,{onSelect:()=>void t.copyCli(e),children:[(0,K.jsx)(Qe,{}),`Copy as CLI`]}),(0,K.jsx)(Je,{}),(0,K.jsxs)(F,{variant:`destructive`,onSelect:()=>i(!0),children:[(0,K.jsx)(je,{}),`Delete`]})]})]}),(0,K.jsx)(gt,{open:r,onOpenChange:i,children:(0,K.jsxs)(dt,{onClick:a,children:[(0,K.jsxs)(ht,{children:[(0,K.jsxs)(ut,{children:[`Delete “`,e.name,`”?`]}),(0,K.jsx)(lt,{children:`The automation is removed for good. Tasks it already launched and its execution log stay.`})]}),(0,K.jsxs)(pt,{children:[(0,K.jsx)(mt,{children:`Cancel`}),(0,K.jsx)(ft,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>void t.remove(e),children:`Delete`})]})]})})]})}var X=`h-[38px] border-b border-border px-[10px] text-left text-[11px] leading-none font-semibold tracking-[.05em] whitespace-nowrap text-soft-foreground uppercase`,Z=`h-12 border-b border-border px-[10px] text-[13px] leading-none whitespace-nowrap`,Q=`cz-auto-wide max-[1280px]:hidden`,jn=(0,K.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`});function Mn({data:e,actions:t,now:n=Date.now()}){return(0,K.jsx)(P,{flush:!0,"data-slot":`automations-table`,className:`min-w-0 overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full border-collapse [&_tbody_tr:last-child>td]:border-b-0`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:w(X,`pl-4`),children:`State`}),(0,K.jsx)(`th`,{className:X,children:`Automation`}),(0,K.jsx)(`th`,{className:X,children:`Trigger`}),(0,K.jsx)(`th`,{className:w(X,Q),children:`Runs as`}),(0,K.jsx)(`th`,{className:X,children:`Next run`}),(0,K.jsx)(`th`,{className:X,children:`Last run`}),(0,K.jsx)(`th`,{className:w(X,Q,`text-right`),children:`Runs 7d`}),null,(0,K.jsx)(`th`,{className:w(X,`pr-4`)})]})}),(0,K.jsx)(`tbody`,{children:e.automations.map(r=>(0,K.jsx)(Nn,{automation:r,actions:t,timeZone:e.timeZone,available:e.available,showCost:!1,now:n},r.id))})]})})}function Nn({automation:e,actions:t,timeZone:n,available:r,showCost:i,now:a}){let o=O(),s=e.kind===`github`,c=s&&!r,l=e.task.dispatch,u=We(e),d=[e.task.workflow,e.task.runner].filter(Boolean);return(0,K.jsxs)(`tr`,{"data-slot":`automation-row`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,className:w(`cursor-pointer hover:bg-muted`,!e.enabled&&`opacity-60`),onClick:()=>o(`/automations/${encodeURIComponent(e.id)}`),children:[(0,K.jsx)(`td`,{className:w(Z,`pl-4`),children:c?(0,K.jsx)(I,{dot:`neutral`,children:`paused by capability`}):(0,K.jsx)(I,{dot:e.enabled?`success`:`neutral`,pulse:e.enabled&&s,children:e.enabled?`enabled`:`paused`})}),(0,K.jsx)(`td`,{className:w(Z,`max-w-0 min-w-[200px]`),children:(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[s?(0,K.jsx)(bt,{className:`size-3.5 shrink-0 text-soft-foreground`}):e.kind===`tracker`?(0,K.jsx)(M,{className:`size-3.5 shrink-0 text-soft-foreground`}):(0,K.jsx)(xt,{className:`size-3.5 shrink-0 text-soft-foreground`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.name}),l?(0,K.jsxs)(`span`,{"data-slot":`dispatch-badge`,title:`dispatch · up to ${l.maxSubtasks??1} subtasks`,className:`inline-flex shrink-0 items-center gap-[3px] rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:[(0,K.jsx)(tt,{className:`size-2.5`}),`×`,l.maxSubtasks??1]}):null]})}),(0,K.jsx)(`td`,{className:w(Z,`max-w-[260px] overflow-hidden font-mono text-xs text-ellipsis text-muted-foreground`),title:u,children:u}),(0,K.jsx)(`td`,{className:w(Z,Q,`text-xs text-muted-foreground`),children:d.length?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[d.map((e,t)=>(0,K.jsxs)(`span`,{className:`contents`,children:[t>0?(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}):null,e]},e)),e.task.autonomous?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsx)(`span`,{title:`autonomous`,"data-slot":`autonomous-mark`,className:`inline-flex`,children:(0,K.jsx)(M,{"aria-hidden":`true`,className:`size-[11px] text-soft-foreground`})})]}):null]}):jn}),(0,K.jsx)(`td`,{"data-slot":`next-run`,className:w(Z,`font-mono text-xs tabular-nums`,e.enabled?`text-foreground`:`text-soft-foreground`),children:Pn(e,n,a)}),(0,K.jsx)(`td`,{className:Z,children:e.lastRun?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(R,{tone:Pe(e.lastRun.status)}),(0,K.jsx)(`span`,{className:`text-[12.5px] text-muted-foreground`,children:He(e.lastRun.status)}),(0,K.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:_t(e.lastRun.ts,a)}),(0,K.jsxs)(k,{to:`/tasks/${encodeURIComponent(e.lastRun.runId)}`,"data-slot":`task-link`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-0.5 rounded-full border border-violet/40 px-1.5 py-px font-mono text-[10.5px] font-semibold text-violet`,children:[`task`,(0,K.jsx)(A,{className:`size-[9px]`})]})]}):jn}),(0,K.jsx)(`td`,{className:w(Z,Q,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.runs7d}),i?(0,K.jsx)(`td`,{className:w(Z,Q,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.costUsd7d===void 0?jn:Fe(e.costUsd7d)}):null,(0,K.jsx)(`td`,{className:w(Z,`pr-3 text-right`),children:(0,K.jsx)(An,{automation:e,actions:t})})]})}function Pn(e,t,n){if(!e.enabled)return`—`;if(e.kind!==`schedule`)return`continuous`;if(e.nextRunAt)return Ve(e.nextRunAt,t)||`—`;let r=e.schedule?ne(e.schedule,n,t):null;return r===null?`—`:Ve(r,t)||`—`}function Fn(e){return e.hour*60+e.minute}function In(e,t,n=0){let r=C(e,t);if(!r)return null;let i=new Date(Date.UTC(r.year,r.month-1,r.day+n));return re(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),0,0,t)}function Ln(e,t,n,r){let i=[];for(let a of e)if(!(a.kind!==`schedule`||!a.schedule))for(let e of S(a.schedule,t,n,r)){let t=C(e,r);t&&i.push({automation:a,at:e,parts:t})}return i.sort((e,t)=>e.at-t.at)}function Rn(e){let t=new Map;return e.map(e=>{let n=Fn(e.parts),r=t.get(n)??0;return t.set(n,r+1),{occurrence:e,stack:r}})}function zn({automation:e,minute:t,stack:n=0,wide:r=!1}){let i=O(),a=x(Math.floor(t/60),t%60),o=[e.task.workflow,e.task.runner].filter(Boolean).join(` · `);return(0,K.jsxs)(`button`,{type:`button`,"data-slot":`event-block`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,title:`${e.name} · ${a}`,onClick:()=>i(`/automations/${encodeURIComponent(e.id)}`),className:w(`absolute right-[3px] left-[3px] flex cursor-pointer overflow-hidden rounded-[6px] border border-border bg-card text-left text-[11.5px] leading-[1.3] font-medium text-foreground shadow-xs`,r?`h-12 flex-col items-start gap-[3px] px-2 py-[5px]`:`h-6 flex-row items-center gap-1.5 px-1.5`,!e.enabled&&`opacity-50`),style:{top:t/60*34+1+26*n},children:[(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(R,{tone:e.task.runner===`codex`?`violet`:`success`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),r?(0,K.jsxs)(`span`,{className:`max-w-full overflow-hidden font-mono text-[10.5px] leading-[1.3] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:[a,o?` · ${o}`:``]}):null]})}function Bn(){return(0,K.jsx)(`div`,{"data-slot":`hour-gutter`,className:`w-12 shrink-0`,children:Array.from({length:24},(e,t)=>(0,K.jsx)(`div`,{className:`-translate-y-[6px] pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,style:{height:34},children:t?x(t):``},t))})}function Vn({minute:e}){return(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`now-line`,className:`absolute inset-x-0 z-[2] h-[2px] bg-primary`,style:{top:e/60*34},children:(0,K.jsx)(`span`,{className:`absolute -top-[3px] -left-[3px] size-[8px] rounded-full bg-primary`})})}function Hn(){return(0,K.jsx)(K.Fragment,{children:Array.from({length:24},(e,t)=>(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 h-px bg-border`,style:{top:t*34}},t))})}function Un({automations:e}){let t=e.filter(e=>e.kind===`github`&&e.enabled);return t.length?(0,K.jsxs)(`div`,{"data-slot":`poll-band`,className:`grid grid-cols-[48px_minmax(0,1fr)] border-b border-border`,children:[(0,K.jsx)(`div`,{className:`py-2 pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,children:`poll`}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1 border-l border-border px-2 py-1.5`,children:t.map(e=>(0,K.jsxs)(`div`,{"data-slot":`poll-row`,className:`flex h-[22px] min-w-0 items-center gap-2 overflow-hidden rounded-[6px] border border-violet/25 bg-violet/8 px-2 text-[11.5px] font-medium`,children:[(0,K.jsx)(bt,{className:`size-3 shrink-0 text-violet`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name}),(0,K.jsx)(`span`,{className:`overflow-hidden font-mono text-[10.5px] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:We(e)}),(0,K.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10.5px] font-normal whitespace-nowrap text-soft-foreground`,children:[e.runs7d,` runs`]})]},e.id))})]}):null}var Wn=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Gn({data:e}){let t=Se(6e4),n=O(),[r,i]=(0,G.useState)(0),a=e.timeZone,o=In(t,a,r),s=In(t,a,r+1),c=o===null?null:C(o,a),l=C(t,a);if(o===null||s===null||!c||!l)return(0,K.jsx)(`div`,{"data-slot":`day-view`,className:`p-5`,children:(0,K.jsxs)(`p`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:[`Cannot draw the day: unknown time zone “`,a,`”.`]})});let u=r===0,d=Rn(Ln(e.automations,o,s,a)),f=e.automations.filter(e=>e.kind===`github`&&e.enabled),p=`${Re(c.weekday)} ${c.day} ${Wn[c.month-1]??``}`;return(0,K.jsxs)(`div`,{"data-slot":`day-view`,className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 p-5 max-md:grid-cols-1`,children:[(0,K.jsxs)(P,{flush:!0,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3.5 py-2.5`,children:[(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous day`,onClick:()=>i(e=>e-1),children:(0,K.jsx)(Ge,{className:`size-3.5`})}),(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next day`,onClick:()=>i(e=>e+1),children:(0,K.jsx)(qe,{className:`size-3.5`})}),(0,K.jsx)(`span`,{"data-slot":`day-title`,className:`text-sm font-semibold whitespace-nowrap`,children:p}),u?(0,K.jsx)(I,{dot:`success`,children:`today`}):null,(0,K.jsxs)(`span`,{className:`ml-auto text-xs whitespace-nowrap text-muted-foreground`,children:[d.length,` scheduled runs`,f.length?` · ${f.length} GitHub poll${f.length===1?``:`s`}`:``]})]}),(0,K.jsx)(Un,{automations:e.automations}),(0,K.jsxs)(`div`,{className:`flex max-h-[600px] overflow-y-auto`,children:[(0,K.jsx)(Bn,{}),(0,K.jsxs)(`div`,{"data-slot":`day-column`,"data-today":u?`true`:void 0,className:`relative flex-1 border-l border-border`,style:{height:816},children:[(0,K.jsx)(Hn,{}),u?(0,K.jsx)(Vn,{minute:Fn(l)}):null,d.map(({occurrence:e,stack:t})=>(0,K.jsx)(zn,{automation:e.automation,minute:Fn(e.parts),stack:t,wide:!0},`${e.automation.id}-${e.at}`))]})]})]}),(0,K.jsxs)(P,{flush:!0,"data-slot":`agenda`,className:`py-3`,children:[(0,K.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`Agenda`}),f.map(e=>(0,K.jsxs)(`button`,{type:`button`,"data-slot":`agenda-poll`,onClick:()=>n(`/automations/${encodeURIComponent(e.id)}`),className:`grid w-full cursor-pointer grid-cols-[48px_1fr] gap-2.5 px-3.5 py-2 text-left hover:bg-muted`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[10.5px] font-medium text-soft-foreground`,children:`poll`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-[13px] font-medium`,children:[(0,K.jsx)(bt,{className:`size-3 shrink-0 text-violet`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),(0,K.jsxs)(`span`,{className:`mt-0.5 block overflow-hidden font-mono text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:[We(e),` · continuous`]})]})]},e.id)),d.map(({occurrence:e})=>{let r=e.at<t,{automation:i}=e;return(0,K.jsxs)(`button`,{type:`button`,"data-slot":`agenda-row`,"data-past":r?`true`:`false`,onClick:()=>n(`/automations/${encodeURIComponent(i.id)}`),className:`grid w-full cursor-pointer grid-cols-[48px_1fr] gap-2.5 px-3.5 py-2 text-left hover:bg-muted`,children:[(0,K.jsx)(`span`,{className:w(`font-mono text-xs font-medium tabular-nums`,r?`text-soft-foreground`:`text-foreground`),children:x(e.parts.hour,e.parts.minute)}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:w(`flex items-center gap-2 text-[13px] font-medium`,r&&`text-muted-foreground`),children:[(0,K.jsx)(R,{tone:r&&i.lastRun?Pe(i.lastRun.status):`neutral`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:i.name})]}),(0,K.jsx)(`span`,{className:`mt-0.5 block overflow-hidden text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:i.task.prompt})]})]},`${i.id}-${e.at}`)}),d.length===0?(0,K.jsx)(`p`,{className:`px-3.5 py-2 text-[12.5px] text-soft-foreground`,children:f.length?`Nothing scheduled — the GitHub polls above still run.`:`Nothing scheduled.`}):null]})]})}function Kn(e,t,n,r=12){let i=[];for(let a of e)if(!(!a.enabled||a.kind!==`schedule`||!a.schedule))for(let e of S(a.schedule,t,t+14*864e5,n,r))i.push({automation:a,at:e});return i.sort((e,t)=>e.at-t.at).slice(0,r)}function qn({open:e,onOpenChange:t,upcoming:n,pollCount:r,timeZone:i,now:a}){let o=O(),s=C(a,i);return(0,K.jsx)(ye,{open:e,onOpenChange:t,children:(0,K.jsxs)(ve,{side:`right`,"data-slot":`next-runs-rail`,"aria-describedby":void 0,className:`w-[360px] gap-0 sm:max-w-[360px]`,children:[(0,K.jsxs)(be,{className:`px-4 pt-4 pb-2`,children:[(0,K.jsxs)(xe,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Be,{className:`size-4`}),`Next runs`]}),(0,K.jsx)(_e,{className:`sr-only`,children:`Upcoming scheduled runs, soonest first.`})]}),(0,K.jsxs)(`div`,{className:`overflow-y-auto`,children:[n.map((e,n)=>{let r=C(e.at,i),c=r!==null&&s!==null&&r.year===s.year&&r.month===s.month&&r.day===s.day,l=r?`${c?``:`${Re(r.weekday)} `}${x(r.hour,r.minute)}`:``;return(0,K.jsxs)(`button`,{type:`button`,"data-slot":`next-run-row`,"data-automation":e.automation.id,onClick:()=>{t(!1),o(`/automations/${encodeURIComponent(e.automation.id)}`)},className:`grid w-full cursor-pointer grid-cols-[76px_1fr_auto] items-center gap-2 px-4 py-2 text-left text-[13px] hover:bg-muted`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs font-medium whitespace-nowrap text-muted-foreground tabular-nums`,children:l}),(0,K.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.automation.name}),(0,K.jsx)(`span`,{className:`text-[11px] whitespace-nowrap text-soft-foreground`,children:Ne(e.at,a)})]},`${e.automation.id}-${n}`)}),n.length===0?(0,K.jsx)(`p`,{className:`px-4 py-2 text-[12.5px] text-soft-foreground`,children:`No scheduled runs in the next two weeks.`}):null,(0,K.jsxs)(`div`,{"data-slot":`next-runs-footer`,className:`mt-1.5 flex items-center gap-2 border-t border-border px-3.5 pt-2.5 pb-1 text-xs text-muted-foreground`,children:[(0,K.jsx)(R,{tone:`pending`,pulse:!0}),r,` GitHub polls running continuously`]})]})]})})}function Jn({stats:e,pollCount:t,upcoming:n,timeZone:r,railOpen:i,onOpenRail:a}){let o=n[0];return(0,K.jsxs)(`div`,{"data-slot":`stats-strip`,className:`flex flex-wrap items-center gap-4 text-[12.5px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`This week`}),(0,K.jsx)(Yn,{label:`runs`,value:String(e.runs)}),null,(0,K.jsx)(Yn,{label:`failed`,value:String(e.failed),danger:e.failed>0}),(0,K.jsx)(Yn,{label:`agent time`,value:Ue(e.agentSeconds)}),(0,K.jsxs)(`span`,{"data-slot":`stats-polls`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,K.jsx)(R,{tone:`pending`,pulse:!0}),t,` GitHub polls continuous`]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsxs)(`span`,{"data-slot":`stats-next`,className:`inline-flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,K.jsx)(xt,{className:`size-[13px] text-soft-foreground`}),`next`,` `,(0,K.jsx)(`b`,{className:`font-mono text-[12.5px] font-medium text-foreground`,children:o?Le(o.at,r):`—`}),` `,(0,K.jsx)(`span`,{className:`max-w-[180px] overflow-hidden text-ellipsis`,children:o?.automation.name??``})]}),(0,K.jsxs)(E,{variant:`outline`,size:`sm`,"aria-expanded":i,className:`shrink-0`,onClick:a,children:[(0,K.jsx)(Be,{className:`size-3.5`}),`Next runs`,(0,K.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:n.length})]})]})}function Yn({label:e,value:t,danger:n=!1}){return(0,K.jsxs)(`span`,{"data-slot":`stat`,"data-label":e,className:`inline-flex shrink-0 items-baseline gap-[5px] whitespace-nowrap`,children:[(0,K.jsx)(`b`,{className:w(`font-mono text-sm font-semibold tabular-nums`,n?`text-danger`:`text-foreground`),children:t}),e]})}var Xn=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function Zn({data:e}){let t=Se(6e4),n=e.timeZone,r=C(t,n),i=r?Array.from({length:8},(e,i)=>In(t,n,i-(r.weekday-1))):[],a=i[0],o=i[7];if(!r||a==null||o==null)return(0,K.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,K.jsxs)(`p`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:[`Cannot draw the week: unknown time zone “`,n,`”.`]})});let s=r.weekday-1,c=Ln(e.automations,a,o,n),l=Xn.map((e,t)=>{let r=i[t];return{label:e,dayOfMonth:r==null?null:C(r,n)?.day??null,isToday:t===s,blocks:Rn(c.filter(e=>e.parts.weekday-1===t))}});return(0,K.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,K.jsxs)(P,{flush:!0,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-[48px_repeat(7,minmax(0,1fr))] border-b border-border`,children:[(0,K.jsx)(`div`,{}),l.map(e=>(0,K.jsxs)(`div`,{"data-slot":`week-day-header`,"data-today":e.isToday?`true`:void 0,className:w(`flex items-center gap-2 border-l border-border px-2 py-2.5 text-[11px] font-semibold tracking-[.05em] uppercase`,e.isToday?`text-foreground`:`text-soft-foreground`),children:[e.label,(0,K.jsx)(`span`,{className:w(`rounded-full px-[7px] py-px text-[13px] font-medium tracking-normal normal-case`,e.isToday?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e.dayOfMonth??``})]},e.label))]}),(0,K.jsx)(Un,{automations:e.automations}),(0,K.jsxs)(`div`,{className:`flex max-h-[560px] overflow-y-auto`,children:[(0,K.jsx)(Bn,{}),l.map(e=>(0,K.jsxs)(`div`,{"data-slot":`week-column`,"data-today":e.isToday?`true`:void 0,className:w(`relative min-w-0 flex-1 border-l border-border`,e.isToday&&`bg-muted/35`),style:{height:816},children:[(0,K.jsx)(Hn,{}),e.isToday?(0,K.jsx)(Vn,{minute:Fn(r)}):null,e.blocks.map(({occurrence:e,stack:t})=>(0,K.jsx)(zn,{automation:e.automation,minute:Fn(e.parts),stack:t},`${e.automation.id}-${e.at}`))]},e.label))]})]})})}function Qn(e){return[{value:`list`,label:`List`,...e===void 0?{}:{count:e}},{value:`week`,label:`Week`},{value:`day`,label:`Day`}]}function $n({data:e,error:t,actions:n,view:r,onViewChange:i}){let[a,o]=(0,G.useState)(!1),s=Date.now(),c=e?Kn(e.automations,s,e.timeZone,12):[],l=e?e.automations.filter(e=>e.kind===`github`&&e.enabled).length:0;return(0,K.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5`,children:[(0,K.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,K.jsx)(ge,{slot:`automations-view`,label:`View`,value:r,options:Qn(e?.automations.length),onChange:i}),(0,K.jsx)(`div`,{className:`flex-1`}),e?(0,K.jsxs)(`span`,{"data-slot":`automations-status`,className:`inline-flex min-w-0 items-center gap-2 overflow-hidden text-[12.5px] text-ellipsis whitespace-nowrap text-muted-foreground max-[1280px]:hidden`,children:[(0,K.jsx)(R,{tone:e.scheduler.state===`scheduled`?`success`:`neutral`}),e.scheduler.state===`scheduled`?`Scheduler running`:`Scheduler idle`,(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),e.available?`GitHub available`:`GitHub unavailable${e.reason?` · ${e.reason}`:``}`,(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.timeZone})]}):null,(0,K.jsx)(E,{asChild:!0,className:`shrink-0`,children:(0,K.jsxs)(k,{to:`/automations/new`,children:[(0,K.jsx)(at,{className:`size-[15px]`}),`New automation`]})})]}),t===void 0?e?e.automations.length===0?(0,K.jsx)(vt,{icon:(0,K.jsx)(M,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,K.jsx)(E,{asChild:!0,children:(0,K.jsxs)(k,{to:`/automations/new`,children:[(0,K.jsx)(at,{className:`size-[15px]`}),`New automation`]})})}):r===`week`?(0,K.jsx)(Zn,{data:e}):r===`day`?(0,K.jsx)(Gn,{data:e}):(0,K.jsxs)(`div`,{"data-slot":`automations-list`,className:`flex flex-col gap-3 p-5`,children:[(0,K.jsx)(Jn,{stats:e.stats,pollCount:l,upcoming:c,timeZone:e.timeZone,railOpen:a,onOpenRail:()=>o(!0)}),(0,K.jsx)(Mn,{data:e,actions:n,now:s}),(0,K.jsx)(qn,{open:a,onOpenChange:o,upcoming:c,pollCount:l,timeZone:e.timeZone,now:s})]}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)($,{text:`Loading automations…`})}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)($,{text:t})})]})}function er({mode:e=`list`}){let{automationId:t}=ce(),n=O(),r=de(),i=ue(r.known&&!r.off),a=me(i.data),[o,s]=ae(),c=tr(o.get(`view`));if(!r.known)return(0,K.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,K.jsx)($,{text:`Loading automations…`})});if(r.off)return(0,K.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,K.jsx)(vt,{icon:(0,K.jsx)(M,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This cockpit was started with CEZ_AUTOMATIONS=0. Unset it and restart the service to turn automations on.`,heading:`h2`})});let l=()=>n(`/automations`);if(e===`new`)return(0,K.jsx)(xn,{data:i.data,onBack:l,onSaved:l});if(e===`edit`){let e=i.data?.automations.find(e=>e.id===t);return i.data&&!e?(0,K.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,K.jsx)($,{text:`Automation not found.`})}):e?(0,K.jsx)(xn,{data:i.data,automation:e,actions:a,onBack:l,onSaved:l,onLog:()=>n(`/automations/${encodeURIComponent(e.id)}/log`)}):(0,K.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,K.jsx)($,{text:`Loading automation…`})})}if(e===`log`){let e=i.data?.automations.find(e=>e.id===t);return t?(0,K.jsx)(Tn,{automationId:t,automation:e,timeZone:i.data?.timeZone,onBack:l}):(0,K.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,K.jsx)($,{text:`Automation not found.`})})}return(0,K.jsx)($n,{data:i.data,error:i.error?String(i.error instanceof Error?i.error.message:i.error):void 0,actions:a,view:c,onViewChange:e=>s(t=>{let n=new URLSearchParams(t);return e===`list`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})})}function tr(e){return e===`week`||e===`day`?e:`list`}function $({text:e}){return(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e})}export{er as AutomationsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Er as r,Ii as i,Nt as a,Tr as o,Ut as s,Yn as c,Yr as l,Zr as u,_a as d,dr as f,ea as p,it as m,j as h,qt as ee,va as g,xa as te,ya as _}from"./queries-Bn7zl9OU.js";import{B as v,F as y,at as b,ct as x,dt as S,lt as ne,mt as re,ot as ie,pt as C,r as w,st as T,t as E,ut as D}from"./button-Clwd6u4_.js";import{T as ae,c as O,f as oe,s as se,t as k,w as ce}from"./project-router-CZzr7lzN.js";import{S as A}from"./reference-chip-CScP5y_O.js";import{O as le,a as ue,i as de,n as fe,o as pe,r as me,t as he,u as ge}from"./use-automations-Dh3Wj-79.js";import{a as _e,i as ve,n as ye,o as be,s as xe,t as Se}from"./use-now-BB7W0F--.js";import{An as j,Dn as Ce,P as we,_ as Te,vn as M,y as N}from"./git-tab-loading-BC6WP7W4.js";import{t as Ee}from"./arrow-left-BELOeFyX.js";import{I as De,c as Oe,d as ke,l as Ae}from"./worktree-lifecycle-operation-vTgExKUM.js";import{r as je,t as Me}from"./textarea-ewNKsXDa.js";import{a as Ne,c as Pe,d as Fe,f as P,i as Ie,l as Le,n as Re,o as ze,p as Be,r as Ve,s as He,t as Ue,u as We}from"./automation-format-BL4n19a2.js";import{t as Ge}from"./chevron-left-Df5IsPem.js";import{f as Ke}from"./tooltip-B628Gs7C.js";import{t as qe}from"./chevron-right-VbYrJ_st.js";import{c as Je,i as F,n as Ye,r as Xe,u as Ze}from"./icon-tooltip-YXzUubMO.js";import{t as Qe}from"./terminal-F3ZJ5fI8.js";import{m as $e}from"./git-toolbar-Dra1QlHb.js";import{t as et}from"./file-text-DmMQx3hx.js";import{n as tt,t as nt}from"./settings-2-COky68xN.js";import{r as rt}from"./use-submit-shortcut-hAaAH4HY.js";import{n as it}from"./square-8OFxLPoA.js";import{t as at}from"./plus-CBVm02wz.js";import{n as ot,o as I,r as st,t as ct}from"./collapsible-Bdyuw-he.js";import{a as lt,c as ut,i as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./alert-dialog-DvPnvVvK.js";import{t as L}from"./input-DIWTlsx6.js";import{i as R,r as _t}from"./token-metrics-Dk2ZNHb_.js";import{t as vt}from"./centered-state-nM7v9xtl.js";import{C as z,D as yt,E as bt,F as xt,O as B,P as St,S as V,T as H,d as Ct,o as wt,r as Tt,w as U,x as W}from"./index-qeFtKZ4e.js";var Et=y(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Dt=y(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Ot=y(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),kt=y(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),G=e(t(),1),K=n();function At({association:e,selected:t,onSelect:n,onRemove:r}){let i=d({queryKey:[`tracker`,v(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>u({association:e,state:`all`,limit:50,cursor:t},{signal:n}),getNextPageParam:e=>e.available&&e.truncated?e.nextCursor:void 0,retry:!1,staleTime:6e4}),a=i.data?.pages??[],o=a.at(-1),s=a.find(e=>!e.available),c=i.isError||!!s,l=[...new Set([...t,...c?[]:a.flatMap(e=>e.available?e.items.flatMap(e=>e.labels):[])])].filter(e=>t.includes(e)||e.length>0&&e.length<=200).sort((e,t)=>e.localeCompare(t));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,K.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,K.jsx)(N,{active:t.includes(e),"aria-pressed":t.includes(e),disabled:!t.includes(e)&&t.length>=100,onClick:()=>t.includes(e)?r(e):n(e),children:e},e))}),i.isFetching?(0,K.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,c?(0,K.jsxs)(`div`,{role:`alert`,children:[(0,K.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,K.jsx)(E,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,K.jsxs)(K.Fragment,{children:[!i.isPending&&!i.isFetching&&l.length===0?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,K.jsx)(E,{type:`button`,variant:`outline`,size:`sm`,disabled:i.isFetching,onClick:()=>void i.fetchNextPage(),children:`Load labels from more tasks`}):null,!i.hasNextPage&&o?.available&&o.truncated?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var jt=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`,`pull_request.closed`,`pull_request.merged`];function Mt(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function Nt(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function Pt(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function Ft(e){return e?.source===`skill`?{skill:e.ref,workflow:we,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var It=[2,5,10,15,30,60],Lt=[1,2,4,6,8],Rt={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},zt={type:`daily`,hour:4,minute:0};function Bt(){return{name:``,kind:`schedule`,schedule:{...zt},events:[`issue.opened`],intervalSeconds:300,filters:{...Rt},prompt:``,workflow:we,skill:null,customSteps:null,runner:null,account:null,model:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var q=e=>(e??[]).join(`, `);function Vt(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Ht(e){return{authors:q(e.authors),assignees:q(e.assignees),anyLabels:q(e.anyLabels),allLabels:q(e.allLabels),excludeLabels:q(e.excludeLabels),changedLabels:q(e.changedLabels),reviewers:q(e.reviewers),lookbackDays:e.lookbackDays,maxRecords:e.maxRecords}}function Ut(e){let t=Bt(),{task:n,filters:r}=e,i=Nt(n.steps);return{...t,name:e.name,kind:e.kind,trackerTrigger:e.trackerTrigger,schedule:e.schedule?{...e.schedule}:t.schedule,events:e.events?.length?[...e.events]:t.events,intervalSeconds:e.intervalSeconds??t.intervalSeconds,filters:r?Ht(r):t.filters,prompt:n.prompt,workflow:n.workflow??t.workflow,skill:i,customSteps:n.steps&&!i?n.steps:null,runner:n.runner??null,account:n.agentProfile??null,model:n.model??null,autonomous:n.autonomous??!1,dispatch:n.dispatch!==void 0,maxSubtasks:n.dispatch?.maxSubtasks??t.maxSubtasks,reviewChild:n.dispatch?.reviewChild??t.reviewChild,enabled:e.enabled,...n.checkout===void 0?{}:{checkout:n.checkout},...n.allowForkHeads===void 0?{}:{allowForkHeads:n.allowForkHeads}}}function Wt(e){return{name:e.name,kind:e.kind,...e.schedule?{schedule:e.schedule}:{},...e.events?{events:e.events}:{},...e.intervalSeconds===void 0?{}:{intervalSeconds:e.intervalSeconds},...e.filters?{filters:e.filters}:{},prompt:e.task.prompt,...e.task.workflow?{workflow:e.task.workflow}:{},...e.task.steps?{steps:e.task.steps}:{},...e.task.runner?{runner:e.task.runner}:{},...e.task.model===void 0?{}:{model:e.task.model},...e.task.autonomous===void 0?{}:{autonomous:e.task.autonomous},...e.task.dispatch?{dispatch:e.task.dispatch}:{},...e.task.checkout?{checkout:e.task.checkout}:{},...e.task.allowForkHeads===void 0?{}:{allowForkHeads:e.task.allowForkHeads}}}var Gt=e=>e===`claude`||e===`codex`||e===`junie`||e===`opencode`||e===`cursor`||e===`pi`||e===`copilot`;function Kt(e,t){let n=Nt(t.steps);return{...e,name:t.name,kind:t.kind,schedule:t.schedule?{...t.schedule}:e.schedule,events:t.events?.length?[...t.events]:e.events,intervalSeconds:t.intervalSeconds??e.intervalSeconds,filters:t.filters?Ht(t.filters):{...Rt},prompt:t.prompt,...t.steps?{skill:n,customSteps:n?null:t.steps,workflow:we}:Ft(t.workflow?{source:`workflow`,ref:t.workflow}:null),checkout:t.checkout,allowForkHeads:t.allowForkHeads,runner:t.runner!==void 0&&Gt(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&Gt(t.runner)?null:e.account,model:t.model??e.model,autonomous:t.autonomous??e.autonomous,dispatch:t.dispatch!==void 0,maxSubtasks:t.dispatch?.maxSubtasks??e.maxSubtasks,reviewChild:t.dispatch?.reviewChild??e.reviewChild}}function qt(e){let t=D(e);switch(t.type){case`hours`:return{type:`hours`,every:t.every};case`weekly`:return{type:`weekly`,hour:t.hour,minute:t.minute,day:t.day};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function Jt(e){let t={prompt:e.prompt,...e.skill?{steps:Mt(e.skill)}:e.customSteps?{steps:e.customSteps}:e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.account?{agentProfile:e.account}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.dispatch?{dispatch:{maxSubtasks:e.maxSubtasks,reviewChild:e.reviewChild}}:{}};if(e.kind===`schedule`)return{name:e.name.trim(),kind:`schedule`,schedule:qt(e.schedule),task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:J(e.filters.lookbackDays,1,90),maxRecords:J(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Vt(e);return n.length>0?{[t]:n}:{}};return{name:e.name.trim(),kind:`github`,events:[...e.events],intervalSeconds:e.intervalSeconds,filters:{...r(n.authors,`authors`),...r(n.assignees,`assignees`),...r(n.anyLabels,`anyLabels`),...r(n.allLabels,`allLabels`),...r(n.excludeLabels,`excludeLabels`),...r(n.changedLabels,`changedLabels`),...r(n.reviewers,`reviewers`),lookbackDays:J(n.lookbackDays,1,90),maxRecords:J(n.maxRecords,1,100)},task:{...t,...e.checkout===void 0?{}:{checkout:e.checkout},...e.allowForkHeads===void 0?{}:{allowForkHeads:e.allowForkHeads}}}}function J(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Yt(e){let t=Jt(e);return{name:t.name,kind:e.kind,...t.trackerTrigger?{trackerTrigger:t.trackerTrigger}:{},...t.schedule?{schedule:t.schedule}:{},...t.events?{events:t.events}:{},...t.intervalSeconds===void 0?{}:{intervalSeconds:t.intervalSeconds},...t.filters?{filters:t.filters}:{},task:t.task,...e.enabled?{enable:!0}:{}}}var Xt=`([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})`,Zt=RegExp(`\\b(?:user|author|by)\\s+(?:\`@?${Xt}\`|@${Xt}(?![\\w/-]))`,`gi`);function Qt(e){if(e.kind!==`github`)return[];let t=new Set([e.filters.authors,e.filters.assignees,e.filters.reviewers].flatMap(Vt).map(e=>e.replace(/^@/,``).toLowerCase())),n=new Map;for(let r of e.prompt.matchAll(Zt)){let e=r[1]??r[2];e&&!t.has(e.toLowerCase())&&!n.has(e.toLowerCase())&&n.set(e.toLowerCase(),e)}return[...n.values()]}function $t(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var en=e=>[1,2,3,4,6,8,12].includes(e);function tn({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,a]=(0,G.useState)(``),o=v(),s=d({queryKey:[`tracker`,o,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>l({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),c=d({queryKey:[`tracker`,o,`automation-options`,i],enabled:!!i&&s.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>l({...i?{search:i}:{},...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),u=i?c:s,f=s.data?.pages[0],p=f?.available?f:void 0,m=!!p&&!!e&&JSON.stringify(p.association)===JSON.stringify(e.association),h=m&&!!e?.events.length&&e.events.every(e=>p?.events.includes(e))&&(e.requiredLabels?.length??0)<=100&&(e.requiredLabels??[]).every(e=>e.length>0&&e.length<=200)&&(!e.events.includes(`issue.status_changed`)||!!e.targetStatusIds?.length)&&(!(e.events.includes(`issue.labeled`)||e.events.includes(`issue.unlabeled`))||!!e.changedLabelIds?.length);(0,G.useEffect)(()=>(r(h),()=>r(!1)),[h,r]);let ee=u.data?.pages.flatMap(e=>e.available?[e]:[])??[],g=[...new Map(ee.flatMap(e=>e.statuses).map(e=>[e.id,e])).values()],te=new Map((s.data?.pages.flatMap(e=>e.available?e.statuses:[])??[]).map(e=>[e.id,e.name])),_=(e?.targetStatusIds??[]).filter(e=>!g.some(t=>t.id===e)),y=[...new Map(ee.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],b=e?.events.includes(`issue.status_changed`),x=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),S=b&&x?`Search tracker statuses and labels`:x?`Search tracker labels`:`Search tracker statuses`;return(0,K.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[s.isPending?(0,K.jsx)(`p`,{children:`Loading tracker events…`}):null,s.isError||f&&!f.available?(0,K.jsxs)(`div`,{role:`alert`,children:[(0,K.jsxs)(`p`,{children:[f&&!f.available?f.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,K.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void s.refetch(),children:`Retry`})]}):null,p?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{children:[p.association.kind===`jira`?`Jira`:`Linear`,` · `,p.association.externalName]}),e&&!m?(0,K.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,K.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,K.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:p.events.map(t=>(0,K.jsx)(N,{active:m&&e?.events.includes(t),"aria-pressed":m&&e?.events.includes(t),onClick:()=>{let r=m?e.events:[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a={...m?e:{},association:p.association,events:i};t===`issue.status_changed`&&!i.includes(t)&&delete a.targetStatusIds,n({trackerTrigger:a,...m?{}:{enabled:!1}})},children:t},t))}),m&&e?(0,K.jsx)(At,{association:p.association,selected:e.requiredLabels??[],onRemove:t=>n({trackerTrigger:{...e,requiredLabels:(e.requiredLabels??[]).filter(e=>e!==t)}}),onSelect:t=>n({trackerTrigger:{...e,requiredLabels:[...new Set([...e.requiredLabels??[],t])]}})},JSON.stringify(p.association)):null,(0,K.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,K.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,K.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),p.limitations.map(e=>(0,K.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(L,{"aria-label":S,placeholder:S,value:i,onChange:e=>a(e.target.value)}),u.isFetching?(0,K.jsx)(`p`,{role:`status`,children:`Searching…`}):null,u.isError||u.data?.pages[0]&&!u.data.pages[0].available?(0,K.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,K.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void u.refetch(),children:`Retry search`})]}):null,!u.isFetching&&u.data?.pages[0]?.available&&b&&g.length===0?(0,K.jsx)(`p`,{children:`No matching statuses.`}):null,!u.isFetching&&u.data?.pages[0]?.available&&x&&y.length===0?(0,K.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,K.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[g.map(t=>(0,K.jsx)(N,{active:e.targetStatusIds?.includes(t.id),"aria-pressed":e.targetStatusIds?.includes(t.id),onClick:()=>{let r=e.targetStatusIds??[];n({trackerTrigger:{...e,targetStatusIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id)),_.map(t=>(0,K.jsxs)(N,{active:!0,"aria-pressed":!0,onClick:()=>{n({trackerTrigger:{...e,targetStatusIds:(e.targetStatusIds??[]).filter(e=>e!==t)}})},children:[te.get(t)??t,` (not in current results)`]},t))]}):null,e.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)?(0,K.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:y.map(t=>(0,K.jsx)(N,{active:e.changedLabelIds?.includes(t.id),"aria-pressed":e.changedLabelIds?.includes(t.id),onClick:()=>{let r=e.changedLabelIds??[];n({trackerTrigger:{...e,changedLabelIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id))}):null,u.hasNextPage?(0,K.jsx)(E,{variant:`outline`,size:`sm`,disabled:u.isFetchingNextPage,onClick:()=>void u.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,K.jsxs)(W,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,K.jsx)(U,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:It.map(e=>(0,K.jsxs)(z,{value:String(e),children:[e,` min`]},e))})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Only events after enabling are eligible. Existing backlog is not launched. The workflow agent receives this project’s tracker credentials to carry out your instructions; status updates are not guaranteed by the scheduler.`})]})}function nn({definition:e}){let t=(0,G.useMemo)(()=>pe(e),[e]);return(0,K.jsxs)(P,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Copy as CLI`}),(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void fe(t),children:[(0,K.jsx)(j,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,K.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-[11.5px] leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:t}),(0,K.jsxs)(`p`,{className:`mt-2 mb-0 text-[11.5px] leading-[1.5] text-soft-foreground`,children:[`The same definition the cockpit saves — `,(0,K.jsx)(`code`,{className:`text-[11px]`,children:`cez automation schema`}),` prints its shape.`]})]})}function rn({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=Lt.includes(n)?Lt:[...Lt,n].sort((e,t)=>e-t);return(0,K.jsxs)(`div`,{"data-slot":`editor-dispatch`,"data-enabled":t?`true`:void 0,title:`Let this run start its own subtasks with cez task create — each in a worktree forked off its branch, reporting back into the parent session.`,className:`flex flex-wrap items-center gap-2.5 border-t border-border pt-3 text-[13px] text-muted-foreground`,children:[(0,K.jsxs)(B,{className:`text-[13px] font-medium text-foreground`,children:[(0,K.jsx)(tt,{"aria-hidden":`true`,className:w(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,K.jsx)(yt,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i({dispatch:e})})]}),t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,K.jsxs)(W,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-[12.5px]`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:a.map(e=>(0,K.jsx)(z,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsxs)(B,{className:`text-[13px] font-normal text-muted-foreground`,children:[(0,K.jsx)(yt,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,K.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-[11.5px] whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null]})}function an({events:e,intervalSeconds:t,filters:n,onChange:r}){let[i,a]=(0,G.useState)([`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].some(e=>n[e].trim().length>0)||n.lookbackDays!==7||n.maxRecords!==25),o=(e,t)=>r({filters:{...n,[e]:t}}),s=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:jt.filter(e=>n.includes(e))})},c=$t(e),l=c&&n.changedLabels.trim().length===0;return(0,K.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-3.5`,children:[(0,K.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:jt.map(t=>(0,K.jsx)(N,{active:e.includes(t),"aria-pressed":e.includes(t),className:`font-mono`,onClick:()=>s(t),children:t},t))}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground`,children:[`poll every`,(0,K.jsxs)(W,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Poll interval`,className:`text-[13px]`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:It.map(e=>(0,K.jsxs)(z,{value:String(e),children:[e,` min`]},e))})]}),(0,K.jsxs)(`span`,{children:[`· last `,n.lookbackDays,` days · maximum `,n.maxRecords,` records`]})]}),(0,K.jsxs)(ct,{open:i,onOpenChange:a,children:[(0,K.jsx)(st,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,K.jsx)(Ke,{"aria-hidden":`true`,className:w(`size-3 transition-transform`,i?``:`-rotate-90`)}),`Filters`,l?(0,K.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):null]})}),(0,K.jsx)(ot,{children:(0,K.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-2 sm:grid-cols-2`,children:[(0,K.jsx)(Y,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>o(`authors`,e)}),(0,K.jsx)(Y,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>o(`assignees`,e)}),(0,K.jsx)(Y,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>o(`anyLabels`,e)}),(0,K.jsx)(Y,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>o(`allLabels`,e)}),(0,K.jsx)(Y,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>o(`excludeLabels`,e)}),(0,K.jsx)(Y,{id:`filter-changed-labels`,label:c?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:l,onChange:e=>o(`changedLabels`,e)}),(0,K.jsx)(Y,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>o(`reviewers`,e)}),(0,K.jsx)(on,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>o(`lookbackDays`,e)}),(0,K.jsx)(on,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>o(`maxRecords`,e)})]})})]})]})}function Y({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(B,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,K.jsx)(L,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-[13px]`})]})}function on({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(B,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,K.jsx)(L,{id:e,type:`number`,min:r,max:i,value:n,onChange:e=>a(J(Number(e.target.value),r,i)),className:`h-8 w-28 font-mono text-[13px] tabular-nums`})]})}function sn({source:e,sourcesReady:t,skills:n,skillUsage:r,workflows:i,onSource:a,pick:o,onPick:s,baseBranch:c,autonomous:l,onAutonomous:u}){return(0,K.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(wt,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,K.jsx)(Ct,{pick:o,onChange:s,accounts:!0}),(0,K.jsx)(Te,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,K.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsxs)(B,{className:`text-[13px] font-medium`,children:[`Autonomous`,(0,K.jsx)(yt,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function cn({className:e,...t}){return(0,K.jsx)(`span`,{"data-slot":`branch-chip`,className:w(`inline-block rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11.5px] leading-[1.3] font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var ln=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`]],un=e=>String(e).padStart(2,`0`);function dn({schedule:e,timeZone:t,onChange:n}){let r=D(e),i=e=>n({...r,...e});return(0,K.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,K.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:ln.map(([e,t])=>(0,K.jsx)(N,{active:r.type===e,"aria-pressed":r.type===e,onClick:()=>i({type:e}),children:t},e))}),r.type===`weekly`?(0,K.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:ie.map((e,t)=>(0,K.jsx)(N,{active:r.day===t+1,"aria-pressed":r.day===t+1,className:`px-[9px]`,onClick:()=>i({day:t+1}),children:e},e))}):null,r.type===`hours`?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`every`,(0,K.jsxs)(W,{value:String(r.every),onValueChange:e=>{let t=Number(e);en(t)&&i({every:t})},children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Every N hours`,className:`text-[13px]`,children:(0,K.jsx)(H,{})}),(0,K.jsx)(V,{children:b.map(e=>(0,K.jsxs)(z,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`at`,(0,K.jsx)(L,{"aria-label":`Hour`,inputMode:`numeric`,value:un(r.hour),onChange:e=>i({hour:Math.min(23,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),`:`,(0,K.jsx)(L,{"aria-label":`Minute`,inputMode:`numeric`,value:un(r.minute),onChange:e=>i({minute:Math.min(59,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 font-mono text-xs text-soft-foreground`,children:[(0,K.jsx)(`span`,{children:`cron`}),(0,K.jsx)(cn,{"data-slot":`editor-cron`,children:T(r)})]})]})}function fn({lastRun:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){return(0,K.jsxs)(P,{flush:!0,"data-slot":`last-run-card`,className:`px-3.5 py-3`,children:[(0,K.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Last run`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,K.jsx)(R,{tone:Pe(e.status)}),He(e.status),(0,K.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:_t(e.ts,i)}),null]}),(0,K.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,K.jsxs)(E,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,K.jsx)(it,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}),n?(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,K.jsx)(kt,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}var pn=864e5;function mn({kind:e,schedule:t,intervalSeconds:n,timeZone:r,now:i}){let[a,o]=(0,G.useState)(()=>Date.now());(0,G.useEffect)(()=>{if(i!==void 0)return;let e=setInterval(()=>o(Date.now()),6e4);return()=>clearInterval(e)},[i]);let s=i??a,c=(0,G.useMemo)(()=>e===`schedule`?S(t,s,s+9*pn,r,5):[],[e,t,s,r]);return(0,K.jsxs)(P,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,K.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:e===`schedule`?`Next 5 runs`:`How it polls`}),e===`schedule`?c.length===0?(0,K.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:`Nothing in the next nine days.`}):c.map(e=>(0,K.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-[13px]`,children:[(0,K.jsx)(`span`,{className:`w-[82px] shrink-0 font-mono text-xs font-medium whitespace-nowrap text-foreground tabular-nums`,children:Ve(e,r)}),(0,K.jsx)(`span`,{className:`text-[11.5px] whitespace-nowrap text-soft-foreground`,children:Ne(e,s)})]},e)):(0,K.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,K.jsxs)(K.Fragment,{children:[`Checks the project tracker every `,Math.round(n/60),` min while this cockpit is open. No webhook or public URL required.`]}):(0,K.jsxs)(K.Fragment,{children:[`Checks GitHub every `,Math.round(n/60),` min while this cockpit is open, through your `,(0,K.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var hn=[{name:`Nightly dependency bump`,when:`Every day at 04:00`,kind:`schedule`,schedule:{type:`daily`,hour:4,minute:0},prompt:`Run npm outdated, bump patch and minor versions, run the test suite, open a draft PR if anything changed.`},{name:`Triage new issues`,when:`On issue.opened · every 5 min`,kind:`github`,events:[`issue.opened`],intervalSeconds:300,prompt:`Read {{github.url}}. Label it, add a repro or a clarification request. Never close it.`},{name:`Weekly changelog draft`,when:`Fridays at 16:00`,kind:`schedule`,schedule:{type:`weekly`,day:5,hour:16,minute:0},prompt:`Collect merged PRs since last week, write CHANGELOG entries, open a draft PR.`},{name:`Stale PR nudge`,when:`Every 6 hours`,kind:`schedule`,schedule:{type:`hours`,every:6},prompt:`Comment on PRs idle for 48h with what is blocking them.`},{name:`Flaky test hunt`,when:`Tuesdays at 02:00`,kind:`schedule`,schedule:{type:`weekly`,day:2,hour:2,minute:0},prompt:`Run the suite 5×, quarantine intermittent tests, open an issue per test.`,dispatch:{maxSubtasks:8,reviewChild:!0}},{name:`Security advisories`,when:`Every day at 06:00`,kind:`schedule`,schedule:{type:`daily`,hour:6,minute:0},prompt:`Run npm audit; for each high/critical advisory open a task with the upgrade path.`}],gn=e=>[v(),`automation-templates`,e??``];function _n({onPick:e}){let[t,n]=(0,G.useState)(`builtin`),i=se(),a=_({queryKey:gn(i),queryFn:({signal:e})=>r(i,{signal:e}),enabled:t===`mine`}),o=t===`builtin`?hn.map(e=>({...e,key:e.name})):(a.data?.templates??[]).map(e=>({...Wt(e),key:`${e.project.id}:${e.id}`,when:We(e),project:e.project.name}));return(0,K.jsxs)(P,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,K.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,K.jsx)(vn,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,K.jsx)(vn,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,K.jsx)(`span`,{className:`ml-auto min-w-0 overflow-hidden pb-2 text-xs text-ellipsis whitespace-nowrap text-soft-foreground`,children:t===`builtin`?`Built-in`:`Registered in ~/.cezar/config.json`})]}),t===`mine`&&a.isPending?(0,K.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`Loading…`}):t===`mine`&&a.isError?(0,K.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-xs text-danger`,children:a.error.message}):o.length===0?(0,K.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`No automations in your other projects yet.`}):(0,K.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:o.map(t=>(0,K.jsxs)(`div`,{"data-slot":`template-card`,className:`flex flex-col gap-1.5 rounded-[10px] border border-border bg-card-2 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-semibold`,children:[t.kind===`github`?(0,K.jsx)(bt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,K.jsx)(xt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,K.jsx)(cn,{className:`ml-auto`,children:t.project}):null]}),(0,K.jsx)(`div`,{className:`font-mono text-[11.5px] text-muted-foreground`,children:t.when}),(0,K.jsx)(`div`,{className:`line-clamp-2 text-xs leading-[1.45] text-soft-foreground`,children:t.prompt}),(0,K.jsx)(E,{variant:`outline`,size:`sm`,className:`mt-0.5 self-start`,"aria-label":`Use this: ${t.name}`,onClick:()=>e(t),children:`Use this`})]},t.key))})]})}function vn({active:e,onClick:t,children:n}){return(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:w(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-[13px] font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function yn(e){let t=e.toLowerCase();return/\b(events?|filters?|schedule|interval|changedlabels|changed labels|lookback|maxrecords)\b/.test(t)?`when`:/\b(prompt|workflow|runner|model|dispatch)\b/.test(t)?`what`:`top`}var bn={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`Describe the task the agent should do each time. Placeholders: {{date}}, {{project}}`,github:`Describe the task the agent should do for each match. Placeholders: {{github.url}}, {{github.title}}, {{github.number}}, {{github.labels}}`};function xn({data:e,automation:t,actions:n,onBack:r,onSaved:i,onLog:o}){let l=te(),u=O(),d=h(),g=s(),_=ee(),v=a(),y=m(),[b,x]=(0,G.useState)(()=>t?Ut(t):Bt()),[S,ne]=(0,G.useState)(!t),[re,ie]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,D]=(0,G.useState)(null),[ae,oe]=(0,G.useState)(!1),se=(0,G.useRef)(null),k=t?.revision,ce=(0,G.useRef)(k);(0,G.useEffect)(()=>{!t||k===ce.current||(ce.current=k,x(Ut(t)),oe(!1),D(null))},[t,k]);let A=e=>x(t=>({...t,...e})),le=e?.timeZone??`UTC`,ue=e?.available!==!1,de=d.data?.capabilities.dispatch===!0,fe=(0,G.useMemo)(()=>Oe(ke(g.data?.promptTemplates),d.data?.capabilities),[g.data?.promptTemplates,d.data?.capabilities]),pe=_.data?.workflows??[],me=pe.map(e=>e.name),ge=v.data,_e=(ge??[]).map(e=>e.name),ve=g.data?.skillUsage,ye=(0,G.useMemo)(()=>De(ge??[],ve),[ge,ve]),be=v.data!==void 0&&_.data!==void 0&&!g.isPending,xe=y.data?.baseBranch??y.data?.info?.branch??void 0,Se=(0,G.useMemo)(()=>Yt(b),[b]),j=(0,G.useMemo)(()=>Qt(b),[b]),Ce=b.name.trim().length>0&&b.prompt.trim().length>0&&!C&&(b.kind!==`tracker`||re),we=e=>{let t=se.current,n=t?.selectionStart??b.prompt.length,r=Ae(b.prompt,n,e);A({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},Te=async()=>{w(!0),D(null),oe(!1);try{let e=Jt(b);t?await p(t.id,{...e,enabled:b.enabled,expectedRevision:t.revision}):await f({...e,enable:b.enabled}),await l.invalidateQueries({queryKey:he()}),i()}catch(e){if(t&&e instanceof c&&e.status===409)oe(!0);else{let t=e instanceof Error?e.message:String(e);D({message:t,section:e instanceof c&&e.status===400?yn(t):`top`})}}finally{w(!1)}},M=()=>void l.invalidateQueries({queryKey:he()}),je=t?`Save changes`:b.enabled?`Save and enable`:`Save paused`;return(0,K.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,className:`flex min-h-full flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex min-h-14 shrink-0 flex-wrap items-center gap-3 border-b border-border bg-background px-5 max-md:py-2 md:h-14 md:flex-nowrap`,children:[(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,K.jsx)(Ee,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,K.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,K.jsx)(I,{dot:t.enabled?`success`:`neutral`,children:t.enabled?`enabled`:`paused`}):null,(0,K.jsx)(`span`,{className:`flex-1`}),t?null:(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,"aria-expanded":S,"aria-label":S?`Hide templates`:`Start from a template`,onClick:()=>ne(e=>!e),children:[(0,K.jsx)(Et,{"aria-hidden":`true`,className:`size-3.5`}),(0,K.jsx)(`span`,{className:`max-md:hidden`,children:S?`Hide templates`:`Start from a template`})]}),(0,K.jsx)(E,{variant:`outline`,onClick:r,children:`Cancel`}),(0,K.jsx)(E,{disabled:!Ce,onClick:()=>void Te(),children:je})]}),(0,K.jsx)(`div`,{className:`flex justify-center p-5`,children:(0,K.jsxs)(`div`,{className:`grid w-full max-w-[1080px] grid-cols-1 items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[ae?(0,K.jsxs)(`div`,{role:`alert`,"data-slot":`editor-conflict`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-[13px] text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,K.jsx)(E,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:M,children:`Reload`})]}):null,T?.section===`top`?(0,K.jsx)(Cn,{children:T.message}):null,S&&!t?(0,K.jsx)(_n,{onPick:e=>{let t=e.workflow&&me.includes(e.workflow)?e.workflow:void 0,n=e.steps?.every(e=>!e.skill||_e.includes(e.skill))?e.steps:void 0;x(r=>Kt(r,{...e,workflow:t,steps:n})),ne(!1)}}):null,(0,K.jsx)(Sn,{title:`Name`,children:(0,K.jsx)(L,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:b.name,onChange:e=>A({name:e.target.value}),className:`max-w-[420px] text-[15px] md:text-[15px]`})}),(0,K.jsxs)(Sn,{title:`When`,children:[(0,K.jsx)(wn,{value:b.kind,editing:!!t,githubAvailable:ue,githubReason:e?.reason,onChange:e=>A({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})}),b.kind===`schedule`?(0,K.jsx)(dn,{schedule:b.schedule,timeZone:le,onChange:e=>A({schedule:e})}):b.kind===`tracker`?(0,K.jsx)(tn,{trigger:b.trackerTrigger,intervalSeconds:b.intervalSeconds,onChange:A,onValid:ie}):(0,K.jsx)(an,{events:b.events,intervalSeconds:b.intervalSeconds,filters:b.filters,onChange:e=>A(e)}),T?.section===`when`?(0,K.jsx)(Cn,{children:T.message}):null]}),(0,K.jsxs)(Sn,{title:`What to run`,children:[(0,K.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,K.jsx)(et,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,fe.map(e=>(0,K.jsx)(N,{className:`h-6 text-[11.5px]`,title:e.text,onClick:()=>we(e.text),children:e.label},e.id)),(0,K.jsx)(N,{dashed:!0,className:`h-6 text-[11.5px]`,icon:(0,K.jsx)(nt,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>u(`${Tt(`project`,`instructions`)}#prompt-templates`),children:`Manage…`})]}),(0,K.jsx)(Me,{ref:se,"aria-label":`Prompt`,rows:5,placeholder:bn[b.kind],value:b.prompt,onChange:e=>A({prompt:e.target.value}),className:`min-h-[104px] text-sm leading-[1.55] md:text-sm`}),j.length>0?(0,K.jsxs)(`div`,{role:`status`,"data-slot":`editor-prompt-condition`,className:`flex flex-wrap items-center gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[12.5px] text-foreground`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`The prompt names `,j.map(e=>`@${e}`).join(`, `),`, but prompt text does not decide what launches — without a filter every matching event starts a task.`]}),(0,K.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>A({filters:{...b.filters,authors:[...Vt(b.filters.authors),...j].join(`, `)}}),children:`Add to Authors`})]}):null,(0,K.jsx)(sn,{source:Pt(b),sourcesReady:be,skills:ye,skillUsage:ve,workflows:pe,onSource:e=>A(Ft(e)),pick:{runner:b.runner,model:b.model,account:b.account},onPick:e=>A({runner:e.runner,model:e.model,account:e.account}),baseBranch:xe,autonomous:b.autonomous,onAutonomous:e=>A({autonomous:e})}),(0,K.jsx)(`p`,{className:`m-0 text-xs leading-[1.5] text-soft-foreground`,children:`Each run is an ordinary cezar task in its own worktree — it queues behind the parallel cap like anything else and never auto-merges.`}),(0,K.jsx)(rn,{available:de,enabled:b.dispatch,maxSubtasks:b.maxSubtasks,reviewChild:b.reviewChild,onChange:e=>A(e)}),T?.section===`what`?(0,K.jsx)(Cn,{children:T.message}):null]}),(0,K.jsx)(Sn,{title:`Enable`,children:(0,K.jsxs)(B,{className:`text-[13px] font-medium`,children:[(0,K.jsx)(yt,{"aria-label":`Enabled`,checked:b.enabled,onCheckedChange:e=>A({enabled:e})}),`Enabled`,b.kind===`schedule`?null:(0,K.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`— from a current-time baseline; existing matches will not launch`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 lg:sticky lg:top-[76px]`,children:[(0,K.jsx)(mn,{kind:b.kind,schedule:b.schedule,intervalSeconds:b.intervalSeconds,timeZone:le}),(0,K.jsx)(nn,{definition:Se}),t&&t.kind!==`schedule`&&n?(0,K.jsx)(E,{variant:`outline`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t?.lastRun?(0,K.jsx)(fn,{lastRun:t.lastRun,busy:n?.busy,onRunNow:()=>void n?.runNow(t),onLog:o}):null]})]})})]})}function Sn({title:e,children:t}){return(0,K.jsxs)(P,{"data-slot":`editor-section`,className:`gap-0 px-6 py-0`,children:[(0,K.jsx)(`div`,{className:`pt-4 pb-1 text-sm font-semibold`,children:e}),(0,K.jsx)(`div`,{className:`flex flex-col gap-3.5 pt-2.5 pb-5`,children:t})]})}function Cn({children:e}){return(0,K.jsx)(`p`,{role:`alert`,className:`m-0 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-[12.5px] text-danger`,children:e})}function wn({value:e,editing:t,githubAvailable:n,githubReason:r,onChange:i}){let a=`Change the kind by creating a new automation`;return(0,K.jsx)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`inline-flex flex-wrap gap-0.5 self-start rounded-md bg-muted p-[3px]`,children:[{value:`schedule`,label:`On a schedule`,disabled:t&&e!==`schedule`,...t&&e!==`schedule`?{title:a}:{}},{value:`github`,label:`When GitHub changes`,disabled:!n||t&&e!==`github`,...n?t&&e!==`github`?{title:a}:{}:{title:r??`GitHub is unavailable`}},{value:`tracker`,label:`When Jira / Linear changes`,disabled:t&&e!==`tracker`,...t&&e!==`tracker`?{title:a}:{}}].map(t=>(0,K.jsx)(`button`,{type:`button`,"data-value":t.value,"aria-pressed":t.value===e,disabled:t.disabled,title:t.title,onClick:()=>{t.value!==e&&i(t.value)},className:w(`flex h-7 items-center justify-center gap-1.5 rounded-[7px] px-3 text-[12.5px] font-medium whitespace-nowrap text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,t.value===e&&`bg-card font-semibold text-foreground shadow-xs`),children:t.label},t.value))})}function Tn({automationId:e,automation:t,timeZone:n,onBack:r}){let a=O(),s=te(),c=v(),l=(0,G.useMemo)(()=>[c,`automation-log`,e],[c,e]),u=_({queryKey:l,queryFn:({signal:t})=>o(e,{signal:t})}),[d,f]=(0,G.useState)(`all`),[p,m]=(0,G.useState)(`all`);(0,G.useEffect)(()=>le((t,n)=>{t===`automation-change`&&n.automationId===e&&s.invalidateQueries({queryKey:l})}),[e,s,l]);let h=g({mutationFn:e=>i(e),onSuccess:()=>s.invalidateQueries({queryKey:l}),onError:e=>oe(e instanceof Error?e.message:String(e),{tone:`danger`})}),ee=n??`UTC`,y=u.data?.records.filter(e=>(d===`all`||e.result===d)&&(p===`all`||e.event===p));return(0,K.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-log`,className:`flex min-h-full flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5`,children:[(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,K.jsx)(Ee,{className:`size-[15px]`})}),(0,K.jsx)(`h1`,{className:`m-0 text-base font-semibold`,children:t?t.name:`Automation`}),(0,K.jsx)(`span`,{className:`text-[13px] text-muted-foreground`,children:`· execution log`}),(0,K.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2`,children:[(0,K.jsxs)(W,{value:d,onValueChange:e=>f(e),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Filter by result`,className:`text-[12.5px]`,children:(0,K.jsx)(H,{placeholder:`All results`})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(z,{value:`all`,children:`All results`}),En.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]}),(0,K.jsxs)(W,{value:p,onValueChange:e=>m(e),children:[(0,K.jsx)(U,{size:`sm`,"aria-label":`Filter by event`,className:`text-[12.5px]`,children:(0,K.jsx)(H,{placeholder:`All events`})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(z,{value:`all`,children:`All events`}),Dn.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]})]}),(0,K.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>a(`/automations/${encodeURIComponent(e)}`),children:[(0,K.jsx)(rt,{className:`size-[13px]`}),`Edit`]})]}),(0,K.jsx)(`div`,{className:`flex justify-center p-5`,children:u.isError?(0,K.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,K.jsx)($,{text:u.error instanceof Error?u.error.message:String(u.error)})}):y===void 0?(0,K.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,K.jsx)($,{text:`Loading execution log…`})}):y.length===0?(0,K.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,K.jsx)($,{text:`No checks have run yet.`})}):(0,K.jsx)(P,{flush:!0,className:`w-full max-w-[820px]`,children:y.map((e,t)=>(0,K.jsx)(kn,{record:e,run:e.runId===void 0?void 0:u.data?.runs[e.runId],last:t===y.length-1,timeZone:ee,retrying:h.isPending&&h.variables===e.receiptId,onRetry:e=>h.mutate(e)},e.seq))})})]})}var En=[`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`manual`,`catch-up`,`skipped`,`failed`],Dn=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`,`pull_request.closed`,`pull_request.merged`];function On(e){return e.result===`failed`&&e.runId===void 0?e.receiptId:void 0}function kn({record:e,run:t,last:n,timeZone:r,retrying:i,onRetry:a}){let o=ze(e.result),s=t?.children??[],c=On(e);return(0,K.jsxs)(`div`,{"data-slot":`log-row`,"data-result":e.result,className:`grid grid-cols-[90px_110px_1fr_auto] items-center gap-x-3 gap-y-2 px-4 py-3 text-[13px] ${n?``:`border-b border-border`}`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:Ie(e.ts,r)}),(0,K.jsx)(I,{dot:o,className:`w-fit`,children:e.result}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap ${o===`danger`?`text-danger`:`text-muted-foreground`}`,title:e.reason,children:e.reason??``}),null,e.runId===void 0?c===void 0?(0,K.jsx)(`span`,{}):(0,K.jsxs)(E,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a(c),children:[(0,K.jsx)(St,{className:`size-3`}),`Retry task`]}):(0,K.jsx)(E,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,K.jsxs)(k,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open task`,(0,K.jsx)(A,{className:`size-3`})]})}),s.length>0?(0,K.jsx)(`div`,{className:`col-span-full flex flex-col gap-1 pl-3.5`,children:s.map(e=>(0,K.jsxs)(`div`,{"data-slot":`log-child`,className:`grid grid-cols-[14px_70px_1fr_auto] items-center gap-2.5 text-[12.5px]`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`└`}),(0,K.jsx)(`span`,{className:`w-fit rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:e.kind??`implement`}),(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(R,{tone:Pe(e.status)}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.title})]}),null,(0,K.jsx)(E,{variant:`ghost`,size:`sm`,className:`h-6`,asChild:!0,children:(0,K.jsxs)(k,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open`,(0,K.jsx)(A,{className:`size-[11px]`})]})})]},e.runId))}):null]})}function An({automation:e,actions:t}){let n=O(),[r,i]=(0,G.useState)(!1),a=e=>e.stopPropagation(),o=`/automations/${encodeURIComponent(e.id)}`;return(0,K.jsxs)(`span`,{"data-slot":`row-actions`,className:`inline-flex gap-0.5`,onClick:a,children:[e.kind===`schedule`?null:(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,title:`Preview matches`,"aria-label":`Preview matches`,disabled:t.busy,onClick:()=>void t.preview(e),children:(0,K.jsx)($e,{className:`size-[13px]`})}),(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,title:`Run now`,"aria-label":`Run now`,disabled:t.busy,onClick:()=>void t.runNow(e),children:(0,K.jsx)(it,{className:`size-[13px]`})}),(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,title:e.enabled?`Pause`:`Enable`,"aria-label":e.enabled?`Pause`:`Enable`,disabled:t.busy,onClick:()=>void t.toggleEnabled(e),children:e.enabled?(0,K.jsx)(Dt,{className:`size-[13px]`}):(0,K.jsx)(Ot,{className:`size-[13px]`})}),(0,K.jsxs)(Ye,{children:[(0,K.jsx)(Ze,{asChild:!0,children:(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`More`,children:(0,K.jsx)(Ce,{className:`size-3.5`})})}),(0,K.jsxs)(Xe,{align:`end`,className:`w-[200px]`,onClick:a,children:[(0,K.jsxs)(F,{onSelect:()=>n(o),children:[(0,K.jsx)(rt,{}),`Edit`]}),(0,K.jsxs)(F,{onSelect:()=>n(`${o}/log`),children:[(0,K.jsx)(kt,{}),`View log`]}),(0,K.jsxs)(F,{onSelect:()=>void t.duplicate(e),children:[(0,K.jsx)(j,{}),`Duplicate`]}),(0,K.jsxs)(F,{onSelect:()=>void t.copyCli(e),children:[(0,K.jsx)(Qe,{}),`Copy as CLI`]}),(0,K.jsx)(Je,{}),(0,K.jsxs)(F,{variant:`destructive`,onSelect:()=>i(!0),children:[(0,K.jsx)(je,{}),`Delete`]})]})]}),(0,K.jsx)(gt,{open:r,onOpenChange:i,children:(0,K.jsxs)(dt,{onClick:a,children:[(0,K.jsxs)(ht,{children:[(0,K.jsxs)(ut,{children:[`Delete “`,e.name,`”?`]}),(0,K.jsx)(lt,{children:`The automation is removed for good. Tasks it already launched and its execution log stay.`})]}),(0,K.jsxs)(pt,{children:[(0,K.jsx)(mt,{children:`Cancel`}),(0,K.jsx)(ft,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>void t.remove(e),children:`Delete`})]})]})})]})}var X=`h-[38px] border-b border-border px-[10px] text-left text-[11px] leading-none font-semibold tracking-[.05em] whitespace-nowrap text-soft-foreground uppercase`,Z=`h-12 border-b border-border px-[10px] text-[13px] leading-none whitespace-nowrap`,jn=`cz-auto-wide max-[1280px]:hidden`,Mn=(0,K.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`});function Nn({data:e,actions:t,now:n=Date.now()}){return(0,K.jsx)(P,{flush:!0,"data-slot":`automations-table`,className:`min-w-0 overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full border-collapse [&_tbody_tr:last-child>td]:border-b-0`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:w(X,`pl-4`),children:`State`}),(0,K.jsx)(`th`,{className:X,children:`Automation`}),(0,K.jsx)(`th`,{className:X,children:`Trigger`}),(0,K.jsx)(`th`,{className:w(X,jn),children:`Runs as`}),(0,K.jsx)(`th`,{className:X,children:`Next run`}),(0,K.jsx)(`th`,{className:X,children:`Last run`}),(0,K.jsx)(`th`,{className:w(X,jn,`text-right`),children:`Runs 7d`}),null,(0,K.jsx)(`th`,{className:w(X,`pr-4`)})]})}),(0,K.jsx)(`tbody`,{children:e.automations.map(r=>(0,K.jsx)(Pn,{automation:r,actions:t,timeZone:e.timeZone,available:e.available,showCost:!1,now:n},r.id))})]})})}function Pn({automation:e,actions:t,timeZone:n,available:r,showCost:i,now:a}){let o=O(),s=e.kind===`github`,c=s&&!r,l=e.task.dispatch,u=We(e),d=[e.task.workflow,e.task.runner].filter(Boolean);return(0,K.jsxs)(`tr`,{"data-slot":`automation-row`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,className:w(`cursor-pointer hover:bg-muted`,!e.enabled&&`opacity-60`),onClick:()=>o(`/automations/${encodeURIComponent(e.id)}`),children:[(0,K.jsx)(`td`,{className:w(Z,`pl-4`),children:c?(0,K.jsx)(I,{dot:`neutral`,children:`paused by capability`}):(0,K.jsx)(I,{dot:e.enabled?`success`:`neutral`,pulse:e.enabled&&s,children:e.enabled?`enabled`:`paused`})}),(0,K.jsx)(`td`,{className:w(Z,`max-w-0 min-w-[200px]`),children:(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[s?(0,K.jsx)(bt,{className:`size-3.5 shrink-0 text-soft-foreground`}):e.kind===`tracker`?(0,K.jsx)(M,{className:`size-3.5 shrink-0 text-soft-foreground`}):(0,K.jsx)(xt,{className:`size-3.5 shrink-0 text-soft-foreground`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.name}),l?(0,K.jsxs)(`span`,{"data-slot":`dispatch-badge`,title:`dispatch · up to ${l.maxSubtasks??1} subtasks`,className:`inline-flex shrink-0 items-center gap-[3px] rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:[(0,K.jsx)(tt,{className:`size-2.5`}),`×`,l.maxSubtasks??1]}):null]})}),(0,K.jsx)(`td`,{className:w(Z,`max-w-[260px] overflow-hidden font-mono text-xs text-ellipsis text-muted-foreground`),title:u,children:u}),(0,K.jsx)(`td`,{className:w(Z,jn,`text-xs text-muted-foreground`),children:d.length?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[d.map((e,t)=>(0,K.jsxs)(`span`,{className:`contents`,children:[t>0?(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}):null,e]},e)),e.task.autonomous?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsx)(`span`,{title:`autonomous`,"data-slot":`autonomous-mark`,className:`inline-flex`,children:(0,K.jsx)(M,{"aria-hidden":`true`,className:`size-[11px] text-soft-foreground`})})]}):null]}):Mn}),(0,K.jsx)(`td`,{"data-slot":`next-run`,className:w(Z,`font-mono text-xs tabular-nums`,e.enabled?`text-foreground`:`text-soft-foreground`),children:Fn(e,n,a)}),(0,K.jsx)(`td`,{className:Z,children:e.lastRun?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(R,{tone:Pe(e.lastRun.status)}),(0,K.jsx)(`span`,{className:`text-[12.5px] text-muted-foreground`,children:He(e.lastRun.status)}),(0,K.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:_t(e.lastRun.ts,a)}),(0,K.jsxs)(k,{to:`/tasks/${encodeURIComponent(e.lastRun.runId)}`,"data-slot":`task-link`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-0.5 rounded-full border border-violet/40 px-1.5 py-px font-mono text-[10.5px] font-semibold text-violet`,children:[`task`,(0,K.jsx)(A,{className:`size-[9px]`})]})]}):Mn}),(0,K.jsx)(`td`,{className:w(Z,jn,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.runs7d}),i?(0,K.jsx)(`td`,{className:w(Z,jn,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.costUsd7d===void 0?Mn:Fe(e.costUsd7d)}):null,(0,K.jsx)(`td`,{className:w(Z,`pr-3 text-right`),children:(0,K.jsx)(An,{automation:e,actions:t})})]})}function Fn(e,t,n){if(!e.enabled)return`—`;if(e.kind!==`schedule`)return`continuous`;if(e.nextRunAt)return Ve(e.nextRunAt,t)||`—`;let r=e.schedule?ne(e.schedule,n,t):null;return r===null?`—`:Ve(r,t)||`—`}function Q(e){return e.hour*60+e.minute}function In(e,t,n=0){let r=C(e,t);if(!r)return null;let i=new Date(Date.UTC(r.year,r.month-1,r.day+n));return re(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),0,0,t)}function Ln(e,t,n,r){let i=[];for(let a of e)if(!(a.kind!==`schedule`||!a.schedule))for(let e of S(a.schedule,t,n,r)){let t=C(e,r);t&&i.push({automation:a,at:e,parts:t})}return i.sort((e,t)=>e.at-t.at)}function Rn(e){let t=new Map;return e.map(e=>{let n=Q(e.parts),r=t.get(n)??0;return t.set(n,r+1),{occurrence:e,stack:r}})}function zn({automation:e,minute:t,stack:n=0,wide:r=!1}){let i=O(),a=x(Math.floor(t/60),t%60),o=[e.task.workflow,e.task.runner].filter(Boolean).join(` · `);return(0,K.jsxs)(`button`,{type:`button`,"data-slot":`event-block`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,title:`${e.name} · ${a}`,onClick:()=>i(`/automations/${encodeURIComponent(e.id)}`),className:w(`absolute right-[3px] left-[3px] flex cursor-pointer overflow-hidden rounded-[6px] border border-border bg-card text-left text-[11.5px] leading-[1.3] font-medium text-foreground shadow-xs`,r?`h-12 flex-col items-start gap-[3px] px-2 py-[5px]`:`h-6 flex-row items-center gap-1.5 px-1.5`,!e.enabled&&`opacity-50`),style:{top:t/60*34+1+26*n},children:[(0,K.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(R,{tone:e.task.runner===`codex`?`violet`:`success`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),r?(0,K.jsxs)(`span`,{className:`max-w-full overflow-hidden font-mono text-[10.5px] leading-[1.3] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:[a,o?` · ${o}`:``]}):null]})}function Bn(){return(0,K.jsx)(`div`,{"data-slot":`hour-gutter`,className:`w-12 shrink-0`,children:Array.from({length:24},(e,t)=>(0,K.jsx)(`div`,{className:`-translate-y-[6px] pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,style:{height:34},children:t?x(t):``},t))})}function Vn({minute:e}){return(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`now-line`,className:`absolute inset-x-0 z-[2] h-[2px] bg-primary`,style:{top:e/60*34},children:(0,K.jsx)(`span`,{className:`absolute -top-[3px] -left-[3px] size-[8px] rounded-full bg-primary`})})}function Hn(){return(0,K.jsx)(K.Fragment,{children:Array.from({length:24},(e,t)=>(0,K.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 h-px bg-border`,style:{top:t*34}},t))})}function Un({automations:e}){let t=e.filter(e=>e.kind===`github`&&e.enabled);return t.length?(0,K.jsxs)(`div`,{"data-slot":`poll-band`,className:`grid grid-cols-[48px_minmax(0,1fr)] border-b border-border`,children:[(0,K.jsx)(`div`,{className:`py-2 pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,children:`poll`}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1 border-l border-border px-2 py-1.5`,children:t.map(e=>(0,K.jsxs)(`div`,{"data-slot":`poll-row`,className:`flex h-[22px] min-w-0 items-center gap-2 overflow-hidden rounded-[6px] border border-violet/25 bg-violet/8 px-2 text-[11.5px] font-medium`,children:[(0,K.jsx)(bt,{className:`size-3 shrink-0 text-violet`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name}),(0,K.jsx)(`span`,{className:`overflow-hidden font-mono text-[10.5px] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:We(e)}),(0,K.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10.5px] font-normal whitespace-nowrap text-soft-foreground`,children:[e.runs7d,` runs`]})]},e.id))})]}):null}var Wn=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Gn({data:e}){let t=Se(6e4),n=O(),[r,i]=(0,G.useState)(0),a=e.timeZone,o=In(t,a,r),s=In(t,a,r+1),c=o===null?null:C(o,a),l=C(t,a);if(o===null||s===null||!c||!l)return(0,K.jsx)(`div`,{"data-slot":`day-view`,className:`p-5`,children:(0,K.jsxs)(`p`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:[`Cannot draw the day: unknown time zone “`,a,`”.`]})});let u=r===0,d=Rn(Ln(e.automations,o,s,a)),f=e.automations.filter(e=>e.kind===`github`&&e.enabled),p=`${Re(c.weekday)} ${c.day} ${Wn[c.month-1]??``}`;return(0,K.jsxs)(`div`,{"data-slot":`day-view`,className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 p-5 max-md:grid-cols-1`,children:[(0,K.jsxs)(P,{flush:!0,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3.5 py-2.5`,children:[(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous day`,onClick:()=>i(e=>e-1),children:(0,K.jsx)(Ge,{className:`size-3.5`})}),(0,K.jsx)(E,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next day`,onClick:()=>i(e=>e+1),children:(0,K.jsx)(qe,{className:`size-3.5`})}),(0,K.jsx)(`span`,{"data-slot":`day-title`,className:`text-sm font-semibold whitespace-nowrap`,children:p}),u?(0,K.jsx)(I,{dot:`success`,children:`today`}):null,(0,K.jsxs)(`span`,{className:`ml-auto text-xs whitespace-nowrap text-muted-foreground`,children:[d.length,` scheduled runs`,f.length?` · ${f.length} GitHub poll${f.length===1?``:`s`}`:``]})]}),(0,K.jsx)(Un,{automations:e.automations}),(0,K.jsxs)(`div`,{className:`flex max-h-[600px] overflow-y-auto`,children:[(0,K.jsx)(Bn,{}),(0,K.jsxs)(`div`,{"data-slot":`day-column`,"data-today":u?`true`:void 0,className:`relative flex-1 border-l border-border`,style:{height:816},children:[(0,K.jsx)(Hn,{}),u?(0,K.jsx)(Vn,{minute:Q(l)}):null,d.map(({occurrence:e,stack:t})=>(0,K.jsx)(zn,{automation:e.automation,minute:Q(e.parts),stack:t,wide:!0},`${e.automation.id}-${e.at}`))]})]})]}),(0,K.jsxs)(P,{flush:!0,"data-slot":`agenda`,className:`py-3`,children:[(0,K.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`Agenda`}),f.map(e=>(0,K.jsxs)(`button`,{type:`button`,"data-slot":`agenda-poll`,onClick:()=>n(`/automations/${encodeURIComponent(e.id)}`),className:`grid w-full cursor-pointer grid-cols-[48px_1fr] gap-2.5 px-3.5 py-2 text-left hover:bg-muted`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[10.5px] font-medium text-soft-foreground`,children:`poll`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-[13px] font-medium`,children:[(0,K.jsx)(bt,{className:`size-3 shrink-0 text-violet`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),(0,K.jsxs)(`span`,{className:`mt-0.5 block overflow-hidden font-mono text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:[We(e),` · continuous`]})]})]},e.id)),d.map(({occurrence:e})=>{let r=e.at<t,{automation:i}=e;return(0,K.jsxs)(`button`,{type:`button`,"data-slot":`agenda-row`,"data-past":r?`true`:`false`,onClick:()=>n(`/automations/${encodeURIComponent(i.id)}`),className:`grid w-full cursor-pointer grid-cols-[48px_1fr] gap-2.5 px-3.5 py-2 text-left hover:bg-muted`,children:[(0,K.jsx)(`span`,{className:w(`font-mono text-xs font-medium tabular-nums`,r?`text-soft-foreground`:`text-foreground`),children:x(e.parts.hour,e.parts.minute)}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:w(`flex items-center gap-2 text-[13px] font-medium`,r&&`text-muted-foreground`),children:[(0,K.jsx)(R,{tone:r&&i.lastRun?Pe(i.lastRun.status):`neutral`}),(0,K.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:i.name})]}),(0,K.jsx)(`span`,{className:`mt-0.5 block overflow-hidden text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:i.task.prompt})]})]},`${i.id}-${e.at}`)}),d.length===0?(0,K.jsx)(`p`,{className:`px-3.5 py-2 text-[12.5px] text-soft-foreground`,children:f.length?`Nothing scheduled — the GitHub polls above still run.`:`Nothing scheduled.`}):null]})]})}function Kn(e,t,n,r=12){let i=[];for(let a of e)if(!(!a.enabled||a.kind!==`schedule`||!a.schedule))for(let e of S(a.schedule,t,t+14*864e5,n,r))i.push({automation:a,at:e});return i.sort((e,t)=>e.at-t.at).slice(0,r)}function qn({open:e,onOpenChange:t,upcoming:n,pollCount:r,timeZone:i,now:a}){let o=O(),s=C(a,i);return(0,K.jsx)(ye,{open:e,onOpenChange:t,children:(0,K.jsxs)(ve,{side:`right`,"data-slot":`next-runs-rail`,"aria-describedby":void 0,className:`w-[360px] gap-0 sm:max-w-[360px]`,children:[(0,K.jsxs)(be,{className:`px-4 pt-4 pb-2`,children:[(0,K.jsxs)(xe,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Be,{className:`size-4`}),`Next runs`]}),(0,K.jsx)(_e,{className:`sr-only`,children:`Upcoming scheduled runs, soonest first.`})]}),(0,K.jsxs)(`div`,{className:`overflow-y-auto`,children:[n.map((e,n)=>{let r=C(e.at,i),c=r!==null&&s!==null&&r.year===s.year&&r.month===s.month&&r.day===s.day,l=r?`${c?``:`${Re(r.weekday)} `}${x(r.hour,r.minute)}`:``;return(0,K.jsxs)(`button`,{type:`button`,"data-slot":`next-run-row`,"data-automation":e.automation.id,onClick:()=>{t(!1),o(`/automations/${encodeURIComponent(e.automation.id)}`)},className:`grid w-full cursor-pointer grid-cols-[76px_1fr_auto] items-center gap-2 px-4 py-2 text-left text-[13px] hover:bg-muted`,children:[(0,K.jsx)(`span`,{className:`font-mono text-xs font-medium whitespace-nowrap text-muted-foreground tabular-nums`,children:l}),(0,K.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.automation.name}),(0,K.jsx)(`span`,{className:`text-[11px] whitespace-nowrap text-soft-foreground`,children:Ne(e.at,a)})]},`${e.automation.id}-${n}`)}),n.length===0?(0,K.jsx)(`p`,{className:`px-4 py-2 text-[12.5px] text-soft-foreground`,children:`No scheduled runs in the next two weeks.`}):null,(0,K.jsxs)(`div`,{"data-slot":`next-runs-footer`,className:`mt-1.5 flex items-center gap-2 border-t border-border px-3.5 pt-2.5 pb-1 text-xs text-muted-foreground`,children:[(0,K.jsx)(R,{tone:`pending`,pulse:!0}),r,` GitHub polls running continuously`]})]})]})})}function Jn({stats:e,pollCount:t,upcoming:n,timeZone:r,railOpen:i,onOpenRail:a}){let o=n[0];return(0,K.jsxs)(`div`,{"data-slot":`stats-strip`,className:`flex flex-wrap items-center gap-4 text-[12.5px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`This week`}),(0,K.jsx)(Yn,{label:`runs`,value:String(e.runs)}),null,(0,K.jsx)(Yn,{label:`failed`,value:String(e.failed),danger:e.failed>0}),(0,K.jsx)(Yn,{label:`agent time`,value:Ue(e.agentSeconds)}),(0,K.jsxs)(`span`,{"data-slot":`stats-polls`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,K.jsx)(R,{tone:`pending`,pulse:!0}),t,` GitHub polls continuous`]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsxs)(`span`,{"data-slot":`stats-next`,className:`inline-flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,K.jsx)(xt,{className:`size-[13px] text-soft-foreground`}),`next`,` `,(0,K.jsx)(`b`,{className:`font-mono text-[12.5px] font-medium text-foreground`,children:o?Le(o.at,r):`—`}),` `,(0,K.jsx)(`span`,{className:`max-w-[180px] overflow-hidden text-ellipsis`,children:o?.automation.name??``})]}),(0,K.jsxs)(E,{variant:`outline`,size:`sm`,"aria-expanded":i,className:`shrink-0`,onClick:a,children:[(0,K.jsx)(Be,{className:`size-3.5`}),`Next runs`,(0,K.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:n.length})]})]})}function Yn({label:e,value:t,danger:n=!1}){return(0,K.jsxs)(`span`,{"data-slot":`stat`,"data-label":e,className:`inline-flex shrink-0 items-baseline gap-[5px] whitespace-nowrap`,children:[(0,K.jsx)(`b`,{className:w(`font-mono text-sm font-semibold tabular-nums`,n?`text-danger`:`text-foreground`),children:t}),e]})}var Xn=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function Zn({data:e}){let t=Se(6e4),n=e.timeZone,r=C(t,n),i=r?Array.from({length:8},(e,i)=>In(t,n,i-(r.weekday-1))):[],a=i[0],o=i[7];if(!r||a==null||o==null)return(0,K.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,K.jsxs)(`p`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:[`Cannot draw the week: unknown time zone “`,n,`”.`]})});let s=r.weekday-1,c=Ln(e.automations,a,o,n),l=Xn.map((e,t)=>{let r=i[t];return{label:e,dayOfMonth:r==null?null:C(r,n)?.day??null,isToday:t===s,blocks:Rn(c.filter(e=>e.parts.weekday-1===t))}});return(0,K.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,K.jsxs)(P,{flush:!0,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-[48px_repeat(7,minmax(0,1fr))] border-b border-border`,children:[(0,K.jsx)(`div`,{}),l.map(e=>(0,K.jsxs)(`div`,{"data-slot":`week-day-header`,"data-today":e.isToday?`true`:void 0,className:w(`flex items-center gap-2 border-l border-border px-2 py-2.5 text-[11px] font-semibold tracking-[.05em] uppercase`,e.isToday?`text-foreground`:`text-soft-foreground`),children:[e.label,(0,K.jsx)(`span`,{className:w(`rounded-full px-[7px] py-px text-[13px] font-medium tracking-normal normal-case`,e.isToday?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e.dayOfMonth??``})]},e.label))]}),(0,K.jsx)(Un,{automations:e.automations}),(0,K.jsxs)(`div`,{className:`flex max-h-[560px] overflow-y-auto`,children:[(0,K.jsx)(Bn,{}),l.map(e=>(0,K.jsxs)(`div`,{"data-slot":`week-column`,"data-today":e.isToday?`true`:void 0,className:w(`relative min-w-0 flex-1 border-l border-border`,e.isToday&&`bg-muted/35`),style:{height:816},children:[(0,K.jsx)(Hn,{}),e.isToday?(0,K.jsx)(Vn,{minute:Q(r)}):null,e.blocks.map(({occurrence:e,stack:t})=>(0,K.jsx)(zn,{automation:e.automation,minute:Q(e.parts),stack:t},`${e.automation.id}-${e.at}`))]},e.label))]})]})})}function Qn(e){return[{value:`list`,label:`List`,...e===void 0?{}:{count:e}},{value:`week`,label:`Week`},{value:`day`,label:`Day`}]}function $n({data:e,error:t,actions:n,view:r,onViewChange:i}){let[a,o]=(0,G.useState)(!1),s=Date.now(),c=e?Kn(e.automations,s,e.timeZone,12):[],l=e?e.automations.filter(e=>e.kind===`github`&&e.enabled).length:0;return(0,K.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5`,children:[(0,K.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,K.jsx)(ge,{slot:`automations-view`,label:`View`,value:r,options:Qn(e?.automations.length),onChange:i}),(0,K.jsx)(`div`,{className:`flex-1`}),e?(0,K.jsxs)(`span`,{"data-slot":`automations-status`,className:`inline-flex min-w-0 items-center gap-2 overflow-hidden text-[12.5px] text-ellipsis whitespace-nowrap text-muted-foreground max-[1280px]:hidden`,children:[(0,K.jsx)(R,{tone:e.scheduler.state===`scheduled`?`success`:`neutral`}),e.scheduler.state===`scheduled`?`Scheduler running`:`Scheduler idle`,(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),e.available?`GitHub available`:`GitHub unavailable${e.reason?` · ${e.reason}`:``}`,(0,K.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,K.jsx)(`span`,{className:`font-mono text-xs`,children:e.timeZone})]}):null,(0,K.jsx)(E,{asChild:!0,className:`shrink-0`,children:(0,K.jsxs)(k,{to:`/automations/new`,children:[(0,K.jsx)(at,{className:`size-[15px]`}),`New automation`]})})]}),t===void 0?e?e.automations.length===0?(0,K.jsx)(vt,{icon:(0,K.jsx)(M,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,K.jsx)(E,{asChild:!0,children:(0,K.jsxs)(k,{to:`/automations/new`,children:[(0,K.jsx)(at,{className:`size-[15px]`}),`New automation`]})})}):r===`week`?(0,K.jsx)(Zn,{data:e}):r===`day`?(0,K.jsx)(Gn,{data:e}):(0,K.jsxs)(`div`,{"data-slot":`automations-list`,className:`flex flex-col gap-3 p-5`,children:[(0,K.jsx)(Jn,{stats:e.stats,pollCount:l,upcoming:c,timeZone:e.timeZone,railOpen:a,onOpenRail:()=>o(!0)}),(0,K.jsx)(Nn,{data:e,actions:n,now:s}),(0,K.jsx)(qn,{open:a,onOpenChange:o,upcoming:c,pollCount:l,timeZone:e.timeZone,now:s})]}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)($,{text:`Loading automations…`})}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)($,{text:t})})]})}function er({mode:e=`list`}){let{automationId:t}=ce(),n=O(),r=de(),i=ue(r.known&&!r.off),a=me(i.data),[o,s]=ae(),c=tr(o.get(`view`));if(!r.known)return(0,K.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,K.jsx)($,{text:`Loading automations…`})});if(r.off)return(0,K.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,K.jsx)(vt,{icon:(0,K.jsx)(M,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This cockpit was started with CEZ_AUTOMATIONS=0. Unset it and restart the service to turn automations on.`,heading:`h2`})});let l=()=>n(`/automations`);if(e===`new`)return(0,K.jsx)(xn,{data:i.data,onBack:l,onSaved:l});if(e===`edit`){let e=i.data?.automations.find(e=>e.id===t);return i.data&&!e?(0,K.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,K.jsx)($,{text:`Automation not found.`})}):e?(0,K.jsx)(xn,{data:i.data,automation:e,actions:a,onBack:l,onSaved:l,onLog:()=>n(`/automations/${encodeURIComponent(e.id)}/log`)}):(0,K.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,K.jsx)($,{text:`Loading automation…`})})}if(e===`log`){let e=i.data?.automations.find(e=>e.id===t);return t?(0,K.jsx)(Tn,{automationId:t,automation:e,timeZone:i.data?.timeZone,onBack:l}):(0,K.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,K.jsx)($,{text:`Automation not found.`})})}return(0,K.jsx)($n,{data:i.data,error:i.error?String(i.error instanceof Error?i.error.message:i.error):void 0,actions:a,view:c,onViewChange:e=>s(t=>{let n=new URLSearchParams(t);return e===`list`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})})}function tr(e){return e===`week`||e===`day`?e:`list`}function $({text:e}){return(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e})}export{er as AutomationsRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-Clwd6u4_.js";import{t as i}from"./project-router-DZsR9P9C.js";import{o as a}from"./scroll-within-Cm6fjjNd.js";var o=e(t(),1),s=n(),c=41;function l({slot:e,commits:t,className:n,onSelect:i}){let l=t.length>150,d=(0,o.useRef)(null),f=(0,o.useRef)(null),[p,m]=(0,o.useState)(0);(0,o.useLayoutEffect)(()=>{if(!l)return;let e=()=>{let e=d.current,t=f.current;!e||!t||m(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[l]);let h=t.map(e=>(0,s.jsx)(u,{commit:e,onSelect:i},e.sha));return(0,s.jsx)(`div`,{ref:e=>{d.current=e,e&&(f.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":l,className:r(`flex flex-col divide-y divide-border px-2 py-1 md:px-4`,n),children:l?(0,s.jsx)(a,{scrollRef:f,startMargin:p,itemSize:c,children:h}):h})}function u({commit:e,onSelect:t}){return(0,s.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_41px] [content-visibility:auto]`,children:(0,s.jsxs)(i,{"data-slot":`commit-row`,"data-sha":e.sha,to:e.href,onClick:t?n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||(n.preventDefault(),t(e.sha))}:void 0,className:`flex min-w-0 items-baseline gap-3 rounded-sm px-2 py-2.5 hover:bg-muted`,children:[(0,s.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:e.shaLabel}),(0,s.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:e.subject}),e.sync?(0,s.jsx)(`span`,{"data-slot":`commit-sync`,"data-sync":e.sync,title:e.sync===`outgoing`?`Not pushed yet`:`On the remote, not pulled yet`,className:r(`shrink-0 rounded-sm border px-1 font-mono text-[10px]`,e.sync===`outgoing`?`border-primary/40 text-primary`:`border-border text-muted-foreground`),children:e.sync===`outgoing`?`↑ local`:`↓ incoming`}):null,(0,s.jsxs)(`span`,{className:`hidden shrink-0 text-[11px] text-soft-foreground sm:inline`,children:[e.author,` · `,e.when]})]})})}export{l as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-Clwd6u4_.js";import{t as i}from"./project-router-CZzr7lzN.js";import{o as a}from"./scroll-within-Cm6fjjNd.js";var o=e(t(),1),s=n(),c=41;function l({slot:e,commits:t,className:n,onSelect:i}){let l=t.length>150,d=(0,o.useRef)(null),f=(0,o.useRef)(null),[p,m]=(0,o.useState)(0);(0,o.useLayoutEffect)(()=>{if(!l)return;let e=()=>{let e=d.current,t=f.current;!e||!t||m(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[l]);let h=t.map(e=>(0,s.jsx)(u,{commit:e,onSelect:i},e.sha));return(0,s.jsx)(`div`,{ref:e=>{d.current=e,e&&(f.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":l,className:r(`flex flex-col divide-y divide-border px-2 py-1 md:px-4`,n),children:l?(0,s.jsx)(a,{scrollRef:f,startMargin:p,itemSize:c,children:h}):h})}function u({commit:e,onSelect:t}){return(0,s.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_41px] [content-visibility:auto]`,children:(0,s.jsxs)(i,{"data-slot":`commit-row`,"data-sha":e.sha,to:e.href,onClick:t?n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||(n.preventDefault(),t(e.sha))}:void 0,className:`flex min-w-0 items-baseline gap-3 rounded-sm px-2 py-2.5 hover:bg-muted`,children:[(0,s.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:e.shaLabel}),(0,s.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:e.subject}),e.sync?(0,s.jsx)(`span`,{"data-slot":`commit-sync`,"data-sync":e.sync,title:e.sync===`outgoing`?`Not pushed yet`:`On the remote, not pulled yet`,className:r(`shrink-0 rounded-sm border px-1 font-mono text-[10px]`,e.sync===`outgoing`?`border-primary/40 text-primary`:`border-border text-muted-foreground`),children:e.sync===`outgoing`?`↑ local`:`↓ incoming`}):null,(0,s.jsxs)(`span`,{className:`hidden shrink-0 text-[11px] text-soft-foreground sm:inline`,children:[e.author,` · `,e.when]})]})})}export{l as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,Cn as i,Ln as a,Sa as o,Yn as s,fi as c,j as l,r as u,rn as d,sn as f,wt as p,ya as m}from"./queries-CI0EmEcH.js";import{r as h,t as g}from"./button-Clwd6u4_.js";import{c as _,f as v,t as y,w as b}from"./project-router-DZsR9P9C.js";import{t as x}from"./check-Dt8U0Zvm.js";import{t as S}from"./chevron-right-VbYrJ_st.js";import{t as C}from"./search-x-CuinYQnl.js";import{i as w,n as T,o as E,r as D,t as O}from"./collapsible-Bdyuw-he.js";import{a as k,c as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-DvPnvVvK.js";import{t as L}from"./token-metrics-Dk2ZNHb_.js";import{t as R}from"./centered-state-nM7v9xtl.js";import{t as z}from"./markdown-Rbaca31B.js";import{N as B,b as V}from"./index-BBND6Sg3.js";import{t as H}from"./run-diff-BPZ85gAE.js";var U=e(t(),1),W=n();function G(){let{groupId:e}=b(),t=r(e),n=L(l().data),i=o();if((0,U.useEffect)(()=>{e&&i.invalidateQueries({queryKey:u.groups.detail(e)})},[i,e,(p().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,W.jsx)(V,{});if(t.isError){let e=t.error instanceof s&&t.error.status===404;return(0,W.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,W.jsx)(R,{icon:e?(0,W.jsx)(C,{}):(0,W.jsx)(B,{}),tone:e?`neutral`:`danger`,title:e?`No such variant group`:`Could not load the variants`,subtitle:e?`No runs share this group id. The group may have been deleted, or a winner was already picked and the others removed.`:t.error.message,actions:(0,W.jsx)(g,{asChild:!0,variant:`outline`,children:(0,W.jsx)(y,{to:`/`,children:`Back to tasks`})})})})}return(0,W.jsx)(K,{groupId:e,variants:t.data.runs,showTokens:n.tokens,showCost:n.cost})}function K({groupId:e,variants:t,showTokens:n,showCost:r}){let a=_(),s=o(),[l,f]=(0,U.useState)(null),p=t.every(e=>d.has(e.status)),g=t[0]?i(t[0]):``,y=m({mutationFn:t=>c(e,t),onSuccess:(t,n)=>{s.invalidateQueries({queryKey:u.runs.all}),s.invalidateQueries({queryKey:u.groups.detail(e)}),a(`/tasks/${t.winner?.id??n}`)},onError:e=>v(e.message,{tone:`danger`})});return(0,W.jsxs)(`div`,{"data-route":`compare`,className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-4 py-5 md:px-6`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,W.jsx)(B,{className:`size-5 shrink-0 text-violet`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:g,children:g})]}),(0,W.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[t.length,` variants of the same task, each in its own worktree — pick the diff you want to keep. The others are cancelled and archived, their worktrees and branches removed.`]})]}),(0,W.jsx)(`div`,{"data-slot":`compare-columns`,className:h(`grid grid-cols-1 gap-3`,t.length>=3?`md:grid-cols-3`:`md:grid-cols-2`),children:t.map(e=>(0,W.jsx)(q,{variant:e,allTerminal:p,pickPending:y.isPending,onPick:()=>f(e),showTokens:n,showCost:r},e.id))}),(0,W.jsx)(`section`,{"aria-label":`Full diffs`,className:`flex flex-col gap-2`,children:t.map(e=>(0,W.jsx)(J,{variant:e},e.id))}),(0,W.jsx)(I,{open:l!==null,onOpenChange:e=>!e&&f(null),children:(0,W.jsxs)(j,{children:[(0,W.jsxs)(F,{children:[(0,W.jsxs)(A,{children:[`Pick variant `,l?.variant,`?`]}),(0,W.jsxs)(k,{children:[`Variant `,l?.variant,`'s changes go to the review gate. The other`,` `,t.length-1==1?`variant is`:`${t.length-1} variants are`,` `,`cancelled if still open, archived, and their worktrees and branches removed. There is no undo.`]})]}),(0,W.jsxs)(N,{children:[(0,W.jsx)(P,{children:`Keep comparing`}),(0,W.jsxs)(M,{"data-slot":`confirm-pick`,onClick:()=>{l&&y.mutate(l.id),f(null)},children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick variant `,l?.variant]})]})]})})]})}function q({variant:e,allTerminal:t,pickPending:n,onPick:r,showTokens:i,showCost:o}){let s=a(e),c=f(e.costUsd),l=e.inputTokens!==void 0||e.outputTokens!==void 0;return(0,W.jsxs)(`article`,{"data-slot":`variant-column`,"data-variant":e.variant,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 shadow-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{"data-slot":`variant-letter`,"aria-label":`Variant ${e.variant}`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-xs font-semibold text-violet`,children:e.variant}),(0,W.jsx)(E,{dot:s.tone,pulse:s.pulse,children:s.label}),i&&l||o&&c?(0,W.jsxs)(`span`,{"data-slot":`variant-token-metrics`,className:`ml-auto flex shrink-0 items-center gap-1.5 text-[11px] text-soft-foreground`,children:[i?(0,W.jsx)(w,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):null,i&&l&&o&&c?(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,o&&c?(0,W.jsx)(`span`,{className:`font-mono tabular-nums`,children:c}):null]}):null]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`git diff --stat`}),(0,W.jsx)(`pre`,{"data-slot":`variant-diffstat`,className:`max-h-36 overflow-auto rounded-md bg-muted/60 px-2.5 py-2 font-mono text-[11px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.diffStat.trimEnd()||`(no changes)`})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`Progress`}),e.handoffExcerpt?(0,W.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-[12.5px] text-muted-foreground [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,W.jsx)(z,{children:e.handoffExcerpt})}):(0,W.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,W.jsxs)(g,{"data-slot":`variant-pick`,title:t?`Keep variant ${e.variant}'s changes and archive the others`:`Every variant must finish before you can pick`,disabled:!t||n,onClick:r,children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick this one`]})]})}function J({variant:e}){let[t,n]=(0,U.useState)(!1);return(0,W.jsxs)(O,{open:t,onOpenChange:n,"data-slot":`variant-diff`,"data-variant":e.variant,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card`,children:[(0,W.jsxs)(D,{className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left text-[13px] font-medium hover:bg-muted/50`,children:[(0,W.jsx)(S,{className:h(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),`Variant `,e.variant,` — full diff`]}),(0,W.jsx)(T,{children:(0,W.jsx)(`div`,{className:`border-t border-border/50 px-3 py-3`,children:(0,W.jsx)(H,{runId:e.id})})})]})}export{G as CompareVariantsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,Cn as i,Ln as a,Yn as o,fi as s,j as c,r as l,rn as u,sn as d,va as f,wt as p,xa as m}from"./queries-Bn7zl9OU.js";import{r as h,t as g}from"./button-Clwd6u4_.js";import{c as _,f as v,t as y,w as b}from"./project-router-CZzr7lzN.js";import{t as x}from"./check-Dt8U0Zvm.js";import{t as S}from"./chevron-right-VbYrJ_st.js";import{t as C}from"./search-x-CuinYQnl.js";import{i as w,n as T,o as E,r as D,t as O}from"./collapsible-Bdyuw-he.js";import{a as k,c as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-DvPnvVvK.js";import{t as L}from"./token-metrics-Dk2ZNHb_.js";import{t as R}from"./centered-state-nM7v9xtl.js";import{t as z}from"./markdown-Rbaca31B.js";import{N as B,b as V}from"./index-qeFtKZ4e.js";import{t as H}from"./run-diff-GHEaeAio.js";var U=e(t(),1),W=n();function G(){let{groupId:e}=b(),t=r(e),n=L(c().data),i=m();if((0,U.useEffect)(()=>{e&&i.invalidateQueries({queryKey:l.groups.detail(e)})},[i,e,(p().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,W.jsx)(V,{});if(t.isError){let e=t.error instanceof o&&t.error.status===404;return(0,W.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,W.jsx)(R,{icon:e?(0,W.jsx)(C,{}):(0,W.jsx)(B,{}),tone:e?`neutral`:`danger`,title:e?`No such variant group`:`Could not load the variants`,subtitle:e?`No runs share this group id. The group may have been deleted, or a winner was already picked and the others removed.`:t.error.message,actions:(0,W.jsx)(g,{asChild:!0,variant:`outline`,children:(0,W.jsx)(y,{to:`/`,children:`Back to tasks`})})})})}return(0,W.jsx)(K,{groupId:e,variants:t.data.runs,showTokens:n.tokens,showCost:n.cost})}function K({groupId:e,variants:t,showTokens:n,showCost:r}){let a=_(),o=m(),[c,d]=(0,U.useState)(null),p=t.every(e=>u.has(e.status)),g=t[0]?i(t[0]):``,y=f({mutationFn:t=>s(e,t),onSuccess:(t,n)=>{o.invalidateQueries({queryKey:l.runs.all}),o.invalidateQueries({queryKey:l.groups.detail(e)}),a(`/tasks/${t.winner?.id??n}`)},onError:e=>v(e.message,{tone:`danger`})});return(0,W.jsxs)(`div`,{"data-route":`compare`,className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-4 py-5 md:px-6`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,W.jsx)(B,{className:`size-5 shrink-0 text-violet`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:g,children:g})]}),(0,W.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[t.length,` variants of the same task, each in its own worktree — pick the diff you want to keep. The others are cancelled and archived, their worktrees and branches removed.`]})]}),(0,W.jsx)(`div`,{"data-slot":`compare-columns`,className:h(`grid grid-cols-1 gap-3`,t.length>=3?`md:grid-cols-3`:`md:grid-cols-2`),children:t.map(e=>(0,W.jsx)(q,{variant:e,allTerminal:p,pickPending:y.isPending,onPick:()=>d(e),showTokens:n,showCost:r},e.id))}),(0,W.jsx)(`section`,{"aria-label":`Full diffs`,className:`flex flex-col gap-2`,children:t.map(e=>(0,W.jsx)(J,{variant:e},e.id))}),(0,W.jsx)(I,{open:c!==null,onOpenChange:e=>!e&&d(null),children:(0,W.jsxs)(j,{children:[(0,W.jsxs)(F,{children:[(0,W.jsxs)(A,{children:[`Pick variant `,c?.variant,`?`]}),(0,W.jsxs)(k,{children:[`Variant `,c?.variant,`'s changes go to the review gate. The other`,` `,t.length-1==1?`variant is`:`${t.length-1} variants are`,` `,`cancelled if still open, archived, and their worktrees and branches removed. There is no undo.`]})]}),(0,W.jsxs)(N,{children:[(0,W.jsx)(P,{children:`Keep comparing`}),(0,W.jsxs)(M,{"data-slot":`confirm-pick`,onClick:()=>{c&&y.mutate(c.id),d(null)},children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick variant `,c?.variant]})]})]})})]})}function q({variant:e,allTerminal:t,pickPending:n,onPick:r,showTokens:i,showCost:o}){let s=a(e),c=d(e.costUsd),l=e.inputTokens!==void 0||e.outputTokens!==void 0;return(0,W.jsxs)(`article`,{"data-slot":`variant-column`,"data-variant":e.variant,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 shadow-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{"data-slot":`variant-letter`,"aria-label":`Variant ${e.variant}`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-xs font-semibold text-violet`,children:e.variant}),(0,W.jsx)(E,{dot:s.tone,pulse:s.pulse,children:s.label}),i&&l||o&&c?(0,W.jsxs)(`span`,{"data-slot":`variant-token-metrics`,className:`ml-auto flex shrink-0 items-center gap-1.5 text-[11px] text-soft-foreground`,children:[i?(0,W.jsx)(w,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):null,i&&l&&o&&c?(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,o&&c?(0,W.jsx)(`span`,{className:`font-mono tabular-nums`,children:c}):null]}):null]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`git diff --stat`}),(0,W.jsx)(`pre`,{"data-slot":`variant-diffstat`,className:`max-h-36 overflow-auto rounded-md bg-muted/60 px-2.5 py-2 font-mono text-[11px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.diffStat.trimEnd()||`(no changes)`})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`Progress`}),e.handoffExcerpt?(0,W.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-[12.5px] text-muted-foreground [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,W.jsx)(z,{children:e.handoffExcerpt})}):(0,W.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,W.jsxs)(g,{"data-slot":`variant-pick`,title:t?`Keep variant ${e.variant}'s changes and archive the others`:`Every variant must finish before you can pick`,disabled:!t||n,onClick:r,children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick this one`]})]})}function J({variant:e}){let[t,n]=(0,U.useState)(!1);return(0,W.jsxs)(O,{open:t,onOpenChange:n,"data-slot":`variant-diff`,"data-variant":e.variant,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card`,children:[(0,W.jsxs)(D,{className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left text-[13px] font-medium hover:bg-muted/50`,children:[(0,W.jsx)(S,{className:h(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),`Variant `,e.variant,` — full diff`]}),(0,W.jsx)(T,{children:(0,W.jsx)(`div`,{className:`border-t border-border/50 px-3 py-3`,children:(0,W.jsx)(H,{runId:e.id})})})]})}export{G as CompareVariantsRoute};