@open-mercato/cezar 0.18.0-pr1995.4555 → 0.18.0-pr1997.4558

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 (77) hide show
  1. package/dist/contract/index.js +4 -1
  2. package/package.json +3 -3
  3. package/web/dist/assets/{agent-task-pickers-CBso_xJT.js → agent-task-pickers-Ba0PLfhZ.js} +1 -1
  4. package/web/dist/assets/{alert-dialog-4Kna6Hd7.js → alert-dialog-BkPaj7ys.js} +1 -1
  5. package/web/dist/assets/arrow-left-Cu-OWry7.js +1 -0
  6. package/web/dist/assets/{automation-format-CXffJGqm.js → automation-format-B75dbm8m.js} +1 -1
  7. package/web/dist/assets/{automations-route-Dj36WeEW.js → automations-route-peVKeS7w.js} +1 -1
  8. package/web/dist/assets/{button-wdWSPx_B.js → button-CvGNeSK2.js} +1 -1
  9. package/web/dist/assets/{centered-state-D-wDs7Y1.js → centered-state-6eXgMviZ.js} +1 -1
  10. package/web/dist/assets/check-X5Qs5F7k.js +1 -0
  11. package/web/dist/assets/chevron-left-BljO3yyN.js +1 -0
  12. package/web/dist/assets/chevron-right-BI-mPHJT.js +1 -0
  13. package/web/dist/assets/circle-check-XLbYmJA0.js +1 -0
  14. package/web/dist/assets/{clipboard-DQGL_gUp.js → clipboard-EdTltTmM.js} +1 -1
  15. package/web/dist/assets/{collapsible-D7qsttC5.js → collapsible-CsAABGPz.js} +1 -1
  16. package/web/dist/assets/{commit-list-DTMGEn0-.js → commit-list-BKK6_14M.js} +1 -1
  17. package/web/dist/assets/{compare-variants-DskisIr6.js → compare-variants-CYA14-aq.js} +1 -1
  18. package/web/dist/assets/{dashboard-BlDc7myS.js → dashboard-CFe_o0yu.js} +1 -1
  19. package/web/dist/assets/{diff-DY-_mmb0.js → diff-Z410Y_2G.js} +2 -2
  20. package/web/dist/assets/{diff-view-oTEcZZ_O.js → diff-view-C78UZozy.js} +1 -1
  21. package/web/dist/assets/{download-BBtWFvsh.js → download-VR2qus0c.js} +1 -1
  22. package/web/dist/assets/{facet-filter-B_AsFqFx.js → facet-filter-Da8GrBFp.js} +1 -1
  23. package/web/dist/assets/{file-CbWEaOku.js → file-CFmbyl_w.js} +1 -1
  24. package/web/dist/assets/{file-preview-DEKEA-Hk.js → file-preview-CIF_V2ki.js} +1 -1
  25. package/web/dist/assets/{git-pull-request-draft-Dwhm6Vhn.js → git-pull-request-draft-DmfS2VSD.js} +1 -1
  26. package/web/dist/assets/git-tab-loading-BDTXdXf1.js +1 -0
  27. package/web/dist/assets/{git-toolbar-C3vpZJaZ.js → git-toolbar-BVr9ySuA.js} +1 -1
  28. package/web/dist/assets/{github-B1xPxoeg.js → github-C0BB36Lm.js} +1 -1
  29. package/web/dist/assets/{host-usage-CI_ZlJQu.js → host-usage-CKqwikDk.js} +1 -1
  30. package/web/dist/assets/{icon-tooltip-CgAWLDxo.js → icon-tooltip-fvgXmwzu.js} +1 -1
  31. package/web/dist/assets/{index-ZWZHYVhn.js → index-DAEQ8mCL.js} +3 -3
  32. package/web/dist/assets/{input-Br4NQpZK.js → input-B1EhOSmt.js} +1 -1
  33. package/web/dist/assets/{layout-cards-B14e3wXL.js → layout-cards-CcqVSm9l.js} +1 -1
  34. package/web/dist/assets/{lib-w_5wfsBF.js → lib-C0_qmnoZ.js} +1 -1
  35. package/web/dist/assets/loader-circle-D40zDUY2.js +1 -0
  36. package/web/dist/assets/{markdown-BfZORc0a.js → markdown-CgE-Rs5t.js} +1 -1
  37. package/web/dist/assets/{markdown-G3dvGJao.js → markdown-DMZtmrf2.js} +1 -1
  38. package/web/dist/assets/{message-square-Dl-ol3uz.js → message-square-BLzN8872.js} +1 -1
  39. package/web/dist/assets/plus-BmtWnEOY.js +1 -0
  40. package/web/dist/assets/{project-router-DgQSavhI.js → project-router-D1cfvRMs.js} +1 -1
  41. package/web/dist/assets/{queries-BTgOLNTK.js → queries-DuK0966_.js} +1 -1
  42. package/web/dist/assets/{reference-chip-BxUGeHDa.js → reference-chip-CtsLfBqz.js} +1 -1
  43. package/web/dist/assets/{repo-git-DD7_YO7w.js → repo-git-uu_4GlD6.js} +1 -1
  44. package/web/dist/assets/{run-diff-CqXLVaDj.js → run-diff-Bihlxnhm.js} +1 -1
  45. package/web/dist/assets/{save-ByUa-aAl.js → save-DMXUDsbw.js} +1 -1
  46. package/web/dist/assets/{scroll-within-Dexi68h1.js → scroll-within-DL0Dobns.js} +1 -1
  47. package/web/dist/assets/{search-x-CLuL49ms.js → search-x-BHraESoW.js} +1 -1
  48. package/web/dist/assets/{settings-2-BvalJGW-.js → settings-2--BmcnOGR.js} +1 -1
  49. package/web/dist/assets/{skills-Bq0wz9vz.js → skills-D4c9k_MW.js} +1 -1
  50. package/web/dist/assets/{square-FwRsgrg-.js → square-C1qtuP9d.js} +1 -1
  51. package/web/dist/assets/{tabs-nC1VLjcX.js → tabs-DhiNAYH8.js} +1 -1
  52. package/web/dist/assets/{tag-CteJEZQp.js → tag-ARQ_hI2l.js} +1 -1
  53. package/web/dist/assets/{task-commits-D3zZ--aw.js → task-commits-BbNm675G.js} +1 -1
  54. package/web/dist/assets/{task-graph-CzlCk84N.js → task-graph-4fhheOf9.js} +1 -1
  55. package/web/dist/assets/{task-notes-BUW9mAu0.js → task-notes-Czz7vBhY.js} +1 -1
  56. package/web/dist/assets/{task-workspace-BT0tz4ns.js → task-workspace-OcXJ7a_x.js} +3 -3
  57. package/web/dist/assets/{terminal-aoRx5eKS.js → terminal-BxD7ogP7.js} +1 -1
  58. package/web/dist/assets/{terminal-drawer-CuGVJS-l.js → terminal-drawer-Hxlprj2U.js} +1 -1
  59. package/web/dist/assets/{textarea-X_NVmVlZ.js → textarea-j1qucn9k.js} +1 -1
  60. package/web/dist/assets/{token-metrics-CdH7TbLP.js → token-metrics-BFQem18c.js} +1 -1
  61. package/web/dist/assets/{tooltip-C2bzSwbQ.js → tooltip-C34OZ7cS.js} +1 -1
  62. package/web/dist/assets/{tracker-Du0TFfZH.js → tracker-CAW76wK8.js} +1 -1
  63. package/web/dist/assets/{triangle-alert-BdMPm9Jb.js → triangle-alert-BjJB906r.js} +1 -1
  64. package/web/dist/assets/{upload-DrvICo_K.js → upload-DZxqIIV1.js} +1 -1
  65. package/web/dist/assets/{use-now-Byfm730u.js → use-now-B0-Ptg98.js} +1 -1
  66. package/web/dist/assets/{use-submit-shortcut-B41NLqM4.js → use-submit-shortcut-UO-A-v3S.js} +1 -1
  67. package/web/dist/assets/{workflow-graph-DPybmv7M.js → workflow-graph-Bo6EfyCz.js} +1 -1
  68. package/web/dist/assets/{worktree-lifecycle-operation-DArtST7T.js → worktree-lifecycle-operation-BQzslyDx.js} +1 -1
  69. package/web/dist/index.html +38 -38
  70. package/web/dist/assets/arrow-left-B1Ed0tpu.js +0 -1
  71. package/web/dist/assets/check-DvAMBXJe.js +0 -1
  72. package/web/dist/assets/chevron-left-Dqb1lvgZ.js +0 -1
  73. package/web/dist/assets/chevron-right-DDQuVTY1.js +0 -1
  74. package/web/dist/assets/circle-check-BiVc-j8x.js +0 -1
  75. package/web/dist/assets/git-tab-loading-K1E0LufY.js +0 -2
  76. package/web/dist/assets/loader-circle-CwT0JWiv.js +0 -1
  77. package/web/dist/assets/plus-BwQyZgNP.js +0 -1
@@ -2131,7 +2131,10 @@ function sanitizeAttachmentName(name, mediaType) {
2131
2131
  const ext = dot > 0 ? cleaned.slice(dot + 1).toLowerCase() : "";
2132
2132
  const keepsExtension = allowed.includes(ext);
2133
2133
  const rawStem = keepsExtension ? cleaned.slice(0, dot) : cleaned;
2134
- const stem = truncateToBounds(rawStem, MAX_ATTACHMENT_NAME_STEM, MAX_ATTACHMENT_NAME_STEM_BYTES).replace(/[. ]+$/, "").trim();
2134
+ const truncated = truncateToBounds(rawStem, MAX_ATTACHMENT_NAME_STEM, MAX_ATTACHMENT_NAME_STEM_BYTES);
2135
+ let end = truncated.length;
2136
+ while (end > 0 && (truncated[end - 1] === "." || truncated[end - 1] === " ")) end -= 1;
2137
+ const stem = truncated.slice(0, end).trim();
2135
2138
  if (stem === "") return null;
2136
2139
  const safeStem = WINDOWS_DEVICE_NAMES.test(stem) ? `${stem}-` : stem;
2137
2140
  return `${safeStem}.${keepsExtension ? ext : canonical}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cezar",
3
- "version": "0.18.0-pr1995.4555",
3
+ "version": "0.18.0-pr1997.4558",
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",
@@ -55,8 +55,8 @@
55
55
  "zod": "^4.4.3"
56
56
  },
57
57
  "devDependencies": {
58
- "@open-mercato/cezar-api-client": "0.18.0-pr1995.4555",
59
- "@open-mercato/cezar-contract": "0.18.0-pr1995.4555",
58
+ "@open-mercato/cezar-api-client": "0.18.0-pr1997.4558",
59
+ "@open-mercato/cezar-contract": "0.18.0-pr1997.4558",
60
60
  "@types/node": "^20.14.0",
61
61
  "@types/proper-lockfile": "4.1.4",
62
62
  "@types/ws": "^8.18.1",
@@ -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-wdWSPx_B.js";import{t as i}from"./project-router-DgQSavhI.js";import{a,o,r as s}from"./reference-chip-BxUGeHDa.js";import{d as c,f as l,h as u,l as d,m as f,p}from"./use-now-Byfm730u.js";import{En as m,x as h}from"./git-tab-loading-K1E0LufY.js";import{B as g,H as _,I as v,U as y,W as b}from"./worktree-lifecycle-operation-DArtST7T.js";import{n as x}from"./textarea-X_NVmVlZ.js";import{t as S}from"./check-DvAMBXJe.js";import{f as C}from"./tooltip-C2bzSwbQ.js";import{h as w}from"./git-toolbar-C3vpZJaZ.js";import{c as T}from"./index-ZWZHYVhn.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({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 k=e(t(),1);function A({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[m,g]=(0,k.useState)(!1),[_,v]=(0,k.useState)(``),w=(0,k.useRef)(null),T=y(e,_);return(0,E.jsxs)(s,{open:m,onOpenChange:e=>{g(e),e||v(``)},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-meta 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:_,onValueChange:v,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:b(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),g(!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 j({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:y,slotPrefix:x=`gh`}){let[D,O]=(0,k.useState)(!1),[A,j]=(0,k.useState)(``),[M,N]=(0,k.useState)(null),P=(0,k.useRef)(null),{mostUsed:F,project:I,global:L}=g(_(e,A,t),t),R=(e,t)=>{let a=n.includes(e.name);return(0,E.jsxs)(f,{value:`skill ${e.name} ${e.path}`,keywords:b(e.name,e.description),"data-slot":`${x}-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,disabled:!a&&y!==void 0&&n.length>=y,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(),N(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:M,onClose:()=>N(null)}),(0,E.jsxs)(s,{open:D,onOpenChange:e=>{O(e),e||j(``)},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:A,onValueChange:j,onInput:()=>P.current?.scrollTo(0,0)}),(0,E.jsxs)(u,{ref:P,"data-slot":`${x}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[F.length===0&&I.length===0&&L.length===0?(0,E.jsx)(c,{children:`Nothing matches.`}):null,F.length>0?(0,E.jsx)(l,{heading:`Most used`,children:F.map(e=>R(e,v(e)))}):null,I.length>0?(0,E.jsx)(l,{heading:`Project skills`,children:I.map(e=>R(e,!0))}):null,L.length>0?(0,E.jsx)(l,{heading:`Global`,children:L.map(e=>R(e,!1))}):null]})]})})]})]})}export{D as i,A as n,O as r,j 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-CvGNeSK2.js";import{t as i}from"./project-router-D1cfvRMs.js";import{a,o,r as s}from"./reference-chip-CtsLfBqz.js";import{d as c,f as l,h as u,l as d,m as f,p}from"./use-now-B0-Ptg98.js";import{En as m,x as h}from"./git-tab-loading-BDTXdXf1.js";import{B as g,H as _,I as v,U as y,W as b}from"./worktree-lifecycle-operation-BQzslyDx.js";import{n as x}from"./textarea-j1qucn9k.js";import{t as S}from"./check-X5Qs5F7k.js";import{f as C}from"./tooltip-C34OZ7cS.js";import{h as w}from"./git-toolbar-BVr9ySuA.js";import{c as T}from"./index-DAEQ8mCL.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({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 k=e(t(),1);function A({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[m,g]=(0,k.useState)(!1),[_,v]=(0,k.useState)(``),w=(0,k.useRef)(null),T=y(e,_);return(0,E.jsxs)(s,{open:m,onOpenChange:e=>{g(e),e||v(``)},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-meta 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:_,onValueChange:v,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:b(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),g(!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 j({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:y,slotPrefix:x=`gh`}){let[D,O]=(0,k.useState)(!1),[A,j]=(0,k.useState)(``),[M,N]=(0,k.useState)(null),P=(0,k.useRef)(null),{mostUsed:F,project:I,global:L}=g(_(e,A,t),t),R=(e,t)=>{let a=n.includes(e.name);return(0,E.jsxs)(f,{value:`skill ${e.name} ${e.path}`,keywords:b(e.name,e.description),"data-slot":`${x}-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,disabled:!a&&y!==void 0&&n.length>=y,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(),N(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:M,onClose:()=>N(null)}),(0,E.jsxs)(s,{open:D,onOpenChange:e=>{O(e),e||j(``)},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:A,onValueChange:j,onInput:()=>P.current?.scrollTo(0,0)}),(0,E.jsxs)(u,{ref:P,"data-slot":`${x}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[F.length===0&&I.length===0&&L.length===0?(0,E.jsx)(c,{children:`Nothing matches.`}):null,F.length>0?(0,E.jsx)(l,{heading:`Most used`,children:F.map(e=>R(e,v(e)))}):null,I.length>0?(0,E.jsx)(l,{heading:`Project skills`,children:I.map(e=>R(e,!0))}):null,L.length>0?(0,E.jsx)(l,{heading:`Global`,children:L.map(e=>R(e,!1))}):null]})]})})]})]})}export{D as i,A as n,O as r,j 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{E as r,N as i,T as a,a as o,c as s,d as c,f as l,l as u,n as d,o as f,p,r as m,s as h,u as g}from"./button-wdWSPx_B.js";var _=e(t(),1),v=n(),y=`AlertDialog`,[b,ee]=r(y,[p]),x=p(),S=e=>{let{__scopeAlertDialog:t,...n}=e,r=x(t);return(0,v.jsx)(o,{...r,...n,modal:!0})};S.displayName=y;var C=`AlertDialogTrigger`,w=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(l,{...i,...r,ref:t})});w.displayName=C;var T=`AlertDialogPortal`,E=e=>{let{__scopeAlertDialog:t,...n}=e,r=x(t);return(0,v.jsx)(g,{...r,...n})};E.displayName=T;var D=`AlertDialogOverlay`,O=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(u,{...i,...r,ref:t})});O.displayName=D;var k=`AlertDialogContent`,[A,j]=b(k),M=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...o}=e,s=x(n),c=i(t,_.useRef(null)),l=_.useRef(null);return(0,v.jsx)(A,{scope:n,cancelRef:l,children:(0,v.jsx)(h,{role:`alertdialog`,...s,...o,ref:c,onOpenAutoFocus:a(o.onOpenAutoFocus,e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})});M.displayName=k;var N=`AlertDialogTitle`,P=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(c,{...i,...r,ref:t})});P.displayName=N;var F=`AlertDialogDescription`,I=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(s,{...i,...r,ref:t})});I.displayName=F;var L=`AlertDialogAction`,R=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(f,{...i,...r,ref:t})});R.displayName=L;var z=`AlertDialogCancel`,B=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:a}=j(z,n),o=x(n),s=i(t,a);return(0,v.jsx)(f,{...o,...r,ref:s})});B.displayName=z;var V=S,H=E,U=O,W=M,G=R,K=B,q=P,J=I;function Y({...e}){return(0,v.jsx)(V,{"data-slot":`alert-dialog`,...e})}function X({...e}){return(0,v.jsx)(H,{"data-slot":`alert-dialog-portal`,...e})}function Z({className:e,...t}){return(0,v.jsx)(U,{"data-slot":`alert-dialog-overlay`,className:m(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Q({className:e,...t}){return(0,v.jsxs)(X,{children:[(0,v.jsx)(Z,{}),(0,v.jsx)(W,{"data-slot":`alert-dialog-content`,className:m(`fixed top-[50%] left-[50%] z-50 grid w-full grid-cols-1 max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-md`,e),...t})]})}function $({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:m(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function te({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:m(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function ne({className:e,...t}){return(0,v.jsx)(q,{"data-slot":`alert-dialog-title`,className:m(`text-lg leading-none font-semibold`,e),...t})}function re({className:e,...t}){return(0,v.jsx)(J,{"data-slot":`alert-dialog-description`,className:m(`text-sm text-muted-foreground`,e),...t})}function ie({className:e,...t}){return(0,v.jsx)(G,{"data-slot":`alert-dialog-action`,className:m(d({variant:`contrast`}),e),...t})}function ae({className:e,...t}){return(0,v.jsx)(K,{"data-slot":`alert-dialog-cancel`,className:m(d({variant:`outline`}),e),...t})}export{re as a,ne as c,Q as i,ie as n,te as o,ae as r,$ as s,Y 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{E as r,N as i,T as a,a as o,c as s,d as c,f as l,l as u,n as d,o as f,p,r as m,s as h,u as g}from"./button-CvGNeSK2.js";var _=e(t(),1),v=n(),y=`AlertDialog`,[b,ee]=r(y,[p]),x=p(),S=e=>{let{__scopeAlertDialog:t,...n}=e,r=x(t);return(0,v.jsx)(o,{...r,...n,modal:!0})};S.displayName=y;var C=`AlertDialogTrigger`,w=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(l,{...i,...r,ref:t})});w.displayName=C;var T=`AlertDialogPortal`,E=e=>{let{__scopeAlertDialog:t,...n}=e,r=x(t);return(0,v.jsx)(g,{...r,...n})};E.displayName=T;var D=`AlertDialogOverlay`,O=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(u,{...i,...r,ref:t})});O.displayName=D;var k=`AlertDialogContent`,[A,j]=b(k),M=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...o}=e,s=x(n),c=i(t,_.useRef(null)),l=_.useRef(null);return(0,v.jsx)(A,{scope:n,cancelRef:l,children:(0,v.jsx)(h,{role:`alertdialog`,...s,...o,ref:c,onOpenAutoFocus:a(o.onOpenAutoFocus,e=>{e.preventDefault(),l.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})});M.displayName=k;var N=`AlertDialogTitle`,P=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(c,{...i,...r,ref:t})});P.displayName=N;var F=`AlertDialogDescription`,I=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(s,{...i,...r,ref:t})});I.displayName=F;var L=`AlertDialogAction`,R=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=x(n);return(0,v.jsx)(f,{...i,...r,ref:t})});R.displayName=L;var z=`AlertDialogCancel`,B=_.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:a}=j(z,n),o=x(n),s=i(t,a);return(0,v.jsx)(f,{...o,...r,ref:s})});B.displayName=z;var V=S,H=E,U=O,W=M,G=R,K=B,q=P,J=I;function Y({...e}){return(0,v.jsx)(V,{"data-slot":`alert-dialog`,...e})}function X({...e}){return(0,v.jsx)(H,{"data-slot":`alert-dialog-portal`,...e})}function Z({className:e,...t}){return(0,v.jsx)(U,{"data-slot":`alert-dialog-overlay`,className:m(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Q({className:e,...t}){return(0,v.jsxs)(X,{children:[(0,v.jsx)(Z,{}),(0,v.jsx)(W,{"data-slot":`alert-dialog-content`,className:m(`fixed top-[50%] left-[50%] z-50 grid w-full grid-cols-1 max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-md`,e),...t})]})}function $({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:m(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function te({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:m(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function ne({className:e,...t}){return(0,v.jsx)(q,{"data-slot":`alert-dialog-title`,className:m(`text-lg leading-none font-semibold`,e),...t})}function re({className:e,...t}){return(0,v.jsx)(J,{"data-slot":`alert-dialog-description`,className:m(`text-sm text-muted-foreground`,e),...t})}function ie({className:e,...t}){return(0,v.jsx)(G,{"data-slot":`alert-dialog-action`,className:m(d({variant:`contrast`}),e),...t})}function ae({className:e,...t}){return(0,v.jsx)(K,{"data-slot":`alert-dialog-cancel`,className:m(d({variant:`outline`}),e),...t})}export{re as a,ne as c,Q as i,ie as n,te as o,ae as r,$ as s,Y as t};
@@ -0,0 +1 @@
1
+ import{F as e}from"./button-CvGNeSK2.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);export{t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{F as n,dt as r,gt as i,ht as a,lt as o,r as s}from"./button-wdWSPx_B.js";var c=n(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),l=n(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);e();var u=t();function d({className:e,flush:t=!1,...n}){return(0,u.jsx)(`div`,{"data-slot":`card`,"data-flush":t?`true`:void 0,className:s(`flex flex-col rounded-lg border bg-card text-card-foreground shadow-xs`,t?`gap-0 overflow-hidden py-0`:`gap-6 py-6`,e),...n})}function f(e){return o[((e-1)%7+7)%7]??``}function p(e,t){let n=i(typeof e==`number`?e:Date.parse(e),t);return n?`${f(n.weekday)} ${r(n.hour,n.minute)}`:``}function m(e,t){let n=i(typeof e==`number`?e:Date.parse(e),t);return n?r(n.hour,n.minute):``}function h(e,t,n=Date.now()){let a=Date.parse(e),o=i(a,t);if(!o)return``;if(n-a<6*864e5)return`${f(o.weekday)} ${r(o.hour,o.minute)}`;let s=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][o.month-1];return`${o.day} ${s} ${r(o.hour,o.minute)}`}function g(e,t=Date.now()){let n=Math.max(0,Math.round((e-t)/6e4));return n<60?`in ${n}m`:n<1440?`in ${Math.round(n/60)}h`:`in ${Math.round(n/1440)}d`}function _(e){let t=Math.round(e/60),n=Math.floor(t/60);return n>0?`${n}h ${String(t%60).padStart(2,`0`)}m`:`${t}m`}function v(e){return e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function y(e){switch(e){case`done`:return`success`;case`running`:case`queued`:case`waiting`:return`pending`;case`failed`:case`cancelled`:return`danger`;case`review`:return`violet`}}function b(e){switch(e){case`review`:return`needs review`;case`waiting`:return`needs you`;default:return e}}function x(e){if(e.kind===`schedule`&&e.schedule)return a(e.schedule);if(e.kind===`tracker`){let t=e.trackerTrigger,n=t?.association.kind===`jira`?`Jira`:t?.association.kind===`linear`?`Linear`:`Tracker`;return t?`${n} · ${t.events.join(`, `)}${t.targetStatusIds?.length?` → ${t.targetStatusIds.join(`, `)}`:``}${t.changedLabelIds?.length?` · labels ${t.changedLabelIds.join(`, `)}`:``} · every ${Math.round((e.intervalSeconds??1800)/60)} min`:`${n} · select an event to complete setup`}let t=(e.events??[]).join(`, `),n=Math.round((e.intervalSeconds??300)/60);return`on ${t||`github`} · every ${n} min`}function S(e){switch(e){case`launched`:case`manual`:case`catch-up`:return`success`;case`failed`:case`error`:case`rate-limited`:return`danger`;default:return`neutral`}}export{g as a,y as c,v as d,d as f,h as i,m as l,c as m,f as n,S as o,l as p,p as r,b as s,_ as t,x as u};
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{F as n,dt as r,gt as i,ht as a,lt as o,r as s}from"./button-CvGNeSK2.js";var c=n(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),l=n(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);e();var u=t();function d({className:e,flush:t=!1,...n}){return(0,u.jsx)(`div`,{"data-slot":`card`,"data-flush":t?`true`:void 0,className:s(`flex flex-col rounded-lg border bg-card text-card-foreground shadow-xs`,t?`gap-0 overflow-hidden py-0`:`gap-6 py-6`,e),...n})}function f(e){return o[((e-1)%7+7)%7]??``}function p(e,t){let n=i(typeof e==`number`?e:Date.parse(e),t);return n?`${f(n.weekday)} ${r(n.hour,n.minute)}`:``}function m(e,t){let n=i(typeof e==`number`?e:Date.parse(e),t);return n?r(n.hour,n.minute):``}function h(e,t,n=Date.now()){let a=Date.parse(e),o=i(a,t);if(!o)return``;if(n-a<6*864e5)return`${f(o.weekday)} ${r(o.hour,o.minute)}`;let s=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][o.month-1];return`${o.day} ${s} ${r(o.hour,o.minute)}`}function g(e,t=Date.now()){let n=Math.max(0,Math.round((e-t)/6e4));return n<60?`in ${n}m`:n<1440?`in ${Math.round(n/60)}h`:`in ${Math.round(n/1440)}d`}function _(e){let t=Math.round(e/60),n=Math.floor(t/60);return n>0?`${n}h ${String(t%60).padStart(2,`0`)}m`:`${t}m`}function v(e){return e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function y(e){switch(e){case`done`:return`success`;case`running`:case`queued`:case`waiting`:return`pending`;case`failed`:case`cancelled`:return`danger`;case`review`:return`violet`}}function b(e){switch(e){case`review`:return`needs review`;case`waiting`:return`needs you`;default:return e}}function x(e){if(e.kind===`schedule`&&e.schedule)return a(e.schedule);if(e.kind===`tracker`){let t=e.trackerTrigger,n=t?.association.kind===`jira`?`Jira`:t?.association.kind===`linear`?`Linear`:`Tracker`;return t?`${n} · ${t.events.join(`, `)}${t.targetStatusIds?.length?` → ${t.targetStatusIds.join(`, `)}`:``}${t.changedLabelIds?.length?` · labels ${t.changedLabelIds.join(`, `)}`:``} · every ${Math.round((e.intervalSeconds??1800)/60)} min`:`${n} · select an event to complete setup`}let t=(e.events??[]).join(`, `),n=Math.round((e.intervalSeconds??300)/60);return`on ${t||`github`} · every ${n} min`}function S(e){switch(e){case`launched`:case`manual`:case`catch-up`:return`success`;case`failed`:case`error`:case`rate-limited`:return`danger`;default:return`neutral`}}export{g as a,y as c,v as d,d as f,h as i,m as l,c as m,f as n,S as o,l as p,p as r,b as s,_ as t,x as u};
@@ -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{Fa as r,Lt as i,M as a,Ma as o,Mr as s,Na as c,Nr as l,Zt as u,_r as d,er as f,fa as p,ii as ee,ja as m,oi as h,qi as g,qt as te,st as ne}from"./queries-BTgOLNTK.js";import{F as _,V as v,_t as y,ct as b,dt as x,ft as S,gt as C,lt as re,mt as ie,pt as ae,r as w,t as T,ut as oe}from"./button-wdWSPx_B.js";import{T as E,c as D,f as se,s as ce,t as O,w as le}from"./project-router-DgQSavhI.js";import{S as k}from"./reference-chip-BxUGeHDa.js";import{O as ue,a as de,c as A,i as fe,l as pe,o as me,s as he,u as ge}from"./facet-filter-B_AsFqFx.js";import{a as _e,i as ve,n as ye,o as be,s as xe,t as Se}from"./use-now-Byfm730u.js";import{I as Ce,In as we,Nn as Te,_ as Ee,wn as De,y as j}from"./git-tab-loading-K1E0LufY.js";import{t as Oe}from"./arrow-left-B1Ed0tpu.js";import{J as ke,c as Ae,d as je,l as Me,z as Ne}from"./worktree-lifecycle-operation-DArtST7T.js";import{r as Pe,t as Fe}from"./textarea-X_NVmVlZ.js";import{a as Ie,c as Le,d as Re,f as M,i as ze,l as Be,m as N,n as P,o as Ve,p as He,r as Ue,s as We,t as Ge,u as F}from"./automation-format-CXffJGqm.js";import{t as Ke}from"./chevron-left-Dqb1lvgZ.js";import{f as qe}from"./tooltip-C2bzSwbQ.js";import{t as Je}from"./chevron-right-DDQuVTY1.js";import{c as Ye,i as I,n as Xe,r as Ze,u as Qe}from"./icon-tooltip-CgAWLDxo.js";import{t as $e}from"./terminal-aoRx5eKS.js";import{h as et}from"./git-toolbar-C3vpZJaZ.js";import{n as tt,t as nt}from"./settings-2-BvalJGW-.js";import{r as rt}from"./use-submit-shortcut-B41NLqM4.js";import{n as it}from"./square-FwRsgrg-.js";import{t as at}from"./plus-BwQyZgNP.js";import{n as ot,o as L,r as st,t as ct}from"./collapsible-D7qsttC5.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-4Kna6Hd7.js";import{t as R}from"./input-Br4NQpZK.js";import{i as z,r as _t}from"./token-metrics-CdH7TbLP.js";import{t as vt}from"./centered-state-D-wDs7Y1.js";import{$ as yt,A as bt,B,F as xt,G as V,H,I as St,L as Ct,M as wt,N as Tt,P as Et,Q as Dt,R as U,U as W,V as G,W as Ot,d as kt,j as At,o as jt,r as Mt,z as K}from"./index-ZWZHYVhn.js";var Nt=_(`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`}]]),Pt=_(`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`}]]),Ft=_(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),It=_(`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`}]]),q=e(t(),1),J=n();function Lt({association:e,selected:t,onSelect:n,onRemove:r}){let i=m({queryKey:[`tracker`,v(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>h({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,J.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,J.jsx)(j,{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,J.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,c?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,J.jsx)(T,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,J.jsxs)(J.Fragment,{children:[!i.isPending&&!i.isFetching&&l.length===0?(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,J.jsx)(T,{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,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var Rt=[`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 zt(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function Bt(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function Vt(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function Ht(e){return e?.source===`skill`?{skill:e.ref,workflow:Ce,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var Ut=[2,5,10,15,30,60],Wt=[1,2,4,6,8],Gt={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},Kt={type:`daily`,hour:4,minute:0};function qt(){return{name:``,kind:`schedule`,schedule:{...Kt},events:[`issue.opened`],intervalSeconds:300,filters:{...Gt},prompt:``,workflow:Ce,skill:null,customSteps:null,runner:null,account:null,model:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var Y=e=>(e??[]).join(`, `);function Jt(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Yt(e){return{authors:Y(e.authors),assignees:Y(e.assignees),anyLabels:Y(e.anyLabels),allLabels:Y(e.allLabels),excludeLabels:Y(e.excludeLabels),changedLabels:Y(e.changedLabels),reviewers:Y(e.reviewers),lookbackDays:e.lookbackDays,maxRecords:e.maxRecords}}function Xt(e){let t=qt(),{task:n,filters:r}=e,i=Bt(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?Yt(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 Zt(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 Qt=e=>e===`claude`||e===`codex`||e===`junie`||e===`opencode`||e===`cursor`||e===`pi`||e===`copilot`;function $t(e,t){let n=Bt(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?Yt(t.filters):{...Gt},prompt:t.prompt,...t.steps?{skill:n,customSteps:n?null:t.steps,workflow:Ce}:Ht(t.workflow?{source:`workflow`,ref:t.workflow}:null),checkout:t.checkout,allowForkHeads:t.allowForkHeads,runner:t.runner!==void 0&&Qt(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&Qt(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 en(e){let t=ae(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};case`once`:return{type:`once`,hour:t.hour,minute:t.minute,...t.date?{date:t.date}:{}};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function tn(e){let t={prompt:e.prompt,...e.skill?{steps:zt(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:en(e.schedule),task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:nn(e.filters.lookbackDays,1,90),maxRecords:nn(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Jt(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:nn(n.lookbackDays,1,90),maxRecords:nn(n.maxRecords,1,100)},task:{...t,...e.checkout===void 0?{}:{checkout:e.checkout},...e.allowForkHeads===void 0?{}:{allowForkHeads:e.allowForkHeads}}}}function nn(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function rn(e){let t=tn(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 an=`([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})`,on=RegExp(`\\b(?:user|author|by)\\s+(?:\`@?${an}\`|@${an}(?![\\w/-]))`,`gi`),sn=[`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`],cn=new Set(`a an the this that these those any all each every some me my you your it its them their us our we he she they who whom which what someone anyone everyone others other pull pr prs issue issues review reviews reviewer reviewers request requests team teams user users human humans changes code now approval merge`.split(` `)),ln=`(?:\`@?${an}\`|@${an}(?![\\w/-]))`,un=RegExp(`\\breview(?:s|\\s+requests?)?\\s+(?:(?:is|are)\\s+)?(?:requested\\s+)?(?:for|from|of)\\s+(?:${ln}|${an}\\b(?![/@-]))`,`gi`),dn=RegExp(`\\b(?:requested\\s+)?reviewer\\s+${ln}`,`gi`),fn=RegExp(`${ln}\\s+(?:(?:is|are|gets?)\\s+)?requested\\s+as\\s+(?:a\\s+)?reviewer\\b`,`gi`);function pn(e){if(e.kind!==`github`)return[];let t=new Set([e.filters.authors,e.filters.assignees,e.filters.reviewers].flatMap(Jt).map(e=>e.replace(/^@/,``).toLowerCase())),n=new Map,r=(e,r)=>{let i=e?.toLowerCase();!e||!i||t.has(i)||n.has(i)||n.set(i,{login:e,field:r})};if(e.events?.some(e=>sn.includes(e)))for(let t of[un,dn,fn])for(let n of e.prompt.matchAll(t)){let e=n[1]??n[2]??n[3];e&&!cn.has(e.toLowerCase())&&r(e,`reviewers`)}for(let t of e.prompt.matchAll(on))r(t[1]??t[2],`authors`);return[...n.values()]}function mn(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var hn=e=>[1,2,3,4,6,8,12].includes(e);function gn({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,a]=(0,q.useState)(``),o=v(),s=m({queryKey:[`tracker`,o,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>ee({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),c=m({queryKey:[`tracker`,o,`automation-options`,i],enabled:!!i&&s.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>ee({...i?{search:i}:{},...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),l=i?c:s,u=s.data?.pages[0],d=u?.available?u:void 0,f=!!d&&!!e&&JSON.stringify(d.association)===JSON.stringify(e.association),p=f&&!!e?.events.length&&e.events.every(e=>d?.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,q.useEffect)(()=>(r(p),()=>r(!1)),[p,r]);let h=l.data?.pages.flatMap(e=>e.available?[e]:[])??[],g=[...new Map(h.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])),ne=(e?.targetStatusIds??[]).filter(e=>!g.some(t=>t.id===e)),_=[...new Map(h.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],y=e?.events.includes(`issue.status_changed`),b=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),x=y&&b?`Search tracker statuses and labels`:b?`Search tracker labels`:`Search tracker statuses`;return(0,J.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[s.isPending?(0,J.jsx)(`p`,{children:`Loading tracker events…`}):null,s.isError||u&&!u.available?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsxs)(`p`,{children:[u&&!u.available?u.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,J.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>void s.refetch(),children:`Retry`})]}):null,d?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{children:[d.association.kind===`jira`?`Jira`:`Linear`,` · `,d.association.externalName]}),e&&!f?(0,J.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,J.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:d.events.map(t=>(0,J.jsx)(j,{active:f&&e?.events.includes(t),"aria-pressed":f&&e?.events.includes(t),onClick:()=>{let r=f?e.events:[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a={...f?e:{},association:d.association,events:i};t===`issue.status_changed`&&!i.includes(t)&&delete a.targetStatusIds,n({trackerTrigger:a,...f?{}:{enabled:!1}})},children:t},t))}),f&&e?(0,J.jsx)(Lt,{association:d.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(d.association)):null,(0,J.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,J.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),d.limitations.map(e=>(0,J.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(R,{"aria-label":x,placeholder:x,value:i,onChange:e=>a(e.target.value)}),l.isFetching?(0,J.jsx)(`p`,{role:`status`,children:`Searching…`}):null,l.isError||l.data?.pages[0]&&!l.data.pages[0].available?(0,J.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,J.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>void l.refetch(),children:`Retry search`})]}):null,!l.isFetching&&l.data?.pages[0]?.available&&y&&g.length===0?(0,J.jsx)(`p`,{children:`No matching statuses.`}):null,!l.isFetching&&l.data?.pages[0]?.available&&b&&_.length===0?(0,J.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[g.map(t=>(0,J.jsx)(j,{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)),ne.map(t=>(0,J.jsxs)(j,{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,J.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:_.map(t=>(0,J.jsx)(j,{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,J.jsx)(T,{variant:`outline`,size:`sm`,disabled:l.isFetchingNextPage,onClick:()=>void l.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,J.jsxs)(U,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(G,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:Ut.map(e=>(0,J.jsxs)(B,{value:String(e),children:[e,` min`]},e))})]})]}),(0,J.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 _n({definition:e}){let t=(0,q.useMemo)(()=>ge(e),[e]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,J.jsx)(`span`,{className:`eyebrow text-soft-foreground`,children:`Copy as CLI`}),(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void me(t),children:[(0,J.jsx)(we,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,J.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-meta leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:t}),(0,J.jsxs)(`p`,{className:`mt-2 mb-0 text-meta leading-[1.5] text-soft-foreground`,children:[`The same definition the cockpit saves — `,(0,J.jsx)(`code`,{className:`text-meta`,children:`cez automation schema`}),` prints its shape.`]})]})}function vn({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=Wt.includes(n)?Wt:[...Wt,n].sort((e,t)=>e-t);return(0,J.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-ui text-muted-foreground`,children:[(0,J.jsxs)(V,{className:`text-ui font-medium text-foreground`,children:[(0,J.jsx)(tt,{"aria-hidden":`true`,className:w(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,J.jsx)(Ot,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i(e?{dispatch:!0}:{dispatch:!1,reviewChild:!1})})]}),t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,J.jsxs)(U,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:a.map(e=>(0,J.jsx)(B,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(V,{className:`text-ui font-normal text-muted-foreground`,children:[(0,J.jsx)(Ot,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,J.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-meta whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null]})}var yn={"pull_request.opened":`A pull request opens`,"issue.opened":`An issue opens`,"issue.labeled":`An issue gets a label`,"issue.unlabeled":`An issue loses a label`,"pull_request.reviewed":`A review is submitted`,"pull_request.review_requested":`A review is requested`,"pull_request.rereview_requested":`A re-review is requested`,"pull_request.closed":`A pull request closes`,"pull_request.merged":`A pull request merges`};function bn({events:e,intervalSeconds:t,filters:n,onChange:r}){let i=[`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].filter(e=>n[e].trim().length>0),[a,o]=(0,q.useState)(i.length>0||n.lookbackDays!==7||n.maxRecords!==25),s=(e,t)=>r({filters:{...n,[e]:t}}),c=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:Rt.filter(e=>n.includes(e))})},l=mn(e),u=l&&n.changedLabels.trim().length===0;return(0,J.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:Rt.map(t=>(0,J.jsxs)(j,{active:e.includes(t),"aria-pressed":e.includes(t),"aria-label":t,title:t,className:`h-8 gap-2 px-3`,onClick:()=>c(t),children:[yn[t],(0,J.jsx)(`span`,{className:`font-mono text-micro font-normal text-soft-foreground`,children:t})]},t))}),e.length===0?(0,J.jsx)(`p`,{className:`m-0 text-label text-danger`,children:`Pick at least one event.`}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-ui text-muted-foreground`,children:[`Checks GitHub every`,(0,J.jsxs)(U,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Poll interval`,className:`text-ui`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:Ut.map(e=>(0,J.jsxs)(B,{value:String(e),children:[e,` min`]},e))})]}),(0,J.jsxs)(`span`,{children:[`while this cockpit is open, looking back `,n.lookbackDays,` days, at most `,n.maxRecords,` records.`]})]}),(0,J.jsxs)(`p`,{"data-slot":`editor-github-how`,className:`-mt-2 m-0 text-label text-soft-foreground`,children:[`Through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL needed.`]}),(0,J.jsxs)(ct,{open:a,onOpenChange:o,children:[(0,J.jsx)(st,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-ui text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(qe,{"aria-hidden":`true`,className:w(`size-3 transition-transform`,a?``:`-rotate-90`)}),`Filters`,u?(0,J.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):i.length>0?(0,J.jsxs)(`span`,{className:`text-soft-foreground`,children:[`· `,i.length,` set`]}):(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`· authors, labels, reviewers`})]})}),(0,J.jsxs)(ot,{children:[(0,J.jsx)(`p`,{className:`m-0 pt-2 text-label text-soft-foreground`,children:`Only matching events start a task. Names in the prompt do not narrow it down; these do.`}),(0,J.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-3 sm:grid-cols-2`,children:[(0,J.jsx)(X,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>s(`authors`,e)}),(0,J.jsx)(X,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>s(`assignees`,e)}),(0,J.jsx)(X,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>s(`anyLabels`,e)}),(0,J.jsx)(X,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>s(`allLabels`,e)}),(0,J.jsx)(X,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>s(`excludeLabels`,e)}),(0,J.jsx)(X,{id:`filter-changed-labels`,label:l?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:u,onChange:e=>s(`changedLabels`,e)}),(0,J.jsx)(X,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>s(`reviewers`,e)}),(0,J.jsx)(xn,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>s(`lookbackDays`,e)}),(0,J.jsx)(xn,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>s(`maxRecords`,e)})]})]})]})]})}function X({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(V,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,J.jsx)(R,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-ui`})]})}function xn({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(V,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,J.jsx)(R,{id:e,type:`number`,min:r,max:i,value:n,onChange:e=>a(nn(Number(e.target.value),r,i)),className:`h-8 w-28 font-mono text-ui 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,J.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(jt,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,J.jsx)(kt,{pick:o,onChange:s,accounts:!0}),(0,J.jsx)(Ee,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,J.jsxs)(`span`,{className:`text-meta`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,J.jsx)(`span`,{className:`flex-1`}),(0,J.jsxs)(V,{className:`text-ui font-medium`,children:[`Autonomous`,(0,J.jsx)(Ot,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function Cn({className:e,...t}){return(0,J.jsx)(`span`,{"data-slot":`branch-chip`,className:w(`inline-block rounded-md bg-muted px-1.5 py-0.5 font-mono text-meta leading-[1.3] font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var wn=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`],[`once`,`Once`]],Tn=e=>String(e).padStart(2,`0`);function En(e){let t=Date.now()+864e5,n=C(t,e);return n?`${n.year}-${Tn(n.month)}-${Tn(n.day)}`:new Date(t).toISOString().slice(0,10)}function Dn({schedule:e,timeZone:t,onChange:n}){let r=ae(e),i=e=>{let{date:i,...a}=r,o={...a,...i?{date:i}:{},...e};o.type===`once`&&!o.date&&(o.date=En(t)),n(o)},a=r.type===`once`&&r.date!==null&&S({type:`once`,date:r.date,hour:r.hour,minute:r.minute},Date.now(),t)===null;return(0,J.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:wn.map(([e,t])=>(0,J.jsx)(j,{active:r.type===e,"aria-pressed":r.type===e,onClick:()=>i({type:e}),children:t},e))}),r.type===`weekly`?(0,J.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:re.map((e,t)=>(0,J.jsx)(j,{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===`once`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`on`,(0,J.jsx)(R,{type:`date`,"aria-label":`Date`,value:r.date??``,onChange:e=>{e.target.value&&i({date:e.target.value})},className:`w-40 font-mono`})]}):null,r.type===`hours`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`every`,(0,J.jsxs)(U,{value:String(r.every),onValueChange:e=>{let t=Number(e);hn(t)&&i({every:t})},children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Every N hours`,className:`text-ui`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:b.map(e=>(0,J.jsxs)(B,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`at`,(0,J.jsx)(R,{"aria-label":`Hour`,inputMode:`numeric`,value:Tn(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,J.jsx)(R,{"aria-label":`Minute`,inputMode:`numeric`,value:Tn(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,J.jsx)(`span`,{className:`font-mono text-xs`,children:t})]}),r.type===`once`?(0,J.jsx)(`p`,{"data-slot":`editor-once-note`,className:`m-0 text-xs ${a?`text-danger`:`text-soft-foreground`}`,children:a?`This time has passed — pick a later one to enable it.`:`Runs a single time, then pauses itself.`}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 font-mono text-xs text-soft-foreground`,children:[(0,J.jsx)(`span`,{children:`cron`}),(0,J.jsx)(Cn,{"data-slot":`editor-cron`,children:oe(e)})]})]})}var On={schedule:[`{{date}}`,`{{project}}`],github:[`{{github.url}}`,`{{github.title}}`,`{{github.number}}`,`{{github.author}}`,`{{github.labels}}`,`{{date}}`,`{{project}}`],tracker:[`{{tracker.key}}`,`{{tracker.title}}`,`{{tracker.url}}`,`{{tracker.status}}`,`{{date}}`,`{{project}}`]};function kn(e){return F({kind:e.kind,events:e.events,intervalSeconds:e.intervalSeconds,schedule:e.schedule,...e.trackerTrigger?{trackerTrigger:e.trackerTrigger}:{}})}function An(e,t){let n=kn(e),r=Vt(e),i=[`${r?`${r.source===`skill`?`skill`:`workflow`} ${r.ref}`:`a quick task`} on ${e.runner??`the default agent`}${e.model?` (${e.model})`:``}`];return i.push(e.autonomous?`autonomous`:`pausing when it needs you`),t&&e.dispatch&&i.push(`up to ${e.maxSubtasks} subtasks`),`${n.charAt(0).toUpperCase()+n.slice(1)}: ${i.join(`, `)}.`}function jn(e,t){return e.kind===`schedule`?!0:e.kind===`tracker`?t:e.events.length>0&&(!mn(e.events)||e.filters.changedLabels.trim().length>0)}function Mn(e,t){let n=[jn(e,t),e.prompt.trim().length>0,e.name.trim().length>0],r=n.indexOf(!1);return[{id:`when`,label:`When`},{id:`what`,label:`What`},{id:`live`,label:`Go live`}].map((e,t)=>({...e,state:n[t]&&(r===-1||t<r)?`done`:t===r||r===-1&&t===2?`current`:`next`}))}function Nn({lastRun:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){return(0,J.jsxs)(M,{flush:!0,"data-slot":`last-run-card`,className:`px-3.5 py-3`,children:[(0,J.jsx)(`div`,{className:`mb-2 eyebrow text-soft-foreground`,children:`Last run`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui`,children:[(0,J.jsx)(z,{tone:Le(e.status)}),We(e.status),(0,J.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:_t(e.ts,i)}),null]}),(0,J.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,J.jsxs)(T,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,J.jsx)(it,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}),n?(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,J.jsx)(It,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}var Pn=864e5;function Fn({kind:e,schedule:t,intervalSeconds:n,timeZone:r,now:i}){let[a,o]=(0,q.useState)(()=>Date.now());(0,q.useEffect)(()=>{if(i!==void 0)return;let e=setInterval(()=>o(Date.now()),6e4);return()=>clearInterval(e)},[i]);let s=i??a,c=(0,q.useMemo)(()=>{if(e!==`schedule`)return[];if(t.type===`once`){let e=S(t,s,r);return e===null?[]:[e]}return ie(t,s,s+9*Pn,r,5)},[e,t,s,r]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,J.jsx)(`div`,{className:`px-3.5 pb-2 eyebrow text-soft-foreground`,children:e===`schedule`?t.type===`once`?`Runs once`:`Next 5 runs`:`How it polls`}),e===`schedule`?c.length===0?(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:t.type===`once`?`This time has already passed.`:`Nothing in the next nine days.`}):c.map(e=>(0,J.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-ui`,children:[(0,J.jsx)(`span`,{className:`w-[82px] shrink-0 font-mono text-xs font-medium whitespace-nowrap text-foreground tabular-nums`,children:Ue(e,r)}),(0,J.jsx)(`span`,{className:`text-meta whitespace-nowrap text-soft-foreground`,children:Ie(e,s)})]},e)):(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,J.jsxs)(J.Fragment,{children:[`Checks the project tracker every `,Math.round(n/60),` min while this cockpit is open. No webhook or public URL required.`]}):(0,J.jsxs)(J.Fragment,{children:[`Checks GitHub every `,Math.round(n/60),` min while this cockpit is open, through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var In=[{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.`}],Ln=e=>[v(),`automation-templates`,e??``];function Rn({onPick:e}){let[t,n]=(0,q.useState)(`builtin`),r=ce(),i=c({queryKey:Ln(r),queryFn:({signal:e})=>l(r,{signal:e}),enabled:t===`mine`}),a=t===`builtin`?In.map(e=>({...e,key:e.name})):(i.data?.templates??[]).map(e=>({...Zt(e),key:`${e.project.id}:${e.id}`,when:F(e),project:e.project.name}));return(0,J.jsxs)(M,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,J.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,J.jsx)(zn,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,J.jsx)(zn,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,J.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`&&i.isPending?(0,J.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`Loading…`}):t===`mine`&&i.isError?(0,J.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-xs text-danger`,children:i.error.message}):a.length===0?(0,J.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`No automations in your other projects yet.`}):(0,J.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:a.map(t=>(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui font-semibold`,children:[t.kind===`github`?(0,J.jsx)(W,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,J.jsx)(yt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,J.jsx)(Cn,{className:`ml-auto`,children:t.project}):null]}),(0,J.jsx)(`div`,{className:`font-mono text-meta text-muted-foreground`,children:t.when}),(0,J.jsx)(`div`,{className:`line-clamp-2 text-xs leading-[1.45] text-soft-foreground`,children:t.prompt}),(0,J.jsx)(T,{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 zn({active:e,onClick:t,children:n}){return(0,J.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-ui font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function Bn(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 Vn={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`What should the agent do each time? Say it the way you would in New task.`,github:`What should the agent do for each match? Say it the way you would in New task.`};function Hn({data:e,automation:t,actions:n,initialKind:o,onBack:s,onSaved:c,onLog:l}){let ee=r(),m=D(),h=a(),g=te(),_=u(),v=i(),y=ne(),b=o===`github`&&e?.available===!1?`schedule`:o,[x,S]=(0,q.useState)(()=>t?Xt(t):b?{...qt(),kind:b,...b===`tracker`?{intervalSeconds:1800,enabled:!1}:{}}:qt()),[C,re]=(0,q.useState)(!t&&!b),[ie,ae]=(0,q.useState)(!1),[w,oe]=(0,q.useState)(!1),[E,se]=(0,q.useState)(null),[ce,O]=(0,q.useState)(!1),le=(0,q.useRef)(null),k=t?.revision,ue=(0,q.useRef)(k);(0,q.useEffect)(()=>{!t||k===ue.current||(ue.current=k,S(Xt(t)),O(!1),se(null))},[t,k]);let A=e=>S(t=>({...t,...e})),fe=e?.timeZone??`UTC`,pe=e?.available!==!1,me=h.data?.capabilities.dispatch===!0,he=(0,q.useMemo)(()=>Ae(je(g.data?.promptTemplates),h.data?.capabilities),[g.data?.promptTemplates,h.data?.capabilities]),ge=_.data?.workflows??[],_e=ge.map(e=>e.name),ve=v.data,ye=(ve??[]).map(e=>e.name),be=g.data?.skillUsage,xe=(0,q.useMemo)(()=>Ne(ve??[],be),[ve,be]),Se=v.data!==void 0&&_.data!==void 0&&!g.isPending,Ce=y.data?.baseBranch??y.data?.info?.branch??void 0,we=(0,q.useMemo)(()=>rn(x),[x]),Te=(0,q.useMemo)(()=>pn(x),[x]),Ee=e=>Te.filter(t=>t.field===e).map(e=>e.login),De=x.name.trim().length>0&&x.prompt.trim().length>0&&!w&&(x.kind!==`tracker`||ie),Pe=Mn(x,ie),Ie=An(x,me),Le=e=>{let t=le.current,n=t?.selectionStart??x.prompt.length,r=Me(x.prompt,n,e);A({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},Re=e=>{let t=le.current,n=t?.selectionStart??x.prompt.length,r=x.prompt.slice(0,n),i=x.prompt.slice(n),a=r.length>0&&!/\s$/.test(r)?` `:``,o=`${r}${a}${e}${i.length>0&&!/^\s/.test(i)?` `:``}${i}`,s=r.length+a.length+e.length;A({prompt:o}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(s,s))})},M=async()=>{oe(!0),se(null),O(!1);try{let e=tn(x);t?await p(t.id,{...e,enabled:x.enabled,expectedRevision:t.revision}):await d({...e,enable:x.enabled}),await ee.invalidateQueries({queryKey:de()}),c()}catch(e){if(t&&e instanceof f&&e.status===409)O(!0);else{let t=e instanceof Error?e.message:String(e);se({message:t,section:e instanceof f&&e.status===400?Bn(t):`top`})}}finally{oe(!1)}},ze=()=>void ee.invalidateQueries({queryKey:de()}),Be=t?`Save changes`:x.enabled?`Save and enable`:`Save paused`,N=`Change the kind by creating a new automation`,P=!!t,Ve=e=>{e!==x.kind&&A({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})};return(0,J.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,"data-onboarding":``,className:`flex min-h-full flex-col`,children:[(0,J.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,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:s,children:(0,J.jsx)(Oe,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,J.jsx)(L,{dot:t.enabled?`success`:`neutral`,children:t.enabled?`enabled`:`paused`}):null,(0,J.jsx)(`span`,{className:`flex-1`}),t?null:(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,"aria-expanded":C,"aria-label":C?`Hide templates`:`Start from a template`,onClick:()=>re(e=>!e),children:[(0,J.jsx)(Nt,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`max-md:hidden`,children:C?`Hide templates`:`Start from a template`})]}),(0,J.jsx)(T,{variant:`outline`,className:`font-normal`,onClick:s,children:`Cancel`}),(0,J.jsx)(T,{className:`font-normal`,disabled:!De,onClick:()=>void M(),children:Be})]}),(0,J.jsx)(`div`,{className:`flex justify-center px-5 pb-16`,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-3xl flex-col items-center`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-strip`,className:`sticky top-14 z-10 flex w-full flex-wrap items-center gap-x-6 gap-y-1.5 border-b border-border bg-background/95 py-2.5 backdrop-blur max-md:static`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 max-md:basis-full`,children:[(0,J.jsx)(`span`,{className:`shrink-0 text-ui text-muted-foreground`,"aria-hidden":`true`,children:`Name`}),(0,J.jsx)(R,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:x.name,onChange:e=>A({name:e.target.value}),className:`h-9 w-full max-w-md text-lead md:text-lead`})]}),(0,J.jsx)(Tt,{steps:Pe})]}),ce||E?.section===`top`||C&&!t?(0,J.jsxs)(`div`,{className:`mt-6 flex w-full flex-col gap-4`,children:[ce?(0,J.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-ui text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,J.jsx)(T,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:ze,children:`Reload`})]}):null,E?.section===`top`?(0,J.jsx)(Wn,{children:E.message}):null,C&&!t?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`p`,{className:`m-0 text-center text-ui text-muted-foreground`,children:`Start from a template, or fill in the three parts below.`}),(0,J.jsx)(Rn,{onPick:e=>{let t=e.workflow&&_e.includes(e.workflow)?e.workflow:void 0,n=e.steps?.every(e=>!e.skill||ye.includes(e.skill))?e.steps:void 0;S(r=>$t(r,{...e,workflow:t,steps:n})),re(!1)}})]}):null]}):null,(0,J.jsxs)(Un,{slot:`when`,title:`When`,why:P?`The trigger is fixed once saved; change it by creating a new automation.`:`What starts a run. Pick one, then say how often or on which change.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`grid gap-3 sm:grid-cols-3`,children:[(0,J.jsx)(xt,{value:`schedule`,title:`On a schedule`,description:`At a time you set.`,selected:x.kind===`schedule`,disabled:P&&x.kind!==`schedule`,reason:P&&x.kind!==`schedule`?N:void 0,onClick:()=>Ve(`schedule`),picture:(0,J.jsx)(Gn,{})}),(0,J.jsx)(xt,{value:`github`,title:`When GitHub changes`,description:`A pull request, an issue, a review.`,selected:x.kind===`github`,disabled:!pe||P&&x.kind!==`github`,reason:pe?P&&x.kind!==`github`?N:void 0:e?.reason??`GitHub is unavailable`,onClick:()=>Ve(`github`),picture:(0,J.jsx)(W,{className:`size-7 text-muted-foreground`,"aria-hidden":!0})}),(0,J.jsx)(xt,{value:`tracker`,title:`When Jira / Linear changes`,description:`An issue is created or moves.`,selected:x.kind===`tracker`,disabled:P&&x.kind!==`tracker`,reason:P&&x.kind!==`tracker`?N:void 0,onClick:()=>Ve(`tracker`),picture:(0,J.jsx)(Kn,{})})]}),(0,J.jsx)(`div`,{className:`mt-5`,children:x.kind===`schedule`?(0,J.jsx)(Dn,{schedule:x.schedule,timeZone:fe,onChange:e=>A({schedule:e})}):x.kind===`tracker`?(0,J.jsx)(gn,{trigger:x.trackerTrigger,intervalSeconds:x.intervalSeconds,onChange:A,onValid:ae}):(0,J.jsx)(bn,{events:x.events,intervalSeconds:x.intervalSeconds,filters:x.filters,onChange:e=>A(e)})}),x.kind===`schedule`?(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(Fn,{kind:x.kind,schedule:x.schedule,intervalSeconds:x.intervalSeconds,timeZone:fe})}):null,E?.section===`when`?(0,J.jsx)(Wn,{children:E.message}):null]}),(0,J.jsxs)(Un,{slot:`what`,title:`What the agent does`,why:`The same words you would type into New task. Placeholders fill in per run.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-placeholders`,className:`flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[`Insert`,On[x.kind].map(e=>(0,J.jsx)(j,{className:`h-6 font-mono text-meta`,title:`Insert ${e} at the caret`,onClick:()=>Re(e),children:e},e))]}),(0,J.jsx)(Fe,{ref:le,"aria-label":`Prompt`,rows:5,placeholder:Vn[x.kind],value:x.prompt,onChange:e=>A({prompt:e.target.value}),className:`mt-3 min-h-[120px] rounded-xl px-4 py-3 text-lead leading-[1.55] md:text-lead`}),(0,J.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,J.jsx)(ke,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,he.map(e=>(0,J.jsx)(j,{className:`h-6 text-meta`,title:e.text,onClick:()=>Le(e.text),children:e.label},e.id)),(0,J.jsx)(j,{dashed:!0,className:`h-6 text-meta`,icon:(0,J.jsx)(nt,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>m(`${Mt(`project`,`instructions`)}#prompt-templates`),children:`Manage…`})]}),Te.length>0?(0,J.jsxs)(`div`,{role:`status`,"data-slot":`editor-prompt-condition`,className:`mt-3 flex flex-wrap items-center gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-label text-foreground`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`The prompt names `,Te.map(({login:e})=>`@${e}`).join(`, `),`, but prompt text does not decide what launches — without a filter every matching event starts a task.`]}),[`authors`,`reviewers`].map(e=>Ee(e).length>0?(0,J.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>A({filters:{...x.filters,[e]:[...Jt(x.filters[e]),...Ee(e)].join(`, `)}}),children:e===`authors`?`Add to Authors`:`Add to Reviewers`},e):null)]}):null,(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(Sn,{source:Vt(x),sourcesReady:Se,skills:xe,skillUsage:be,workflows:ge,onSource:e=>A(Ht(e)),pick:{runner:x.runner,model:x.model,account:x.account},onPick:e=>A({runner:e.runner,model:e.model,account:e.account}),baseBranch:Ce,autonomous:x.autonomous,onAutonomous:e=>A({autonomous:e})})}),(0,J.jsx)(`p`,{className:`mt-3 mb-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,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(vn,{available:me,enabled:x.dispatch,maxSubtasks:x.maxSubtasks,reviewChild:x.reviewChild,onChange:e=>A(e)})}),E?.section===`what`?(0,J.jsx)(Wn,{children:E.message}):null]}),(0,J.jsxs)(Un,{slot:`live`,title:`Go live`,why:`Paused, it waits in the list where you can preview it. Enabled, it starts counting from now.`,children:[(0,J.jsx)(`p`,{"data-slot":`editor-summary`,className:`m-0 rounded-xl border border-violet/40 bg-violet/10 px-4 py-3 text-body text-foreground`,children:Ie}),(0,J.jsxs)(V,{className:`mt-4 flex items-start gap-3 text-ui font-normal`,children:[(0,J.jsx)(Ot,{"aria-label":`Enabled`,checked:x.enabled,onCheckedChange:e=>A({enabled:e}),className:`mt-0.5`}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-body text-foreground`,children:`Enabled`}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:x.kind===`schedule`?x.enabled?`Runs at the next time listed above.`:`Saved paused. Enable it from the list, or Run now to try it once.`:`Counts from a current-time baseline; existing matches will not launch.`})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3`,children:[(0,J.jsx)(_n,{definition:we}),t&&t.kind!==`schedule`&&n?(0,J.jsx)(T,{variant:`outline`,className:`self-start font-normal`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t?.lastRun?(0,J.jsx)(Nn,{lastRun:t.lastRun,busy:n?.busy,onRunNow:()=>void n?.runNow(t),onLog:l}):null]})]})]})})]})}function Un({slot:e,title:t,why:n,children:r}){return(0,J.jsxs)(`section`,{"data-slot":`editor-section`,"data-section":e,className:`mt-7 w-full border-t border-border pt-6 first-of-type:mt-6 first-of-type:border-t-0 first-of-type:pt-0`,children:[(0,J.jsx)(`h2`,{className:`text-xl font-light tracking-tight text-foreground`,children:t}),(0,J.jsx)(`p`,{className:`mt-1 mb-5 text-ui text-muted-foreground`,children:n}),r]})}function Wn({children:e}){return(0,J.jsx)(`div`,{role:`alert`,className:w(`mt-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-ui text-foreground`),children:e})}function Gn(){return(0,J.jsxs)(`span`,{className:`flex w-12 flex-col gap-1`,children:[(0,J.jsxs)(`span`,{className:`flex items-center justify-between rounded-md border border-violet bg-violet/15 px-1 py-0.5 font-mono text-[7px] text-foreground`,children:[`09:00`,(0,J.jsx)(`span`,{className:`size-1 rounded-full bg-violet`})]}),(0,J.jsxs)(`span`,{className:`flex items-center justify-between rounded-md border border-border px-1 py-0.5 font-mono text-[7px] text-muted-foreground`,children:[`16:00`,(0,J.jsx)(`span`,{className:`size-1 rounded-full bg-muted-foreground/50`})]})]})}function Kn(){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-[7px]`,children:[(0,J.jsx)(`span`,{className:`rounded border border-border px-1 py-0.5 text-muted-foreground`,children:`To do`}),(0,J.jsx)(`span`,{className:`h-px w-1.5 bg-violet`}),(0,J.jsx)(`span`,{className:`rounded border border-violet bg-violet/15 px-1 py-0.5 text-foreground`,children:`Ready`})]})}function qn({automationId:e,automation:t,timeZone:n,onBack:i}){let a=D(),l=r(),u=v(),d=(0,q.useMemo)(()=>[u,`automation-log`,e],[u,e]),f=c({queryKey:d,queryFn:({signal:t})=>s(e,{signal:t})}),[p,ee]=(0,q.useState)(`all`),[m,h]=(0,q.useState)(`all`);(0,q.useEffect)(()=>ue((t,n)=>{t===`automation-change`&&n.automationId===e&&l.invalidateQueries({queryKey:d})}),[e,l,d]);let te=o({mutationFn:e=>g(e),onSuccess:()=>l.invalidateQueries({queryKey:d}),onError:e=>se(e instanceof Error?e.message:String(e),{tone:`danger`})}),ne=n??`UTC`,_=f.data?.records.filter(e=>(p===`all`||e.result===p)&&(m===`all`||e.event===m));return(0,J.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-log`,className:`flex min-h-full flex-col`,children:[(0,J.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,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:i,children:(0,J.jsx)(Oe,{className:`size-[15px]`})}),(0,J.jsx)(`h1`,{className:`m-0 text-base font-semibold`,children:t?t.name:`Automation`}),(0,J.jsx)(`span`,{className:`text-ui text-muted-foreground`,children:`· execution log`}),(0,J.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2`,children:[(0,J.jsxs)(U,{value:p,onValueChange:e=>ee(e),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Filter by result`,className:`text-label`,children:(0,J.jsx)(H,{placeholder:`All results`})}),(0,J.jsxs)(K,{children:[(0,J.jsx)(B,{value:`all`,children:`All results`}),Jn.map(e=>(0,J.jsx)(B,{value:e,children:e},e))]})]}),(0,J.jsxs)(U,{value:m,onValueChange:e=>h(e),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Filter by event`,className:`text-label`,children:(0,J.jsx)(H,{placeholder:`All events`})}),(0,J.jsxs)(K,{children:[(0,J.jsx)(B,{value:`all`,children:`All events`}),Yn.map(e=>(0,J.jsx)(B,{value:e,children:e},e))]})]})]}),(0,J.jsxs)(T,{variant:`outline`,size:`sm`,onClick:()=>a(`/automations/${encodeURIComponent(e)}`),children:[(0,J.jsx)(rt,{className:`size-[13px]`}),`Edit`]})]}),(0,J.jsx)(`div`,{className:`flex justify-center p-5`,children:f.isError?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:f.error instanceof Error?f.error.message:String(f.error)})}):_===void 0?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:`Loading execution log…`})}):_.length===0?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:`No checks have run yet.`})}):(0,J.jsx)(M,{flush:!0,className:`w-full max-w-[820px]`,children:_.map((e,t)=>(0,J.jsx)(Zn,{record:e,run:e.runId===void 0?void 0:f.data?.runs[e.runId],last:t===_.length-1,timeZone:ne,retrying:te.isPending&&te.variables===e.receiptId,onRetry:e=>te.mutate(e)},e.seq))})})]})}var Jn=[`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`manual`,`catch-up`,`skipped`,`failed`],Yn=[`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 Xn(e){return e.result===`failed`&&e.runId===void 0?e.receiptId:void 0}function Zn({record:e,run:t,last:n,timeZone:r,retrying:i,onRetry:a}){let o=Ve(e.result),s=t?.children??[],c=Xn(e);return(0,J.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-ui ${n?``:`border-b border-border`}`,children:[(0,J.jsx)(`span`,{className:`font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:ze(e.ts,r)}),(0,J.jsx)(L,{dot:o,className:`w-fit`,children:e.result}),(0,J.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,J.jsx)(`span`,{}):(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a(c),children:[(0,J.jsx)(Dt,{className:`size-3`}),`Retry task`]}):(0,J.jsx)(T,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,J.jsxs)(O,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open task`,(0,J.jsx)(k,{className:`size-3`})]})}),s.length>0?(0,J.jsx)(`div`,{className:`col-span-full flex flex-col gap-1 pl-3.5`,children:s.map(e=>(0,J.jsxs)(`div`,{"data-slot":`log-child`,className:`grid grid-cols-[14px_70px_1fr_auto] items-center gap-2.5 text-label`,children:[(0,J.jsx)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:`└`}),(0,J.jsx)(`span`,{className:`w-fit rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:e.kind??`implement`}),(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(z,{tone:Le(e.status)}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.title})]}),null,(0,J.jsx)(T,{variant:`ghost`,size:`sm`,className:`h-6`,asChild:!0,children:(0,J.jsxs)(O,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open`,(0,J.jsx)(k,{className:`size-[11px]`})]})})]},e.runId))}):null]})}function Qn({data:e}){let t=D(),[n,r]=q.useState(!1),i=e.available===!1,a=e=>t(`/automations/new?kind=${e}`);return(0,J.jsxs)(wt,{wide:!0,slot:`automations`,title:`Let the routine run itself`,why:`An automation is a prompt cezar turns into a task on its own: at a time you set, when something happens on GitHub, or when an issue moves in Jira or Linear.`,children:[(0,J.jsxs)(`div`,{"data-slot":`automation-triggers`,className:`mt-8 grid w-full gap-3 sm:grid-cols-3`,children:[(0,J.jsx)(bt,{title:`On a schedule`,description:`Every weekday at 9:00, Fridays at 16:00, every six hours.`,recommended:!0,onClick:()=>a(`schedule`),picture:(0,J.jsx)(ir,{})}),(0,J.jsx)(bt,{title:`When GitHub changes`,description:i?`Sign in to the GitHub CLI first.`:`A new pull request, an issue labelled, a review requested.`,onClick:()=>i?t(`/github`):a(`github`),picture:i?(0,J.jsx)(W,{className:`size-9 text-muted-foreground`,"aria-hidden":!0}):(0,J.jsx)(ar,{})}),(0,J.jsx)(bt,{title:`When an issue moves`,description:`A Jira or Linear issue is created or changes status.`,onClick:()=>a(`tracker`),picture:(0,J.jsx)(or,{})})]}),(0,J.jsx)(`ol`,{"data-slot":`automation-steps`,className:`mt-10 grid w-full gap-6 text-left sm:grid-cols-3`,children:$n.map((e,t)=>(0,J.jsxs)(`li`,{className:`flex gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 grid size-6 shrink-0 place-items-center rounded-full border border-violet font-mono text-meta text-foreground`,"aria-hidden":`true`,children:t+1}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-lead text-foreground`,children:e.title}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:e.body})]})]},e.title))}),(0,J.jsxs)(`div`,{className:`mt-10 flex flex-col items-center gap-4`,children:[(0,J.jsx)(T,{asChild:!0,className:`font-normal`,children:(0,J.jsxs)(O,{to:`/automations/new`,children:[(0,J.jsx)(at,{className:`size-[15px]`,"aria-hidden":`true`}),`New automation`]})}),(0,J.jsxs)(`button`,{type:`button`,className:Ct,onClick:()=>r(!0),children:[(0,J.jsx)(He,{className:`size-3.5`,"aria-hidden":`true`}),`See it in pictures`]})]}),n?(0,J.jsx)(tr,{onOpenChange:r}):null]})}var $n=[{title:`Write it as a prompt`,body:`Say what the agent should do each time. Placeholders such as {{github.url}} or {{date}} fill in per run.`},{title:`Preview, then enable`,body:`A new automation starts paused. A poll shows what it would have matched, a schedule shows its next runs. Enable it when that looks right.`},{title:`Every run is a task`,body:`Each match starts an ordinary task in its own worktree. It ends at the review gate, never merges on its own, and the log keeps every run.`}];function er(){let[e,t]=q.useState(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,"data-slot":`automations-guide`,"aria-label":`How automations work`,className:`text-muted-foreground`,onClick:()=>t(!0),children:[(0,J.jsx)(He,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`max-md:hidden`,children:`How it works`})]}),e?(0,J.jsx)(tr,{onOpenChange:t}):null]})}function tr({onOpenChange:e}){let t=D();return(0,J.jsx)(At,{slot:`automations-guide-page`,title:`How automations work`,description:`Four things to know.`,pages:[{id:`prompt`,title:`A prompt that runs itself`,body:`An automation is the same thing you type into New task, kept and run for you. Placeholders fill in what changed: the pull request, the issue, the date.`,picture:(0,J.jsx)(sr,{})},{id:`triggers`,title:`Three ways to start`,body:`On a schedule, when GitHub changes, or when an issue moves in Jira or Linear. A GitHub or tracker automation polls every few minutes and starts one task per match.`,picture:(0,J.jsx)(cr,{})},{id:`paused`,title:`Paused first, then live`,body:`A new automation is paused. Preview shows what it would have matched, or when it runs next. Enable it when that looks right, and pause it again any time.`,picture:(0,J.jsx)(lr,{})},{id:`tasks`,title:`Every run is a task`,body:`Each run shows up in the task list like one you started yourself, in its own worktree, ending at the review gate. The automation’s log keeps every run.`,picture:(0,J.jsx)(ur,{}),action:{label:`New automation`,onClick:()=>t(`/automations/new`)}}],onOpenChange:e})}var nr=`flex items-center gap-2 rounded-md px-2 py-1 text-micro`;function rr({on:e=!0}){return(0,J.jsx)(`span`,{className:w(`flex h-3.5 w-6 items-center rounded-full px-0.5`,e?`justify-end bg-violet`:`justify-start bg-muted-foreground/40`),children:(0,J.jsx)(`span`,{className:`size-2.5 rounded-full bg-background`})})}function ir(){return(0,J.jsx)(`span`,{className:`flex w-20 flex-col gap-1`,children:[`Mon 09:00`,`Fri 16:00`].map((e,t)=>(0,J.jsxs)(`span`,{className:w(`flex items-center justify-between rounded-md border px-1.5 py-1 font-mono text-[9px]`,t===0?`border-violet bg-violet/15 text-foreground`:`border-border text-muted-foreground`),children:[e,(0,J.jsx)(`span`,{className:w(`size-1.5 rounded-full`,t===0?`bg-violet`:`bg-muted-foreground/50`)})]},e))})}function ar(){return(0,J.jsxs)(`span`,{className:`flex w-20 flex-col gap-1.5`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-violet bg-violet/15 px-1.5 py-1`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`}),(0,J.jsx)(`span`,{className:`h-1 flex-1 rounded bg-violet/60`}),(0,J.jsx)(`span`,{className:`rounded-sm bg-violet/40 px-1 text-[7px] text-foreground`,children:`PR`})]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-border px-1.5 py-1`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`}),(0,J.jsx)(`span`,{className:`h-1 w-2/3 rounded bg-muted`})]})]})}function or(){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[9px]`,children:[(0,J.jsx)(`span`,{className:`rounded-md border border-border px-1.5 py-1 text-muted-foreground`,children:`To do`}),(0,J.jsx)(`span`,{className:`h-px w-3 bg-violet`}),(0,J.jsx)(`span`,{className:`rounded-md border border-violet bg-violet/15 px-1.5 py-1 text-foreground`,children:`Ready`})]})}function sr(){return(0,J.jsxs)(Et,{bar:(0,J.jsx)(`span`,{className:`ml-3 text-micro text-soft-foreground`,children:`What to run`}),children:[(0,J.jsxs)(`p`,{className:`text-meta leading-relaxed text-foreground`,children:[`Review `,(0,J.jsx)(`span`,{className:`rounded-sm bg-violet/15 px-1 text-violet`,children:`{{github.url}}`}),` for real issues only and leave one comment per finding.`]}),(0,J.jsx)(`div`,{className:w(St,`mt-3 w-1/2`)})]})}function cr(){return(0,J.jsx)(Et,{children:[`Every weekday at 9:00`,`When a pull request opens`,`When PROJ-42 reaches Ready`].map((e,t)=>(0,J.jsxs)(`div`,{style:{"--i":t},className:w(nr,`tip-rise justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(rr,{})]},e))})}function lr(){return(0,J.jsxs)(Et,{children:[(0,J.jsxs)(`div`,{className:w(nr,`justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:`Triage new issues`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-[9.5px] text-soft-foreground`,children:[`paused`,(0,J.jsx)(rr,{on:!1})]})]}),(0,J.jsx)(`div`,{style:{"--i":2},className:`tip-rise mt-2 rounded-md border border-violet/50 bg-violet/10 px-2 py-1.5 text-micro text-foreground`,children:`Preview: would have matched 3 issues this week`}),(0,J.jsxs)(`div`,{style:{"--i":5},className:w(nr,`tip-rise mt-2 justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:`Triage new issues`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-[9.5px] text-violet`,children:[`enabled`,(0,J.jsx)(rr,{})]})]})]})}function ur(){return(0,J.jsx)(Et,{bar:(0,J.jsx)(`span`,{className:`ml-3 text-micro text-soft-foreground`,children:`Tasks`}),children:[[`needs review`,`Triage issue 412: missing repro`,`text-violet`],[`running`,`Nightly dependency bump`,`text-success`],[`done`,`Weekly changelog draft`,`text-muted-foreground`]].map(([e,t,n],r)=>(0,J.jsxs)(`div`,{style:{"--i":r},className:w(nr,`tip-rise text-foreground`),children:[(0,J.jsx)(`span`,{className:w(`w-16 shrink-0 text-[9.5px]`,n),children:e}),(0,J.jsx)(`span`,{className:`truncate`,children:t})]},t))})}function dr({automation:e,actions:t}){let n=D(),[r,i]=(0,q.useState)(!1),a=e=>e.stopPropagation(),o=`/automations/${encodeURIComponent(e.id)}`;return(0,J.jsxs)(`span`,{"data-slot":`row-actions`,className:`inline-flex gap-0.5`,onClick:a,children:[e.kind===`schedule`?null:(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,title:`Preview matches`,"aria-label":`Preview matches`,disabled:t.busy,onClick:()=>void t.preview(e),children:(0,J.jsx)(et,{className:`size-[13px]`})}),(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,title:`Run now`,"aria-label":`Run now`,disabled:t.busy,onClick:()=>void t.runNow(e),children:(0,J.jsx)(it,{className:`size-[13px]`})}),(0,J.jsx)(T,{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,J.jsx)(Pt,{className:`size-[13px]`}):(0,J.jsx)(Ft,{className:`size-[13px]`})}),(0,J.jsxs)(Xe,{children:[(0,J.jsx)(Qe,{asChild:!0,children:(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`More`,children:(0,J.jsx)(Te,{className:`size-3.5`})})}),(0,J.jsxs)(Ze,{align:`end`,className:`w-[200px]`,onClick:a,children:[(0,J.jsxs)(I,{onSelect:()=>n(o),children:[(0,J.jsx)(rt,{}),`Edit`]}),(0,J.jsxs)(I,{onSelect:()=>n(`${o}/log`),children:[(0,J.jsx)(It,{}),`View log`]}),(0,J.jsxs)(I,{onSelect:()=>void t.duplicate(e),children:[(0,J.jsx)(we,{}),`Duplicate`]}),(0,J.jsxs)(I,{onSelect:()=>void t.copyCli(e),children:[(0,J.jsx)($e,{}),`Copy as CLI`]}),(0,J.jsx)(Ye,{}),(0,J.jsxs)(I,{variant:`destructive`,onSelect:()=>i(!0),children:[(0,J.jsx)(Pe,{}),`Delete`]})]})]}),(0,J.jsx)(gt,{open:r,onOpenChange:i,children:(0,J.jsxs)(dt,{onClick:a,children:[(0,J.jsxs)(ht,{children:[(0,J.jsxs)(ut,{children:[`Delete “`,e.name,`”?`]}),(0,J.jsx)(lt,{children:`The automation is removed for good. Tasks it already launched and its execution log stay.`})]}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(mt,{children:`Cancel`}),(0,J.jsx)(ft,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>void t.remove(e),children:`Delete`})]})]})})]})}var Z=`h-[38px] border-b border-border px-[10px] text-left eyebrow whitespace-nowrap text-soft-foreground`,Q=`h-12 border-b border-border px-[10px] text-ui leading-none whitespace-nowrap`,fr=`cz-auto-wide max-[1280px]:hidden`,pr=(0,J.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`});function mr({data:e,actions:t,now:n=Date.now()}){return(0,J.jsx)(M,{flush:!0,"data-slot":`automations-table`,className:`min-w-0 overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`w-full border-collapse [&_tbody_tr:last-child>td]:border-b-0`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:w(Z,`pl-4`),children:`State`}),(0,J.jsx)(`th`,{className:Z,children:`Automation`}),(0,J.jsx)(`th`,{className:Z,children:`Trigger`}),(0,J.jsx)(`th`,{className:w(Z,fr),children:`Runs as`}),(0,J.jsx)(`th`,{className:Z,children:`Next run`}),(0,J.jsx)(`th`,{className:Z,children:`Last run`}),(0,J.jsx)(`th`,{className:w(Z,fr,`text-right`),children:`Runs 7d`}),null,(0,J.jsx)(`th`,{className:w(Z,`pr-4`)})]})}),(0,J.jsx)(`tbody`,{children:e.automations.map(r=>(0,J.jsx)(hr,{automation:r,actions:t,timeZone:e.timeZone,available:e.available,showCost:!1,now:n},r.id))})]})})}function hr({automation:e,actions:t,timeZone:n,available:r,showCost:i,now:a}){let o=D(),s=e.kind===`github`,c=s&&!r,l=e.task.dispatch,u=F(e),d=[e.task.workflow,e.task.runner].filter(Boolean);return(0,J.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,J.jsx)(`td`,{className:w(Q,`pl-4`),children:c?(0,J.jsx)(L,{dot:`neutral`,children:`paused by capability`}):(0,J.jsx)(L,{dot:e.enabled?`success`:`neutral`,pulse:e.enabled&&s,children:e.enabled?`enabled`:`paused`})}),(0,J.jsx)(`td`,{className:w(Q,`max-w-0 min-w-[200px]`),children:(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[s?(0,J.jsx)(W,{className:`size-3.5 shrink-0 text-soft-foreground`}):e.kind===`tracker`?(0,J.jsx)(De,{className:`size-3.5 shrink-0 text-soft-foreground`}):(0,J.jsx)(yt,{className:`size-3.5 shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ui font-medium text-ellipsis whitespace-nowrap`,children:e.name}),l?(0,J.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-micro font-medium text-muted-foreground`,children:[(0,J.jsx)(tt,{className:`size-2.5`}),`×`,l.maxSubtasks??1]}):null]})}),(0,J.jsx)(`td`,{className:w(Q,`max-w-[260px] overflow-hidden font-mono text-xs text-ellipsis text-muted-foreground`),title:u,children:u}),(0,J.jsx)(`td`,{className:w(Q,fr,`text-xs text-muted-foreground`),children:d.length?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[d.map((e,t)=>(0,J.jsxs)(`span`,{className:`contents`,children:[t>0?(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}):null,e]},e)),e.task.autonomous?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsx)(`span`,{title:`autonomous`,"data-slot":`autonomous-mark`,className:`inline-flex`,children:(0,J.jsx)(De,{"aria-hidden":`true`,className:`size-[11px] text-soft-foreground`})})]}):null]}):pr}),(0,J.jsx)(`td`,{"data-slot":`next-run`,className:w(Q,`font-mono text-xs tabular-nums`,e.enabled?`text-foreground`:`text-soft-foreground`),children:gr(e,n,a)}),(0,J.jsx)(`td`,{className:Q,children:e.lastRun?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,J.jsx)(z,{tone:Le(e.lastRun.status)}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:We(e.lastRun.status)}),(0,J.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:_t(e.lastRun.ts,a)}),(0,J.jsxs)(O,{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-micro font-semibold text-violet`,children:[`task`,(0,J.jsx)(k,{className:`size-[9px]`})]})]}):pr}),(0,J.jsx)(`td`,{className:w(Q,fr,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.runs7d}),i?(0,J.jsx)(`td`,{className:w(Q,fr,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.costUsd7d===void 0?pr:Re(e.costUsd7d)}):null,(0,J.jsx)(`td`,{className:w(Q,`pr-3 text-right`),children:(0,J.jsx)(dr,{automation:e,actions:t})})]})}function gr(e,t,n){if(!e.enabled)return`—`;if(e.kind!==`schedule`)return`continuous`;if(e.nextRunAt)return Ue(e.nextRunAt,t)||`—`;let r=e.schedule?S(e.schedule,n,t):null;return r===null?`—`:Ue(r,t)||`—`}function _r(e){return e.hour*60+e.minute}function vr(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 y(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),0,0,t)}function yr(e,t,n,r){let i=[];for(let a of e)if(!(a.kind!==`schedule`||!a.schedule))for(let e of ie(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 br(e){let t=new Map;return e.map(e=>{let n=_r(e.parts),r=t.get(n)??0;return t.set(n,r+1),{occurrence:e,stack:r}})}function xr({automation:e,minute:t,stack:n=0,wide:r=!1}){let i=D(),a=x(Math.floor(t/60),t%60),o=[e.task.workflow,e.task.runner].filter(Boolean).join(` · `);return(0,J.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-meta 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,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(z,{tone:e.task.runner===`codex`?`violet`:`success`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),r?(0,J.jsxs)(`span`,{className:`max-w-full overflow-hidden font-mono text-micro leading-[1.3] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:[a,o?` · ${o}`:``]}):null]})}function Sr(){return(0,J.jsx)(`div`,{"data-slot":`hour-gutter`,className:`w-12 shrink-0`,children:Array.from({length:24},(e,t)=>(0,J.jsx)(`div`,{className:`-translate-y-[6px] pr-2 text-right font-mono text-micro text-soft-foreground`,style:{height:34},children:t?x(t):``},t))})}function Cr({minute:e}){return(0,J.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,J.jsx)(`span`,{className:`absolute -top-[3px] -left-[3px] size-[8px] rounded-full bg-primary`})})}function wr(){return(0,J.jsx)(J.Fragment,{children:Array.from({length:24},(e,t)=>(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 h-px bg-border`,style:{top:t*34}},t))})}function Tr({automations:e}){let t=e.filter(e=>e.kind===`github`&&e.enabled);return t.length?(0,J.jsxs)(`div`,{"data-slot":`poll-band`,className:`grid grid-cols-[48px_minmax(0,1fr)] border-b border-border`,children:[(0,J.jsx)(`div`,{className:`py-2 pr-2 text-right font-mono text-micro text-soft-foreground`,children:`poll`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1 border-l border-border px-2 py-1.5`,children:t.map(e=>(0,J.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-meta font-medium`,children:[(0,J.jsx)(W,{className:`size-3 shrink-0 text-violet`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name}),(0,J.jsx)(`span`,{className:`overflow-hidden font-mono text-micro font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:F(e)}),(0,J.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-micro font-normal whitespace-nowrap text-soft-foreground`,children:[e.runs7d,` runs`]})]},e.id))})]}):null}var Er=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Dr({data:e}){let t=Se(6e4),n=D(),[r,i]=(0,q.useState)(0),a=e.timeZone,o=vr(t,a,r),s=vr(t,a,r+1),c=o===null?null:C(o,a),l=C(t,a);if(o===null||s===null||!c||!l)return(0,J.jsx)(`div`,{"data-slot":`day-view`,className:`p-5`,children:(0,J.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=br(yr(e.automations,o,s,a)),f=e.automations.filter(e=>e.kind===`github`&&e.enabled),p=`${P(c.weekday)} ${c.day} ${Er[c.month-1]??``}`;return(0,J.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,J.jsxs)(M,{flush:!0,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3.5 py-2.5`,children:[(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous day`,onClick:()=>i(e=>e-1),children:(0,J.jsx)(Ke,{className:`size-3.5`})}),(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next day`,onClick:()=>i(e=>e+1),children:(0,J.jsx)(Je,{className:`size-3.5`})}),(0,J.jsx)(`span`,{"data-slot":`day-title`,className:`text-sm font-semibold whitespace-nowrap`,children:p}),u?(0,J.jsx)(L,{dot:`success`,children:`today`}):null,(0,J.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,J.jsx)(Tr,{automations:e.automations}),(0,J.jsxs)(`div`,{className:`flex max-h-[600px] overflow-y-auto`,children:[(0,J.jsx)(Sr,{}),(0,J.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,J.jsx)(wr,{}),u?(0,J.jsx)(Cr,{minute:_r(l)}):null,d.map(({occurrence:e,stack:t})=>(0,J.jsx)(xr,{automation:e.automation,minute:_r(e.parts),stack:t,wide:!0},`${e.automation.id}-${e.at}`))]})]})]}),(0,J.jsxs)(M,{flush:!0,"data-slot":`agenda`,className:`py-3`,children:[(0,J.jsx)(`div`,{className:`px-3.5 pb-2 eyebrow text-soft-foreground`,children:`Agenda`}),f.map(e=>(0,J.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,J.jsx)(`span`,{className:`font-mono text-micro font-medium text-soft-foreground`,children:`poll`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-ui font-medium`,children:[(0,J.jsx)(W,{className:`size-3 shrink-0 text-violet`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),(0,J.jsxs)(`span`,{className:`mt-0.5 block overflow-hidden font-mono text-meta leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:[F(e),` · continuous`]})]})]},e.id)),d.map(({occurrence:e})=>{let r=e.at<t,{automation:i}=e;return(0,J.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,J.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,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:w(`flex items-center gap-2 text-ui font-medium`,r&&`text-muted-foreground`),children:[(0,J.jsx)(z,{tone:r&&i.lastRun?Le(i.lastRun.status):`neutral`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:i.name})]}),(0,J.jsx)(`span`,{className:`mt-0.5 block overflow-hidden text-meta leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:i.task.prompt})]})]},`${i.id}-${e.at}`)}),d.length===0?(0,J.jsx)(`p`,{className:`px-3.5 py-2 text-label text-soft-foreground`,children:f.length?`Nothing scheduled — the GitHub polls above still run.`:`Nothing scheduled.`}):null]})]})}function Or(e,t,n,r=12){let i=[];for(let a of e)if(!(!a.enabled||a.kind!==`schedule`||!a.schedule))for(let e of ie(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 kr({open:e,onOpenChange:t,upcoming:n,pollCount:r,timeZone:i,now:a}){let o=D(),s=C(a,i);return(0,J.jsx)(ye,{open:e,onOpenChange:t,children:(0,J.jsxs)(ve,{side:`right`,"data-slot":`next-runs-rail`,"aria-describedby":void 0,className:`w-[360px] gap-0 sm:max-w-[360px]`,children:[(0,J.jsxs)(be,{className:`px-4 pt-4 pb-2`,children:[(0,J.jsxs)(xe,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,J.jsx)(N,{className:`size-4`}),`Next runs`]}),(0,J.jsx)(_e,{className:`sr-only`,children:`Upcoming scheduled runs, soonest first.`})]}),(0,J.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?``:`${P(r.weekday)} `}${x(r.hour,r.minute)}`:``;return(0,J.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-ui hover:bg-muted`,children:[(0,J.jsx)(`span`,{className:`font-mono text-xs font-medium whitespace-nowrap text-muted-foreground tabular-nums`,children:l}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ui font-medium text-ellipsis whitespace-nowrap`,children:e.automation.name}),(0,J.jsx)(`span`,{className:`text-meta whitespace-nowrap text-soft-foreground`,children:Ie(e.at,a)})]},`${e.automation.id}-${n}`)}),n.length===0?(0,J.jsx)(`p`,{className:`px-4 py-2 text-label text-soft-foreground`,children:`No scheduled runs in the next two weeks.`}):null,(0,J.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,J.jsx)(z,{tone:`pending`,pulse:!0}),r,` GitHub polls running continuously`]})]})]})})}function Ar({stats:e,pollCount:t,upcoming:n,timeZone:r,railOpen:i,onOpenRail:a}){let o=n[0];return(0,J.jsxs)(`div`,{"data-slot":`stats-strip`,className:`flex flex-wrap items-center gap-4 text-label text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`eyebrow text-soft-foreground`,children:`This week`}),(0,J.jsx)(jr,{label:`runs`,value:String(e.runs)}),null,(0,J.jsx)(jr,{label:`failed`,value:String(e.failed),danger:e.failed>0}),(0,J.jsx)(jr,{label:`agent time`,value:Ge(e.agentSeconds)}),(0,J.jsxs)(`span`,{"data-slot":`stats-polls`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,J.jsx)(z,{tone:`pending`,pulse:!0}),t,` GitHub polls continuous`]}),(0,J.jsx)(`span`,{className:`flex-1`}),(0,J.jsxs)(`span`,{"data-slot":`stats-next`,className:`inline-flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,J.jsx)(yt,{className:`size-[13px] text-soft-foreground`}),`next`,` `,(0,J.jsx)(`b`,{className:`font-mono text-label font-medium text-foreground`,children:o?Be(o.at,r):`—`}),` `,(0,J.jsx)(`span`,{className:`max-w-[180px] overflow-hidden text-ellipsis`,children:o?.automation.name??``})]}),(0,J.jsxs)(T,{variant:`outline`,size:`sm`,"aria-expanded":i,className:`shrink-0`,onClick:a,children:[(0,J.jsx)(N,{className:`size-3.5`}),`Next runs`,(0,J.jsx)(`span`,{className:`font-mono text-meta font-medium text-muted-foreground`,children:n.length})]})]})}function jr({label:e,value:t,danger:n=!1}){return(0,J.jsxs)(`span`,{"data-slot":`stat`,"data-label":e,className:`inline-flex shrink-0 items-baseline gap-[5px] whitespace-nowrap`,children:[(0,J.jsx)(`b`,{className:w(`font-mono text-sm font-semibold tabular-nums`,n?`text-danger`:`text-foreground`),children:t}),e]})}var Mr=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function Nr({data:e}){let t=Se(6e4),n=e.timeZone,r=C(t,n),i=r?Array.from({length:8},(e,i)=>vr(t,n,i-(r.weekday-1))):[],a=i[0],o=i[7];if(!r||a==null||o==null)return(0,J.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,J.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=yr(e.automations,a,o,n),l=Mr.map((e,t)=>{let r=i[t];return{label:e,dayOfMonth:r==null?null:C(r,n)?.day??null,isToday:t===s,blocks:br(c.filter(e=>e.parts.weekday-1===t))}});return(0,J.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,J.jsxs)(M,{flush:!0,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-[48px_repeat(7,minmax(0,1fr))] border-b border-border`,children:[(0,J.jsx)(`div`,{}),l.map(e=>(0,J.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 eyebrow`,e.isToday?`text-foreground`:`text-soft-foreground`),children:[e.label,(0,J.jsx)(`span`,{className:w(`rounded-full px-[7px] py-px text-ui font-medium tracking-normal normal-case`,e.isToday?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e.dayOfMonth??``})]},e.label))]}),(0,J.jsx)(Tr,{automations:e.automations}),(0,J.jsxs)(`div`,{className:`flex max-h-[560px] overflow-y-auto`,children:[(0,J.jsx)(Sr,{}),l.map(e=>(0,J.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,J.jsx)(wr,{}),e.isToday?(0,J.jsx)(Cr,{minute:_r(r)}):null,e.blocks.map(({occurrence:e,stack:t})=>(0,J.jsx)(xr,{automation:e.automation,minute:_r(e.parts),stack:t},`${e.automation.id}-${e.at}`))]},e.label))]})]})})}function Pr(e){return[{value:`list`,label:`List`,...e===void 0?{}:{count:e}},{value:`week`,label:`Week`},{value:`day`,label:`Day`}]}function Fr({data:e,error:t,actions:n,view:r,onViewChange:i}){let[a,o]=(0,q.useState)(!1),s=Date.now(),c=e?Or(e.automations,s,e.timeZone,12):[],l=e?e.automations.filter(e=>e.kind===`github`&&e.enabled).length:0;return(0,J.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,J.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,J.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,J.jsx)(fe,{slot:`automations-view`,label:`View`,value:r,options:Pr(e?.automations.length),onChange:i}),(0,J.jsx)(`div`,{className:`flex-1`}),e?(0,J.jsxs)(`span`,{"data-slot":`automations-status`,className:`inline-flex min-w-0 items-center gap-2 overflow-hidden text-label text-ellipsis whitespace-nowrap text-muted-foreground max-[1280px]:hidden`,children:[(0,J.jsx)(z,{tone:e.scheduler.state===`scheduled`?`success`:`neutral`}),e.scheduler.state===`scheduled`?`Scheduler running`:`Scheduler idle`,(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),e.available?`GitHub available`:`GitHub unavailable${e.reason?` · ${e.reason}`:``}`,(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:e.timeZone})]}):null,(0,J.jsx)(er,{}),(0,J.jsx)(T,{asChild:!0,className:`shrink-0`,children:(0,J.jsxs)(O,{to:`/automations/new`,children:[(0,J.jsx)(at,{className:`size-[15px]`}),`New automation`]})})]}),t===void 0?e?e.automations.length===0?(0,J.jsx)(`div`,{className:`flex flex-1 flex-col px-5`,children:(0,J.jsx)(Qn,{data:e})}):r===`week`?(0,J.jsx)(Nr,{data:e}):r===`day`?(0,J.jsx)(Dr,{data:e}):(0,J.jsxs)(`div`,{"data-slot":`automations-list`,className:`flex flex-col gap-3 p-5`,children:[(0,J.jsx)(Ar,{stats:e.stats,pollCount:l,upcoming:c,timeZone:e.timeZone,railOpen:a,onOpenRail:()=>o(!0)}),(0,J.jsx)(mr,{data:e,actions:n,now:s}),(0,J.jsx)(kr,{open:a,onOpenChange:o,upcoming:c,pollCount:l,timeZone:e.timeZone,now:s})]}):(0,J.jsx)(`div`,{className:`p-5`,children:(0,J.jsx)($,{text:`Loading automations…`})}):(0,J.jsx)(`div`,{className:`p-5`,children:(0,J.jsx)($,{text:t})})]})}function Ir({mode:e=`list`}){let{automationId:t}=le(),n=D(),r=A(),i=pe(r.known&&!r.off),a=i.data?{...i.data,automations:i.data.automations.filter(e=>!e.deferredStart)}:void 0,o=he(a),[s,c]=E(),l=Lr(s.get(`view`));if(!r.known)return(0,J.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,J.jsx)($,{text:`Loading automations…`})});if(r.off)return(0,J.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,J.jsx)(vt,{icon:(0,J.jsx)(De,{}),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 u=()=>n(`/automations`);if(e===`new`)return(0,J.jsx)(Hn,{data:a,initialKind:Rr(s.get(`kind`)),onBack:u,onSaved:u});if(e===`edit`){let e=a?.automations.find(e=>e.id===t);return a&&!e?(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Automation not found.`})}):e?(0,J.jsx)(Hn,{data:a,automation:e,actions:o,onBack:u,onSaved:u,onLog:()=>n(`/automations/${encodeURIComponent(e.id)}/log`)}):(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Loading automation…`})})}if(e===`log`){let e=a?.automations.find(e=>e.id===t);return t?(0,J.jsx)(qn,{automationId:t,automation:e,timeZone:a?.timeZone,onBack:u}):(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Automation not found.`})})}return(0,J.jsx)(Fr,{data:a,error:i.error?String(i.error instanceof Error?i.error.message:i.error):void 0,actions:o,view:l,onViewChange:e=>c(t=>{let n=new URLSearchParams(t);return e===`list`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})})}function Lr(e){return e===`week`||e===`day`?e:`list`}function Rr(e){return e===`schedule`||e===`github`||e===`tracker`?e:void 0}function $({text:e}){return(0,J.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e})}export{Ir 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{Fa as r,Lt as i,M as a,Ma as o,Mr as s,Na as c,Nr as l,Zt as u,_r as d,er as f,fa as p,ii as ee,ja as m,oi as h,qi as g,qt as te,st as ne}from"./queries-DuK0966_.js";import{F as _,V as v,_t as y,ct as b,dt as x,ft as S,gt as C,lt as re,mt as ie,pt as ae,r as w,t as T,ut as oe}from"./button-CvGNeSK2.js";import{T as E,c as D,f as se,s as ce,t as O,w as le}from"./project-router-D1cfvRMs.js";import{S as k}from"./reference-chip-CtsLfBqz.js";import{O as ue,a as de,c as A,i as fe,l as pe,o as me,s as he,u as ge}from"./facet-filter-Da8GrBFp.js";import{a as _e,i as ve,n as ye,o as be,s as xe,t as Se}from"./use-now-B0-Ptg98.js";import{I as Ce,In as we,Nn as Te,_ as Ee,wn as De,y as j}from"./git-tab-loading-BDTXdXf1.js";import{t as Oe}from"./arrow-left-Cu-OWry7.js";import{J as ke,c as Ae,d as je,l as Me,z as Ne}from"./worktree-lifecycle-operation-BQzslyDx.js";import{r as Pe,t as Fe}from"./textarea-j1qucn9k.js";import{a as Ie,c as Le,d as Re,f as M,i as ze,l as Be,m as N,n as P,o as Ve,p as He,r as Ue,s as We,t as Ge,u as F}from"./automation-format-B75dbm8m.js";import{t as Ke}from"./chevron-left-BljO3yyN.js";import{f as qe}from"./tooltip-C34OZ7cS.js";import{t as Je}from"./chevron-right-BI-mPHJT.js";import{c as Ye,i as I,n as Xe,r as Ze,u as Qe}from"./icon-tooltip-fvgXmwzu.js";import{t as $e}from"./terminal-BxD7ogP7.js";import{h as et}from"./git-toolbar-BVr9ySuA.js";import{n as tt,t as nt}from"./settings-2--BmcnOGR.js";import{r as rt}from"./use-submit-shortcut-UO-A-v3S.js";import{n as it}from"./square-C1qtuP9d.js";import{t as at}from"./plus-BmtWnEOY.js";import{n as ot,o as L,r as st,t as ct}from"./collapsible-CsAABGPz.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-BkPaj7ys.js";import{t as R}from"./input-B1EhOSmt.js";import{i as z,r as _t}from"./token-metrics-BFQem18c.js";import{t as vt}from"./centered-state-6eXgMviZ.js";import{$ as yt,A as bt,B,F as xt,G as V,H,I as St,L as Ct,M as wt,N as Tt,P as Et,Q as Dt,R as U,U as W,V as G,W as Ot,d as kt,j as At,o as jt,r as Mt,z as K}from"./index-DAEQ8mCL.js";var Nt=_(`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`}]]),Pt=_(`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`}]]),Ft=_(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),It=_(`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`}]]),q=e(t(),1),J=n();function Lt({association:e,selected:t,onSelect:n,onRemove:r}){let i=m({queryKey:[`tracker`,v(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>h({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,J.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,J.jsx)(j,{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,J.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,c?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,J.jsx)(T,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,J.jsxs)(J.Fragment,{children:[!i.isPending&&!i.isFetching&&l.length===0?(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,J.jsx)(T,{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,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var Rt=[`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 zt(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function Bt(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function Vt(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function Ht(e){return e?.source===`skill`?{skill:e.ref,workflow:Ce,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var Ut=[2,5,10,15,30,60],Wt=[1,2,4,6,8],Gt={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},Kt={type:`daily`,hour:4,minute:0};function qt(){return{name:``,kind:`schedule`,schedule:{...Kt},events:[`issue.opened`],intervalSeconds:300,filters:{...Gt},prompt:``,workflow:Ce,skill:null,customSteps:null,runner:null,account:null,model:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var Y=e=>(e??[]).join(`, `);function Jt(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Yt(e){return{authors:Y(e.authors),assignees:Y(e.assignees),anyLabels:Y(e.anyLabels),allLabels:Y(e.allLabels),excludeLabels:Y(e.excludeLabels),changedLabels:Y(e.changedLabels),reviewers:Y(e.reviewers),lookbackDays:e.lookbackDays,maxRecords:e.maxRecords}}function Xt(e){let t=qt(),{task:n,filters:r}=e,i=Bt(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?Yt(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 Zt(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 Qt=e=>e===`claude`||e===`codex`||e===`junie`||e===`opencode`||e===`cursor`||e===`pi`||e===`copilot`;function $t(e,t){let n=Bt(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?Yt(t.filters):{...Gt},prompt:t.prompt,...t.steps?{skill:n,customSteps:n?null:t.steps,workflow:Ce}:Ht(t.workflow?{source:`workflow`,ref:t.workflow}:null),checkout:t.checkout,allowForkHeads:t.allowForkHeads,runner:t.runner!==void 0&&Qt(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&Qt(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 en(e){let t=ae(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};case`once`:return{type:`once`,hour:t.hour,minute:t.minute,...t.date?{date:t.date}:{}};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function tn(e){let t={prompt:e.prompt,...e.skill?{steps:zt(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:en(e.schedule),task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:nn(e.filters.lookbackDays,1,90),maxRecords:nn(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Jt(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:nn(n.lookbackDays,1,90),maxRecords:nn(n.maxRecords,1,100)},task:{...t,...e.checkout===void 0?{}:{checkout:e.checkout},...e.allowForkHeads===void 0?{}:{allowForkHeads:e.allowForkHeads}}}}function nn(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function rn(e){let t=tn(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 an=`([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})`,on=RegExp(`\\b(?:user|author|by)\\s+(?:\`@?${an}\`|@${an}(?![\\w/-]))`,`gi`),sn=[`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`],cn=new Set(`a an the this that these those any all each every some me my you your it its them their us our we he she they who whom which what someone anyone everyone others other pull pr prs issue issues review reviews reviewer reviewers request requests team teams user users human humans changes code now approval merge`.split(` `)),ln=`(?:\`@?${an}\`|@${an}(?![\\w/-]))`,un=RegExp(`\\breview(?:s|\\s+requests?)?\\s+(?:(?:is|are)\\s+)?(?:requested\\s+)?(?:for|from|of)\\s+(?:${ln}|${an}\\b(?![/@-]))`,`gi`),dn=RegExp(`\\b(?:requested\\s+)?reviewer\\s+${ln}`,`gi`),fn=RegExp(`${ln}\\s+(?:(?:is|are|gets?)\\s+)?requested\\s+as\\s+(?:a\\s+)?reviewer\\b`,`gi`);function pn(e){if(e.kind!==`github`)return[];let t=new Set([e.filters.authors,e.filters.assignees,e.filters.reviewers].flatMap(Jt).map(e=>e.replace(/^@/,``).toLowerCase())),n=new Map,r=(e,r)=>{let i=e?.toLowerCase();!e||!i||t.has(i)||n.has(i)||n.set(i,{login:e,field:r})};if(e.events?.some(e=>sn.includes(e)))for(let t of[un,dn,fn])for(let n of e.prompt.matchAll(t)){let e=n[1]??n[2]??n[3];e&&!cn.has(e.toLowerCase())&&r(e,`reviewers`)}for(let t of e.prompt.matchAll(on))r(t[1]??t[2],`authors`);return[...n.values()]}function mn(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var hn=e=>[1,2,3,4,6,8,12].includes(e);function gn({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,a]=(0,q.useState)(``),o=v(),s=m({queryKey:[`tracker`,o,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>ee({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),c=m({queryKey:[`tracker`,o,`automation-options`,i],enabled:!!i&&s.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>ee({...i?{search:i}:{},...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),l=i?c:s,u=s.data?.pages[0],d=u?.available?u:void 0,f=!!d&&!!e&&JSON.stringify(d.association)===JSON.stringify(e.association),p=f&&!!e?.events.length&&e.events.every(e=>d?.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,q.useEffect)(()=>(r(p),()=>r(!1)),[p,r]);let h=l.data?.pages.flatMap(e=>e.available?[e]:[])??[],g=[...new Map(h.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])),ne=(e?.targetStatusIds??[]).filter(e=>!g.some(t=>t.id===e)),_=[...new Map(h.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],y=e?.events.includes(`issue.status_changed`),b=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),x=y&&b?`Search tracker statuses and labels`:b?`Search tracker labels`:`Search tracker statuses`;return(0,J.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[s.isPending?(0,J.jsx)(`p`,{children:`Loading tracker events…`}):null,s.isError||u&&!u.available?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsxs)(`p`,{children:[u&&!u.available?u.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,J.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>void s.refetch(),children:`Retry`})]}):null,d?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{children:[d.association.kind===`jira`?`Jira`:`Linear`,` · `,d.association.externalName]}),e&&!f?(0,J.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,J.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:d.events.map(t=>(0,J.jsx)(j,{active:f&&e?.events.includes(t),"aria-pressed":f&&e?.events.includes(t),onClick:()=>{let r=f?e.events:[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a={...f?e:{},association:d.association,events:i};t===`issue.status_changed`&&!i.includes(t)&&delete a.targetStatusIds,n({trackerTrigger:a,...f?{}:{enabled:!1}})},children:t},t))}),f&&e?(0,J.jsx)(Lt,{association:d.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(d.association)):null,(0,J.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,J.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),d.limitations.map(e=>(0,J.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(R,{"aria-label":x,placeholder:x,value:i,onChange:e=>a(e.target.value)}),l.isFetching?(0,J.jsx)(`p`,{role:`status`,children:`Searching…`}):null,l.isError||l.data?.pages[0]&&!l.data.pages[0].available?(0,J.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,J.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>void l.refetch(),children:`Retry search`})]}):null,!l.isFetching&&l.data?.pages[0]?.available&&y&&g.length===0?(0,J.jsx)(`p`,{children:`No matching statuses.`}):null,!l.isFetching&&l.data?.pages[0]?.available&&b&&_.length===0?(0,J.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[g.map(t=>(0,J.jsx)(j,{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)),ne.map(t=>(0,J.jsxs)(j,{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,J.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:_.map(t=>(0,J.jsx)(j,{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,J.jsx)(T,{variant:`outline`,size:`sm`,disabled:l.isFetchingNextPage,onClick:()=>void l.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,J.jsxs)(U,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(G,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:Ut.map(e=>(0,J.jsxs)(B,{value:String(e),children:[e,` min`]},e))})]})]}),(0,J.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 _n({definition:e}){let t=(0,q.useMemo)(()=>ge(e),[e]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,J.jsx)(`span`,{className:`eyebrow text-soft-foreground`,children:`Copy as CLI`}),(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void me(t),children:[(0,J.jsx)(we,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,J.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-meta leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:t}),(0,J.jsxs)(`p`,{className:`mt-2 mb-0 text-meta leading-[1.5] text-soft-foreground`,children:[`The same definition the cockpit saves — `,(0,J.jsx)(`code`,{className:`text-meta`,children:`cez automation schema`}),` prints its shape.`]})]})}function vn({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=Wt.includes(n)?Wt:[...Wt,n].sort((e,t)=>e-t);return(0,J.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-ui text-muted-foreground`,children:[(0,J.jsxs)(V,{className:`text-ui font-medium text-foreground`,children:[(0,J.jsx)(tt,{"aria-hidden":`true`,className:w(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,J.jsx)(Ot,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i(e?{dispatch:!0}:{dispatch:!1,reviewChild:!1})})]}),t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,J.jsxs)(U,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:a.map(e=>(0,J.jsx)(B,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(V,{className:`text-ui font-normal text-muted-foreground`,children:[(0,J.jsx)(Ot,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,J.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-meta whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null]})}var yn={"pull_request.opened":`A pull request opens`,"issue.opened":`An issue opens`,"issue.labeled":`An issue gets a label`,"issue.unlabeled":`An issue loses a label`,"pull_request.reviewed":`A review is submitted`,"pull_request.review_requested":`A review is requested`,"pull_request.rereview_requested":`A re-review is requested`,"pull_request.closed":`A pull request closes`,"pull_request.merged":`A pull request merges`};function bn({events:e,intervalSeconds:t,filters:n,onChange:r}){let i=[`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].filter(e=>n[e].trim().length>0),[a,o]=(0,q.useState)(i.length>0||n.lookbackDays!==7||n.maxRecords!==25),s=(e,t)=>r({filters:{...n,[e]:t}}),c=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:Rt.filter(e=>n.includes(e))})},l=mn(e),u=l&&n.changedLabels.trim().length===0;return(0,J.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:Rt.map(t=>(0,J.jsxs)(j,{active:e.includes(t),"aria-pressed":e.includes(t),"aria-label":t,title:t,className:`h-8 gap-2 px-3`,onClick:()=>c(t),children:[yn[t],(0,J.jsx)(`span`,{className:`font-mono text-micro font-normal text-soft-foreground`,children:t})]},t))}),e.length===0?(0,J.jsx)(`p`,{className:`m-0 text-label text-danger`,children:`Pick at least one event.`}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-ui text-muted-foreground`,children:[`Checks GitHub every`,(0,J.jsxs)(U,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Poll interval`,className:`text-ui`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:Ut.map(e=>(0,J.jsxs)(B,{value:String(e),children:[e,` min`]},e))})]}),(0,J.jsxs)(`span`,{children:[`while this cockpit is open, looking back `,n.lookbackDays,` days, at most `,n.maxRecords,` records.`]})]}),(0,J.jsxs)(`p`,{"data-slot":`editor-github-how`,className:`-mt-2 m-0 text-label text-soft-foreground`,children:[`Through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL needed.`]}),(0,J.jsxs)(ct,{open:a,onOpenChange:o,children:[(0,J.jsx)(st,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-ui text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(qe,{"aria-hidden":`true`,className:w(`size-3 transition-transform`,a?``:`-rotate-90`)}),`Filters`,u?(0,J.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):i.length>0?(0,J.jsxs)(`span`,{className:`text-soft-foreground`,children:[`· `,i.length,` set`]}):(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`· authors, labels, reviewers`})]})}),(0,J.jsxs)(ot,{children:[(0,J.jsx)(`p`,{className:`m-0 pt-2 text-label text-soft-foreground`,children:`Only matching events start a task. Names in the prompt do not narrow it down; these do.`}),(0,J.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-3 sm:grid-cols-2`,children:[(0,J.jsx)(X,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>s(`authors`,e)}),(0,J.jsx)(X,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>s(`assignees`,e)}),(0,J.jsx)(X,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>s(`anyLabels`,e)}),(0,J.jsx)(X,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>s(`allLabels`,e)}),(0,J.jsx)(X,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>s(`excludeLabels`,e)}),(0,J.jsx)(X,{id:`filter-changed-labels`,label:l?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:u,onChange:e=>s(`changedLabels`,e)}),(0,J.jsx)(X,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>s(`reviewers`,e)}),(0,J.jsx)(xn,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>s(`lookbackDays`,e)}),(0,J.jsx)(xn,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>s(`maxRecords`,e)})]})]})]})]})}function X({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(V,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,J.jsx)(R,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-ui`})]})}function xn({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(V,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,J.jsx)(R,{id:e,type:`number`,min:r,max:i,value:n,onChange:e=>a(nn(Number(e.target.value),r,i)),className:`h-8 w-28 font-mono text-ui 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,J.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(jt,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,J.jsx)(kt,{pick:o,onChange:s,accounts:!0}),(0,J.jsx)(Ee,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,J.jsxs)(`span`,{className:`text-meta`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,J.jsx)(`span`,{className:`flex-1`}),(0,J.jsxs)(V,{className:`text-ui font-medium`,children:[`Autonomous`,(0,J.jsx)(Ot,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function Cn({className:e,...t}){return(0,J.jsx)(`span`,{"data-slot":`branch-chip`,className:w(`inline-block rounded-md bg-muted px-1.5 py-0.5 font-mono text-meta leading-[1.3] font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var wn=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`],[`once`,`Once`]],Tn=e=>String(e).padStart(2,`0`);function En(e){let t=Date.now()+864e5,n=C(t,e);return n?`${n.year}-${Tn(n.month)}-${Tn(n.day)}`:new Date(t).toISOString().slice(0,10)}function Dn({schedule:e,timeZone:t,onChange:n}){let r=ae(e),i=e=>{let{date:i,...a}=r,o={...a,...i?{date:i}:{},...e};o.type===`once`&&!o.date&&(o.date=En(t)),n(o)},a=r.type===`once`&&r.date!==null&&S({type:`once`,date:r.date,hour:r.hour,minute:r.minute},Date.now(),t)===null;return(0,J.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:wn.map(([e,t])=>(0,J.jsx)(j,{active:r.type===e,"aria-pressed":r.type===e,onClick:()=>i({type:e}),children:t},e))}),r.type===`weekly`?(0,J.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:re.map((e,t)=>(0,J.jsx)(j,{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===`once`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`on`,(0,J.jsx)(R,{type:`date`,"aria-label":`Date`,value:r.date??``,onChange:e=>{e.target.value&&i({date:e.target.value})},className:`w-40 font-mono`})]}):null,r.type===`hours`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`every`,(0,J.jsxs)(U,{value:String(r.every),onValueChange:e=>{let t=Number(e);hn(t)&&i({every:t})},children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Every N hours`,className:`text-ui`,children:(0,J.jsx)(H,{})}),(0,J.jsx)(K,{children:b.map(e=>(0,J.jsxs)(B,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`at`,(0,J.jsx)(R,{"aria-label":`Hour`,inputMode:`numeric`,value:Tn(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,J.jsx)(R,{"aria-label":`Minute`,inputMode:`numeric`,value:Tn(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,J.jsx)(`span`,{className:`font-mono text-xs`,children:t})]}),r.type===`once`?(0,J.jsx)(`p`,{"data-slot":`editor-once-note`,className:`m-0 text-xs ${a?`text-danger`:`text-soft-foreground`}`,children:a?`This time has passed — pick a later one to enable it.`:`Runs a single time, then pauses itself.`}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 font-mono text-xs text-soft-foreground`,children:[(0,J.jsx)(`span`,{children:`cron`}),(0,J.jsx)(Cn,{"data-slot":`editor-cron`,children:oe(e)})]})]})}var On={schedule:[`{{date}}`,`{{project}}`],github:[`{{github.url}}`,`{{github.title}}`,`{{github.number}}`,`{{github.author}}`,`{{github.labels}}`,`{{date}}`,`{{project}}`],tracker:[`{{tracker.key}}`,`{{tracker.title}}`,`{{tracker.url}}`,`{{tracker.status}}`,`{{date}}`,`{{project}}`]};function kn(e){return F({kind:e.kind,events:e.events,intervalSeconds:e.intervalSeconds,schedule:e.schedule,...e.trackerTrigger?{trackerTrigger:e.trackerTrigger}:{}})}function An(e,t){let n=kn(e),r=Vt(e),i=[`${r?`${r.source===`skill`?`skill`:`workflow`} ${r.ref}`:`a quick task`} on ${e.runner??`the default agent`}${e.model?` (${e.model})`:``}`];return i.push(e.autonomous?`autonomous`:`pausing when it needs you`),t&&e.dispatch&&i.push(`up to ${e.maxSubtasks} subtasks`),`${n.charAt(0).toUpperCase()+n.slice(1)}: ${i.join(`, `)}.`}function jn(e,t){return e.kind===`schedule`?!0:e.kind===`tracker`?t:e.events.length>0&&(!mn(e.events)||e.filters.changedLabels.trim().length>0)}function Mn(e,t){let n=[jn(e,t),e.prompt.trim().length>0,e.name.trim().length>0],r=n.indexOf(!1);return[{id:`when`,label:`When`},{id:`what`,label:`What`},{id:`live`,label:`Go live`}].map((e,t)=>({...e,state:n[t]&&(r===-1||t<r)?`done`:t===r||r===-1&&t===2?`current`:`next`}))}function Nn({lastRun:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){return(0,J.jsxs)(M,{flush:!0,"data-slot":`last-run-card`,className:`px-3.5 py-3`,children:[(0,J.jsx)(`div`,{className:`mb-2 eyebrow text-soft-foreground`,children:`Last run`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui`,children:[(0,J.jsx)(z,{tone:Le(e.status)}),We(e.status),(0,J.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:_t(e.ts,i)}),null]}),(0,J.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,J.jsxs)(T,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,J.jsx)(it,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}),n?(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,J.jsx)(It,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}var Pn=864e5;function Fn({kind:e,schedule:t,intervalSeconds:n,timeZone:r,now:i}){let[a,o]=(0,q.useState)(()=>Date.now());(0,q.useEffect)(()=>{if(i!==void 0)return;let e=setInterval(()=>o(Date.now()),6e4);return()=>clearInterval(e)},[i]);let s=i??a,c=(0,q.useMemo)(()=>{if(e!==`schedule`)return[];if(t.type===`once`){let e=S(t,s,r);return e===null?[]:[e]}return ie(t,s,s+9*Pn,r,5)},[e,t,s,r]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,J.jsx)(`div`,{className:`px-3.5 pb-2 eyebrow text-soft-foreground`,children:e===`schedule`?t.type===`once`?`Runs once`:`Next 5 runs`:`How it polls`}),e===`schedule`?c.length===0?(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:t.type===`once`?`This time has already passed.`:`Nothing in the next nine days.`}):c.map(e=>(0,J.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-ui`,children:[(0,J.jsx)(`span`,{className:`w-[82px] shrink-0 font-mono text-xs font-medium whitespace-nowrap text-foreground tabular-nums`,children:Ue(e,r)}),(0,J.jsx)(`span`,{className:`text-meta whitespace-nowrap text-soft-foreground`,children:Ie(e,s)})]},e)):(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,J.jsxs)(J.Fragment,{children:[`Checks the project tracker every `,Math.round(n/60),` min while this cockpit is open. No webhook or public URL required.`]}):(0,J.jsxs)(J.Fragment,{children:[`Checks GitHub every `,Math.round(n/60),` min while this cockpit is open, through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var In=[{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.`}],Ln=e=>[v(),`automation-templates`,e??``];function Rn({onPick:e}){let[t,n]=(0,q.useState)(`builtin`),r=ce(),i=c({queryKey:Ln(r),queryFn:({signal:e})=>l(r,{signal:e}),enabled:t===`mine`}),a=t===`builtin`?In.map(e=>({...e,key:e.name})):(i.data?.templates??[]).map(e=>({...Zt(e),key:`${e.project.id}:${e.id}`,when:F(e),project:e.project.name}));return(0,J.jsxs)(M,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,J.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,J.jsx)(zn,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,J.jsx)(zn,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,J.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`&&i.isPending?(0,J.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`Loading…`}):t===`mine`&&i.isError?(0,J.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-xs text-danger`,children:i.error.message}):a.length===0?(0,J.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`No automations in your other projects yet.`}):(0,J.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:a.map(t=>(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui font-semibold`,children:[t.kind===`github`?(0,J.jsx)(W,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,J.jsx)(yt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,J.jsx)(Cn,{className:`ml-auto`,children:t.project}):null]}),(0,J.jsx)(`div`,{className:`font-mono text-meta text-muted-foreground`,children:t.when}),(0,J.jsx)(`div`,{className:`line-clamp-2 text-xs leading-[1.45] text-soft-foreground`,children:t.prompt}),(0,J.jsx)(T,{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 zn({active:e,onClick:t,children:n}){return(0,J.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-ui font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function Bn(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 Vn={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`What should the agent do each time? Say it the way you would in New task.`,github:`What should the agent do for each match? Say it the way you would in New task.`};function Hn({data:e,automation:t,actions:n,initialKind:o,onBack:s,onSaved:c,onLog:l}){let ee=r(),m=D(),h=a(),g=te(),_=u(),v=i(),y=ne(),b=o===`github`&&e?.available===!1?`schedule`:o,[x,S]=(0,q.useState)(()=>t?Xt(t):b?{...qt(),kind:b,...b===`tracker`?{intervalSeconds:1800,enabled:!1}:{}}:qt()),[C,re]=(0,q.useState)(!t&&!b),[ie,ae]=(0,q.useState)(!1),[w,oe]=(0,q.useState)(!1),[E,se]=(0,q.useState)(null),[ce,O]=(0,q.useState)(!1),le=(0,q.useRef)(null),k=t?.revision,ue=(0,q.useRef)(k);(0,q.useEffect)(()=>{!t||k===ue.current||(ue.current=k,S(Xt(t)),O(!1),se(null))},[t,k]);let A=e=>S(t=>({...t,...e})),fe=e?.timeZone??`UTC`,pe=e?.available!==!1,me=h.data?.capabilities.dispatch===!0,he=(0,q.useMemo)(()=>Ae(je(g.data?.promptTemplates),h.data?.capabilities),[g.data?.promptTemplates,h.data?.capabilities]),ge=_.data?.workflows??[],_e=ge.map(e=>e.name),ve=v.data,ye=(ve??[]).map(e=>e.name),be=g.data?.skillUsage,xe=(0,q.useMemo)(()=>Ne(ve??[],be),[ve,be]),Se=v.data!==void 0&&_.data!==void 0&&!g.isPending,Ce=y.data?.baseBranch??y.data?.info?.branch??void 0,we=(0,q.useMemo)(()=>rn(x),[x]),Te=(0,q.useMemo)(()=>pn(x),[x]),Ee=e=>Te.filter(t=>t.field===e).map(e=>e.login),De=x.name.trim().length>0&&x.prompt.trim().length>0&&!w&&(x.kind!==`tracker`||ie),Pe=Mn(x,ie),Ie=An(x,me),Le=e=>{let t=le.current,n=t?.selectionStart??x.prompt.length,r=Me(x.prompt,n,e);A({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},Re=e=>{let t=le.current,n=t?.selectionStart??x.prompt.length,r=x.prompt.slice(0,n),i=x.prompt.slice(n),a=r.length>0&&!/\s$/.test(r)?` `:``,o=`${r}${a}${e}${i.length>0&&!/^\s/.test(i)?` `:``}${i}`,s=r.length+a.length+e.length;A({prompt:o}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(s,s))})},M=async()=>{oe(!0),se(null),O(!1);try{let e=tn(x);t?await p(t.id,{...e,enabled:x.enabled,expectedRevision:t.revision}):await d({...e,enable:x.enabled}),await ee.invalidateQueries({queryKey:de()}),c()}catch(e){if(t&&e instanceof f&&e.status===409)O(!0);else{let t=e instanceof Error?e.message:String(e);se({message:t,section:e instanceof f&&e.status===400?Bn(t):`top`})}}finally{oe(!1)}},ze=()=>void ee.invalidateQueries({queryKey:de()}),Be=t?`Save changes`:x.enabled?`Save and enable`:`Save paused`,N=`Change the kind by creating a new automation`,P=!!t,Ve=e=>{e!==x.kind&&A({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})};return(0,J.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,"data-onboarding":``,className:`flex min-h-full flex-col`,children:[(0,J.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,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:s,children:(0,J.jsx)(Oe,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,J.jsx)(L,{dot:t.enabled?`success`:`neutral`,children:t.enabled?`enabled`:`paused`}):null,(0,J.jsx)(`span`,{className:`flex-1`}),t?null:(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,"aria-expanded":C,"aria-label":C?`Hide templates`:`Start from a template`,onClick:()=>re(e=>!e),children:[(0,J.jsx)(Nt,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`max-md:hidden`,children:C?`Hide templates`:`Start from a template`})]}),(0,J.jsx)(T,{variant:`outline`,className:`font-normal`,onClick:s,children:`Cancel`}),(0,J.jsx)(T,{className:`font-normal`,disabled:!De,onClick:()=>void M(),children:Be})]}),(0,J.jsx)(`div`,{className:`flex justify-center px-5 pb-16`,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-3xl flex-col items-center`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-strip`,className:`sticky top-14 z-10 flex w-full flex-wrap items-center gap-x-6 gap-y-1.5 border-b border-border bg-background/95 py-2.5 backdrop-blur max-md:static`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 max-md:basis-full`,children:[(0,J.jsx)(`span`,{className:`shrink-0 text-ui text-muted-foreground`,"aria-hidden":`true`,children:`Name`}),(0,J.jsx)(R,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:x.name,onChange:e=>A({name:e.target.value}),className:`h-9 w-full max-w-md text-lead md:text-lead`})]}),(0,J.jsx)(Tt,{steps:Pe})]}),ce||E?.section===`top`||C&&!t?(0,J.jsxs)(`div`,{className:`mt-6 flex w-full flex-col gap-4`,children:[ce?(0,J.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-ui text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,J.jsx)(T,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:ze,children:`Reload`})]}):null,E?.section===`top`?(0,J.jsx)(Wn,{children:E.message}):null,C&&!t?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`p`,{className:`m-0 text-center text-ui text-muted-foreground`,children:`Start from a template, or fill in the three parts below.`}),(0,J.jsx)(Rn,{onPick:e=>{let t=e.workflow&&_e.includes(e.workflow)?e.workflow:void 0,n=e.steps?.every(e=>!e.skill||ye.includes(e.skill))?e.steps:void 0;S(r=>$t(r,{...e,workflow:t,steps:n})),re(!1)}})]}):null]}):null,(0,J.jsxs)(Un,{slot:`when`,title:`When`,why:P?`The trigger is fixed once saved; change it by creating a new automation.`:`What starts a run. Pick one, then say how often or on which change.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`grid gap-3 sm:grid-cols-3`,children:[(0,J.jsx)(xt,{value:`schedule`,title:`On a schedule`,description:`At a time you set.`,selected:x.kind===`schedule`,disabled:P&&x.kind!==`schedule`,reason:P&&x.kind!==`schedule`?N:void 0,onClick:()=>Ve(`schedule`),picture:(0,J.jsx)(Gn,{})}),(0,J.jsx)(xt,{value:`github`,title:`When GitHub changes`,description:`A pull request, an issue, a review.`,selected:x.kind===`github`,disabled:!pe||P&&x.kind!==`github`,reason:pe?P&&x.kind!==`github`?N:void 0:e?.reason??`GitHub is unavailable`,onClick:()=>Ve(`github`),picture:(0,J.jsx)(W,{className:`size-7 text-muted-foreground`,"aria-hidden":!0})}),(0,J.jsx)(xt,{value:`tracker`,title:`When Jira / Linear changes`,description:`An issue is created or moves.`,selected:x.kind===`tracker`,disabled:P&&x.kind!==`tracker`,reason:P&&x.kind!==`tracker`?N:void 0,onClick:()=>Ve(`tracker`),picture:(0,J.jsx)(Kn,{})})]}),(0,J.jsx)(`div`,{className:`mt-5`,children:x.kind===`schedule`?(0,J.jsx)(Dn,{schedule:x.schedule,timeZone:fe,onChange:e=>A({schedule:e})}):x.kind===`tracker`?(0,J.jsx)(gn,{trigger:x.trackerTrigger,intervalSeconds:x.intervalSeconds,onChange:A,onValid:ae}):(0,J.jsx)(bn,{events:x.events,intervalSeconds:x.intervalSeconds,filters:x.filters,onChange:e=>A(e)})}),x.kind===`schedule`?(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(Fn,{kind:x.kind,schedule:x.schedule,intervalSeconds:x.intervalSeconds,timeZone:fe})}):null,E?.section===`when`?(0,J.jsx)(Wn,{children:E.message}):null]}),(0,J.jsxs)(Un,{slot:`what`,title:`What the agent does`,why:`The same words you would type into New task. Placeholders fill in per run.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-placeholders`,className:`flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[`Insert`,On[x.kind].map(e=>(0,J.jsx)(j,{className:`h-6 font-mono text-meta`,title:`Insert ${e} at the caret`,onClick:()=>Re(e),children:e},e))]}),(0,J.jsx)(Fe,{ref:le,"aria-label":`Prompt`,rows:5,placeholder:Vn[x.kind],value:x.prompt,onChange:e=>A({prompt:e.target.value}),className:`mt-3 min-h-[120px] rounded-xl px-4 py-3 text-lead leading-[1.55] md:text-lead`}),(0,J.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,J.jsx)(ke,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,he.map(e=>(0,J.jsx)(j,{className:`h-6 text-meta`,title:e.text,onClick:()=>Le(e.text),children:e.label},e.id)),(0,J.jsx)(j,{dashed:!0,className:`h-6 text-meta`,icon:(0,J.jsx)(nt,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>m(`${Mt(`project`,`instructions`)}#prompt-templates`),children:`Manage…`})]}),Te.length>0?(0,J.jsxs)(`div`,{role:`status`,"data-slot":`editor-prompt-condition`,className:`mt-3 flex flex-wrap items-center gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-label text-foreground`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`The prompt names `,Te.map(({login:e})=>`@${e}`).join(`, `),`, but prompt text does not decide what launches — without a filter every matching event starts a task.`]}),[`authors`,`reviewers`].map(e=>Ee(e).length>0?(0,J.jsx)(T,{variant:`outline`,size:`sm`,onClick:()=>A({filters:{...x.filters,[e]:[...Jt(x.filters[e]),...Ee(e)].join(`, `)}}),children:e===`authors`?`Add to Authors`:`Add to Reviewers`},e):null)]}):null,(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(Sn,{source:Vt(x),sourcesReady:Se,skills:xe,skillUsage:be,workflows:ge,onSource:e=>A(Ht(e)),pick:{runner:x.runner,model:x.model,account:x.account},onPick:e=>A({runner:e.runner,model:e.model,account:e.account}),baseBranch:Ce,autonomous:x.autonomous,onAutonomous:e=>A({autonomous:e})})}),(0,J.jsx)(`p`,{className:`mt-3 mb-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,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(vn,{available:me,enabled:x.dispatch,maxSubtasks:x.maxSubtasks,reviewChild:x.reviewChild,onChange:e=>A(e)})}),E?.section===`what`?(0,J.jsx)(Wn,{children:E.message}):null]}),(0,J.jsxs)(Un,{slot:`live`,title:`Go live`,why:`Paused, it waits in the list where you can preview it. Enabled, it starts counting from now.`,children:[(0,J.jsx)(`p`,{"data-slot":`editor-summary`,className:`m-0 rounded-xl border border-violet/40 bg-violet/10 px-4 py-3 text-body text-foreground`,children:Ie}),(0,J.jsxs)(V,{className:`mt-4 flex items-start gap-3 text-ui font-normal`,children:[(0,J.jsx)(Ot,{"aria-label":`Enabled`,checked:x.enabled,onCheckedChange:e=>A({enabled:e}),className:`mt-0.5`}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-body text-foreground`,children:`Enabled`}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:x.kind===`schedule`?x.enabled?`Runs at the next time listed above.`:`Saved paused. Enable it from the list, or Run now to try it once.`:`Counts from a current-time baseline; existing matches will not launch.`})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3`,children:[(0,J.jsx)(_n,{definition:we}),t&&t.kind!==`schedule`&&n?(0,J.jsx)(T,{variant:`outline`,className:`self-start font-normal`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t?.lastRun?(0,J.jsx)(Nn,{lastRun:t.lastRun,busy:n?.busy,onRunNow:()=>void n?.runNow(t),onLog:l}):null]})]})]})})]})}function Un({slot:e,title:t,why:n,children:r}){return(0,J.jsxs)(`section`,{"data-slot":`editor-section`,"data-section":e,className:`mt-7 w-full border-t border-border pt-6 first-of-type:mt-6 first-of-type:border-t-0 first-of-type:pt-0`,children:[(0,J.jsx)(`h2`,{className:`text-xl font-light tracking-tight text-foreground`,children:t}),(0,J.jsx)(`p`,{className:`mt-1 mb-5 text-ui text-muted-foreground`,children:n}),r]})}function Wn({children:e}){return(0,J.jsx)(`div`,{role:`alert`,className:w(`mt-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-ui text-foreground`),children:e})}function Gn(){return(0,J.jsxs)(`span`,{className:`flex w-12 flex-col gap-1`,children:[(0,J.jsxs)(`span`,{className:`flex items-center justify-between rounded-md border border-violet bg-violet/15 px-1 py-0.5 font-mono text-[7px] text-foreground`,children:[`09:00`,(0,J.jsx)(`span`,{className:`size-1 rounded-full bg-violet`})]}),(0,J.jsxs)(`span`,{className:`flex items-center justify-between rounded-md border border-border px-1 py-0.5 font-mono text-[7px] text-muted-foreground`,children:[`16:00`,(0,J.jsx)(`span`,{className:`size-1 rounded-full bg-muted-foreground/50`})]})]})}function Kn(){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-[7px]`,children:[(0,J.jsx)(`span`,{className:`rounded border border-border px-1 py-0.5 text-muted-foreground`,children:`To do`}),(0,J.jsx)(`span`,{className:`h-px w-1.5 bg-violet`}),(0,J.jsx)(`span`,{className:`rounded border border-violet bg-violet/15 px-1 py-0.5 text-foreground`,children:`Ready`})]})}function qn({automationId:e,automation:t,timeZone:n,onBack:i}){let a=D(),l=r(),u=v(),d=(0,q.useMemo)(()=>[u,`automation-log`,e],[u,e]),f=c({queryKey:d,queryFn:({signal:t})=>s(e,{signal:t})}),[p,ee]=(0,q.useState)(`all`),[m,h]=(0,q.useState)(`all`);(0,q.useEffect)(()=>ue((t,n)=>{t===`automation-change`&&n.automationId===e&&l.invalidateQueries({queryKey:d})}),[e,l,d]);let te=o({mutationFn:e=>g(e),onSuccess:()=>l.invalidateQueries({queryKey:d}),onError:e=>se(e instanceof Error?e.message:String(e),{tone:`danger`})}),ne=n??`UTC`,_=f.data?.records.filter(e=>(p===`all`||e.result===p)&&(m===`all`||e.event===m));return(0,J.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-log`,className:`flex min-h-full flex-col`,children:[(0,J.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,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:i,children:(0,J.jsx)(Oe,{className:`size-[15px]`})}),(0,J.jsx)(`h1`,{className:`m-0 text-base font-semibold`,children:t?t.name:`Automation`}),(0,J.jsx)(`span`,{className:`text-ui text-muted-foreground`,children:`· execution log`}),(0,J.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2`,children:[(0,J.jsxs)(U,{value:p,onValueChange:e=>ee(e),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Filter by result`,className:`text-label`,children:(0,J.jsx)(H,{placeholder:`All results`})}),(0,J.jsxs)(K,{children:[(0,J.jsx)(B,{value:`all`,children:`All results`}),Jn.map(e=>(0,J.jsx)(B,{value:e,children:e},e))]})]}),(0,J.jsxs)(U,{value:m,onValueChange:e=>h(e),children:[(0,J.jsx)(G,{size:`sm`,"aria-label":`Filter by event`,className:`text-label`,children:(0,J.jsx)(H,{placeholder:`All events`})}),(0,J.jsxs)(K,{children:[(0,J.jsx)(B,{value:`all`,children:`All events`}),Yn.map(e=>(0,J.jsx)(B,{value:e,children:e},e))]})]})]}),(0,J.jsxs)(T,{variant:`outline`,size:`sm`,onClick:()=>a(`/automations/${encodeURIComponent(e)}`),children:[(0,J.jsx)(rt,{className:`size-[13px]`}),`Edit`]})]}),(0,J.jsx)(`div`,{className:`flex justify-center p-5`,children:f.isError?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:f.error instanceof Error?f.error.message:String(f.error)})}):_===void 0?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:`Loading execution log…`})}):_.length===0?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:`No checks have run yet.`})}):(0,J.jsx)(M,{flush:!0,className:`w-full max-w-[820px]`,children:_.map((e,t)=>(0,J.jsx)(Zn,{record:e,run:e.runId===void 0?void 0:f.data?.runs[e.runId],last:t===_.length-1,timeZone:ne,retrying:te.isPending&&te.variables===e.receiptId,onRetry:e=>te.mutate(e)},e.seq))})})]})}var Jn=[`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`manual`,`catch-up`,`skipped`,`failed`],Yn=[`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 Xn(e){return e.result===`failed`&&e.runId===void 0?e.receiptId:void 0}function Zn({record:e,run:t,last:n,timeZone:r,retrying:i,onRetry:a}){let o=Ve(e.result),s=t?.children??[],c=Xn(e);return(0,J.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-ui ${n?``:`border-b border-border`}`,children:[(0,J.jsx)(`span`,{className:`font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:ze(e.ts,r)}),(0,J.jsx)(L,{dot:o,className:`w-fit`,children:e.result}),(0,J.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,J.jsx)(`span`,{}):(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a(c),children:[(0,J.jsx)(Dt,{className:`size-3`}),`Retry task`]}):(0,J.jsx)(T,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,J.jsxs)(O,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open task`,(0,J.jsx)(k,{className:`size-3`})]})}),s.length>0?(0,J.jsx)(`div`,{className:`col-span-full flex flex-col gap-1 pl-3.5`,children:s.map(e=>(0,J.jsxs)(`div`,{"data-slot":`log-child`,className:`grid grid-cols-[14px_70px_1fr_auto] items-center gap-2.5 text-label`,children:[(0,J.jsx)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:`└`}),(0,J.jsx)(`span`,{className:`w-fit rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:e.kind??`implement`}),(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(z,{tone:Le(e.status)}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.title})]}),null,(0,J.jsx)(T,{variant:`ghost`,size:`sm`,className:`h-6`,asChild:!0,children:(0,J.jsxs)(O,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open`,(0,J.jsx)(k,{className:`size-[11px]`})]})})]},e.runId))}):null]})}function Qn({data:e}){let t=D(),[n,r]=q.useState(!1),i=e.available===!1,a=e=>t(`/automations/new?kind=${e}`);return(0,J.jsxs)(wt,{wide:!0,slot:`automations`,title:`Let the routine run itself`,why:`An automation is a prompt cezar turns into a task on its own: at a time you set, when something happens on GitHub, or when an issue moves in Jira or Linear.`,children:[(0,J.jsxs)(`div`,{"data-slot":`automation-triggers`,className:`mt-8 grid w-full gap-3 sm:grid-cols-3`,children:[(0,J.jsx)(bt,{title:`On a schedule`,description:`Every weekday at 9:00, Fridays at 16:00, every six hours.`,recommended:!0,onClick:()=>a(`schedule`),picture:(0,J.jsx)(ir,{})}),(0,J.jsx)(bt,{title:`When GitHub changes`,description:i?`Sign in to the GitHub CLI first.`:`A new pull request, an issue labelled, a review requested.`,onClick:()=>i?t(`/github`):a(`github`),picture:i?(0,J.jsx)(W,{className:`size-9 text-muted-foreground`,"aria-hidden":!0}):(0,J.jsx)(ar,{})}),(0,J.jsx)(bt,{title:`When an issue moves`,description:`A Jira or Linear issue is created or changes status.`,onClick:()=>a(`tracker`),picture:(0,J.jsx)(or,{})})]}),(0,J.jsx)(`ol`,{"data-slot":`automation-steps`,className:`mt-10 grid w-full gap-6 text-left sm:grid-cols-3`,children:$n.map((e,t)=>(0,J.jsxs)(`li`,{className:`flex gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 grid size-6 shrink-0 place-items-center rounded-full border border-violet font-mono text-meta text-foreground`,"aria-hidden":`true`,children:t+1}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-lead text-foreground`,children:e.title}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:e.body})]})]},e.title))}),(0,J.jsxs)(`div`,{className:`mt-10 flex flex-col items-center gap-4`,children:[(0,J.jsx)(T,{asChild:!0,className:`font-normal`,children:(0,J.jsxs)(O,{to:`/automations/new`,children:[(0,J.jsx)(at,{className:`size-[15px]`,"aria-hidden":`true`}),`New automation`]})}),(0,J.jsxs)(`button`,{type:`button`,className:Ct,onClick:()=>r(!0),children:[(0,J.jsx)(He,{className:`size-3.5`,"aria-hidden":`true`}),`See it in pictures`]})]}),n?(0,J.jsx)(tr,{onOpenChange:r}):null]})}var $n=[{title:`Write it as a prompt`,body:`Say what the agent should do each time. Placeholders such as {{github.url}} or {{date}} fill in per run.`},{title:`Preview, then enable`,body:`A new automation starts paused. A poll shows what it would have matched, a schedule shows its next runs. Enable it when that looks right.`},{title:`Every run is a task`,body:`Each match starts an ordinary task in its own worktree. It ends at the review gate, never merges on its own, and the log keeps every run.`}];function er(){let[e,t]=q.useState(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(T,{variant:`ghost`,size:`sm`,"data-slot":`automations-guide`,"aria-label":`How automations work`,className:`text-muted-foreground`,onClick:()=>t(!0),children:[(0,J.jsx)(He,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`max-md:hidden`,children:`How it works`})]}),e?(0,J.jsx)(tr,{onOpenChange:t}):null]})}function tr({onOpenChange:e}){let t=D();return(0,J.jsx)(At,{slot:`automations-guide-page`,title:`How automations work`,description:`Four things to know.`,pages:[{id:`prompt`,title:`A prompt that runs itself`,body:`An automation is the same thing you type into New task, kept and run for you. Placeholders fill in what changed: the pull request, the issue, the date.`,picture:(0,J.jsx)(sr,{})},{id:`triggers`,title:`Three ways to start`,body:`On a schedule, when GitHub changes, or when an issue moves in Jira or Linear. A GitHub or tracker automation polls every few minutes and starts one task per match.`,picture:(0,J.jsx)(cr,{})},{id:`paused`,title:`Paused first, then live`,body:`A new automation is paused. Preview shows what it would have matched, or when it runs next. Enable it when that looks right, and pause it again any time.`,picture:(0,J.jsx)(lr,{})},{id:`tasks`,title:`Every run is a task`,body:`Each run shows up in the task list like one you started yourself, in its own worktree, ending at the review gate. The automation’s log keeps every run.`,picture:(0,J.jsx)(ur,{}),action:{label:`New automation`,onClick:()=>t(`/automations/new`)}}],onOpenChange:e})}var nr=`flex items-center gap-2 rounded-md px-2 py-1 text-micro`;function rr({on:e=!0}){return(0,J.jsx)(`span`,{className:w(`flex h-3.5 w-6 items-center rounded-full px-0.5`,e?`justify-end bg-violet`:`justify-start bg-muted-foreground/40`),children:(0,J.jsx)(`span`,{className:`size-2.5 rounded-full bg-background`})})}function ir(){return(0,J.jsx)(`span`,{className:`flex w-20 flex-col gap-1`,children:[`Mon 09:00`,`Fri 16:00`].map((e,t)=>(0,J.jsxs)(`span`,{className:w(`flex items-center justify-between rounded-md border px-1.5 py-1 font-mono text-[9px]`,t===0?`border-violet bg-violet/15 text-foreground`:`border-border text-muted-foreground`),children:[e,(0,J.jsx)(`span`,{className:w(`size-1.5 rounded-full`,t===0?`bg-violet`:`bg-muted-foreground/50`)})]},e))})}function ar(){return(0,J.jsxs)(`span`,{className:`flex w-20 flex-col gap-1.5`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-violet bg-violet/15 px-1.5 py-1`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`}),(0,J.jsx)(`span`,{className:`h-1 flex-1 rounded bg-violet/60`}),(0,J.jsx)(`span`,{className:`rounded-sm bg-violet/40 px-1 text-[7px] text-foreground`,children:`PR`})]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-border px-1.5 py-1`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`}),(0,J.jsx)(`span`,{className:`h-1 w-2/3 rounded bg-muted`})]})]})}function or(){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[9px]`,children:[(0,J.jsx)(`span`,{className:`rounded-md border border-border px-1.5 py-1 text-muted-foreground`,children:`To do`}),(0,J.jsx)(`span`,{className:`h-px w-3 bg-violet`}),(0,J.jsx)(`span`,{className:`rounded-md border border-violet bg-violet/15 px-1.5 py-1 text-foreground`,children:`Ready`})]})}function sr(){return(0,J.jsxs)(Et,{bar:(0,J.jsx)(`span`,{className:`ml-3 text-micro text-soft-foreground`,children:`What to run`}),children:[(0,J.jsxs)(`p`,{className:`text-meta leading-relaxed text-foreground`,children:[`Review `,(0,J.jsx)(`span`,{className:`rounded-sm bg-violet/15 px-1 text-violet`,children:`{{github.url}}`}),` for real issues only and leave one comment per finding.`]}),(0,J.jsx)(`div`,{className:w(St,`mt-3 w-1/2`)})]})}function cr(){return(0,J.jsx)(Et,{children:[`Every weekday at 9:00`,`When a pull request opens`,`When PROJ-42 reaches Ready`].map((e,t)=>(0,J.jsxs)(`div`,{style:{"--i":t},className:w(nr,`tip-rise justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(rr,{})]},e))})}function lr(){return(0,J.jsxs)(Et,{children:[(0,J.jsxs)(`div`,{className:w(nr,`justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:`Triage new issues`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-[9.5px] text-soft-foreground`,children:[`paused`,(0,J.jsx)(rr,{on:!1})]})]}),(0,J.jsx)(`div`,{style:{"--i":2},className:`tip-rise mt-2 rounded-md border border-violet/50 bg-violet/10 px-2 py-1.5 text-micro text-foreground`,children:`Preview: would have matched 3 issues this week`}),(0,J.jsxs)(`div`,{style:{"--i":5},className:w(nr,`tip-rise mt-2 justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:`Triage new issues`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-[9.5px] text-violet`,children:[`enabled`,(0,J.jsx)(rr,{})]})]})]})}function ur(){return(0,J.jsx)(Et,{bar:(0,J.jsx)(`span`,{className:`ml-3 text-micro text-soft-foreground`,children:`Tasks`}),children:[[`needs review`,`Triage issue 412: missing repro`,`text-violet`],[`running`,`Nightly dependency bump`,`text-success`],[`done`,`Weekly changelog draft`,`text-muted-foreground`]].map(([e,t,n],r)=>(0,J.jsxs)(`div`,{style:{"--i":r},className:w(nr,`tip-rise text-foreground`),children:[(0,J.jsx)(`span`,{className:w(`w-16 shrink-0 text-[9.5px]`,n),children:e}),(0,J.jsx)(`span`,{className:`truncate`,children:t})]},t))})}function dr({automation:e,actions:t}){let n=D(),[r,i]=(0,q.useState)(!1),a=e=>e.stopPropagation(),o=`/automations/${encodeURIComponent(e.id)}`;return(0,J.jsxs)(`span`,{"data-slot":`row-actions`,className:`inline-flex gap-0.5`,onClick:a,children:[e.kind===`schedule`?null:(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,title:`Preview matches`,"aria-label":`Preview matches`,disabled:t.busy,onClick:()=>void t.preview(e),children:(0,J.jsx)(et,{className:`size-[13px]`})}),(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,title:`Run now`,"aria-label":`Run now`,disabled:t.busy,onClick:()=>void t.runNow(e),children:(0,J.jsx)(it,{className:`size-[13px]`})}),(0,J.jsx)(T,{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,J.jsx)(Pt,{className:`size-[13px]`}):(0,J.jsx)(Ft,{className:`size-[13px]`})}),(0,J.jsxs)(Xe,{children:[(0,J.jsx)(Qe,{asChild:!0,children:(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`More`,children:(0,J.jsx)(Te,{className:`size-3.5`})})}),(0,J.jsxs)(Ze,{align:`end`,className:`w-[200px]`,onClick:a,children:[(0,J.jsxs)(I,{onSelect:()=>n(o),children:[(0,J.jsx)(rt,{}),`Edit`]}),(0,J.jsxs)(I,{onSelect:()=>n(`${o}/log`),children:[(0,J.jsx)(It,{}),`View log`]}),(0,J.jsxs)(I,{onSelect:()=>void t.duplicate(e),children:[(0,J.jsx)(we,{}),`Duplicate`]}),(0,J.jsxs)(I,{onSelect:()=>void t.copyCli(e),children:[(0,J.jsx)($e,{}),`Copy as CLI`]}),(0,J.jsx)(Ye,{}),(0,J.jsxs)(I,{variant:`destructive`,onSelect:()=>i(!0),children:[(0,J.jsx)(Pe,{}),`Delete`]})]})]}),(0,J.jsx)(gt,{open:r,onOpenChange:i,children:(0,J.jsxs)(dt,{onClick:a,children:[(0,J.jsxs)(ht,{children:[(0,J.jsxs)(ut,{children:[`Delete “`,e.name,`”?`]}),(0,J.jsx)(lt,{children:`The automation is removed for good. Tasks it already launched and its execution log stay.`})]}),(0,J.jsxs)(pt,{children:[(0,J.jsx)(mt,{children:`Cancel`}),(0,J.jsx)(ft,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>void t.remove(e),children:`Delete`})]})]})})]})}var Z=`h-[38px] border-b border-border px-[10px] text-left eyebrow whitespace-nowrap text-soft-foreground`,Q=`h-12 border-b border-border px-[10px] text-ui leading-none whitespace-nowrap`,fr=`cz-auto-wide max-[1280px]:hidden`,pr=(0,J.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`});function mr({data:e,actions:t,now:n=Date.now()}){return(0,J.jsx)(M,{flush:!0,"data-slot":`automations-table`,className:`min-w-0 overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`w-full border-collapse [&_tbody_tr:last-child>td]:border-b-0`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:w(Z,`pl-4`),children:`State`}),(0,J.jsx)(`th`,{className:Z,children:`Automation`}),(0,J.jsx)(`th`,{className:Z,children:`Trigger`}),(0,J.jsx)(`th`,{className:w(Z,fr),children:`Runs as`}),(0,J.jsx)(`th`,{className:Z,children:`Next run`}),(0,J.jsx)(`th`,{className:Z,children:`Last run`}),(0,J.jsx)(`th`,{className:w(Z,fr,`text-right`),children:`Runs 7d`}),null,(0,J.jsx)(`th`,{className:w(Z,`pr-4`)})]})}),(0,J.jsx)(`tbody`,{children:e.automations.map(r=>(0,J.jsx)(hr,{automation:r,actions:t,timeZone:e.timeZone,available:e.available,showCost:!1,now:n},r.id))})]})})}function hr({automation:e,actions:t,timeZone:n,available:r,showCost:i,now:a}){let o=D(),s=e.kind===`github`,c=s&&!r,l=e.task.dispatch,u=F(e),d=[e.task.workflow,e.task.runner].filter(Boolean);return(0,J.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,J.jsx)(`td`,{className:w(Q,`pl-4`),children:c?(0,J.jsx)(L,{dot:`neutral`,children:`paused by capability`}):(0,J.jsx)(L,{dot:e.enabled?`success`:`neutral`,pulse:e.enabled&&s,children:e.enabled?`enabled`:`paused`})}),(0,J.jsx)(`td`,{className:w(Q,`max-w-0 min-w-[200px]`),children:(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[s?(0,J.jsx)(W,{className:`size-3.5 shrink-0 text-soft-foreground`}):e.kind===`tracker`?(0,J.jsx)(De,{className:`size-3.5 shrink-0 text-soft-foreground`}):(0,J.jsx)(yt,{className:`size-3.5 shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ui font-medium text-ellipsis whitespace-nowrap`,children:e.name}),l?(0,J.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-micro font-medium text-muted-foreground`,children:[(0,J.jsx)(tt,{className:`size-2.5`}),`×`,l.maxSubtasks??1]}):null]})}),(0,J.jsx)(`td`,{className:w(Q,`max-w-[260px] overflow-hidden font-mono text-xs text-ellipsis text-muted-foreground`),title:u,children:u}),(0,J.jsx)(`td`,{className:w(Q,fr,`text-xs text-muted-foreground`),children:d.length?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[d.map((e,t)=>(0,J.jsxs)(`span`,{className:`contents`,children:[t>0?(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}):null,e]},e)),e.task.autonomous?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsx)(`span`,{title:`autonomous`,"data-slot":`autonomous-mark`,className:`inline-flex`,children:(0,J.jsx)(De,{"aria-hidden":`true`,className:`size-[11px] text-soft-foreground`})})]}):null]}):pr}),(0,J.jsx)(`td`,{"data-slot":`next-run`,className:w(Q,`font-mono text-xs tabular-nums`,e.enabled?`text-foreground`:`text-soft-foreground`),children:gr(e,n,a)}),(0,J.jsx)(`td`,{className:Q,children:e.lastRun?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,J.jsx)(z,{tone:Le(e.lastRun.status)}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:We(e.lastRun.status)}),(0,J.jsx)(`span`,{className:`text-meta text-soft-foreground`,children:_t(e.lastRun.ts,a)}),(0,J.jsxs)(O,{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-micro font-semibold text-violet`,children:[`task`,(0,J.jsx)(k,{className:`size-[9px]`})]})]}):pr}),(0,J.jsx)(`td`,{className:w(Q,fr,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.runs7d}),i?(0,J.jsx)(`td`,{className:w(Q,fr,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.costUsd7d===void 0?pr:Re(e.costUsd7d)}):null,(0,J.jsx)(`td`,{className:w(Q,`pr-3 text-right`),children:(0,J.jsx)(dr,{automation:e,actions:t})})]})}function gr(e,t,n){if(!e.enabled)return`—`;if(e.kind!==`schedule`)return`continuous`;if(e.nextRunAt)return Ue(e.nextRunAt,t)||`—`;let r=e.schedule?S(e.schedule,n,t):null;return r===null?`—`:Ue(r,t)||`—`}function _r(e){return e.hour*60+e.minute}function vr(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 y(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),0,0,t)}function yr(e,t,n,r){let i=[];for(let a of e)if(!(a.kind!==`schedule`||!a.schedule))for(let e of ie(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 br(e){let t=new Map;return e.map(e=>{let n=_r(e.parts),r=t.get(n)??0;return t.set(n,r+1),{occurrence:e,stack:r}})}function xr({automation:e,minute:t,stack:n=0,wide:r=!1}){let i=D(),a=x(Math.floor(t/60),t%60),o=[e.task.workflow,e.task.runner].filter(Boolean).join(` · `);return(0,J.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-meta 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,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(z,{tone:e.task.runner===`codex`?`violet`:`success`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),r?(0,J.jsxs)(`span`,{className:`max-w-full overflow-hidden font-mono text-micro leading-[1.3] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:[a,o?` · ${o}`:``]}):null]})}function Sr(){return(0,J.jsx)(`div`,{"data-slot":`hour-gutter`,className:`w-12 shrink-0`,children:Array.from({length:24},(e,t)=>(0,J.jsx)(`div`,{className:`-translate-y-[6px] pr-2 text-right font-mono text-micro text-soft-foreground`,style:{height:34},children:t?x(t):``},t))})}function Cr({minute:e}){return(0,J.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,J.jsx)(`span`,{className:`absolute -top-[3px] -left-[3px] size-[8px] rounded-full bg-primary`})})}function wr(){return(0,J.jsx)(J.Fragment,{children:Array.from({length:24},(e,t)=>(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 h-px bg-border`,style:{top:t*34}},t))})}function Tr({automations:e}){let t=e.filter(e=>e.kind===`github`&&e.enabled);return t.length?(0,J.jsxs)(`div`,{"data-slot":`poll-band`,className:`grid grid-cols-[48px_minmax(0,1fr)] border-b border-border`,children:[(0,J.jsx)(`div`,{className:`py-2 pr-2 text-right font-mono text-micro text-soft-foreground`,children:`poll`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1 border-l border-border px-2 py-1.5`,children:t.map(e=>(0,J.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-meta font-medium`,children:[(0,J.jsx)(W,{className:`size-3 shrink-0 text-violet`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name}),(0,J.jsx)(`span`,{className:`overflow-hidden font-mono text-micro font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:F(e)}),(0,J.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-micro font-normal whitespace-nowrap text-soft-foreground`,children:[e.runs7d,` runs`]})]},e.id))})]}):null}var Er=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Dr({data:e}){let t=Se(6e4),n=D(),[r,i]=(0,q.useState)(0),a=e.timeZone,o=vr(t,a,r),s=vr(t,a,r+1),c=o===null?null:C(o,a),l=C(t,a);if(o===null||s===null||!c||!l)return(0,J.jsx)(`div`,{"data-slot":`day-view`,className:`p-5`,children:(0,J.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=br(yr(e.automations,o,s,a)),f=e.automations.filter(e=>e.kind===`github`&&e.enabled),p=`${P(c.weekday)} ${c.day} ${Er[c.month-1]??``}`;return(0,J.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,J.jsxs)(M,{flush:!0,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3.5 py-2.5`,children:[(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous day`,onClick:()=>i(e=>e-1),children:(0,J.jsx)(Ke,{className:`size-3.5`})}),(0,J.jsx)(T,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next day`,onClick:()=>i(e=>e+1),children:(0,J.jsx)(Je,{className:`size-3.5`})}),(0,J.jsx)(`span`,{"data-slot":`day-title`,className:`text-sm font-semibold whitespace-nowrap`,children:p}),u?(0,J.jsx)(L,{dot:`success`,children:`today`}):null,(0,J.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,J.jsx)(Tr,{automations:e.automations}),(0,J.jsxs)(`div`,{className:`flex max-h-[600px] overflow-y-auto`,children:[(0,J.jsx)(Sr,{}),(0,J.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,J.jsx)(wr,{}),u?(0,J.jsx)(Cr,{minute:_r(l)}):null,d.map(({occurrence:e,stack:t})=>(0,J.jsx)(xr,{automation:e.automation,minute:_r(e.parts),stack:t,wide:!0},`${e.automation.id}-${e.at}`))]})]})]}),(0,J.jsxs)(M,{flush:!0,"data-slot":`agenda`,className:`py-3`,children:[(0,J.jsx)(`div`,{className:`px-3.5 pb-2 eyebrow text-soft-foreground`,children:`Agenda`}),f.map(e=>(0,J.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,J.jsx)(`span`,{className:`font-mono text-micro font-medium text-soft-foreground`,children:`poll`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-ui font-medium`,children:[(0,J.jsx)(W,{className:`size-3 shrink-0 text-violet`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),(0,J.jsxs)(`span`,{className:`mt-0.5 block overflow-hidden font-mono text-meta leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:[F(e),` · continuous`]})]})]},e.id)),d.map(({occurrence:e})=>{let r=e.at<t,{automation:i}=e;return(0,J.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,J.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,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:w(`flex items-center gap-2 text-ui font-medium`,r&&`text-muted-foreground`),children:[(0,J.jsx)(z,{tone:r&&i.lastRun?Le(i.lastRun.status):`neutral`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:i.name})]}),(0,J.jsx)(`span`,{className:`mt-0.5 block overflow-hidden text-meta leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:i.task.prompt})]})]},`${i.id}-${e.at}`)}),d.length===0?(0,J.jsx)(`p`,{className:`px-3.5 py-2 text-label text-soft-foreground`,children:f.length?`Nothing scheduled — the GitHub polls above still run.`:`Nothing scheduled.`}):null]})]})}function Or(e,t,n,r=12){let i=[];for(let a of e)if(!(!a.enabled||a.kind!==`schedule`||!a.schedule))for(let e of ie(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 kr({open:e,onOpenChange:t,upcoming:n,pollCount:r,timeZone:i,now:a}){let o=D(),s=C(a,i);return(0,J.jsx)(ye,{open:e,onOpenChange:t,children:(0,J.jsxs)(ve,{side:`right`,"data-slot":`next-runs-rail`,"aria-describedby":void 0,className:`w-[360px] gap-0 sm:max-w-[360px]`,children:[(0,J.jsxs)(be,{className:`px-4 pt-4 pb-2`,children:[(0,J.jsxs)(xe,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,J.jsx)(N,{className:`size-4`}),`Next runs`]}),(0,J.jsx)(_e,{className:`sr-only`,children:`Upcoming scheduled runs, soonest first.`})]}),(0,J.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?``:`${P(r.weekday)} `}${x(r.hour,r.minute)}`:``;return(0,J.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-ui hover:bg-muted`,children:[(0,J.jsx)(`span`,{className:`font-mono text-xs font-medium whitespace-nowrap text-muted-foreground tabular-nums`,children:l}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ui font-medium text-ellipsis whitespace-nowrap`,children:e.automation.name}),(0,J.jsx)(`span`,{className:`text-meta whitespace-nowrap text-soft-foreground`,children:Ie(e.at,a)})]},`${e.automation.id}-${n}`)}),n.length===0?(0,J.jsx)(`p`,{className:`px-4 py-2 text-label text-soft-foreground`,children:`No scheduled runs in the next two weeks.`}):null,(0,J.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,J.jsx)(z,{tone:`pending`,pulse:!0}),r,` GitHub polls running continuously`]})]})]})})}function Ar({stats:e,pollCount:t,upcoming:n,timeZone:r,railOpen:i,onOpenRail:a}){let o=n[0];return(0,J.jsxs)(`div`,{"data-slot":`stats-strip`,className:`flex flex-wrap items-center gap-4 text-label text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`eyebrow text-soft-foreground`,children:`This week`}),(0,J.jsx)(jr,{label:`runs`,value:String(e.runs)}),null,(0,J.jsx)(jr,{label:`failed`,value:String(e.failed),danger:e.failed>0}),(0,J.jsx)(jr,{label:`agent time`,value:Ge(e.agentSeconds)}),(0,J.jsxs)(`span`,{"data-slot":`stats-polls`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,J.jsx)(z,{tone:`pending`,pulse:!0}),t,` GitHub polls continuous`]}),(0,J.jsx)(`span`,{className:`flex-1`}),(0,J.jsxs)(`span`,{"data-slot":`stats-next`,className:`inline-flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,J.jsx)(yt,{className:`size-[13px] text-soft-foreground`}),`next`,` `,(0,J.jsx)(`b`,{className:`font-mono text-label font-medium text-foreground`,children:o?Be(o.at,r):`—`}),` `,(0,J.jsx)(`span`,{className:`max-w-[180px] overflow-hidden text-ellipsis`,children:o?.automation.name??``})]}),(0,J.jsxs)(T,{variant:`outline`,size:`sm`,"aria-expanded":i,className:`shrink-0`,onClick:a,children:[(0,J.jsx)(N,{className:`size-3.5`}),`Next runs`,(0,J.jsx)(`span`,{className:`font-mono text-meta font-medium text-muted-foreground`,children:n.length})]})]})}function jr({label:e,value:t,danger:n=!1}){return(0,J.jsxs)(`span`,{"data-slot":`stat`,"data-label":e,className:`inline-flex shrink-0 items-baseline gap-[5px] whitespace-nowrap`,children:[(0,J.jsx)(`b`,{className:w(`font-mono text-sm font-semibold tabular-nums`,n?`text-danger`:`text-foreground`),children:t}),e]})}var Mr=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function Nr({data:e}){let t=Se(6e4),n=e.timeZone,r=C(t,n),i=r?Array.from({length:8},(e,i)=>vr(t,n,i-(r.weekday-1))):[],a=i[0],o=i[7];if(!r||a==null||o==null)return(0,J.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,J.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=yr(e.automations,a,o,n),l=Mr.map((e,t)=>{let r=i[t];return{label:e,dayOfMonth:r==null?null:C(r,n)?.day??null,isToday:t===s,blocks:br(c.filter(e=>e.parts.weekday-1===t))}});return(0,J.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,J.jsxs)(M,{flush:!0,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-[48px_repeat(7,minmax(0,1fr))] border-b border-border`,children:[(0,J.jsx)(`div`,{}),l.map(e=>(0,J.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 eyebrow`,e.isToday?`text-foreground`:`text-soft-foreground`),children:[e.label,(0,J.jsx)(`span`,{className:w(`rounded-full px-[7px] py-px text-ui font-medium tracking-normal normal-case`,e.isToday?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e.dayOfMonth??``})]},e.label))]}),(0,J.jsx)(Tr,{automations:e.automations}),(0,J.jsxs)(`div`,{className:`flex max-h-[560px] overflow-y-auto`,children:[(0,J.jsx)(Sr,{}),l.map(e=>(0,J.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,J.jsx)(wr,{}),e.isToday?(0,J.jsx)(Cr,{minute:_r(r)}):null,e.blocks.map(({occurrence:e,stack:t})=>(0,J.jsx)(xr,{automation:e.automation,minute:_r(e.parts),stack:t},`${e.automation.id}-${e.at}`))]},e.label))]})]})})}function Pr(e){return[{value:`list`,label:`List`,...e===void 0?{}:{count:e}},{value:`week`,label:`Week`},{value:`day`,label:`Day`}]}function Fr({data:e,error:t,actions:n,view:r,onViewChange:i}){let[a,o]=(0,q.useState)(!1),s=Date.now(),c=e?Or(e.automations,s,e.timeZone,12):[],l=e?e.automations.filter(e=>e.kind===`github`&&e.enabled).length:0;return(0,J.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,J.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,J.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,J.jsx)(fe,{slot:`automations-view`,label:`View`,value:r,options:Pr(e?.automations.length),onChange:i}),(0,J.jsx)(`div`,{className:`flex-1`}),e?(0,J.jsxs)(`span`,{"data-slot":`automations-status`,className:`inline-flex min-w-0 items-center gap-2 overflow-hidden text-label text-ellipsis whitespace-nowrap text-muted-foreground max-[1280px]:hidden`,children:[(0,J.jsx)(z,{tone:e.scheduler.state===`scheduled`?`success`:`neutral`}),e.scheduler.state===`scheduled`?`Scheduler running`:`Scheduler idle`,(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),e.available?`GitHub available`:`GitHub unavailable${e.reason?` · ${e.reason}`:``}`,(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:e.timeZone})]}):null,(0,J.jsx)(er,{}),(0,J.jsx)(T,{asChild:!0,className:`shrink-0`,children:(0,J.jsxs)(O,{to:`/automations/new`,children:[(0,J.jsx)(at,{className:`size-[15px]`}),`New automation`]})})]}),t===void 0?e?e.automations.length===0?(0,J.jsx)(`div`,{className:`flex flex-1 flex-col px-5`,children:(0,J.jsx)(Qn,{data:e})}):r===`week`?(0,J.jsx)(Nr,{data:e}):r===`day`?(0,J.jsx)(Dr,{data:e}):(0,J.jsxs)(`div`,{"data-slot":`automations-list`,className:`flex flex-col gap-3 p-5`,children:[(0,J.jsx)(Ar,{stats:e.stats,pollCount:l,upcoming:c,timeZone:e.timeZone,railOpen:a,onOpenRail:()=>o(!0)}),(0,J.jsx)(mr,{data:e,actions:n,now:s}),(0,J.jsx)(kr,{open:a,onOpenChange:o,upcoming:c,pollCount:l,timeZone:e.timeZone,now:s})]}):(0,J.jsx)(`div`,{className:`p-5`,children:(0,J.jsx)($,{text:`Loading automations…`})}):(0,J.jsx)(`div`,{className:`p-5`,children:(0,J.jsx)($,{text:t})})]})}function Ir({mode:e=`list`}){let{automationId:t}=le(),n=D(),r=A(),i=pe(r.known&&!r.off),a=i.data?{...i.data,automations:i.data.automations.filter(e=>!e.deferredStart)}:void 0,o=he(a),[s,c]=E(),l=Lr(s.get(`view`));if(!r.known)return(0,J.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,J.jsx)($,{text:`Loading automations…`})});if(r.off)return(0,J.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,J.jsx)(vt,{icon:(0,J.jsx)(De,{}),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 u=()=>n(`/automations`);if(e===`new`)return(0,J.jsx)(Hn,{data:a,initialKind:Rr(s.get(`kind`)),onBack:u,onSaved:u});if(e===`edit`){let e=a?.automations.find(e=>e.id===t);return a&&!e?(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Automation not found.`})}):e?(0,J.jsx)(Hn,{data:a,automation:e,actions:o,onBack:u,onSaved:u,onLog:()=>n(`/automations/${encodeURIComponent(e.id)}/log`)}):(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Loading automation…`})})}if(e===`log`){let e=a?.automations.find(e=>e.id===t);return t?(0,J.jsx)(qn,{automationId:t,automation:e,timeZone:a?.timeZone,onBack:u}):(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Automation not found.`})})}return(0,J.jsx)(Fr,{data:a,error:i.error?String(i.error instanceof Error?i.error.message:i.error):void 0,actions:o,view:l,onViewChange:e=>c(t=>{let n=new URLSearchParams(t);return e===`list`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})})}function Lr(e){return e===`week`||e===`day`?e:`list`}function Rr(e){return e===`schedule`||e===`github`||e===`tracker`?e:void 0}function $({text:e}){return(0,J.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e})}export{Ir as AutomationsRoute};