@open-mercato/cezar 0.12.0-pr1121.1925 → 0.12.0-pr1122.1936

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cezar",
3
- "version": "0.12.0-pr1121.1925",
3
+ "version": "0.12.0-pr1122.1936",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -54,8 +54,8 @@
54
54
  "zod": "^4.4.3"
55
55
  },
56
56
  "devDependencies": {
57
- "@open-mercato/cezar-api-client": "0.12.0-pr1121.1925",
58
- "@open-mercato/cezar-contract": "0.12.0-pr1121.1925",
57
+ "@open-mercato/cezar-api-client": "0.12.0-pr1122.1936",
58
+ "@open-mercato/cezar-contract": "0.12.0-pr1122.1936",
59
59
  "@types/node": "^20.14.0",
60
60
  "@types/proper-lockfile": "4.1.4",
61
61
  "@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{k as r}from"./centered-state-CLXeAT-P.js";import{r as i,t as a}from"./utils-R1j1Kev9.js";import{i as o,r as s,s as c,t as l}from"./popover-CBd2q-UG.js";import{a as u,c as d}from"./picker-pill-B4psQ_6Z.js";import{a as f,i as p,o as m,r as h,s as g,t as _}from"./command-INYKi4fh.js";import{t as v}from"./sparkles-IOH7tM19.js";import{t as y}from"./project-router-CkynDkNI.js";import{c as b,d as x,f as S,i as C,u as w}from"./skills-9oR_oHse.js";import{l as T,z as E}from"./index-BJMs7KMj.js";var D=i(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),O=n();function k({name:e,route:t,selected:n,list:r,detail:i}){return(0,O.jsxs)(`div`,{"data-route":t,className:`flex h-full min-h-0 items-stretch`,children:[(0,O.jsx)(`section`,{"data-slot":`${e}-list`,className:a(`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:r}),(0,O.jsx)(`section`,{"data-slot":`${e}-detail`,className:a(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n?`flex`:`hidden md:flex`),children:i})]})}function A(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function j(e,t=[]){let n=A(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=M(t)),n}function M(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function N(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function P(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function F(e,t,n){let r=(n??``).trim();if(!r)return j(e,t);let i=A(e),a=r.startsWith(i)?i+N(r.slice(i.length),e):N(r,e),o=P(a,e)?a:`${i}\n\n${a}`;return t.length?o+M(t):o}function I(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function L(e,t,n,r,i={}){return t?{...i,workflow:t,task:F(e,n,r)}:n.length?{...i,steps:I(n),task:F(e,[],r)}:{...i,workflow:`quick-task`,task:F(e,[],r)}}function R({resolved:e,dataSlot:t}){return e.providerPending||e.canRun?null:(0,O.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,O.jsx)(y,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]})}var z=e(t(),1);function B({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[d,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(``),C=(0,z.useRef)(null),w=x(e,y);return(0,O.jsxs)(l,{open:d,onOpenChange:e=>{v(e),e||b(``)},children:[(0,O.jsx)(o,{asChild:!0,children:(0,O.jsxs)(`button`,{type:`button`,"data-slot":`${i}-workflow-trigger`,"aria-label":`Choose a workflow`,className:a(u,t&&`border-foreground/60 font-mono text-[11.5px] font-semibold text-foreground`),children:[(0,O.jsx)(E,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,O.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,O.jsx)(c,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,O.jsx)(s,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,O.jsxs)(_,{label:`Choose a workflow`,shouldFilter:!1,children:[(0,O.jsx)(f,{placeholder:`search workflows…`,value:y,onValueChange:b,onInput:()=>C.current?.scrollTo(0,0)}),(0,O.jsxs)(g,{ref:C,"data-slot":`${i}-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[w.length===0?(0,O.jsx)(h,{children:`Nothing matches.`}):null,(0,O.jsx)(p,{children:w.map(e=>{let a=t===e.name;return(0,O.jsxs)(m,{value:`workflow ${e.name}`,keywords:S(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(a?null:e.name),v(!1)},children:[(0,O.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,a?(0,O.jsx)(r,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function V({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:y,slotPrefix:x=`gh`}){let[E,D]=(0,z.useState)(!1),[k,A]=(0,z.useState)(``),[j,M]=(0,z.useState)(null),N=(0,z.useRef)(null),{mostUsed:P,project:F,global:I}=b(w(e,k,t),t),L=(e,t)=>{let o=n.includes(e.name);return(0,O.jsxs)(m,{value:`skill ${e.name} ${e.path}`,keywords:S(e.name,e.description),"data-slot":`${x}-skill-option`,"data-skill":e.name,"data-selected":o?`true`:void 0,disabled:!o&&y!==void 0&&n.length>=y,onSelect:()=>i(e.name),children:[(0,O.jsx)(`span`,{className:a(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,O.jsx)(`button`,{type:`button`,"data-slot":`${x}-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),M(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,O.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`})}),o?(0,O.jsx)(r,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(T,{skill:j,onClose:()=>M(null)}),(0,O.jsxs)(l,{open:E,onOpenChange:e=>{D(e),e||A(``)},children:[(0,O.jsx)(o,{asChild:!0,children:(0,O.jsxs)(`button`,{type:`button`,"data-slot":`${x}-skills-trigger`,"aria-label":`Choose skills`,className:a(u,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,O.jsx)(v,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,O.jsx)(c,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,O.jsx)(s,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,O.jsxs)(_,{label:`Choose skills`,shouldFilter:!1,children:[(0,O.jsx)(f,{placeholder:`search skills…`,value:k,onValueChange:A,onInput:()=>N.current?.scrollTo(0,0)}),(0,O.jsxs)(g,{ref:N,"data-slot":`${x}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[P.length===0&&F.length===0&&I.length===0?(0,O.jsx)(h,{children:`Nothing matches.`}):null,P.length>0?(0,O.jsx)(p,{heading:`Most used`,children:P.map(e=>L(e,C(e)))}):null,F.length>0?(0,O.jsx)(p,{heading:`Project skills`,children:F.map(e=>L(e,!0))}):null,I.length>0?(0,O.jsx)(p,{heading:`Global`,children:I.map(e=>L(e,!1))}):null]})]})})]})]})}export{j as a,k as c,L as i,D as l,B as n,A as o,R as r,I as s,V 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{k as r}from"./centered-state-CLXeAT-P.js";import{r as i,t as a}from"./utils-R1j1Kev9.js";import{i as o,r as s,s as c,t as l}from"./popover-CBd2q-UG.js";import{a as u,c as d}from"./picker-pill-B4psQ_6Z.js";import{a as f,i as p,o as m,r as h,s as g,t as _}from"./command-INYKi4fh.js";import{t as v}from"./sparkles-IOH7tM19.js";import{t as y}from"./project-router-CkynDkNI.js";import{c as b,d as x,f as S,i as C,u as w}from"./skills-9oR_oHse.js";import{l as T,z as E}from"./index-CQc7jbyM.js";var D=i(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),O=n();function k({name:e,route:t,selected:n,list:r,detail:i}){return(0,O.jsxs)(`div`,{"data-route":t,className:`flex h-full min-h-0 items-stretch`,children:[(0,O.jsx)(`section`,{"data-slot":`${e}-list`,className:a(`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:r}),(0,O.jsx)(`section`,{"data-slot":`${e}-detail`,className:a(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n?`flex`:`hidden md:flex`),children:i})]})}function A(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function j(e,t=[]){let n=A(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=M(t)),n}function M(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function N(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function P(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function F(e,t,n){let r=(n??``).trim();if(!r)return j(e,t);let i=A(e),a=r.startsWith(i)?i+N(r.slice(i.length),e):N(r,e),o=P(a,e)?a:`${i}\n\n${a}`;return t.length?o+M(t):o}function I(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function L(e,t,n,r,i={}){return t?{...i,workflow:t,task:F(e,n,r)}:n.length?{...i,steps:I(n),task:F(e,[],r)}:{...i,workflow:`quick-task`,task:F(e,[],r)}}function R({resolved:e,dataSlot:t}){return e.providerPending||e.canRun?null:(0,O.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,O.jsx)(y,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]})}var z=e(t(),1);function B({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[d,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(``),C=(0,z.useRef)(null),w=x(e,y);return(0,O.jsxs)(l,{open:d,onOpenChange:e=>{v(e),e||b(``)},children:[(0,O.jsx)(o,{asChild:!0,children:(0,O.jsxs)(`button`,{type:`button`,"data-slot":`${i}-workflow-trigger`,"aria-label":`Choose a workflow`,className:a(u,t&&`border-foreground/60 font-mono text-[11.5px] font-semibold text-foreground`),children:[(0,O.jsx)(E,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,O.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,O.jsx)(c,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,O.jsx)(s,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,O.jsxs)(_,{label:`Choose a workflow`,shouldFilter:!1,children:[(0,O.jsx)(f,{placeholder:`search workflows…`,value:y,onValueChange:b,onInput:()=>C.current?.scrollTo(0,0)}),(0,O.jsxs)(g,{ref:C,"data-slot":`${i}-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[w.length===0?(0,O.jsx)(h,{children:`Nothing matches.`}):null,(0,O.jsx)(p,{children:w.map(e=>{let a=t===e.name;return(0,O.jsxs)(m,{value:`workflow ${e.name}`,keywords:S(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(a?null:e.name),v(!1)},children:[(0,O.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,a?(0,O.jsx)(r,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function V({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:y,slotPrefix:x=`gh`}){let[E,D]=(0,z.useState)(!1),[k,A]=(0,z.useState)(``),[j,M]=(0,z.useState)(null),N=(0,z.useRef)(null),{mostUsed:P,project:F,global:I}=b(w(e,k,t),t),L=(e,t)=>{let o=n.includes(e.name);return(0,O.jsxs)(m,{value:`skill ${e.name} ${e.path}`,keywords:S(e.name,e.description),"data-slot":`${x}-skill-option`,"data-skill":e.name,"data-selected":o?`true`:void 0,disabled:!o&&y!==void 0&&n.length>=y,onSelect:()=>i(e.name),children:[(0,O.jsx)(`span`,{className:a(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,O.jsx)(`button`,{type:`button`,"data-slot":`${x}-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),M(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,O.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`})}),o?(0,O.jsx)(r,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(T,{skill:j,onClose:()=>M(null)}),(0,O.jsxs)(l,{open:E,onOpenChange:e=>{D(e),e||A(``)},children:[(0,O.jsx)(o,{asChild:!0,children:(0,O.jsxs)(`button`,{type:`button`,"data-slot":`${x}-skills-trigger`,"aria-label":`Choose skills`,className:a(u,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,O.jsx)(v,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,O.jsx)(c,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,O.jsx)(s,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,O.jsxs)(_,{label:`Choose skills`,shouldFilter:!1,children:[(0,O.jsx)(f,{placeholder:`search skills…`,value:k,onValueChange:A,onInput:()=>N.current?.scrollTo(0,0)}),(0,O.jsxs)(g,{ref:N,"data-slot":`${x}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[P.length===0&&F.length===0&&I.length===0?(0,O.jsx)(h,{children:`Nothing matches.`}):null,P.length>0?(0,O.jsx)(p,{heading:`Most used`,children:P.map(e=>L(e,C(e)))}):null,F.length>0?(0,O.jsx)(p,{heading:`Project skills`,children:F.map(e=>L(e,!0))}):null,I.length>0?(0,O.jsx)(p,{heading:`Global`,children:I.map(e=>L(e,!1))}):null]})]})})]})]})}export{j as a,k as c,L as i,D as l,B as n,A as o,R as r,I as s,V as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{$ as i,$t as a,Ct as o,D as s,Ht as c,Jn as l,Kr as u,Pn as d,Si as f,Xt as p,_ as m,a as h,ar as g,b as _,bi as v,c as y,d as b,f as x,g as S,gr as C,h as w,i as T,ir as E,k as ee,l as D,m as O,ni as k,s as te,t as ne,u as re,v as A,vi as j,vr as ie,w as M,wi as ae,x as N,xi as oe,y as P,yi as se}from"./centered-state-CLXeAT-P.js";import{A as ce,C as le,D as ue,E as de,S as fe,T as pe,c as me,k as F,r as I,t as L,w as he,x as ge}from"./utils-R1j1Kev9.js";import{i as _e,u as ve}from"./facet-filter-BRRVNtZY.js";import{a as ye,i as be,n as xe,o as Se,s as Ce,t as we}from"./use-now-B04hkXJF.js";import{E as Te}from"./editable-title-BxM_4PmX.js";import{t as Ee}from"./arrow-left-CGgyNclf.js";import{d as De,l as Oe}from"./tooltip-EnWGRZ-b.js";import{_ as ke,a as Ae,c as je,d as Me,f as Ne,g as Pe,h as Fe,i as Ie,l as Le,m as Re,n as ze,o as Be,p as Ve,r as He,s as Ue,t as We,u as Ge,v as R,y as Ke}from"./automation-format-DUj3D5GW.js";import{t as qe}from"./chevron-left-kXrg7RiT.js";import{s as Je}from"./popover-CBd2q-UG.js";import{t as Ye}from"./chevron-right-Djhs_Y97.js";import{c as Xe,f as Ze,n as Qe,p as $e,r as et,s as tt,t as nt}from"./dropdown-menu-D_f8VdfX.js";import{n as rt,t as it}from"./trash-2-qfu5zdbW.js";import{c as at,r as z,t as ot}from"./picker-pill-B4psQ_6Z.js";import{t as st}from"./file-text-OBjZeSyD.js";import{f as ct,m as lt,p as ut}from"./new-task-form-ChW4VQlz.js";import{n as dt,r as ft,t as pt}from"./collapsible-BI1pq6sH.js";import{a as mt,c as ht,i as gt,n as _t,o as vt,r as yt,s as bt,t as xt}from"./alert-dialog-BSwo0F4G.js";import{a as St,i as Ct,n as wt,r as Tt,t as Et}from"./dist-BG6m4Jzn.js";import{c as B,s as Dt,t as Ot}from"./project-router-CkynDkNI.js";import{i as V}from"./token-metrics-DAiDb02U.js";import{n as kt}from"./format-DHK74MwW.js";import{s as At}from"./skills-9oR_oHse.js";import{t as jt}from"./pill-BQuNfP0B.js";import{t as Mt}from"./textarea-AOyg8DK7.js";import{i as Nt,o as Pt,r as Ft}from"./prompt-templates-CGGHGApJ.js";import{F as It,I as Lt,J as Rt,L as zt,P as Bt,U as Vt,d as Ht,p as Ut,q as Wt,s as Gt,t as Kt}from"./index-BJMs7KMj.js";var qt=I(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Jt=I(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Yt=I(`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`}]]),Xt=I(`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`}]]),Zt=I(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Qt=I(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),$t=I(`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`}]]),en=I(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),tn=I(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]);function nn(e,[t,n]){return Math.min(n,Math.max(t,e))}var H=e(t(),1),rn=e(n(),1),U=r(),an=[` `,`Enter`,`ArrowUp`,`ArrowDown`],on=[` `,`Enter`],W=`Select`,[sn,cn,ln]=$e(W),[G,un]=_(W,[ln,St]),dn=St(),[fn,K]=G(W),[pn,mn]=G(W),hn=`SelectProvider`;function gn(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:h,internal_do_not_use_render:g}=e,_=dn(t),[v,y]=H.useState(null),[b,x]=H.useState(null),[S,C]=H.useState(!1),T=Ze(l),[E,ee]=m({prop:r,defaultProp:i??!1,onChange:a,caller:W}),[D,O]=m({prop:o,defaultProp:s,onChange:c,caller:W}),k=H.useRef(null),te=H.useRef(D);H.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=()=>O(te.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,O]);let ne=!v||!!h||!!v.closest(`form`),[re,A]=H.useState(new Set),j=w(),ie=Array.from(re).map(e=>e.props.value).join(`;`),M=H.useCallback(e=>{A(t=>new Set(t).add(e))},[]),ae=H.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),N={required:p,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:C,contentId:j,value:D,onValueChange:O,open:E,onOpenChange:ee,dir:T,triggerPointerDownPosRef:k,disabled:f,name:u,autoComplete:d,form:h,nativeOptions:re,nativeSelectKey:ie,isFormControl:ne};return(0,U.jsx)(Ct,{..._,children:(0,U.jsx)(fn,{scope:t,...N,children:(0,U.jsx)(sn.Provider,{scope:t,children:(0,U.jsx)(pn,{scope:t,onNativeOptionAdd:M,onNativeOptionRemove:ae,children:pr(g)?g(N):n})})})})}gn.displayName=hn;var _n=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,U.jsx)(gn,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,U.jsxs)(U.Fragment,{children:[n,e?(0,U.jsx)(fr,{__scopeSelect:t}):null]})})};_n.displayName=W;var vn=`SelectTrigger`,yn=H.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=dn(n),o=K(vn,n),c=o.disabled||r,l=s(t,o.onTriggerChange),u=cn(n),d=H.useRef(`touch`),[f,p,m]=hr(e=>{let t=u().filter(e=>!e.disabled),n=gr(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=e=>{c||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,U.jsx)(Et,{asChild:!0,...a,children:(0,U.jsx)(N.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":mr(o.value)?``:void 0,...i,ref:l,onClick:P(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:P(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:P(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&an.includes(e.key)&&(h(),e.preventDefault())})})})});yn.displayName=vn;var bn=`SelectValue`,xn=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...c}=e,l=K(bn,n),{onValueNodeHasChildrenChange:u}=l,d=a!==void 0,f=s(t,l.onValueNodeChange);A(()=>{u(d)},[u,d]);let p=mr(l.value);return(0,U.jsx)(N.span,{...c,asChild:!p&&c.asChild,ref:f,style:{pointerEvents:`none`},children:(0,U.jsx)(H.Fragment,{children:p?o:a},p?`placeholder`:`value`)})});xn.displayName=bn;var Sn=`SelectIcon`,Cn=H.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,U.jsx)(N.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Cn.displayName=Sn;var wn=`SelectPortal`,[Tn,En]=G(wn,{forceMount:void 0}),Dn=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,U.jsx)(Tn,{scope:e.__scopeSelect,forceMount:n,children:(0,U.jsx)(re,{asChild:!0,...r})})};Dn.displayName=wn;var q=`SelectContent`,On=H.forwardRef((e,t)=>{let n=En(q,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=K(q,e.__scopeSelect),[o,s]=H.useState();return A(()=>{s(new DocumentFragment)},[]),(0,U.jsx)(S,{present:r||a.open,children:({present:e})=>e?(0,U.jsx)(Nn,{...i,ref:t}):(0,U.jsx)(kn,{...i,fragment:o})})});On.displayName=q;var kn=H.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?rn.createPortal((0,U.jsx)(An,{scope:n,children:(0,U.jsx)(sn.Slot,{scope:n,children:(0,U.jsx)(`div`,{ref:t,children:r})})}),i):null});kn.displayName=`SelectContentFragment`;var J=10,[An,Y]=G(q),jn=`SelectContentImpl`,Mn=M(`SelectContent.RemoveScroll`),Nn=H.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,S=K(q,n),[C,w]=H.useState(null),[T,E]=H.useState(null),ee=s(t,w),[O,k]=H.useState(null),[ne,re]=H.useState(null),A=cn(n),[j,ie]=H.useState(!1),M=H.useRef(!1);H.useEffect(()=>{if(C)return te(C)},[C]),D();let ae=H.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,T]),N=H.useCallback(()=>ae([O,C]),[ae,O,C]);H.useEffect(()=>{j&&N()},[j,N]);let{onOpenChange:oe,triggerPointerDownPosRef:se}=S;H.useEffect(()=>{if(C){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(se.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(se.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(C)||oe(!1),document.removeEventListener(`pointermove`,t),se.current=null};return se.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[C,oe,se]),H.useEffect(()=>{let e=()=>oe(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[oe]);let[ce,le]=hr(e=>{let t=A().filter(e=>!e.disabled),n=gr(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ue=H.useCallback((e,t,n)=>{let r=!M.current&&!n;(S.value!==void 0&&S.value===t||r)&&(k(e),r&&(M.current=!0))},[S.value]),de=H.useCallback(()=>C?.focus(),[C]),fe=H.useCallback((e,t,n)=>{let r=!M.current&&!n;(S.value!==void 0&&S.value===t||r)&&re(e)},[S.value]),pe=r===`popper`?Ln:Fn,me=pe===Ln?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,U.jsx)(An,{scope:n,content:C,viewport:T,onViewportChange:E,itemRefCallback:ue,selectedItem:O,onItemLeave:de,itemTextRefCallback:fe,focusSelectedItem:N,selectedItemText:ne,position:r,isPositioned:j,searchRef:ce,children:(0,U.jsx)(y,{as:Mn,allowPinchZoom:!0,children:(0,U.jsx)(b,{asChild:!0,trapped:S.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:P(i,e=>{S.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,U.jsx)(x,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:(0,U.jsx)(pe,{role:`listbox`,id:S.contentId,"data-state":S.open?`open`:`closed`,dir:S.dir,onContextMenu:e=>e.preventDefault(),...v,...me,onPlaced:()=>ie(!0),ref:ee,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:P(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&le(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ae(t)),e.preventDefault()}})})})})})})});Nn.displayName=jn;var Pn=`SelectItemAlignedPosition`,Fn=H.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=K(q,n),o=Y(q,n),[c,l]=H.useState(null),[u,d]=H.useState(null),f=s(t,d),p=cn(n),m=H.useRef(!1),h=H.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=H.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-J,d=nn(a,[J,Math.max(J,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-J,d=nn(a,[J,Math.max(J,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let o=p(),s=window.innerHeight-J*2,l=g.scrollHeight,d=window.getComputedStyle(u),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+l+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-J,ee=s-E,D=_.offsetHeight/2,O=_.offsetTop+D,k=f+h+O,te=x-k;if(k<=E){let e=o.length>0&&_===o[o.length-1].ref.current;c.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=k+Math.max(ee,D+(e?T:0)+t+y);c.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+D)+te;c.style.height=t+`px`,g.scrollTop=k-E+g.offsetTop}c.style.margin=`${J}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,u,g,_,v,a.dir,r]);A(()=>b(),[b]);let[x,S]=H.useState();return A(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]),(0,U.jsx)(Rn,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:H.useCallback(e=>{e&&h.current===!0&&(b(),y?.(),h.current=!1)},[b,y]),children:(0,U.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,U.jsx)(N.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Fn.displayName=Pn;var In=`SelectPopperPosition`,Ln=H.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=J,...a}=e,o=dn(n);return(0,U.jsx)(Tt,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Ln.displayName=In;var[Rn,zn]=G(q,{}),Bn=`SelectViewport`,Vn=H.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Y(Bn,n),o=zn(Bn,n),c=s(t,a.onViewportChange),l=H.useRef(0);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,U.jsx)(sn.Slot,{scope:n,children:(0,U.jsx)(N.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:P(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-J*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})});Vn.displayName=Bn;var Hn=`SelectGroup`,[Un,Wn]=G(Hn),Gn=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=w();return(0,U.jsx)(Un,{scope:n,id:i,children:(0,U.jsx)(N.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Gn.displayName=Hn;var Kn=`SelectLabel`,qn=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Wn(Kn,n);return(0,U.jsx)(N.div,{id:i.id,...r,ref:t})});qn.displayName=Kn;var Jn=`SelectItem`,[Yn,Xn]=G(Jn),Zn=H.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,c=K(Jn,n),l=Y(Jn,n),u=c.value===r,[d,f]=H.useState(a??``),[p,m]=H.useState(!1),h=s(t,O(e=>l.itemRefCallback?.(e,r,i))),g=w(),_=H.useRef(`touch`),v=()=>{i||(c.onValueChange(r),c.onOpenChange(!1))};return(0,U.jsx)(Yn,{scope:n,value:r,disabled:i,textId:g,isSelected:u,onItemTextChange:H.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,U.jsx)(sn.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,U.jsx)(N.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":u&&p,"data-state":u?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:P(o.onFocus,()=>m(!0)),onBlur:P(o.onBlur,()=>m(!1)),onClick:P(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:P(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:P(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:P(o.onPointerMove,e=>{_.current=e.pointerType,i?l.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:P(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:P(o.onKeyDown,e=>{i||e.target!==e.currentTarget||l.searchRef?.current!==``&&e.key===` `||(on.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})});Zn.displayName=Jn;var Qn=`SelectItemText`,$n=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=K(Qn,n),c=Y(Qn,n),l=Xn(Qn,n),u=mn(Qn,n),[d,f]=H.useState(null),p=O(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),m=s(t,f,l.onItemTextChange,p),h=d?.textContent,g=H.useMemo(()=>(0,U.jsx)(`option`,{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:_,onNativeOptionRemove:v}=u;return A(()=>(_(g),()=>v(g)),[_,v,g]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(N.span,{id:l.textId,...a,ref:m}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!mr(o.value)?rn.createPortal(a.children,o.valueNode):null]})});$n.displayName=Qn;var er=`SelectItemIndicator`,tr=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Xn(er,n).isSelected?(0,U.jsx)(N.span,{"aria-hidden":!0,...r,ref:t}):null});tr.displayName=er;var nr=`SelectScrollUpButton`,rr=H.forwardRef((e,t)=>{let n=Y(nr,e.__scopeSelect),r=zn(nr,e.__scopeSelect),[i,a]=H.useState(!1),o=s(t,r.onScrollButtonChange);return A(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,U.jsx)(or,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});rr.displayName=nr;var ir=`SelectScrollDownButton`,ar=H.forwardRef((e,t)=>{let n=Y(ir,e.__scopeSelect),r=zn(ir,e.__scopeSelect),[i,a]=H.useState(!1),o=s(t,r.onScrollButtonChange);return A(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,U.jsx)(or,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});ar.displayName=ir;var or=H.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Y(`SelectScrollButton`,n),o=H.useRef(null),s=cn(n),c=H.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return H.useEffect(()=>()=>c(),[c]),A(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,U.jsx)(N.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:P(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:P(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:P(i.onPointerLeave,()=>{c()})})}),sr=`SelectSeparator`,cr=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,U.jsx)(N.div,{"aria-hidden":!0,...r,ref:t})});cr.displayName=sr;var lr=`SelectArrow`,ur=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=dn(n);return Y(lr,n).position===`popper`?(0,U.jsx)(wt,{...i,...r,ref:t}):null});ur.displayName=lr;var dr=`SelectBubbleInput`,fr=H.forwardRef(({__scopeSelect:e,...t},n)=>{let r=K(dr,e),{value:i,onValueChange:a,required:o,disabled:c,name:l,autoComplete:u,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=H.useRef(null),h=s(n,m),g=i??``,_=zt(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return H.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,U.jsxs)(N.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:l,autoComplete:u,disabled:c,form:d,onChange:e=>a(e.target.value),...t,style:{...Oe,...t.style},ref:h,defaultValue:g,children:[mr(i)&&!v?(0,U.jsx)(`option`,{value:``}):null,Array.from(f)]},p)});fr.displayName=dr;function pr(e){return typeof e==`function`}function mr(e){return e===``||e===void 0}function hr(e){let t=O(e),n=H.useRef(``),r=H.useRef(0),i=H.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=H.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return H.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function gr(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=_r(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function _r(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function vr({...e}){return(0,U.jsx)(_n,{"data-slot":`select`,...e})}function yr({...e}){return(0,U.jsx)(xn,{"data-slot":`select-value`,...e})}function br({className:e,size:t=`default`,children:n,...r}){return(0,U.jsxs)(yn,{"data-slot":`select-trigger`,"data-size":t,className:L(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-card px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 hover:bg-muted [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,U.jsx)(Cn,{asChild:!0,children:(0,U.jsx)(Je,{className:`size-4 opacity-50`})})]})}function xr({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,U.jsx)(Dn,{children:(0,U.jsxs)(On,{"data-slot":`select-content`,className:L(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,U.jsx)(Sr,{}),(0,U.jsx)(Vn,{className:L(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,U.jsx)(Cr,{})]})})}function X({className:e,children:t,...n}){return(0,U.jsxs)(Zn,{"data-slot":`select-item`,className:L(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,U.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,U.jsx)(tr,{children:(0,U.jsx)(ee,{className:`size-4`})})}),(0,U.jsx)($n,{children:t})]})}function Sr({className:e,...t}){return(0,U.jsx)(rr,{"data-slot":`select-scroll-up-button`,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,U.jsx)(Rt,{className:`size-4`})})}function Cr({className:e,...t}){return(0,U.jsx)(ar,{"data-slot":`select-scroll-down-button`,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,U.jsx)(Je,{className:`size-4`})})}function wr({association:e,selected:t,onSelect:n,onRemove:r}){let i=v({queryKey:[`tracker`,me(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ie({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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,U.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,U.jsx)(z,{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,U.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,c?(0,U.jsxs)(`div`,{role:`alert`,children:[(0,U.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,U.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,U.jsxs)(U.Fragment,{children:[!i.isPending&&!i.isFetching&&l.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,U.jsx)(h,{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,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var Tr=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`];function Er(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function Dr(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function Or(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function kr(e){return e?.source===`skill`?{skill:e.ref,workflow:ct,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var Ar=[2,5,10,15,30,60],jr=[1,2,4,6,8],Mr={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},Nr={type:`daily`,hour:4,minute:0};function Pr(){return{name:``,kind:`schedule`,schedule:{...Nr},events:[`issue.opened`],intervalSeconds:300,filters:{...Mr},prompt:``,workflow:ct,skill:null,customSteps:null,runner:null,account:null,model:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var Fr=e=>(e??[]).join(`, `);function Ir(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Lr(e){let t=Pr(),{task:n,filters:r}=e,i=Dr(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?{authors:Fr(r.authors),assignees:Fr(r.assignees),anyLabels:Fr(r.anyLabels),allLabels:Fr(r.allLabels),excludeLabels:Fr(r.excludeLabels),changedLabels:Fr(r.changedLabels),reviewers:Fr(r.reviewers),lookbackDays:r.lookbackDays,maxRecords:r.maxRecords}: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}}function Rr(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},prompt:e.task.prompt,...e.task.workflow?{workflow:e.task.workflow}:{},...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}:{}}}var zr=e=>e===`claude`||e===`codex`||e===`opencode`||e===`pi`;function Br(e,t){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,prompt:t.prompt,...t.workflow?kr({source:`workflow`,ref:t.workflow}):{},runner:t.runner!==void 0&&zr(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&zr(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 Vr(e){let t=de(e);switch(t.type){case`hours`:return{type:`hours`,every:t.every};case`weekly`:return{type:`weekly`,hour:t.hour,minute:t.minute,day:t.day};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function Hr(e){let t={prompt:e.prompt,...e.skill?{steps:Er(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:Vr(e.schedule),task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:Ur(e.filters.lookbackDays,1,90),maxRecords:Ur(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Ir(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:Ur(n.lookbackDays,1,90),maxRecords:Ur(n.maxRecords,1,100)},task:t}}function Ur(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Wr(e){let t=Hr(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}:{}}}function Gr(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var Kr=e=>[1,2,3,4,6,8,12].includes(e);function qr({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,a]=(0,H.useState)(``),o=me(),s=v({queryKey:[`tracker`,o,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>C({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),c=v({queryKey:[`tracker`,o,`automation-options`,i],enabled:!!i&&s.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>C({...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,H.useEffect)(()=>(r(p),()=>r(!1)),[p,r]);let m=l.data?.pages.flatMap(e=>e.available?[e]:[])??[],g=[...new Map(m.flatMap(e=>e.statuses).map(e=>[e.id,e])).values()],_=new Map((s.data?.pages.flatMap(e=>e.available?e.statuses:[])??[]).map(e=>[e.id,e.name])),y=(e?.targetStatusIds??[]).filter(e=>!g.some(t=>t.id===e)),b=[...new Map(m.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],x=e?.events.includes(`issue.status_changed`),S=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),w=x&&S?`Search tracker statuses and labels`:S?`Search tracker labels`:`Search tracker statuses`;return(0,U.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[s.isPending?(0,U.jsx)(`p`,{children:`Loading tracker events…`}):null,s.isError||u&&!u.available?(0,U.jsxs)(`div`,{role:`alert`,children:[(0,U.jsxs)(`p`,{children:[u&&!u.available?u.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,U.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void s.refetch(),children:`Retry`})]}):null,d?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{children:[d.association.kind===`jira`?`Jira`:`Linear`,` · `,d.association.externalName]}),e&&!f?(0,U.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,U.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,U.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:d.events.map(t=>(0,U.jsx)(z,{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,U.jsx)(wr,{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,U.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,U.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),d.limitations.map(e=>(0,U.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Lt,{"aria-label":w,placeholder:w,value:i,onChange:e=>a(e.target.value)}),l.isFetching?(0,U.jsx)(`p`,{role:`status`,children:`Searching…`}):null,l.isError||l.data?.pages[0]&&!l.data.pages[0].available?(0,U.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,U.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void l.refetch(),children:`Retry search`})]}):null,!l.isFetching&&l.data?.pages[0]?.available&&x&&g.length===0?(0,U.jsx)(`p`,{children:`No matching statuses.`}):null,!l.isFetching&&l.data?.pages[0]?.available&&S&&b.length===0?(0,U.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,U.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[g.map(t=>(0,U.jsx)(z,{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)),y.map(t=>(0,U.jsxs)(z,{active:!0,"aria-pressed":!0,onClick:()=>{n({trackerTrigger:{...e,targetStatusIds:(e.targetStatusIds??[]).filter(e=>e!==t)}})},children:[_.get(t)??t,` (not in current results)`]},t))]}):null,e.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)?(0,U.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,U.jsx)(z,{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,U.jsx)(h,{variant:`outline`,size:`sm`,disabled:l.isFetchingNextPage,onClick:()=>void l.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,U.jsxs)(vr,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,U.jsx)(br,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:Ar.map(e=>(0,U.jsxs)(X,{value:String(e),children:[e,` min`]},e))})]})]}),(0,U.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 Jr({definition:e}){let t=(0,H.useMemo)(()=>ke(e),[e]);return(0,U.jsxs)(R,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,U.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Copy as CLI`}),(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void Ve(t),children:[(0,U.jsx)(rt,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,U.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-[11.5px] leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:t}),(0,U.jsxs)(`p`,{className:`mt-2 mb-0 text-[11.5px] leading-[1.5] text-soft-foreground`,children:[`The same definition the cockpit saves — `,(0,U.jsx)(`code`,{className:`text-[11px]`,children:`cez automation schema`}),` prints its shape.`]})]})}function Yr({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=jr.includes(n)?jr:[...jr,n].sort((e,t)=>e-t);return(0,U.jsxs)(`div`,{"data-slot":`editor-dispatch`,"data-enabled":t?`true`:void 0,title:`Let this run start its own subtasks with cez task create — each in a worktree forked off its branch, reporting back into the parent session.`,className:`flex flex-wrap items-center gap-2.5 border-t border-border pt-3 text-[13px] text-muted-foreground`,children:[(0,U.jsxs)(It,{className:`text-[13px] font-medium text-foreground`,children:[(0,U.jsx)(Jt,{"aria-hidden":`true`,className:L(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,U.jsx)(Ht,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i({dispatch:e})})]}),t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,U.jsxs)(vr,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-[12.5px]`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:a.map(e=>(0,U.jsx)(X,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsxs)(It,{className:`text-[13px] font-normal text-muted-foreground`,children:[(0,U.jsx)(Ht,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,U.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-[11.5px] whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null]})}function Xr({events:e,intervalSeconds:t,filters:n,onChange:r}){let[i,a]=(0,H.useState)([`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].some(e=>n[e].trim().length>0)||n.lookbackDays!==7||n.maxRecords!==25),o=(e,t)=>r({filters:{...n,[e]:t}}),s=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:Tr.filter(e=>n.includes(e))})},c=Gr(e),l=c&&n.changedLabels.trim().length===0;return(0,U.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-3.5`,children:[(0,U.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:Tr.map(t=>(0,U.jsx)(z,{active:e.includes(t),"aria-pressed":e.includes(t),className:`font-mono`,onClick:()=>s(t),children:t},t))}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground`,children:[`poll every`,(0,U.jsxs)(vr,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Poll interval`,className:`text-[13px]`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:Ar.map(e=>(0,U.jsxs)(X,{value:String(e),children:[e,` min`]},e))})]}),(0,U.jsxs)(`span`,{children:[`· last `,n.lookbackDays,` days · maximum `,n.maxRecords,` records`]})]}),(0,U.jsxs)(pt,{open:i,onOpenChange:a,children:[(0,U.jsx)(ft,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(Je,{"aria-hidden":`true`,className:L(`size-3 transition-transform`,i?``:`-rotate-90`)}),`Filters`,l?(0,U.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):null]})}),(0,U.jsx)(dt,{children:(0,U.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-2 sm:grid-cols-2`,children:[(0,U.jsx)(Zr,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>o(`authors`,e)}),(0,U.jsx)(Zr,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>o(`assignees`,e)}),(0,U.jsx)(Zr,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>o(`anyLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>o(`allLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>o(`excludeLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-changed-labels`,label:c?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:l,onChange:e=>o(`changedLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>o(`reviewers`,e)}),(0,U.jsx)(Qr,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>o(`lookbackDays`,e)}),(0,U.jsx)(Qr,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>o(`maxRecords`,e)})]})})]})]})}function Zr({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(It,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,U.jsx)(Lt,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-[13px]`})]})}function Qr({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(It,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,U.jsx)(Lt,{id:e,type:`number`,min:r,max:i,value:n,onChange:e=>a(Ur(Number(e.target.value),r,i)),className:`h-8 w-28 font-mono text-[13px] tabular-nums`})]})}function $r({source:e,sourcesReady:t,skills:n,skillUsage:r,workflows:i,onSource:a,pick:o,onPick:s,baseBranch:c,autonomous:l,onAutonomous:u}){return(0,U.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(Gt,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,U.jsx)(Ut,{pick:o,onChange:s,accounts:!0}),(0,U.jsx)(ot,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,U.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsxs)(It,{className:`text-[13px] font-medium`,children:[`Autonomous`,(0,U.jsx)(Ht,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function ei({className:e,...t}){return(0,U.jsx)(`span`,{"data-slot":`branch-chip`,className:L(`inline-block rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11.5px] leading-[1.3] font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var ti=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`]],ni=e=>String(e).padStart(2,`0`);function ri({schedule:e,timeZone:t,onChange:n}){let r=de(e),i=e=>n({...r,...e});return(0,U.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,U.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:ti.map(([e,t])=>(0,U.jsx)(z,{active:r.type===e,"aria-pressed":r.type===e,onClick:()=>i({type:e}),children:t},e))}),r.type===`weekly`?(0,U.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:fe.map((e,t)=>(0,U.jsx)(z,{active:r.day===t+1,"aria-pressed":r.day===t+1,className:`px-[9px]`,onClick:()=>i({day:t+1}),children:e},e))}):null,r.type===`hours`?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`every`,(0,U.jsxs)(vr,{value:String(r.every),onValueChange:e=>{let t=Number(e);Kr(t)&&i({every:t})},children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Every N hours`,className:`text-[13px]`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:ge.map(e=>(0,U.jsxs)(X,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`at`,(0,U.jsx)(Lt,{"aria-label":`Hour`,inputMode:`numeric`,value:ni(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,U.jsx)(Lt,{"aria-label":`Minute`,inputMode:`numeric`,value:ni(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,U.jsx)(`span`,{className:`font-mono text-xs`,children:t})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 font-mono text-xs text-soft-foreground`,children:[(0,U.jsx)(`span`,{children:`cron`}),(0,U.jsx)(ei,{"data-slot":`editor-cron`,children:le(r)})]})]})}function ii({lastRun:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){return(0,U.jsxs)(R,{flush:!0,"data-slot":`last-run-card`,className:`px-3.5 py-3`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Last run`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,U.jsx)(V,{tone:je(e.status)}),Ue(e.status),(0,U.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:kt(e.ts,i)}),null]}),(0,U.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,U.jsxs)(h,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,U.jsx)(lt,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}),n?(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,U.jsx)($t,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}var ai=864e5;function oi({kind:e,schedule:t,intervalSeconds:n,timeZone:r,now:i}){let[a,o]=(0,H.useState)(()=>Date.now());(0,H.useEffect)(()=>{if(i!==void 0)return;let e=setInterval(()=>o(Date.now()),6e4);return()=>clearInterval(e)},[i]);let s=i??a,c=(0,H.useMemo)(()=>e===`schedule`?ue(t,s,s+9*ai,r,5):[],[e,t,s,r]);return(0,U.jsxs)(R,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,U.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:e===`schedule`?`Next 5 runs`:`How it polls`}),e===`schedule`?c.length===0?(0,U.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:`Nothing in the next nine days.`}):c.map(e=>(0,U.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-[13px]`,children:[(0,U.jsx)(`span`,{className:`w-[82px] shrink-0 font-mono text-xs font-medium whitespace-nowrap text-foreground tabular-nums`,children:He(e,r)}),(0,U.jsx)(`span`,{className:`text-[11.5px] whitespace-nowrap text-soft-foreground`,children:Ae(e,s)})]},e)):(0,U.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,U.jsxs)(U.Fragment,{children:[`Checks the project tracker every `,Math.round(n/60),` min while cezar is open. No webhook or public URL required.`]}):(0,U.jsxs)(U.Fragment,{children:[`Checks GitHub every `,Math.round(n/60),` min while cezar is open, through your `,(0,U.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var si=[{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.`}],ci=e=>[me(),`automation-templates`,e??``];function li({onPick:e}){let[t,n]=(0,H.useState)(`builtin`),r=Dt(),i=f({queryKey:ci(r),queryFn:({signal:e})=>g(r,{signal:e}),enabled:t===`mine`}),a=t===`builtin`?si.map(e=>({...e,key:e.name})):(i.data?.templates??[]).map(e=>({...Rr(e),key:`${e.project.id}:${e.id}`,when:Ge(e),project:e.project.name}));return(0,U.jsxs)(R,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,U.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,U.jsx)(ui,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,U.jsx)(ui,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,U.jsx)(`span`,{className:`ml-auto min-w-0 overflow-hidden pb-2 text-xs text-ellipsis whitespace-nowrap text-soft-foreground`,children:t===`builtin`?`Ship with cezar`:`Registered in ~/.cezar/config.json`})]}),t===`mine`&&i.isPending?(0,U.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`Loading…`}):t===`mine`&&i.isError?(0,U.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-xs text-danger`,children:i.error.message}):a.length===0?(0,U.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`No automations in your other projects yet.`}):(0,U.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:a.map(t=>(0,U.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,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-semibold`,children:[t.kind===`github`?(0,U.jsx)(Bt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,U.jsx)(Wt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,U.jsx)(ei,{className:`ml-auto`,children:t.project}):null]}),(0,U.jsx)(`div`,{className:`font-mono text-[11.5px] text-muted-foreground`,children:t.when}),(0,U.jsx)(`div`,{className:`line-clamp-2 text-xs leading-[1.45] text-soft-foreground`,children:t.prompt}),(0,U.jsx)(h,{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 ui({active:e,onClick:t,children:n}){return(0,U.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:L(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-[13px] font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function di(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 fi={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`Describe the task the agent should do each time. Placeholders: {{date}}, {{project}}`,github:`Describe the task the agent should do for each match. Placeholders: {{github.url}}, {{github.title}}, {{github.number}}, {{github.labels}}`};function pi({data:e,automation:t,actions:n,onBack:r,onSaved:s,onLog:u}){let f=ae(),m=B(),g=i(),_=p(),v=a(),y=c(),b=o(),[x,S]=(0,H.useState)(()=>t?Lr(t):Pr()),[C,w]=(0,H.useState)(!t),[T,E]=(0,H.useState)(!1),[ee,D]=(0,H.useState)(!1),[O,te]=(0,H.useState)(null),[ne,re]=(0,H.useState)(!1),A=(0,H.useRef)(null),j=t?.revision,ie=(0,H.useRef)(j);(0,H.useEffect)(()=>{!t||j===ie.current||(ie.current=j,S(Lr(t)),re(!1),te(null))},[t,j]);let M=e=>S(t=>({...t,...e})),N=e?.timeZone??`UTC`,oe=e?.available!==!1,P=g.data?.capabilities.dispatch===!0,se=(0,H.useMemo)(()=>Ft(Pt(_.data?.promptTemplates),g.data?.capabilities),[_.data?.promptTemplates,g.data?.capabilities]),ce=v.data?.workflows??[],le=ce.map(e=>e.name),ue=y.data,de=_.data?.skillUsage,fe=(0,H.useMemo)(()=>At(ue??[],de),[ue,de]),pe=y.data!==void 0&&v.data!==void 0&&!_.isPending,me=b.data?.baseBranch??b.data?.info?.branch??void 0,F=(0,H.useMemo)(()=>Wr(x),[x]),I=x.name.trim().length>0&&x.prompt.trim().length>0&&!ee&&(x.kind!==`tracker`||T),L=e=>{let t=A.current,n=t?.selectionStart??x.prompt.length,r=Nt(x.prompt,n,e);M({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},he=async()=>{D(!0),te(null),re(!1);try{let e=Hr(x);t?await k(t.id,{...e,enabled:x.enabled,expectedRevision:t.revision}):await l({...e,enable:x.enabled}),await f.invalidateQueries({queryKey:Ne()}),s()}catch(e){if(t&&e instanceof d&&e.status===409)re(!0);else{let t=e instanceof Error?e.message:String(e);te({message:t,section:e instanceof d&&e.status===400?di(t):`top`})}}finally{D(!1)}},ge=()=>void f.invalidateQueries({queryKey:Ne()}),_e=t?`Save changes`:x.enabled?`Save and enable`:`Save paused`;return(0,U.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,className:`flex min-h-full flex-col`,children:[(0,U.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,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,U.jsx)(Ee,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,U.jsx)(jt,{dot:t.enabled?`success`:`neutral`,children:t.enabled?`enabled`:`paused`}):null,(0,U.jsx)(`span`,{className:`flex-1`}),t?null:(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,"aria-expanded":C,"aria-label":C?`Hide templates`:`Start from a template`,onClick:()=>w(e=>!e),children:[(0,U.jsx)(Yt,{"aria-hidden":`true`,className:`size-3.5`}),(0,U.jsx)(`span`,{className:`max-md:hidden`,children:C?`Hide templates`:`Start from a template`})]}),(0,U.jsx)(h,{variant:`outline`,onClick:r,children:`Cancel`}),(0,U.jsx)(h,{disabled:!I,onClick:()=>void he(),children:_e})]}),(0,U.jsx)(`div`,{className:`flex justify-center p-5`,children:(0,U.jsxs)(`div`,{className:`grid w-full max-w-[1080px] grid-cols-1 items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[ne?(0,U.jsxs)(`div`,{role:`alert`,"data-slot":`editor-conflict`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-[13px] text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,U.jsx)(h,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:ge,children:`Reload`})]}):null,O?.section===`top`?(0,U.jsx)(hi,{children:O.message}):null,C&&!t?(0,U.jsx)(li,{onPick:e=>{let t=e.workflow&&le.includes(e.workflow)?e.workflow:void 0;S(n=>Br(n,{...e,workflow:t})),w(!1)}}):null,(0,U.jsx)(mi,{title:`Name`,children:(0,U.jsx)(Lt,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:x.name,onChange:e=>M({name:e.target.value}),className:`max-w-[420px] text-[15px] md:text-[15px]`})}),(0,U.jsxs)(mi,{title:`When`,children:[(0,U.jsx)(gi,{value:x.kind,editing:!!t,githubAvailable:oe,githubReason:e?.reason,onChange:e=>M({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})}),x.kind===`schedule`?(0,U.jsx)(ri,{schedule:x.schedule,timeZone:N,onChange:e=>M({schedule:e})}):x.kind===`tracker`?(0,U.jsx)(qr,{trigger:x.trackerTrigger,intervalSeconds:x.intervalSeconds,onChange:M,onValid:E}):(0,U.jsx)(Xr,{events:x.events,intervalSeconds:x.intervalSeconds,filters:x.filters,onChange:e=>M(e)}),O?.section===`when`?(0,U.jsx)(hi,{children:O.message}):null]}),(0,U.jsxs)(mi,{title:`What to run`,children:[(0,U.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,U.jsx)(st,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,se.map(e=>(0,U.jsx)(z,{className:`h-6 text-[11.5px]`,title:e.text,onClick:()=>L(e.text),children:e.label},e.id)),(0,U.jsx)(z,{dashed:!0,className:`h-6 text-[11.5px]`,icon:(0,U.jsx)(en,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>m(Kt(`project`,`prompt-templates`)),children:`Manage…`})]}),(0,U.jsx)(Mt,{ref:A,"aria-label":`Prompt`,rows:5,placeholder:fi[x.kind],value:x.prompt,onChange:e=>M({prompt:e.target.value}),className:`min-h-[104px] text-sm leading-[1.55] md:text-sm`}),(0,U.jsx)($r,{source:Or(x),sourcesReady:pe,skills:fe,skillUsage:de,workflows:ce,onSource:e=>M(kr(e)),pick:{runner:x.runner,model:x.model,account:x.account},onPick:e=>M({runner:e.runner,model:e.model,account:e.account}),baseBranch:me,autonomous:x.autonomous,onAutonomous:e=>M({autonomous:e})}),(0,U.jsx)(`p`,{className:`m-0 text-xs leading-[1.5] text-soft-foreground`,children:`Each run is an ordinary cezar task in its own worktree — it queues behind the parallel cap like anything else and never auto-merges.`}),(0,U.jsx)(Yr,{available:P,enabled:x.dispatch,maxSubtasks:x.maxSubtasks,reviewChild:x.reviewChild,onChange:e=>M(e)}),O?.section===`what`?(0,U.jsx)(hi,{children:O.message}):null]}),(0,U.jsx)(mi,{title:`Enable`,children:(0,U.jsxs)(It,{className:`text-[13px] font-medium`,children:[(0,U.jsx)(Ht,{"aria-label":`Enabled`,checked:x.enabled,onCheckedChange:e=>M({enabled:e})}),`Enabled`,x.kind===`schedule`?null:(0,U.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`— from a current-time baseline; existing matches will not launch`})]})})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 lg:sticky lg:top-[76px]`,children:[(0,U.jsx)(oi,{kind:x.kind,schedule:x.schedule,intervalSeconds:x.intervalSeconds,timeZone:N}),(0,U.jsx)(Jr,{definition:F}),t&&t.kind!==`schedule`&&n?(0,U.jsx)(h,{variant:`outline`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t?.lastRun?(0,U.jsx)(ii,{lastRun:t.lastRun,busy:n?.busy,onRunNow:()=>void n?.runNow(t),onLog:u}):null]})]})})]})}function mi({title:e,children:t}){return(0,U.jsxs)(R,{"data-slot":`editor-section`,className:`gap-0 px-6 py-0`,children:[(0,U.jsx)(`div`,{className:`pt-4 pb-1 text-sm font-semibold`,children:e}),(0,U.jsx)(`div`,{className:`flex flex-col gap-3.5 pt-2.5 pb-5`,children:t})]})}function hi({children:e}){return(0,U.jsx)(`p`,{role:`alert`,className:`m-0 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-[12.5px] text-danger`,children:e})}function gi({value:e,editing:t,githubAvailable:n,githubReason:r,onChange:i}){let a=`Change the kind by creating a new automation`;return(0,U.jsx)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`inline-flex flex-wrap gap-0.5 self-start rounded-md bg-muted p-[3px]`,children:[{value:`schedule`,label:`On a schedule`,disabled:t&&e!==`schedule`,...t&&e!==`schedule`?{title:a}:{}},{value:`github`,label:`When GitHub changes`,disabled:!n||t&&e!==`github`,...n?t&&e!==`github`?{title:a}:{}:{title:r??`GitHub is unavailable`}},{value:`tracker`,label:`When Jira / Linear changes`,disabled:t&&e!==`tracker`,...t&&e!==`tracker`?{title:a}:{}}].map(t=>(0,U.jsx)(`button`,{type:`button`,"data-value":t.value,"aria-pressed":t.value===e,disabled:t.disabled,title:t.title,onClick:()=>{t.value!==e&&i(t.value)},className:L(`flex h-7 items-center justify-center gap-1.5 rounded-[7px] px-3 text-[12.5px] font-medium whitespace-nowrap text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,t.value===e&&`bg-card font-semibold text-foreground shadow-xs`),children:t.label},t.value))})}function _i({automationId:e,automation:t,timeZone:n,onBack:r}){let i=B(),a=ae(),o=me(),s=(0,H.useMemo)(()=>[o,`automation-log`,e],[o,e]),c=f({queryKey:s,queryFn:({signal:t})=>E(e,{signal:t})}),[l,d]=(0,H.useState)(`all`),[p,m]=(0,H.useState)(`all`);(0,H.useEffect)(()=>ve((t,n)=>{t===`automation-change`&&n.automationId===e&&a.invalidateQueries({queryKey:s})}),[e,a,s]);let g=oe({mutationFn:e=>u(e),onSuccess:()=>a.invalidateQueries({queryKey:s}),onError:e=>T(e instanceof Error?e.message:String(e),{tone:`danger`})}),_=n??`UTC`,v=c.data?.records.filter(e=>(l===`all`||e.result===l)&&(p===`all`||e.event===p));return(0,U.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-log`,className:`flex min-h-full flex-col`,children:[(0,U.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,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,U.jsx)(Ee,{className:`size-[15px]`})}),(0,U.jsx)(`h1`,{className:`m-0 text-base font-semibold`,children:t?t.name:`Automation`}),(0,U.jsx)(`span`,{className:`text-[13px] text-muted-foreground`,children:`· execution log`}),(0,U.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2`,children:[(0,U.jsxs)(vr,{value:l,onValueChange:e=>d(e),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Filter by result`,className:`text-[12.5px]`,children:(0,U.jsx)(yr,{placeholder:`All results`})}),(0,U.jsxs)(xr,{children:[(0,U.jsx)(X,{value:`all`,children:`All results`}),vi.map(e=>(0,U.jsx)(X,{value:e,children:e},e))]})]}),(0,U.jsxs)(vr,{value:p,onValueChange:e=>m(e),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Filter by event`,className:`text-[12.5px]`,children:(0,U.jsx)(yr,{placeholder:`All events`})}),(0,U.jsxs)(xr,{children:[(0,U.jsx)(X,{value:`all`,children:`All events`}),yi.map(e=>(0,U.jsx)(X,{value:e,children:e},e))]})]})]}),(0,U.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>i(`/automations/${encodeURIComponent(e)}`),children:[(0,U.jsx)(Te,{className:`size-[13px]`}),`Edit`]})]}),(0,U.jsx)(`div`,{className:`flex justify-center p-5`,children:c.isError?(0,U.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,U.jsx)($,{text:c.error instanceof Error?c.error.message:String(c.error)})}):v===void 0?(0,U.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,U.jsx)($,{text:`Loading execution log…`})}):v.length===0?(0,U.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,U.jsx)($,{text:`No checks have run yet.`})}):(0,U.jsx)(R,{flush:!0,className:`w-full max-w-[820px]`,children:v.map((e,t)=>(0,U.jsx)(xi,{record:e,run:e.runId===void 0?void 0:c.data?.runs[e.runId],last:t===v.length-1,timeZone:_,retrying:g.isPending&&g.variables===e.receiptId,onRetry:e=>g.mutate(e)},e.seq))})})]})}var vi=[`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`manual`,`catch-up`,`skipped`,`failed`],yi=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`];function bi(e){return e.result===`failed`&&e.runId===void 0?e.receiptId:void 0}function xi({record:e,run:t,last:n,timeZone:r,retrying:i,onRetry:a}){let o=Be(e.result),s=t?.children??[],c=bi(e);return(0,U.jsxs)(`div`,{"data-slot":`log-row`,"data-result":e.result,className:`grid grid-cols-[90px_110px_1fr_auto] items-center gap-x-3 gap-y-2 px-4 py-3 text-[13px] ${n?``:`border-b border-border`}`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:Ie(e.ts,r)}),(0,U.jsx)(jt,{dot:o,className:`w-fit`,children:e.result}),(0,U.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,U.jsx)(`span`,{}):(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a(c),children:[(0,U.jsx)(Qt,{className:`size-3`}),`Retry task`]}):(0,U.jsx)(h,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,U.jsxs)(Ot,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open task`,(0,U.jsx)(De,{className:`size-3`})]})}),s.length>0?(0,U.jsx)(`div`,{className:`col-span-full flex flex-col gap-1 pl-3.5`,children:s.map(e=>(0,U.jsxs)(`div`,{"data-slot":`log-child`,className:`grid grid-cols-[14px_70px_1fr_auto] items-center gap-2.5 text-[12.5px]`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`└`}),(0,U.jsx)(`span`,{className:`w-fit rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:e.kind??`implement`}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(V,{tone:je(e.status)}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.title})]}),null,(0,U.jsx)(h,{variant:`ghost`,size:`sm`,className:`h-6`,asChild:!0,children:(0,U.jsxs)(Ot,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open`,(0,U.jsx)(De,{className:`size-[11px]`})]})})]},e.runId))}):null]})}function Si({automation:e,actions:t}){let n=B(),[r,i]=(0,H.useState)(!1),a=e=>e.stopPropagation(),o=`/automations/${encodeURIComponent(e.id)}`;return(0,U.jsxs)(`span`,{"data-slot":`row-actions`,className:`inline-flex gap-0.5`,onClick:a,children:[e.kind===`schedule`?null:(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,title:`Preview matches`,"aria-label":`Preview matches`,disabled:t.busy,onClick:()=>void t.preview(e),children:(0,U.jsx)(at,{className:`size-[13px]`})}),(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,title:`Run now`,"aria-label":`Run now`,disabled:t.busy,onClick:()=>void t.runNow(e),children:(0,U.jsx)(lt,{className:`size-[13px]`})}),(0,U.jsx)(h,{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,U.jsx)(Xt,{className:`size-[13px]`}):(0,U.jsx)(Zt,{className:`size-[13px]`})}),(0,U.jsxs)(nt,{children:[(0,U.jsx)(Xe,{asChild:!0,children:(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`More`,children:(0,U.jsx)(qt,{className:`size-3.5`})})}),(0,U.jsxs)(Qe,{align:`end`,className:`w-[200px]`,onClick:a,children:[(0,U.jsxs)(et,{onSelect:()=>n(o),children:[(0,U.jsx)(Te,{}),`Edit`]}),(0,U.jsxs)(et,{onSelect:()=>n(`${o}/log`),children:[(0,U.jsx)($t,{}),`View log`]}),(0,U.jsxs)(et,{onSelect:()=>void t.duplicate(e),children:[(0,U.jsx)(rt,{}),`Duplicate`]}),(0,U.jsxs)(et,{onSelect:()=>void t.copyCli(e),children:[(0,U.jsx)(tn,{}),`Copy as CLI`]}),(0,U.jsx)(tt,{}),(0,U.jsxs)(et,{variant:`destructive`,onSelect:()=>i(!0),children:[(0,U.jsx)(it,{}),`Delete`]})]})]}),(0,U.jsx)(xt,{open:r,onOpenChange:i,children:(0,U.jsxs)(gt,{onClick:a,children:[(0,U.jsxs)(bt,{children:[(0,U.jsxs)(ht,{children:[`Delete “`,e.name,`”?`]}),(0,U.jsx)(mt,{children:`The automation is removed for good. Tasks it already launched and its execution log stay.`})]}),(0,U.jsxs)(vt,{children:[(0,U.jsx)(yt,{children:`Cancel`}),(0,U.jsx)(_t,{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 text-[11px] leading-none font-semibold tracking-[.05em] whitespace-nowrap text-soft-foreground uppercase`,Q=`h-12 border-b border-border px-[10px] text-[13px] leading-none whitespace-nowrap`,Ci=`cz-auto-wide max-[1280px]:hidden`,wi=(0,U.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`});function Ti({data:e,actions:t,now:n=Date.now()}){return(0,U.jsx)(R,{flush:!0,"data-slot":`automations-table`,className:`min-w-0 overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full border-collapse [&_tbody_tr:last-child>td]:border-b-0`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{children:[(0,U.jsx)(`th`,{className:L(Z,`pl-4`),children:`State`}),(0,U.jsx)(`th`,{className:Z,children:`Automation`}),(0,U.jsx)(`th`,{className:Z,children:`Trigger`}),(0,U.jsx)(`th`,{className:L(Z,Ci),children:`Runs as`}),(0,U.jsx)(`th`,{className:Z,children:`Next run`}),(0,U.jsx)(`th`,{className:Z,children:`Last run`}),(0,U.jsx)(`th`,{className:L(Z,Ci,`text-right`),children:`Runs 7d`}),null,(0,U.jsx)(`th`,{className:L(Z,`pr-4`)})]})}),(0,U.jsx)(`tbody`,{children:e.automations.map(r=>(0,U.jsx)(Ei,{automation:r,actions:t,timeZone:e.timeZone,available:e.available,showCost:!1,now:n},r.id))})]})})}function Ei({automation:e,actions:t,timeZone:n,available:r,showCost:i,now:a}){let o=B(),s=e.kind===`github`,c=s&&!r,l=e.task.dispatch,u=Ge(e),d=[e.task.workflow,e.task.runner].filter(Boolean);return(0,U.jsxs)(`tr`,{"data-slot":`automation-row`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,className:L(`cursor-pointer hover:bg-muted`,!e.enabled&&`opacity-60`),onClick:()=>o(`/automations/${encodeURIComponent(e.id)}`),children:[(0,U.jsx)(`td`,{className:L(Q,`pl-4`),children:c?(0,U.jsx)(jt,{dot:`neutral`,children:`paused by capability`}):(0,U.jsx)(jt,{dot:e.enabled?`success`:`neutral`,pulse:e.enabled&&s,children:e.enabled?`enabled`:`paused`})}),(0,U.jsx)(`td`,{className:L(Q,`max-w-0 min-w-[200px]`),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[s?(0,U.jsx)(Bt,{className:`size-3.5 shrink-0 text-soft-foreground`}):e.kind===`tracker`?(0,U.jsx)(ut,{className:`size-3.5 shrink-0 text-soft-foreground`}):(0,U.jsx)(Wt,{className:`size-3.5 shrink-0 text-soft-foreground`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.name}),l?(0,U.jsxs)(`span`,{"data-slot":`dispatch-badge`,title:`dispatch · up to ${l.maxSubtasks??1} subtasks`,className:`inline-flex shrink-0 items-center gap-[3px] rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:[(0,U.jsx)(Jt,{className:`size-2.5`}),`×`,l.maxSubtasks??1]}):null]})}),(0,U.jsx)(`td`,{className:L(Q,`max-w-[260px] overflow-hidden font-mono text-xs text-ellipsis text-muted-foreground`),title:u,children:u}),(0,U.jsx)(`td`,{className:L(Q,Ci,`text-xs text-muted-foreground`),children:d.length?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[d.map((e,t)=>(0,U.jsxs)(`span`,{className:`contents`,children:[t>0?(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}):null,e]},e)),e.task.autonomous?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsx)(`span`,{title:`autonomous`,"data-slot":`autonomous-mark`,className:`inline-flex`,children:(0,U.jsx)(ut,{"aria-hidden":`true`,className:`size-[11px] text-soft-foreground`})})]}):null]}):wi}),(0,U.jsx)(`td`,{"data-slot":`next-run`,className:L(Q,`font-mono text-xs tabular-nums`,e.enabled?`text-foreground`:`text-soft-foreground`),children:Di(e,n,a)}),(0,U.jsx)(`td`,{className:Q,children:e.lastRun?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,U.jsx)(V,{tone:je(e.lastRun.status)}),(0,U.jsx)(`span`,{className:`text-[12.5px] text-muted-foreground`,children:Ue(e.lastRun.status)}),(0,U.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:kt(e.lastRun.ts,a)}),(0,U.jsxs)(Ot,{to:`/tasks/${encodeURIComponent(e.lastRun.runId)}`,"data-slot":`task-link`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-0.5 rounded-full border border-violet/40 px-1.5 py-px font-mono text-[10.5px] font-semibold text-violet`,children:[`task`,(0,U.jsx)(De,{className:`size-[9px]`})]})]}):wi}),(0,U.jsx)(`td`,{className:L(Q,Ci,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.runs7d}),i?(0,U.jsx)(`td`,{className:L(Q,Ci,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.costUsd7d===void 0?wi:Me(e.costUsd7d)}):null,(0,U.jsx)(`td`,{className:L(Q,`pr-3 text-right`),children:(0,U.jsx)(Si,{automation:e,actions:t})})]})}function Di(e,t,n){if(!e.enabled)return`—`;if(e.kind!==`schedule`)return`continuous`;if(e.nextRunAt)return He(e.nextRunAt,t)||`—`;let r=e.schedule?pe(e.schedule,n,t):null;return r===null?`—`:He(r,t)||`—`}function Oi(e){return e.hour*60+e.minute}function ki(e,t,n=0){let r=F(e,t);if(!r)return null;let i=new Date(Date.UTC(r.year,r.month-1,r.day+n));return ce(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),0,0,t)}function Ai(e,t,n,r){let i=[];for(let a of e)if(!(a.kind!==`schedule`||!a.schedule))for(let e of ue(a.schedule,t,n,r)){let t=F(e,r);t&&i.push({automation:a,at:e,parts:t})}return i.sort((e,t)=>e.at-t.at)}function ji(e){let t=new Map;return e.map(e=>{let n=Oi(e.parts),r=t.get(n)??0;return t.set(n,r+1),{occurrence:e,stack:r}})}function Mi({automation:e,minute:t,stack:n=0,wide:r=!1}){let i=B(),a=he(Math.floor(t/60),t%60),o=[e.task.workflow,e.task.runner].filter(Boolean).join(` · `);return(0,U.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:L(`absolute right-[3px] left-[3px] flex cursor-pointer overflow-hidden rounded-[6px] border border-border bg-card text-left text-[11.5px] leading-[1.3] font-medium text-foreground shadow-xs`,r?`h-12 flex-col items-start gap-[3px] px-2 py-[5px]`:`h-6 flex-row items-center gap-1.5 px-1.5`,!e.enabled&&`opacity-50`),style:{top:t/60*34+1+26*n},children:[(0,U.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(V,{tone:e.task.runner===`codex`?`violet`:`success`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),r?(0,U.jsxs)(`span`,{className:`max-w-full overflow-hidden font-mono text-[10.5px] leading-[1.3] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:[a,o?` · ${o}`:``]}):null]})}function Ni(){return(0,U.jsx)(`div`,{"data-slot":`hour-gutter`,className:`w-12 shrink-0`,children:Array.from({length:24},(e,t)=>(0,U.jsx)(`div`,{className:`-translate-y-[6px] pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,style:{height:34},children:t?he(t):``},t))})}function Pi({minute:e}){return(0,U.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,U.jsx)(`span`,{className:`absolute -top-[3px] -left-[3px] size-[8px] rounded-full bg-primary`})})}function Fi(){return(0,U.jsx)(U.Fragment,{children:Array.from({length:24},(e,t)=>(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 h-px bg-border`,style:{top:t*34}},t))})}function Ii({automations:e}){let t=e.filter(e=>e.kind===`github`&&e.enabled);return t.length?(0,U.jsxs)(`div`,{"data-slot":`poll-band`,className:`grid grid-cols-[48px_minmax(0,1fr)] border-b border-border`,children:[(0,U.jsx)(`div`,{className:`py-2 pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,children:`poll`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-1 border-l border-border px-2 py-1.5`,children:t.map(e=>(0,U.jsxs)(`div`,{"data-slot":`poll-row`,className:`flex h-[22px] min-w-0 items-center gap-2 overflow-hidden rounded-[6px] border border-violet/25 bg-violet/8 px-2 text-[11.5px] font-medium`,children:[(0,U.jsx)(Bt,{className:`size-3 shrink-0 text-violet`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name}),(0,U.jsx)(`span`,{className:`overflow-hidden font-mono text-[10.5px] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:Ge(e)}),(0,U.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10.5px] font-normal whitespace-nowrap text-soft-foreground`,children:[e.runs7d,` runs`]})]},e.id))})]}):null}var Li=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Ri({data:e}){let t=we(6e4),n=B(),[r,i]=(0,H.useState)(0),a=e.timeZone,o=ki(t,a,r),s=ki(t,a,r+1),c=o===null?null:F(o,a),l=F(t,a);if(o===null||s===null||!c||!l)return(0,U.jsx)(`div`,{"data-slot":`day-view`,className:`p-5`,children:(0,U.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=ji(Ai(e.automations,o,s,a)),f=e.automations.filter(e=>e.kind===`github`&&e.enabled),p=`${ze(c.weekday)} ${c.day} ${Li[c.month-1]??``}`;return(0,U.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,U.jsxs)(R,{flush:!0,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3.5 py-2.5`,children:[(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous day`,onClick:()=>i(e=>e-1),children:(0,U.jsx)(qe,{className:`size-3.5`})}),(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next day`,onClick:()=>i(e=>e+1),children:(0,U.jsx)(Ye,{className:`size-3.5`})}),(0,U.jsx)(`span`,{"data-slot":`day-title`,className:`text-sm font-semibold whitespace-nowrap`,children:p}),u?(0,U.jsx)(jt,{dot:`success`,children:`today`}):null,(0,U.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,U.jsx)(Ii,{automations:e.automations}),(0,U.jsxs)(`div`,{className:`flex max-h-[600px] overflow-y-auto`,children:[(0,U.jsx)(Ni,{}),(0,U.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,U.jsx)(Fi,{}),u?(0,U.jsx)(Pi,{minute:Oi(l)}):null,d.map(({occurrence:e,stack:t})=>(0,U.jsx)(Mi,{automation:e.automation,minute:Oi(e.parts),stack:t,wide:!0},`${e.automation.id}-${e.at}`))]})]})]}),(0,U.jsxs)(R,{flush:!0,"data-slot":`agenda`,className:`py-3`,children:[(0,U.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`Agenda`}),f.map(e=>(0,U.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,U.jsx)(`span`,{className:`font-mono text-[10.5px] font-medium text-soft-foreground`,children:`poll`}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-[13px] font-medium`,children:[(0,U.jsx)(Bt,{className:`size-3 shrink-0 text-violet`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),(0,U.jsxs)(`span`,{className:`mt-0.5 block overflow-hidden font-mono text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:[Ge(e),` · continuous`]})]})]},e.id)),d.map(({occurrence:e})=>{let r=e.at<t,{automation:i}=e;return(0,U.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,U.jsx)(`span`,{className:L(`font-mono text-xs font-medium tabular-nums`,r?`text-soft-foreground`:`text-foreground`),children:he(e.parts.hour,e.parts.minute)}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsxs)(`span`,{className:L(`flex items-center gap-2 text-[13px] font-medium`,r&&`text-muted-foreground`),children:[(0,U.jsx)(V,{tone:r&&i.lastRun?je(i.lastRun.status):`neutral`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:i.name})]}),(0,U.jsx)(`span`,{className:`mt-0.5 block overflow-hidden text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:i.task.prompt})]})]},`${i.id}-${e.at}`)}),d.length===0?(0,U.jsx)(`p`,{className:`px-3.5 py-2 text-[12.5px] text-soft-foreground`,children:f.length?`Nothing scheduled — the GitHub polls above still run.`:`Nothing scheduled.`}):null]})]})}function zi(e,t,n,r=12){let i=[];for(let a of e)if(!(!a.enabled||a.kind!==`schedule`||!a.schedule))for(let e of ue(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 Bi({open:e,onOpenChange:t,upcoming:n,pollCount:r,timeZone:i,now:a}){let o=B(),s=F(a,i);return(0,U.jsx)(xe,{open:e,onOpenChange:t,children:(0,U.jsxs)(be,{side:`right`,"data-slot":`next-runs-rail`,"aria-describedby":void 0,className:`w-[360px] gap-0 sm:max-w-[360px]`,children:[(0,U.jsxs)(Se,{className:`px-4 pt-4 pb-2`,children:[(0,U.jsxs)(Ce,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,U.jsx)(Ke,{className:`size-4`}),`Next runs`]}),(0,U.jsx)(ye,{className:`sr-only`,children:`Upcoming scheduled runs, soonest first.`})]}),(0,U.jsxs)(`div`,{className:`overflow-y-auto`,children:[n.map((e,n)=>{let r=F(e.at,i),c=r!==null&&s!==null&&r.year===s.year&&r.month===s.month&&r.day===s.day,l=r?`${c?``:`${ze(r.weekday)} `}${he(r.hour,r.minute)}`:``;return(0,U.jsxs)(`button`,{type:`button`,"data-slot":`next-run-row`,"data-automation":e.automation.id,onClick:()=>{t(!1),o(`/automations/${encodeURIComponent(e.automation.id)}`)},className:`grid w-full cursor-pointer grid-cols-[76px_1fr_auto] items-center gap-2 px-4 py-2 text-left text-[13px] hover:bg-muted`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-medium whitespace-nowrap text-muted-foreground tabular-nums`,children:l}),(0,U.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.automation.name}),(0,U.jsx)(`span`,{className:`text-[11px] whitespace-nowrap text-soft-foreground`,children:Ae(e.at,a)})]},`${e.automation.id}-${n}`)}),n.length===0?(0,U.jsx)(`p`,{className:`px-4 py-2 text-[12.5px] text-soft-foreground`,children:`No scheduled runs in the next two weeks.`}):null,(0,U.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,U.jsx)(V,{tone:`pending`,pulse:!0}),r,` GitHub polls running continuously`]})]})]})})}function Vi({stats:e,pollCount:t,upcoming:n,timeZone:r,railOpen:i,onOpenRail:a}){let o=n[0];return(0,U.jsxs)(`div`,{"data-slot":`stats-strip`,className:`flex flex-wrap items-center gap-4 text-[12.5px] text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`This week`}),(0,U.jsx)(Hi,{label:`runs`,value:String(e.runs)}),null,(0,U.jsx)(Hi,{label:`failed`,value:String(e.failed),danger:e.failed>0}),(0,U.jsx)(Hi,{label:`agent time`,value:We(e.agentSeconds)}),(0,U.jsxs)(`span`,{"data-slot":`stats-polls`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,U.jsx)(V,{tone:`pending`,pulse:!0}),t,` GitHub polls continuous`]}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsxs)(`span`,{"data-slot":`stats-next`,className:`inline-flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,U.jsx)(Wt,{className:`size-[13px] text-soft-foreground`}),`next`,` `,(0,U.jsx)(`b`,{className:`font-mono text-[12.5px] font-medium text-foreground`,children:o?Le(o.at,r):`—`}),` `,(0,U.jsx)(`span`,{className:`max-w-[180px] overflow-hidden text-ellipsis`,children:o?.automation.name??``})]}),(0,U.jsxs)(h,{variant:`outline`,size:`sm`,"aria-expanded":i,className:`shrink-0`,onClick:a,children:[(0,U.jsx)(Ke,{className:`size-3.5`}),`Next runs`,(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:n.length})]})]})}function Hi({label:e,value:t,danger:n=!1}){return(0,U.jsxs)(`span`,{"data-slot":`stat`,"data-label":e,className:`inline-flex shrink-0 items-baseline gap-[5px] whitespace-nowrap`,children:[(0,U.jsx)(`b`,{className:L(`font-mono text-sm font-semibold tabular-nums`,n?`text-danger`:`text-foreground`),children:t}),e]})}var Ui=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function Wi({data:e}){let t=we(6e4),n=e.timeZone,r=F(t,n),i=r?Array.from({length:8},(e,i)=>ki(t,n,i-(r.weekday-1))):[],a=i[0],o=i[7];if(!r||a==null||o==null)return(0,U.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,U.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=Ai(e.automations,a,o,n),l=Ui.map((e,t)=>{let r=i[t];return{label:e,dayOfMonth:r==null?null:F(r,n)?.day??null,isToday:t===s,blocks:ji(c.filter(e=>e.parts.weekday-1===t))}});return(0,U.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,U.jsxs)(R,{flush:!0,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-[48px_repeat(7,minmax(0,1fr))] border-b border-border`,children:[(0,U.jsx)(`div`,{}),l.map(e=>(0,U.jsxs)(`div`,{"data-slot":`week-day-header`,"data-today":e.isToday?`true`:void 0,className:L(`flex items-center gap-2 border-l border-border px-2 py-2.5 text-[11px] font-semibold tracking-[.05em] uppercase`,e.isToday?`text-foreground`:`text-soft-foreground`),children:[e.label,(0,U.jsx)(`span`,{className:L(`rounded-full px-[7px] py-px text-[13px] font-medium tracking-normal normal-case`,e.isToday?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e.dayOfMonth??``})]},e.label))]}),(0,U.jsx)(Ii,{automations:e.automations}),(0,U.jsxs)(`div`,{className:`flex max-h-[560px] overflow-y-auto`,children:[(0,U.jsx)(Ni,{}),l.map(e=>(0,U.jsxs)(`div`,{"data-slot":`week-column`,"data-today":e.isToday?`true`:void 0,className:L(`relative min-w-0 flex-1 border-l border-border`,e.isToday&&`bg-muted/35`),style:{height:816},children:[(0,U.jsx)(Fi,{}),e.isToday?(0,U.jsx)(Pi,{minute:Oi(r)}):null,e.blocks.map(({occurrence:e,stack:t})=>(0,U.jsx)(Mi,{automation:e.automation,minute:Oi(e.parts),stack:t},`${e.automation.id}-${e.at}`))]},e.label))]})]})})}function Gi(e){return[{value:`list`,label:`List`,...e===void 0?{}:{count:e}},{value:`week`,label:`Week`},{value:`day`,label:`Day`}]}function Ki({data:e,error:t,actions:n,view:r,onViewChange:i}){let[a,o]=(0,H.useState)(!1),s=Date.now(),c=e?zi(e.automations,s,e.timeZone,12):[],l=e?e.automations.filter(e=>e.kind===`github`&&e.enabled).length:0;return(0,U.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,U.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,U.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,U.jsx)(_e,{slot:`automations-view`,label:`View`,value:r,options:Gi(e?.automations.length),onChange:i}),(0,U.jsx)(`div`,{className:`flex-1`}),e?(0,U.jsxs)(`span`,{"data-slot":`automations-status`,className:`inline-flex min-w-0 items-center gap-2 overflow-hidden text-[12.5px] text-ellipsis whitespace-nowrap text-muted-foreground max-[1280px]:hidden`,children:[(0,U.jsx)(V,{tone:e.scheduler.state===`scheduled`?`success`:`neutral`}),e.scheduler.state===`scheduled`?`Scheduler running`:`Scheduler idle`,(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),e.available?`GitHub available`:`GitHub unavailable${e.reason?` · ${e.reason}`:``}`,(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.timeZone})]}):null,(0,U.jsx)(h,{asChild:!0,className:`shrink-0`,children:(0,U.jsxs)(Ot,{to:`/automations/new`,children:[(0,U.jsx)(Vt,{className:`size-[15px]`}),`New automation`]})})]}),t===void 0?e?e.automations.length===0?(0,U.jsx)(ne,{icon:(0,U.jsx)(ut,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,U.jsx)(h,{asChild:!0,children:(0,U.jsxs)(Ot,{to:`/automations/new`,children:[(0,U.jsx)(Vt,{className:`size-[15px]`}),`New automation`]})})}):r===`week`?(0,U.jsx)(Wi,{data:e}):r===`day`?(0,U.jsx)(Ri,{data:e}):(0,U.jsxs)(`div`,{"data-slot":`automations-list`,className:`flex flex-col gap-3 p-5`,children:[(0,U.jsx)(Vi,{stats:e.stats,pollCount:l,upcoming:c,timeZone:e.timeZone,railOpen:a,onOpenRail:()=>o(!0)}),(0,U.jsx)(Ti,{data:e,actions:n,now:s}),(0,U.jsx)(Bi,{open:a,onOpenChange:o,upcoming:c,pollCount:l,timeZone:e.timeZone,now:s})]}):(0,U.jsx)(`div`,{className:`p-5`,children:(0,U.jsx)($,{text:`Loading automations…`})}):(0,U.jsx)(`div`,{className:`p-5`,children:(0,U.jsx)($,{text:t})})]})}function qi({mode:e=`list`}){let{automationId:t}=j(),n=B(),r=Fe(),i=Pe(r.known&&!r.off),a=Re(i.data),[o,s]=se(),c=Ji(o.get(`view`));if(!r.known)return(0,U.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,U.jsx)($,{text:`Loading automations…`})});if(r.off)return(0,U.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,U.jsx)(ne,{icon:(0,U.jsx)(ut,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This cockpit was started with CEZ_AUTOMATIONS=0. Unset it and restart cezar to turn automations on.`,heading:`h2`})});let l=()=>n(`/automations`);if(e===`new`)return(0,U.jsx)(pi,{data:i.data,onBack:l,onSaved:l});if(e===`edit`){let e=i.data?.automations.find(e=>e.id===t);return i.data&&!e?(0,U.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,U.jsx)($,{text:`Automation not found.`})}):e?(0,U.jsx)(pi,{data:i.data,automation:e,actions:a,onBack:l,onSaved:l,onLog:()=>n(`/automations/${encodeURIComponent(e.id)}/log`)}):(0,U.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,U.jsx)($,{text:`Loading automation…`})})}if(e===`log`){let e=i.data?.automations.find(e=>e.id===t);return t?(0,U.jsx)(_i,{automationId:t,automation:e,timeZone:i.data?.timeZone,onBack:l}):(0,U.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,U.jsx)($,{text:`Automation not found.`})})}return(0,U.jsx)(Ki,{data:i.data,error:i.error?String(i.error instanceof Error?i.error.message:i.error):void 0,actions:a,view:c,onViewChange:e=>s(t=>{let n=new URLSearchParams(t);return e===`list`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})})}function Ji(e){return e===`week`||e===`day`?e:`list`}function $({text:e}){return(0,U.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e})}export{qi as AutomationsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{$ as i,$t as a,Ct as o,D as s,Ht as c,Jn as l,Kr as u,Pn as d,Si as f,Xt as p,_ as m,a as h,ar as g,b as _,bi as v,c as y,d as b,f as x,g as S,gr as C,h as w,i as T,ir as E,k as ee,l as D,m as O,ni as k,s as te,t as ne,u as re,v as A,vi as j,vr as ie,w as M,wi as ae,x as N,xi as oe,y as P,yi as se}from"./centered-state-CLXeAT-P.js";import{A as ce,C as le,D as ue,E as de,S as fe,T as pe,c as me,k as F,r as I,t as L,w as he,x as ge}from"./utils-R1j1Kev9.js";import{i as _e,u as ve}from"./facet-filter-BRRVNtZY.js";import{a as ye,i as be,n as xe,o as Se,s as Ce,t as we}from"./use-now-B04hkXJF.js";import{E as Te}from"./editable-title-BxM_4PmX.js";import{t as Ee}from"./arrow-left-CGgyNclf.js";import{d as De,l as Oe}from"./tooltip-EnWGRZ-b.js";import{_ as ke,a as Ae,c as je,d as Me,f as Ne,g as Pe,h as Fe,i as Ie,l as Le,m as Re,n as ze,o as Be,p as Ve,r as He,s as Ue,t as We,u as Ge,v as R,y as Ke}from"./automation-format-DUj3D5GW.js";import{t as qe}from"./chevron-left-kXrg7RiT.js";import{s as Je}from"./popover-CBd2q-UG.js";import{t as Ye}from"./chevron-right-Djhs_Y97.js";import{c as Xe,f as Ze,n as Qe,p as $e,r as et,s as tt,t as nt}from"./dropdown-menu-D_f8VdfX.js";import{n as rt,t as it}from"./trash-2-qfu5zdbW.js";import{c as at,r as z,t as ot}from"./picker-pill-B4psQ_6Z.js";import{t as st}from"./file-text-OBjZeSyD.js";import{f as ct,m as lt,p as ut}from"./new-task-form-ChW4VQlz.js";import{n as dt,r as ft,t as pt}from"./collapsible-BI1pq6sH.js";import{a as mt,c as ht,i as gt,n as _t,o as vt,r as yt,s as bt,t as xt}from"./alert-dialog-BSwo0F4G.js";import{a as St,i as Ct,n as wt,r as Tt,t as Et}from"./dist-BG6m4Jzn.js";import{c as B,s as Dt,t as Ot}from"./project-router-CkynDkNI.js";import{i as V}from"./token-metrics-DAiDb02U.js";import{n as kt}from"./format-DHK74MwW.js";import{s as At}from"./skills-9oR_oHse.js";import{t as jt}from"./pill-BQuNfP0B.js";import{t as Mt}from"./textarea-AOyg8DK7.js";import{i as Nt,o as Pt,r as Ft}from"./prompt-templates-CGGHGApJ.js";import{F as It,I as Lt,J as Rt,L as zt,P as Bt,U as Vt,d as Ht,p as Ut,q as Wt,s as Gt,t as Kt}from"./index-CQc7jbyM.js";var qt=I(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Jt=I(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Yt=I(`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`}]]),Xt=I(`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`}]]),Zt=I(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Qt=I(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),$t=I(`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`}]]),en=I(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),tn=I(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]);function nn(e,[t,n]){return Math.min(n,Math.max(t,e))}var H=e(t(),1),rn=e(n(),1),U=r(),an=[` `,`Enter`,`ArrowUp`,`ArrowDown`],on=[` `,`Enter`],W=`Select`,[sn,cn,ln]=$e(W),[G,un]=_(W,[ln,St]),dn=St(),[fn,K]=G(W),[pn,mn]=G(W),hn=`SelectProvider`;function gn(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:h,internal_do_not_use_render:g}=e,_=dn(t),[v,y]=H.useState(null),[b,x]=H.useState(null),[S,C]=H.useState(!1),T=Ze(l),[E,ee]=m({prop:r,defaultProp:i??!1,onChange:a,caller:W}),[D,O]=m({prop:o,defaultProp:s,onChange:c,caller:W}),k=H.useRef(null),te=H.useRef(D);H.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=()=>O(te.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,O]);let ne=!v||!!h||!!v.closest(`form`),[re,A]=H.useState(new Set),j=w(),ie=Array.from(re).map(e=>e.props.value).join(`;`),M=H.useCallback(e=>{A(t=>new Set(t).add(e))},[]),ae=H.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),N={required:p,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:C,contentId:j,value:D,onValueChange:O,open:E,onOpenChange:ee,dir:T,triggerPointerDownPosRef:k,disabled:f,name:u,autoComplete:d,form:h,nativeOptions:re,nativeSelectKey:ie,isFormControl:ne};return(0,U.jsx)(Ct,{..._,children:(0,U.jsx)(fn,{scope:t,...N,children:(0,U.jsx)(sn.Provider,{scope:t,children:(0,U.jsx)(pn,{scope:t,onNativeOptionAdd:M,onNativeOptionRemove:ae,children:pr(g)?g(N):n})})})})}gn.displayName=hn;var _n=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,U.jsx)(gn,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,U.jsxs)(U.Fragment,{children:[n,e?(0,U.jsx)(fr,{__scopeSelect:t}):null]})})};_n.displayName=W;var vn=`SelectTrigger`,yn=H.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=dn(n),o=K(vn,n),c=o.disabled||r,l=s(t,o.onTriggerChange),u=cn(n),d=H.useRef(`touch`),[f,p,m]=hr(e=>{let t=u().filter(e=>!e.disabled),n=gr(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),h=e=>{c||(o.onOpenChange(!0),m()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,U.jsx)(Et,{asChild:!0,...a,children:(0,U.jsx)(N.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":mr(o.value)?``:void 0,...i,ref:l,onClick:P(i.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:P(i.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:P(i.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&an.includes(e.key)&&(h(),e.preventDefault())})})})});yn.displayName=vn;var bn=`SelectValue`,xn=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...c}=e,l=K(bn,n),{onValueNodeHasChildrenChange:u}=l,d=a!==void 0,f=s(t,l.onValueNodeChange);A(()=>{u(d)},[u,d]);let p=mr(l.value);return(0,U.jsx)(N.span,{...c,asChild:!p&&c.asChild,ref:f,style:{pointerEvents:`none`},children:(0,U.jsx)(H.Fragment,{children:p?o:a},p?`placeholder`:`value`)})});xn.displayName=bn;var Sn=`SelectIcon`,Cn=H.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,U.jsx)(N.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Cn.displayName=Sn;var wn=`SelectPortal`,[Tn,En]=G(wn,{forceMount:void 0}),Dn=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,U.jsx)(Tn,{scope:e.__scopeSelect,forceMount:n,children:(0,U.jsx)(re,{asChild:!0,...r})})};Dn.displayName=wn;var q=`SelectContent`,On=H.forwardRef((e,t)=>{let n=En(q,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=K(q,e.__scopeSelect),[o,s]=H.useState();return A(()=>{s(new DocumentFragment)},[]),(0,U.jsx)(S,{present:r||a.open,children:({present:e})=>e?(0,U.jsx)(Nn,{...i,ref:t}):(0,U.jsx)(kn,{...i,fragment:o})})});On.displayName=q;var kn=H.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?rn.createPortal((0,U.jsx)(An,{scope:n,children:(0,U.jsx)(sn.Slot,{scope:n,children:(0,U.jsx)(`div`,{ref:t,children:r})})}),i):null});kn.displayName=`SelectContentFragment`;var J=10,[An,Y]=G(q),jn=`SelectContentImpl`,Mn=M(`SelectContent.RemoveScroll`),Nn=H.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_,...v}=e,S=K(q,n),[C,w]=H.useState(null),[T,E]=H.useState(null),ee=s(t,w),[O,k]=H.useState(null),[ne,re]=H.useState(null),A=cn(n),[j,ie]=H.useState(!1),M=H.useRef(!1);H.useEffect(()=>{if(C)return te(C)},[C]),D();let ae=H.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,T]),N=H.useCallback(()=>ae([O,C]),[ae,O,C]);H.useEffect(()=>{j&&N()},[j,N]);let{onOpenChange:oe,triggerPointerDownPosRef:se}=S;H.useEffect(()=>{if(C){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(se.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(se.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(C)||oe(!1),document.removeEventListener(`pointermove`,t),se.current=null};return se.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[C,oe,se]),H.useEffect(()=>{let e=()=>oe(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[oe]);let[ce,le]=hr(e=>{let t=A().filter(e=>!e.disabled),n=gr(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ue=H.useCallback((e,t,n)=>{let r=!M.current&&!n;(S.value!==void 0&&S.value===t||r)&&(k(e),r&&(M.current=!0))},[S.value]),de=H.useCallback(()=>C?.focus(),[C]),fe=H.useCallback((e,t,n)=>{let r=!M.current&&!n;(S.value!==void 0&&S.value===t||r)&&re(e)},[S.value]),pe=r===`popper`?Ln:Fn,me=pe===Ln?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:h,hideWhenDetached:g,avoidCollisions:_}:{};return(0,U.jsx)(An,{scope:n,content:C,viewport:T,onViewportChange:E,itemRefCallback:ue,selectedItem:O,onItemLeave:de,itemTextRefCallback:fe,focusSelectedItem:N,selectedItemText:ne,position:r,isPositioned:j,searchRef:ce,children:(0,U.jsx)(y,{as:Mn,allowPinchZoom:!0,children:(0,U.jsx)(b,{asChild:!0,trapped:S.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:P(i,e=>{S.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,U.jsx)(x,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:(0,U.jsx)(pe,{role:`listbox`,id:S.contentId,"data-state":S.open?`open`:`closed`,dir:S.dir,onContextMenu:e=>e.preventDefault(),...v,...me,onPlaced:()=>ie(!0),ref:ee,style:{display:`flex`,flexDirection:`column`,outline:`none`,...v.style},onKeyDown:P(v.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&le(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>ae(t)),e.preventDefault()}})})})})})})});Nn.displayName=jn;var Pn=`SelectItemAlignedPosition`,Fn=H.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=K(q,n),o=Y(q,n),[c,l]=H.useState(null),[u,d]=H.useState(null),f=s(t,d),p=cn(n),m=H.useRef(!1),h=H.useRef(!0),{viewport:g,selectedItem:_,selectedItemText:v,focusSelectedItem:y}=o,b=H.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&g&&_&&v){let e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-J,d=nn(a,[J,Math.max(J,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-J,d=nn(a,[J,Math.max(J,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let o=p(),s=window.innerHeight-J*2,l=g.scrollHeight,d=window.getComputedStyle(u),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+l+b+y,S=Math.min(_.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-J,ee=s-E,D=_.offsetHeight/2,O=_.offsetTop+D,k=f+h+O,te=x-k;if(k<=E){let e=o.length>0&&_===o[o.length-1].ref.current;c.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=k+Math.max(ee,D+(e?T:0)+t+y);c.style.height=n+`px`}else{let e=o.length>0&&_===o[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+D)+te;c.style.height=t+`px`,g.scrollTop=k-E+g.offsetTop}c.style.margin=`${J}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,u,g,_,v,a.dir,r]);A(()=>b(),[b]);let[x,S]=H.useState();return A(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]),(0,U.jsx)(Rn,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:H.useCallback(e=>{e&&h.current===!0&&(b(),y?.(),h.current=!1)},[b,y]),children:(0,U.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,U.jsx)(N.div,{...i,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Fn.displayName=Pn;var In=`SelectPopperPosition`,Ln=H.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=J,...a}=e,o=dn(n);return(0,U.jsx)(Tt,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Ln.displayName=In;var[Rn,zn]=G(q,{}),Bn=`SelectViewport`,Vn=H.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Y(Bn,n),o=zn(Bn,n),c=s(t,a.onViewportChange),l=H.useRef(0);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,U.jsx)(sn.Slot,{scope:n,children:(0,U.jsx)(N.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:P(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-J*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})});Vn.displayName=Bn;var Hn=`SelectGroup`,[Un,Wn]=G(Hn),Gn=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=w();return(0,U.jsx)(Un,{scope:n,id:i,children:(0,U.jsx)(N.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Gn.displayName=Hn;var Kn=`SelectLabel`,qn=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Wn(Kn,n);return(0,U.jsx)(N.div,{id:i.id,...r,ref:t})});qn.displayName=Kn;var Jn=`SelectItem`,[Yn,Xn]=G(Jn),Zn=H.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,c=K(Jn,n),l=Y(Jn,n),u=c.value===r,[d,f]=H.useState(a??``),[p,m]=H.useState(!1),h=s(t,O(e=>l.itemRefCallback?.(e,r,i))),g=w(),_=H.useRef(`touch`),v=()=>{i||(c.onValueChange(r),c.onOpenChange(!1))};return(0,U.jsx)(Yn,{scope:n,value:r,disabled:i,textId:g,isSelected:u,onItemTextChange:H.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,U.jsx)(sn.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:(0,U.jsx)(N.div,{role:`option`,"aria-labelledby":g,"data-highlighted":p?``:void 0,"aria-selected":u&&p,"data-state":u?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:h,onFocus:P(o.onFocus,()=>m(!0)),onBlur:P(o.onBlur,()=>m(!1)),onClick:P(o.onClick,()=>{_.current!==`mouse`&&v()}),onPointerUp:P(o.onPointerUp,()=>{_.current===`mouse`&&v()}),onPointerDown:P(o.onPointerDown,e=>{_.current=e.pointerType}),onPointerMove:P(o.onPointerMove,e=>{_.current=e.pointerType,i?l.onItemLeave?.():_.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:P(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:P(o.onKeyDown,e=>{i||e.target!==e.currentTarget||l.searchRef?.current!==``&&e.key===` `||(on.includes(e.key)&&v(),e.key===` `&&e.preventDefault())})})})})});Zn.displayName=Jn;var Qn=`SelectItemText`,$n=H.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=K(Qn,n),c=Y(Qn,n),l=Xn(Qn,n),u=mn(Qn,n),[d,f]=H.useState(null),p=O(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),m=s(t,f,l.onItemTextChange,p),h=d?.textContent,g=H.useMemo(()=>(0,U.jsx)(`option`,{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:_,onNativeOptionRemove:v}=u;return A(()=>(_(g),()=>v(g)),[_,v,g]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(N.span,{id:l.textId,...a,ref:m}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!mr(o.value)?rn.createPortal(a.children,o.valueNode):null]})});$n.displayName=Qn;var er=`SelectItemIndicator`,tr=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Xn(er,n).isSelected?(0,U.jsx)(N.span,{"aria-hidden":!0,...r,ref:t}):null});tr.displayName=er;var nr=`SelectScrollUpButton`,rr=H.forwardRef((e,t)=>{let n=Y(nr,e.__scopeSelect),r=zn(nr,e.__scopeSelect),[i,a]=H.useState(!1),o=s(t,r.onScrollButtonChange);return A(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,U.jsx)(or,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});rr.displayName=nr;var ir=`SelectScrollDownButton`,ar=H.forwardRef((e,t)=>{let n=Y(ir,e.__scopeSelect),r=zn(ir,e.__scopeSelect),[i,a]=H.useState(!1),o=s(t,r.onScrollButtonChange);return A(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,U.jsx)(or,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});ar.displayName=ir;var or=H.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Y(`SelectScrollButton`,n),o=H.useRef(null),s=cn(n),c=H.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return H.useEffect(()=>()=>c(),[c]),A(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,U.jsx)(N.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:P(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:P(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:P(i.onPointerLeave,()=>{c()})})}),sr=`SelectSeparator`,cr=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,U.jsx)(N.div,{"aria-hidden":!0,...r,ref:t})});cr.displayName=sr;var lr=`SelectArrow`,ur=H.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=dn(n);return Y(lr,n).position===`popper`?(0,U.jsx)(wt,{...i,...r,ref:t}):null});ur.displayName=lr;var dr=`SelectBubbleInput`,fr=H.forwardRef(({__scopeSelect:e,...t},n)=>{let r=K(dr,e),{value:i,onValueChange:a,required:o,disabled:c,name:l,autoComplete:u,form:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=H.useRef(null),h=s(n,m),g=i??``,_=zt(g),v=Array.from(f).some(e=>(e.props.value??``)===``);return H.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(_!==g&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,g),e.dispatchEvent(t)}},[_,g]),(0,U.jsxs)(N.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:l,autoComplete:u,disabled:c,form:d,onChange:e=>a(e.target.value),...t,style:{...Oe,...t.style},ref:h,defaultValue:g,children:[mr(i)&&!v?(0,U.jsx)(`option`,{value:``}):null,Array.from(f)]},p)});fr.displayName=dr;function pr(e){return typeof e==`function`}function mr(e){return e===``||e===void 0}function hr(e){let t=O(e),n=H.useRef(``),r=H.useRef(0),i=H.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=H.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return H.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function gr(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=_r(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function _r(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function vr({...e}){return(0,U.jsx)(_n,{"data-slot":`select`,...e})}function yr({...e}){return(0,U.jsx)(xn,{"data-slot":`select-value`,...e})}function br({className:e,size:t=`default`,children:n,...r}){return(0,U.jsxs)(yn,{"data-slot":`select-trigger`,"data-size":t,className:L(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-card px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 hover:bg-muted [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,U.jsx)(Cn,{asChild:!0,children:(0,U.jsx)(Je,{className:`size-4 opacity-50`})})]})}function xr({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,U.jsx)(Dn,{children:(0,U.jsxs)(On,{"data-slot":`select-content`,className:L(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,U.jsx)(Sr,{}),(0,U.jsx)(Vn,{className:L(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,U.jsx)(Cr,{})]})})}function X({className:e,children:t,...n}){return(0,U.jsxs)(Zn,{"data-slot":`select-item`,className:L(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,U.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,U.jsx)(tr,{children:(0,U.jsx)(ee,{className:`size-4`})})}),(0,U.jsx)($n,{children:t})]})}function Sr({className:e,...t}){return(0,U.jsx)(rr,{"data-slot":`select-scroll-up-button`,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,U.jsx)(Rt,{className:`size-4`})})}function Cr({className:e,...t}){return(0,U.jsx)(ar,{"data-slot":`select-scroll-down-button`,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,U.jsx)(Je,{className:`size-4`})})}function wr({association:e,selected:t,onSelect:n,onRemove:r}){let i=v({queryKey:[`tracker`,me(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ie({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,U.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,U.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,U.jsx)(z,{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,U.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,c?(0,U.jsxs)(`div`,{role:`alert`,children:[(0,U.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,U.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,U.jsxs)(U.Fragment,{children:[!i.isPending&&!i.isFetching&&l.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,U.jsx)(h,{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,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var Tr=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`];function Er(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function Dr(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function Or(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function kr(e){return e?.source===`skill`?{skill:e.ref,workflow:ct,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var Ar=[2,5,10,15,30,60],jr=[1,2,4,6,8],Mr={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},Nr={type:`daily`,hour:4,minute:0};function Pr(){return{name:``,kind:`schedule`,schedule:{...Nr},events:[`issue.opened`],intervalSeconds:300,filters:{...Mr},prompt:``,workflow:ct,skill:null,customSteps:null,runner:null,account:null,model:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var Fr=e=>(e??[]).join(`, `);function Ir(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Lr(e){let t=Pr(),{task:n,filters:r}=e,i=Dr(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?{authors:Fr(r.authors),assignees:Fr(r.assignees),anyLabels:Fr(r.anyLabels),allLabels:Fr(r.allLabels),excludeLabels:Fr(r.excludeLabels),changedLabels:Fr(r.changedLabels),reviewers:Fr(r.reviewers),lookbackDays:r.lookbackDays,maxRecords:r.maxRecords}: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}}function Rr(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},prompt:e.task.prompt,...e.task.workflow?{workflow:e.task.workflow}:{},...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}:{}}}var zr=e=>e===`claude`||e===`codex`||e===`opencode`||e===`pi`;function Br(e,t){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,prompt:t.prompt,...t.workflow?kr({source:`workflow`,ref:t.workflow}):{},runner:t.runner!==void 0&&zr(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&zr(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 Vr(e){let t=de(e);switch(t.type){case`hours`:return{type:`hours`,every:t.every};case`weekly`:return{type:`weekly`,hour:t.hour,minute:t.minute,day:t.day};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function Hr(e){let t={prompt:e.prompt,...e.skill?{steps:Er(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:Vr(e.schedule),task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:Ur(e.filters.lookbackDays,1,90),maxRecords:Ur(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Ir(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:Ur(n.lookbackDays,1,90),maxRecords:Ur(n.maxRecords,1,100)},task:t}}function Ur(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Wr(e){let t=Hr(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}:{}}}function Gr(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var Kr=e=>[1,2,3,4,6,8,12].includes(e);function qr({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,a]=(0,H.useState)(``),o=me(),s=v({queryKey:[`tracker`,o,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>C({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),c=v({queryKey:[`tracker`,o,`automation-options`,i],enabled:!!i&&s.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>C({...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,H.useEffect)(()=>(r(p),()=>r(!1)),[p,r]);let m=l.data?.pages.flatMap(e=>e.available?[e]:[])??[],g=[...new Map(m.flatMap(e=>e.statuses).map(e=>[e.id,e])).values()],_=new Map((s.data?.pages.flatMap(e=>e.available?e.statuses:[])??[]).map(e=>[e.id,e.name])),y=(e?.targetStatusIds??[]).filter(e=>!g.some(t=>t.id===e)),b=[...new Map(m.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],x=e?.events.includes(`issue.status_changed`),S=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),w=x&&S?`Search tracker statuses and labels`:S?`Search tracker labels`:`Search tracker statuses`;return(0,U.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[s.isPending?(0,U.jsx)(`p`,{children:`Loading tracker events…`}):null,s.isError||u&&!u.available?(0,U.jsxs)(`div`,{role:`alert`,children:[(0,U.jsxs)(`p`,{children:[u&&!u.available?u.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,U.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void s.refetch(),children:`Retry`})]}):null,d?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{children:[d.association.kind===`jira`?`Jira`:`Linear`,` · `,d.association.externalName]}),e&&!f?(0,U.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,U.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,U.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:d.events.map(t=>(0,U.jsx)(z,{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,U.jsx)(wr,{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,U.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,U.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),d.limitations.map(e=>(0,U.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Lt,{"aria-label":w,placeholder:w,value:i,onChange:e=>a(e.target.value)}),l.isFetching?(0,U.jsx)(`p`,{role:`status`,children:`Searching…`}):null,l.isError||l.data?.pages[0]&&!l.data.pages[0].available?(0,U.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,U.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>void l.refetch(),children:`Retry search`})]}):null,!l.isFetching&&l.data?.pages[0]?.available&&x&&g.length===0?(0,U.jsx)(`p`,{children:`No matching statuses.`}):null,!l.isFetching&&l.data?.pages[0]?.available&&S&&b.length===0?(0,U.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,U.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[g.map(t=>(0,U.jsx)(z,{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)),y.map(t=>(0,U.jsxs)(z,{active:!0,"aria-pressed":!0,onClick:()=>{n({trackerTrigger:{...e,targetStatusIds:(e.targetStatusIds??[]).filter(e=>e!==t)}})},children:[_.get(t)??t,` (not in current results)`]},t))]}):null,e.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)?(0,U.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,U.jsx)(z,{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,U.jsx)(h,{variant:`outline`,size:`sm`,disabled:l.isFetchingNextPage,onClick:()=>void l.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,U.jsxs)(vr,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,U.jsx)(br,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:Ar.map(e=>(0,U.jsxs)(X,{value:String(e),children:[e,` min`]},e))})]})]}),(0,U.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 Jr({definition:e}){let t=(0,H.useMemo)(()=>ke(e),[e]);return(0,U.jsxs)(R,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,U.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Copy as CLI`}),(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void Ve(t),children:[(0,U.jsx)(rt,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,U.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-[11.5px] leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:t}),(0,U.jsxs)(`p`,{className:`mt-2 mb-0 text-[11.5px] leading-[1.5] text-soft-foreground`,children:[`The same definition the cockpit saves — `,(0,U.jsx)(`code`,{className:`text-[11px]`,children:`cez automation schema`}),` prints its shape.`]})]})}function Yr({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=jr.includes(n)?jr:[...jr,n].sort((e,t)=>e-t);return(0,U.jsxs)(`div`,{"data-slot":`editor-dispatch`,"data-enabled":t?`true`:void 0,title:`Let this run start its own subtasks with cez task create — each in a worktree forked off its branch, reporting back into the parent session.`,className:`flex flex-wrap items-center gap-2.5 border-t border-border pt-3 text-[13px] text-muted-foreground`,children:[(0,U.jsxs)(It,{className:`text-[13px] font-medium text-foreground`,children:[(0,U.jsx)(Jt,{"aria-hidden":`true`,className:L(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,U.jsx)(Ht,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i({dispatch:e})})]}),t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,U.jsxs)(vr,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-[12.5px]`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:a.map(e=>(0,U.jsx)(X,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsxs)(It,{className:`text-[13px] font-normal text-muted-foreground`,children:[(0,U.jsx)(Ht,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,U.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-[11.5px] whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null]})}function Xr({events:e,intervalSeconds:t,filters:n,onChange:r}){let[i,a]=(0,H.useState)([`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].some(e=>n[e].trim().length>0)||n.lookbackDays!==7||n.maxRecords!==25),o=(e,t)=>r({filters:{...n,[e]:t}}),s=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:Tr.filter(e=>n.includes(e))})},c=Gr(e),l=c&&n.changedLabels.trim().length===0;return(0,U.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-3.5`,children:[(0,U.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:Tr.map(t=>(0,U.jsx)(z,{active:e.includes(t),"aria-pressed":e.includes(t),className:`font-mono`,onClick:()=>s(t),children:t},t))}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted-foreground`,children:[`poll every`,(0,U.jsxs)(vr,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Poll interval`,className:`text-[13px]`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:Ar.map(e=>(0,U.jsxs)(X,{value:String(e),children:[e,` min`]},e))})]}),(0,U.jsxs)(`span`,{children:[`· last `,n.lookbackDays,` days · maximum `,n.maxRecords,` records`]})]}),(0,U.jsxs)(pt,{open:i,onOpenChange:a,children:[(0,U.jsx)(ft,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(Je,{"aria-hidden":`true`,className:L(`size-3 transition-transform`,i?``:`-rotate-90`)}),`Filters`,l?(0,U.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):null]})}),(0,U.jsx)(dt,{children:(0,U.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-2 sm:grid-cols-2`,children:[(0,U.jsx)(Zr,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>o(`authors`,e)}),(0,U.jsx)(Zr,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>o(`assignees`,e)}),(0,U.jsx)(Zr,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>o(`anyLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>o(`allLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>o(`excludeLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-changed-labels`,label:c?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:l,onChange:e=>o(`changedLabels`,e)}),(0,U.jsx)(Zr,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>o(`reviewers`,e)}),(0,U.jsx)(Qr,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>o(`lookbackDays`,e)}),(0,U.jsx)(Qr,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>o(`maxRecords`,e)})]})})]})]})}function Zr({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(It,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,U.jsx)(Lt,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-[13px]`})]})}function Qr({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(It,{htmlFor:e,className:`text-xs text-muted-foreground`,children:t}),(0,U.jsx)(Lt,{id:e,type:`number`,min:r,max:i,value:n,onChange:e=>a(Ur(Number(e.target.value),r,i)),className:`h-8 w-28 font-mono text-[13px] tabular-nums`})]})}function $r({source:e,sourcesReady:t,skills:n,skillUsage:r,workflows:i,onSource:a,pick:o,onPick:s,baseBranch:c,autonomous:l,onAutonomous:u}){return(0,U.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(Gt,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,U.jsx)(Ut,{pick:o,onChange:s,accounts:!0}),(0,U.jsx)(ot,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,U.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsxs)(It,{className:`text-[13px] font-medium`,children:[`Autonomous`,(0,U.jsx)(Ht,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function ei({className:e,...t}){return(0,U.jsx)(`span`,{"data-slot":`branch-chip`,className:L(`inline-block rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11.5px] leading-[1.3] font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var ti=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`]],ni=e=>String(e).padStart(2,`0`);function ri({schedule:e,timeZone:t,onChange:n}){let r=de(e),i=e=>n({...r,...e});return(0,U.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,U.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:ti.map(([e,t])=>(0,U.jsx)(z,{active:r.type===e,"aria-pressed":r.type===e,onClick:()=>i({type:e}),children:t},e))}),r.type===`weekly`?(0,U.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:fe.map((e,t)=>(0,U.jsx)(z,{active:r.day===t+1,"aria-pressed":r.day===t+1,className:`px-[9px]`,onClick:()=>i({day:t+1}),children:e},e))}):null,r.type===`hours`?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`every`,(0,U.jsxs)(vr,{value:String(r.every),onValueChange:e=>{let t=Number(e);Kr(t)&&i({every:t})},children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Every N hours`,className:`text-[13px]`,children:(0,U.jsx)(yr,{})}),(0,U.jsx)(xr,{children:ge.map(e=>(0,U.jsxs)(X,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-muted-foreground`,children:[`at`,(0,U.jsx)(Lt,{"aria-label":`Hour`,inputMode:`numeric`,value:ni(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,U.jsx)(Lt,{"aria-label":`Minute`,inputMode:`numeric`,value:ni(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,U.jsx)(`span`,{className:`font-mono text-xs`,children:t})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 font-mono text-xs text-soft-foreground`,children:[(0,U.jsx)(`span`,{children:`cron`}),(0,U.jsx)(ei,{"data-slot":`editor-cron`,children:le(r)})]})]})}function ii({lastRun:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){return(0,U.jsxs)(R,{flush:!0,"data-slot":`last-run-card`,className:`px-3.5 py-3`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Last run`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,U.jsx)(V,{tone:je(e.status)}),Ue(e.status),(0,U.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:kt(e.ts,i)}),null]}),(0,U.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,U.jsxs)(h,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,U.jsx)(lt,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}),n?(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,U.jsx)($t,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}var ai=864e5;function oi({kind:e,schedule:t,intervalSeconds:n,timeZone:r,now:i}){let[a,o]=(0,H.useState)(()=>Date.now());(0,H.useEffect)(()=>{if(i!==void 0)return;let e=setInterval(()=>o(Date.now()),6e4);return()=>clearInterval(e)},[i]);let s=i??a,c=(0,H.useMemo)(()=>e===`schedule`?ue(t,s,s+9*ai,r,5):[],[e,t,s,r]);return(0,U.jsxs)(R,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,U.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:e===`schedule`?`Next 5 runs`:`How it polls`}),e===`schedule`?c.length===0?(0,U.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:`Nothing in the next nine days.`}):c.map(e=>(0,U.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-[13px]`,children:[(0,U.jsx)(`span`,{className:`w-[82px] shrink-0 font-mono text-xs font-medium whitespace-nowrap text-foreground tabular-nums`,children:He(e,r)}),(0,U.jsx)(`span`,{className:`text-[11.5px] whitespace-nowrap text-soft-foreground`,children:Ae(e,s)})]},e)):(0,U.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-[12.5px] leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,U.jsxs)(U.Fragment,{children:[`Checks the project tracker every `,Math.round(n/60),` min while cezar is open. No webhook or public URL required.`]}):(0,U.jsxs)(U.Fragment,{children:[`Checks GitHub every `,Math.round(n/60),` min while cezar is open, through your `,(0,U.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var si=[{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.`}],ci=e=>[me(),`automation-templates`,e??``];function li({onPick:e}){let[t,n]=(0,H.useState)(`builtin`),r=Dt(),i=f({queryKey:ci(r),queryFn:({signal:e})=>g(r,{signal:e}),enabled:t===`mine`}),a=t===`builtin`?si.map(e=>({...e,key:e.name})):(i.data?.templates??[]).map(e=>({...Rr(e),key:`${e.project.id}:${e.id}`,when:Ge(e),project:e.project.name}));return(0,U.jsxs)(R,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,U.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,U.jsx)(ui,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,U.jsx)(ui,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,U.jsx)(`span`,{className:`ml-auto min-w-0 overflow-hidden pb-2 text-xs text-ellipsis whitespace-nowrap text-soft-foreground`,children:t===`builtin`?`Ship with cezar`:`Registered in ~/.cezar/config.json`})]}),t===`mine`&&i.isPending?(0,U.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`Loading…`}):t===`mine`&&i.isError?(0,U.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-xs text-danger`,children:i.error.message}):a.length===0?(0,U.jsx)(`p`,{className:`px-4 pt-3 text-xs text-soft-foreground`,children:`No automations in your other projects yet.`}):(0,U.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:a.map(t=>(0,U.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,U.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-semibold`,children:[t.kind===`github`?(0,U.jsx)(Bt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,U.jsx)(Wt,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,U.jsx)(ei,{className:`ml-auto`,children:t.project}):null]}),(0,U.jsx)(`div`,{className:`font-mono text-[11.5px] text-muted-foreground`,children:t.when}),(0,U.jsx)(`div`,{className:`line-clamp-2 text-xs leading-[1.45] text-soft-foreground`,children:t.prompt}),(0,U.jsx)(h,{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 ui({active:e,onClick:t,children:n}){return(0,U.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:L(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-[13px] font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function di(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 fi={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`Describe the task the agent should do each time. Placeholders: {{date}}, {{project}}`,github:`Describe the task the agent should do for each match. Placeholders: {{github.url}}, {{github.title}}, {{github.number}}, {{github.labels}}`};function pi({data:e,automation:t,actions:n,onBack:r,onSaved:s,onLog:u}){let f=ae(),m=B(),g=i(),_=p(),v=a(),y=c(),b=o(),[x,S]=(0,H.useState)(()=>t?Lr(t):Pr()),[C,w]=(0,H.useState)(!t),[T,E]=(0,H.useState)(!1),[ee,D]=(0,H.useState)(!1),[O,te]=(0,H.useState)(null),[ne,re]=(0,H.useState)(!1),A=(0,H.useRef)(null),j=t?.revision,ie=(0,H.useRef)(j);(0,H.useEffect)(()=>{!t||j===ie.current||(ie.current=j,S(Lr(t)),re(!1),te(null))},[t,j]);let M=e=>S(t=>({...t,...e})),N=e?.timeZone??`UTC`,oe=e?.available!==!1,P=g.data?.capabilities.dispatch===!0,se=(0,H.useMemo)(()=>Ft(Pt(_.data?.promptTemplates),g.data?.capabilities),[_.data?.promptTemplates,g.data?.capabilities]),ce=v.data?.workflows??[],le=ce.map(e=>e.name),ue=y.data,de=_.data?.skillUsage,fe=(0,H.useMemo)(()=>At(ue??[],de),[ue,de]),pe=y.data!==void 0&&v.data!==void 0&&!_.isPending,me=b.data?.baseBranch??b.data?.info?.branch??void 0,F=(0,H.useMemo)(()=>Wr(x),[x]),I=x.name.trim().length>0&&x.prompt.trim().length>0&&!ee&&(x.kind!==`tracker`||T),L=e=>{let t=A.current,n=t?.selectionStart??x.prompt.length,r=Nt(x.prompt,n,e);M({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},he=async()=>{D(!0),te(null),re(!1);try{let e=Hr(x);t?await k(t.id,{...e,enabled:x.enabled,expectedRevision:t.revision}):await l({...e,enable:x.enabled}),await f.invalidateQueries({queryKey:Ne()}),s()}catch(e){if(t&&e instanceof d&&e.status===409)re(!0);else{let t=e instanceof Error?e.message:String(e);te({message:t,section:e instanceof d&&e.status===400?di(t):`top`})}}finally{D(!1)}},ge=()=>void f.invalidateQueries({queryKey:Ne()}),_e=t?`Save changes`:x.enabled?`Save and enable`:`Save paused`;return(0,U.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,className:`flex min-h-full flex-col`,children:[(0,U.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,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,U.jsx)(Ee,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,U.jsx)(jt,{dot:t.enabled?`success`:`neutral`,children:t.enabled?`enabled`:`paused`}):null,(0,U.jsx)(`span`,{className:`flex-1`}),t?null:(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,"aria-expanded":C,"aria-label":C?`Hide templates`:`Start from a template`,onClick:()=>w(e=>!e),children:[(0,U.jsx)(Yt,{"aria-hidden":`true`,className:`size-3.5`}),(0,U.jsx)(`span`,{className:`max-md:hidden`,children:C?`Hide templates`:`Start from a template`})]}),(0,U.jsx)(h,{variant:`outline`,onClick:r,children:`Cancel`}),(0,U.jsx)(h,{disabled:!I,onClick:()=>void he(),children:_e})]}),(0,U.jsx)(`div`,{className:`flex justify-center p-5`,children:(0,U.jsxs)(`div`,{className:`grid w-full max-w-[1080px] grid-cols-1 items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[ne?(0,U.jsxs)(`div`,{role:`alert`,"data-slot":`editor-conflict`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-[13px] text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,U.jsx)(h,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:ge,children:`Reload`})]}):null,O?.section===`top`?(0,U.jsx)(hi,{children:O.message}):null,C&&!t?(0,U.jsx)(li,{onPick:e=>{let t=e.workflow&&le.includes(e.workflow)?e.workflow:void 0;S(n=>Br(n,{...e,workflow:t})),w(!1)}}):null,(0,U.jsx)(mi,{title:`Name`,children:(0,U.jsx)(Lt,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:x.name,onChange:e=>M({name:e.target.value}),className:`max-w-[420px] text-[15px] md:text-[15px]`})}),(0,U.jsxs)(mi,{title:`When`,children:[(0,U.jsx)(gi,{value:x.kind,editing:!!t,githubAvailable:oe,githubReason:e?.reason,onChange:e=>M({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})}),x.kind===`schedule`?(0,U.jsx)(ri,{schedule:x.schedule,timeZone:N,onChange:e=>M({schedule:e})}):x.kind===`tracker`?(0,U.jsx)(qr,{trigger:x.trackerTrigger,intervalSeconds:x.intervalSeconds,onChange:M,onValid:E}):(0,U.jsx)(Xr,{events:x.events,intervalSeconds:x.intervalSeconds,filters:x.filters,onChange:e=>M(e)}),O?.section===`when`?(0,U.jsx)(hi,{children:O.message}):null]}),(0,U.jsxs)(mi,{title:`What to run`,children:[(0,U.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`flex flex-wrap items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,U.jsx)(st,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,se.map(e=>(0,U.jsx)(z,{className:`h-6 text-[11.5px]`,title:e.text,onClick:()=>L(e.text),children:e.label},e.id)),(0,U.jsx)(z,{dashed:!0,className:`h-6 text-[11.5px]`,icon:(0,U.jsx)(en,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>m(Kt(`project`,`prompt-templates`)),children:`Manage…`})]}),(0,U.jsx)(Mt,{ref:A,"aria-label":`Prompt`,rows:5,placeholder:fi[x.kind],value:x.prompt,onChange:e=>M({prompt:e.target.value}),className:`min-h-[104px] text-sm leading-[1.55] md:text-sm`}),(0,U.jsx)($r,{source:Or(x),sourcesReady:pe,skills:fe,skillUsage:de,workflows:ce,onSource:e=>M(kr(e)),pick:{runner:x.runner,model:x.model,account:x.account},onPick:e=>M({runner:e.runner,model:e.model,account:e.account}),baseBranch:me,autonomous:x.autonomous,onAutonomous:e=>M({autonomous:e})}),(0,U.jsx)(`p`,{className:`m-0 text-xs leading-[1.5] text-soft-foreground`,children:`Each run is an ordinary cezar task in its own worktree — it queues behind the parallel cap like anything else and never auto-merges.`}),(0,U.jsx)(Yr,{available:P,enabled:x.dispatch,maxSubtasks:x.maxSubtasks,reviewChild:x.reviewChild,onChange:e=>M(e)}),O?.section===`what`?(0,U.jsx)(hi,{children:O.message}):null]}),(0,U.jsx)(mi,{title:`Enable`,children:(0,U.jsxs)(It,{className:`text-[13px] font-medium`,children:[(0,U.jsx)(Ht,{"aria-label":`Enabled`,checked:x.enabled,onCheckedChange:e=>M({enabled:e})}),`Enabled`,x.kind===`schedule`?null:(0,U.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`— from a current-time baseline; existing matches will not launch`})]})})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 lg:sticky lg:top-[76px]`,children:[(0,U.jsx)(oi,{kind:x.kind,schedule:x.schedule,intervalSeconds:x.intervalSeconds,timeZone:N}),(0,U.jsx)(Jr,{definition:F}),t&&t.kind!==`schedule`&&n?(0,U.jsx)(h,{variant:`outline`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t?.lastRun?(0,U.jsx)(ii,{lastRun:t.lastRun,busy:n?.busy,onRunNow:()=>void n?.runNow(t),onLog:u}):null]})]})})]})}function mi({title:e,children:t}){return(0,U.jsxs)(R,{"data-slot":`editor-section`,className:`gap-0 px-6 py-0`,children:[(0,U.jsx)(`div`,{className:`pt-4 pb-1 text-sm font-semibold`,children:e}),(0,U.jsx)(`div`,{className:`flex flex-col gap-3.5 pt-2.5 pb-5`,children:t})]})}function hi({children:e}){return(0,U.jsx)(`p`,{role:`alert`,className:`m-0 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-[12.5px] text-danger`,children:e})}function gi({value:e,editing:t,githubAvailable:n,githubReason:r,onChange:i}){let a=`Change the kind by creating a new automation`;return(0,U.jsx)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`inline-flex flex-wrap gap-0.5 self-start rounded-md bg-muted p-[3px]`,children:[{value:`schedule`,label:`On a schedule`,disabled:t&&e!==`schedule`,...t&&e!==`schedule`?{title:a}:{}},{value:`github`,label:`When GitHub changes`,disabled:!n||t&&e!==`github`,...n?t&&e!==`github`?{title:a}:{}:{title:r??`GitHub is unavailable`}},{value:`tracker`,label:`When Jira / Linear changes`,disabled:t&&e!==`tracker`,...t&&e!==`tracker`?{title:a}:{}}].map(t=>(0,U.jsx)(`button`,{type:`button`,"data-value":t.value,"aria-pressed":t.value===e,disabled:t.disabled,title:t.title,onClick:()=>{t.value!==e&&i(t.value)},className:L(`flex h-7 items-center justify-center gap-1.5 rounded-[7px] px-3 text-[12.5px] font-medium whitespace-nowrap text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,t.value===e&&`bg-card font-semibold text-foreground shadow-xs`),children:t.label},t.value))})}function _i({automationId:e,automation:t,timeZone:n,onBack:r}){let i=B(),a=ae(),o=me(),s=(0,H.useMemo)(()=>[o,`automation-log`,e],[o,e]),c=f({queryKey:s,queryFn:({signal:t})=>E(e,{signal:t})}),[l,d]=(0,H.useState)(`all`),[p,m]=(0,H.useState)(`all`);(0,H.useEffect)(()=>ve((t,n)=>{t===`automation-change`&&n.automationId===e&&a.invalidateQueries({queryKey:s})}),[e,a,s]);let g=oe({mutationFn:e=>u(e),onSuccess:()=>a.invalidateQueries({queryKey:s}),onError:e=>T(e instanceof Error?e.message:String(e),{tone:`danger`})}),_=n??`UTC`,v=c.data?.records.filter(e=>(l===`all`||e.result===l)&&(p===`all`||e.event===p));return(0,U.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-log`,className:`flex min-h-full flex-col`,children:[(0,U.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,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,U.jsx)(Ee,{className:`size-[15px]`})}),(0,U.jsx)(`h1`,{className:`m-0 text-base font-semibold`,children:t?t.name:`Automation`}),(0,U.jsx)(`span`,{className:`text-[13px] text-muted-foreground`,children:`· execution log`}),(0,U.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2`,children:[(0,U.jsxs)(vr,{value:l,onValueChange:e=>d(e),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Filter by result`,className:`text-[12.5px]`,children:(0,U.jsx)(yr,{placeholder:`All results`})}),(0,U.jsxs)(xr,{children:[(0,U.jsx)(X,{value:`all`,children:`All results`}),vi.map(e=>(0,U.jsx)(X,{value:e,children:e},e))]})]}),(0,U.jsxs)(vr,{value:p,onValueChange:e=>m(e),children:[(0,U.jsx)(br,{size:`sm`,"aria-label":`Filter by event`,className:`text-[12.5px]`,children:(0,U.jsx)(yr,{placeholder:`All events`})}),(0,U.jsxs)(xr,{children:[(0,U.jsx)(X,{value:`all`,children:`All events`}),yi.map(e=>(0,U.jsx)(X,{value:e,children:e},e))]})]})]}),(0,U.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>i(`/automations/${encodeURIComponent(e)}`),children:[(0,U.jsx)(Te,{className:`size-[13px]`}),`Edit`]})]}),(0,U.jsx)(`div`,{className:`flex justify-center p-5`,children:c.isError?(0,U.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,U.jsx)($,{text:c.error instanceof Error?c.error.message:String(c.error)})}):v===void 0?(0,U.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,U.jsx)($,{text:`Loading execution log…`})}):v.length===0?(0,U.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,U.jsx)($,{text:`No checks have run yet.`})}):(0,U.jsx)(R,{flush:!0,className:`w-full max-w-[820px]`,children:v.map((e,t)=>(0,U.jsx)(xi,{record:e,run:e.runId===void 0?void 0:c.data?.runs[e.runId],last:t===v.length-1,timeZone:_,retrying:g.isPending&&g.variables===e.receiptId,onRetry:e=>g.mutate(e)},e.seq))})})]})}var vi=[`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`manual`,`catch-up`,`skipped`,`failed`],yi=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`];function bi(e){return e.result===`failed`&&e.runId===void 0?e.receiptId:void 0}function xi({record:e,run:t,last:n,timeZone:r,retrying:i,onRetry:a}){let o=Be(e.result),s=t?.children??[],c=bi(e);return(0,U.jsxs)(`div`,{"data-slot":`log-row`,"data-result":e.result,className:`grid grid-cols-[90px_110px_1fr_auto] items-center gap-x-3 gap-y-2 px-4 py-3 text-[13px] ${n?``:`border-b border-border`}`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:Ie(e.ts,r)}),(0,U.jsx)(jt,{dot:o,className:`w-fit`,children:e.result}),(0,U.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,U.jsx)(`span`,{}):(0,U.jsxs)(h,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a(c),children:[(0,U.jsx)(Qt,{className:`size-3`}),`Retry task`]}):(0,U.jsx)(h,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,U.jsxs)(Ot,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open task`,(0,U.jsx)(De,{className:`size-3`})]})}),s.length>0?(0,U.jsx)(`div`,{className:`col-span-full flex flex-col gap-1 pl-3.5`,children:s.map(e=>(0,U.jsxs)(`div`,{"data-slot":`log-child`,className:`grid grid-cols-[14px_70px_1fr_auto] items-center gap-2.5 text-[12.5px]`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`└`}),(0,U.jsx)(`span`,{className:`w-fit rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:e.kind??`implement`}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(V,{tone:je(e.status)}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.title})]}),null,(0,U.jsx)(h,{variant:`ghost`,size:`sm`,className:`h-6`,asChild:!0,children:(0,U.jsxs)(Ot,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open`,(0,U.jsx)(De,{className:`size-[11px]`})]})})]},e.runId))}):null]})}function Si({automation:e,actions:t}){let n=B(),[r,i]=(0,H.useState)(!1),a=e=>e.stopPropagation(),o=`/automations/${encodeURIComponent(e.id)}`;return(0,U.jsxs)(`span`,{"data-slot":`row-actions`,className:`inline-flex gap-0.5`,onClick:a,children:[e.kind===`schedule`?null:(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,title:`Preview matches`,"aria-label":`Preview matches`,disabled:t.busy,onClick:()=>void t.preview(e),children:(0,U.jsx)(at,{className:`size-[13px]`})}),(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,title:`Run now`,"aria-label":`Run now`,disabled:t.busy,onClick:()=>void t.runNow(e),children:(0,U.jsx)(lt,{className:`size-[13px]`})}),(0,U.jsx)(h,{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,U.jsx)(Xt,{className:`size-[13px]`}):(0,U.jsx)(Zt,{className:`size-[13px]`})}),(0,U.jsxs)(nt,{children:[(0,U.jsx)(Xe,{asChild:!0,children:(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`More`,children:(0,U.jsx)(qt,{className:`size-3.5`})})}),(0,U.jsxs)(Qe,{align:`end`,className:`w-[200px]`,onClick:a,children:[(0,U.jsxs)(et,{onSelect:()=>n(o),children:[(0,U.jsx)(Te,{}),`Edit`]}),(0,U.jsxs)(et,{onSelect:()=>n(`${o}/log`),children:[(0,U.jsx)($t,{}),`View log`]}),(0,U.jsxs)(et,{onSelect:()=>void t.duplicate(e),children:[(0,U.jsx)(rt,{}),`Duplicate`]}),(0,U.jsxs)(et,{onSelect:()=>void t.copyCli(e),children:[(0,U.jsx)(tn,{}),`Copy as CLI`]}),(0,U.jsx)(tt,{}),(0,U.jsxs)(et,{variant:`destructive`,onSelect:()=>i(!0),children:[(0,U.jsx)(it,{}),`Delete`]})]})]}),(0,U.jsx)(xt,{open:r,onOpenChange:i,children:(0,U.jsxs)(gt,{onClick:a,children:[(0,U.jsxs)(bt,{children:[(0,U.jsxs)(ht,{children:[`Delete “`,e.name,`”?`]}),(0,U.jsx)(mt,{children:`The automation is removed for good. Tasks it already launched and its execution log stay.`})]}),(0,U.jsxs)(vt,{children:[(0,U.jsx)(yt,{children:`Cancel`}),(0,U.jsx)(_t,{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 text-[11px] leading-none font-semibold tracking-[.05em] whitespace-nowrap text-soft-foreground uppercase`,Q=`h-12 border-b border-border px-[10px] text-[13px] leading-none whitespace-nowrap`,Ci=`cz-auto-wide max-[1280px]:hidden`,wi=(0,U.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`});function Ti({data:e,actions:t,now:n=Date.now()}){return(0,U.jsx)(R,{flush:!0,"data-slot":`automations-table`,className:`min-w-0 overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full border-collapse [&_tbody_tr:last-child>td]:border-b-0`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{children:[(0,U.jsx)(`th`,{className:L(Z,`pl-4`),children:`State`}),(0,U.jsx)(`th`,{className:Z,children:`Automation`}),(0,U.jsx)(`th`,{className:Z,children:`Trigger`}),(0,U.jsx)(`th`,{className:L(Z,Ci),children:`Runs as`}),(0,U.jsx)(`th`,{className:Z,children:`Next run`}),(0,U.jsx)(`th`,{className:Z,children:`Last run`}),(0,U.jsx)(`th`,{className:L(Z,Ci,`text-right`),children:`Runs 7d`}),null,(0,U.jsx)(`th`,{className:L(Z,`pr-4`)})]})}),(0,U.jsx)(`tbody`,{children:e.automations.map(r=>(0,U.jsx)(Ei,{automation:r,actions:t,timeZone:e.timeZone,available:e.available,showCost:!1,now:n},r.id))})]})})}function Ei({automation:e,actions:t,timeZone:n,available:r,showCost:i,now:a}){let o=B(),s=e.kind===`github`,c=s&&!r,l=e.task.dispatch,u=Ge(e),d=[e.task.workflow,e.task.runner].filter(Boolean);return(0,U.jsxs)(`tr`,{"data-slot":`automation-row`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,className:L(`cursor-pointer hover:bg-muted`,!e.enabled&&`opacity-60`),onClick:()=>o(`/automations/${encodeURIComponent(e.id)}`),children:[(0,U.jsx)(`td`,{className:L(Q,`pl-4`),children:c?(0,U.jsx)(jt,{dot:`neutral`,children:`paused by capability`}):(0,U.jsx)(jt,{dot:e.enabled?`success`:`neutral`,pulse:e.enabled&&s,children:e.enabled?`enabled`:`paused`})}),(0,U.jsx)(`td`,{className:L(Q,`max-w-0 min-w-[200px]`),children:(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[s?(0,U.jsx)(Bt,{className:`size-3.5 shrink-0 text-soft-foreground`}):e.kind===`tracker`?(0,U.jsx)(ut,{className:`size-3.5 shrink-0 text-soft-foreground`}):(0,U.jsx)(Wt,{className:`size-3.5 shrink-0 text-soft-foreground`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.name}),l?(0,U.jsxs)(`span`,{"data-slot":`dispatch-badge`,title:`dispatch · up to ${l.maxSubtasks??1} subtasks`,className:`inline-flex shrink-0 items-center gap-[3px] rounded-full bg-muted px-1.5 py-px text-[10.5px] font-medium text-muted-foreground`,children:[(0,U.jsx)(Jt,{className:`size-2.5`}),`×`,l.maxSubtasks??1]}):null]})}),(0,U.jsx)(`td`,{className:L(Q,`max-w-[260px] overflow-hidden font-mono text-xs text-ellipsis text-muted-foreground`),title:u,children:u}),(0,U.jsx)(`td`,{className:L(Q,Ci,`text-xs text-muted-foreground`),children:d.length?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[d.map((e,t)=>(0,U.jsxs)(`span`,{className:`contents`,children:[t>0?(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}):null,e]},e)),e.task.autonomous?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsx)(`span`,{title:`autonomous`,"data-slot":`autonomous-mark`,className:`inline-flex`,children:(0,U.jsx)(ut,{"aria-hidden":`true`,className:`size-[11px] text-soft-foreground`})})]}):null]}):wi}),(0,U.jsx)(`td`,{"data-slot":`next-run`,className:L(Q,`font-mono text-xs tabular-nums`,e.enabled?`text-foreground`:`text-soft-foreground`),children:Di(e,n,a)}),(0,U.jsx)(`td`,{className:Q,children:e.lastRun?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,U.jsx)(V,{tone:je(e.lastRun.status)}),(0,U.jsx)(`span`,{className:`text-[12.5px] text-muted-foreground`,children:Ue(e.lastRun.status)}),(0,U.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:kt(e.lastRun.ts,a)}),(0,U.jsxs)(Ot,{to:`/tasks/${encodeURIComponent(e.lastRun.runId)}`,"data-slot":`task-link`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-0.5 rounded-full border border-violet/40 px-1.5 py-px font-mono text-[10.5px] font-semibold text-violet`,children:[`task`,(0,U.jsx)(De,{className:`size-[9px]`})]})]}):wi}),(0,U.jsx)(`td`,{className:L(Q,Ci,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.runs7d}),i?(0,U.jsx)(`td`,{className:L(Q,Ci,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:e.costUsd7d===void 0?wi:Me(e.costUsd7d)}):null,(0,U.jsx)(`td`,{className:L(Q,`pr-3 text-right`),children:(0,U.jsx)(Si,{automation:e,actions:t})})]})}function Di(e,t,n){if(!e.enabled)return`—`;if(e.kind!==`schedule`)return`continuous`;if(e.nextRunAt)return He(e.nextRunAt,t)||`—`;let r=e.schedule?pe(e.schedule,n,t):null;return r===null?`—`:He(r,t)||`—`}function Oi(e){return e.hour*60+e.minute}function ki(e,t,n=0){let r=F(e,t);if(!r)return null;let i=new Date(Date.UTC(r.year,r.month-1,r.day+n));return ce(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),0,0,t)}function Ai(e,t,n,r){let i=[];for(let a of e)if(!(a.kind!==`schedule`||!a.schedule))for(let e of ue(a.schedule,t,n,r)){let t=F(e,r);t&&i.push({automation:a,at:e,parts:t})}return i.sort((e,t)=>e.at-t.at)}function ji(e){let t=new Map;return e.map(e=>{let n=Oi(e.parts),r=t.get(n)??0;return t.set(n,r+1),{occurrence:e,stack:r}})}function Mi({automation:e,minute:t,stack:n=0,wide:r=!1}){let i=B(),a=he(Math.floor(t/60),t%60),o=[e.task.workflow,e.task.runner].filter(Boolean).join(` · `);return(0,U.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:L(`absolute right-[3px] left-[3px] flex cursor-pointer overflow-hidden rounded-[6px] border border-border bg-card text-left text-[11.5px] leading-[1.3] font-medium text-foreground shadow-xs`,r?`h-12 flex-col items-start gap-[3px] px-2 py-[5px]`:`h-6 flex-row items-center gap-1.5 px-1.5`,!e.enabled&&`opacity-50`),style:{top:t/60*34+1+26*n},children:[(0,U.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(V,{tone:e.task.runner===`codex`?`violet`:`success`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),r?(0,U.jsxs)(`span`,{className:`max-w-full overflow-hidden font-mono text-[10.5px] leading-[1.3] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:[a,o?` · ${o}`:``]}):null]})}function Ni(){return(0,U.jsx)(`div`,{"data-slot":`hour-gutter`,className:`w-12 shrink-0`,children:Array.from({length:24},(e,t)=>(0,U.jsx)(`div`,{className:`-translate-y-[6px] pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,style:{height:34},children:t?he(t):``},t))})}function Pi({minute:e}){return(0,U.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,U.jsx)(`span`,{className:`absolute -top-[3px] -left-[3px] size-[8px] rounded-full bg-primary`})})}function Fi(){return(0,U.jsx)(U.Fragment,{children:Array.from({length:24},(e,t)=>(0,U.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 h-px bg-border`,style:{top:t*34}},t))})}function Ii({automations:e}){let t=e.filter(e=>e.kind===`github`&&e.enabled);return t.length?(0,U.jsxs)(`div`,{"data-slot":`poll-band`,className:`grid grid-cols-[48px_minmax(0,1fr)] border-b border-border`,children:[(0,U.jsx)(`div`,{className:`py-2 pr-2 text-right font-mono text-[10.5px] text-soft-foreground`,children:`poll`}),(0,U.jsx)(`div`,{className:`flex flex-col gap-1 border-l border-border px-2 py-1.5`,children:t.map(e=>(0,U.jsxs)(`div`,{"data-slot":`poll-row`,className:`flex h-[22px] min-w-0 items-center gap-2 overflow-hidden rounded-[6px] border border-violet/25 bg-violet/8 px-2 text-[11.5px] font-medium`,children:[(0,U.jsx)(Bt,{className:`size-3 shrink-0 text-violet`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name}),(0,U.jsx)(`span`,{className:`overflow-hidden font-mono text-[10.5px] font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:Ge(e)}),(0,U.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10.5px] font-normal whitespace-nowrap text-soft-foreground`,children:[e.runs7d,` runs`]})]},e.id))})]}):null}var Li=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Ri({data:e}){let t=we(6e4),n=B(),[r,i]=(0,H.useState)(0),a=e.timeZone,o=ki(t,a,r),s=ki(t,a,r+1),c=o===null?null:F(o,a),l=F(t,a);if(o===null||s===null||!c||!l)return(0,U.jsx)(`div`,{"data-slot":`day-view`,className:`p-5`,children:(0,U.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=ji(Ai(e.automations,o,s,a)),f=e.automations.filter(e=>e.kind===`github`&&e.enabled),p=`${ze(c.weekday)} ${c.day} ${Li[c.month-1]??``}`;return(0,U.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,U.jsxs)(R,{flush:!0,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3.5 py-2.5`,children:[(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous day`,onClick:()=>i(e=>e-1),children:(0,U.jsx)(qe,{className:`size-3.5`})}),(0,U.jsx)(h,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next day`,onClick:()=>i(e=>e+1),children:(0,U.jsx)(Ye,{className:`size-3.5`})}),(0,U.jsx)(`span`,{"data-slot":`day-title`,className:`text-sm font-semibold whitespace-nowrap`,children:p}),u?(0,U.jsx)(jt,{dot:`success`,children:`today`}):null,(0,U.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,U.jsx)(Ii,{automations:e.automations}),(0,U.jsxs)(`div`,{className:`flex max-h-[600px] overflow-y-auto`,children:[(0,U.jsx)(Ni,{}),(0,U.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,U.jsx)(Fi,{}),u?(0,U.jsx)(Pi,{minute:Oi(l)}):null,d.map(({occurrence:e,stack:t})=>(0,U.jsx)(Mi,{automation:e.automation,minute:Oi(e.parts),stack:t,wide:!0},`${e.automation.id}-${e.at}`))]})]})]}),(0,U.jsxs)(R,{flush:!0,"data-slot":`agenda`,className:`py-3`,children:[(0,U.jsx)(`div`,{className:`px-3.5 pb-2 text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`Agenda`}),f.map(e=>(0,U.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,U.jsx)(`span`,{className:`font-mono text-[10.5px] font-medium text-soft-foreground`,children:`poll`}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-[13px] font-medium`,children:[(0,U.jsx)(Bt,{className:`size-3 shrink-0 text-violet`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),(0,U.jsxs)(`span`,{className:`mt-0.5 block overflow-hidden font-mono text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:[Ge(e),` · continuous`]})]})]},e.id)),d.map(({occurrence:e})=>{let r=e.at<t,{automation:i}=e;return(0,U.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,U.jsx)(`span`,{className:L(`font-mono text-xs font-medium tabular-nums`,r?`text-soft-foreground`:`text-foreground`),children:he(e.parts.hour,e.parts.minute)}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsxs)(`span`,{className:L(`flex items-center gap-2 text-[13px] font-medium`,r&&`text-muted-foreground`),children:[(0,U.jsx)(V,{tone:r&&i.lastRun?je(i.lastRun.status):`neutral`}),(0,U.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:i.name})]}),(0,U.jsx)(`span`,{className:`mt-0.5 block overflow-hidden text-[11.5px] leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:i.task.prompt})]})]},`${i.id}-${e.at}`)}),d.length===0?(0,U.jsx)(`p`,{className:`px-3.5 py-2 text-[12.5px] text-soft-foreground`,children:f.length?`Nothing scheduled — the GitHub polls above still run.`:`Nothing scheduled.`}):null]})]})}function zi(e,t,n,r=12){let i=[];for(let a of e)if(!(!a.enabled||a.kind!==`schedule`||!a.schedule))for(let e of ue(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 Bi({open:e,onOpenChange:t,upcoming:n,pollCount:r,timeZone:i,now:a}){let o=B(),s=F(a,i);return(0,U.jsx)(xe,{open:e,onOpenChange:t,children:(0,U.jsxs)(be,{side:`right`,"data-slot":`next-runs-rail`,"aria-describedby":void 0,className:`w-[360px] gap-0 sm:max-w-[360px]`,children:[(0,U.jsxs)(Se,{className:`px-4 pt-4 pb-2`,children:[(0,U.jsxs)(Ce,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,U.jsx)(Ke,{className:`size-4`}),`Next runs`]}),(0,U.jsx)(ye,{className:`sr-only`,children:`Upcoming scheduled runs, soonest first.`})]}),(0,U.jsxs)(`div`,{className:`overflow-y-auto`,children:[n.map((e,n)=>{let r=F(e.at,i),c=r!==null&&s!==null&&r.year===s.year&&r.month===s.month&&r.day===s.day,l=r?`${c?``:`${ze(r.weekday)} `}${he(r.hour,r.minute)}`:``;return(0,U.jsxs)(`button`,{type:`button`,"data-slot":`next-run-row`,"data-automation":e.automation.id,onClick:()=>{t(!1),o(`/automations/${encodeURIComponent(e.automation.id)}`)},className:`grid w-full cursor-pointer grid-cols-[76px_1fr_auto] items-center gap-2 px-4 py-2 text-left text-[13px] hover:bg-muted`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-medium whitespace-nowrap text-muted-foreground tabular-nums`,children:l}),(0,U.jsx)(`span`,{className:`overflow-hidden text-[13px] font-medium text-ellipsis whitespace-nowrap`,children:e.automation.name}),(0,U.jsx)(`span`,{className:`text-[11px] whitespace-nowrap text-soft-foreground`,children:Ae(e.at,a)})]},`${e.automation.id}-${n}`)}),n.length===0?(0,U.jsx)(`p`,{className:`px-4 py-2 text-[12.5px] text-soft-foreground`,children:`No scheduled runs in the next two weeks.`}):null,(0,U.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,U.jsx)(V,{tone:`pending`,pulse:!0}),r,` GitHub polls running continuously`]})]})]})})}function Vi({stats:e,pollCount:t,upcoming:n,timeZone:r,railOpen:i,onOpenRail:a}){let o=n[0];return(0,U.jsxs)(`div`,{"data-slot":`stats-strip`,className:`flex flex-wrap items-center gap-4 text-[12.5px] text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[.05em] text-soft-foreground uppercase`,children:`This week`}),(0,U.jsx)(Hi,{label:`runs`,value:String(e.runs)}),null,(0,U.jsx)(Hi,{label:`failed`,value:String(e.failed),danger:e.failed>0}),(0,U.jsx)(Hi,{label:`agent time`,value:We(e.agentSeconds)}),(0,U.jsxs)(`span`,{"data-slot":`stats-polls`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,U.jsx)(V,{tone:`pending`,pulse:!0}),t,` GitHub polls continuous`]}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsxs)(`span`,{"data-slot":`stats-next`,className:`inline-flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,U.jsx)(Wt,{className:`size-[13px] text-soft-foreground`}),`next`,` `,(0,U.jsx)(`b`,{className:`font-mono text-[12.5px] font-medium text-foreground`,children:o?Le(o.at,r):`—`}),` `,(0,U.jsx)(`span`,{className:`max-w-[180px] overflow-hidden text-ellipsis`,children:o?.automation.name??``})]}),(0,U.jsxs)(h,{variant:`outline`,size:`sm`,"aria-expanded":i,className:`shrink-0`,onClick:a,children:[(0,U.jsx)(Ke,{className:`size-3.5`}),`Next runs`,(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:n.length})]})]})}function Hi({label:e,value:t,danger:n=!1}){return(0,U.jsxs)(`span`,{"data-slot":`stat`,"data-label":e,className:`inline-flex shrink-0 items-baseline gap-[5px] whitespace-nowrap`,children:[(0,U.jsx)(`b`,{className:L(`font-mono text-sm font-semibold tabular-nums`,n?`text-danger`:`text-foreground`),children:t}),e]})}var Ui=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function Wi({data:e}){let t=we(6e4),n=e.timeZone,r=F(t,n),i=r?Array.from({length:8},(e,i)=>ki(t,n,i-(r.weekday-1))):[],a=i[0],o=i[7];if(!r||a==null||o==null)return(0,U.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,U.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=Ai(e.automations,a,o,n),l=Ui.map((e,t)=>{let r=i[t];return{label:e,dayOfMonth:r==null?null:F(r,n)?.day??null,isToday:t===s,blocks:ji(c.filter(e=>e.parts.weekday-1===t))}});return(0,U.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,U.jsxs)(R,{flush:!0,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-[48px_repeat(7,minmax(0,1fr))] border-b border-border`,children:[(0,U.jsx)(`div`,{}),l.map(e=>(0,U.jsxs)(`div`,{"data-slot":`week-day-header`,"data-today":e.isToday?`true`:void 0,className:L(`flex items-center gap-2 border-l border-border px-2 py-2.5 text-[11px] font-semibold tracking-[.05em] uppercase`,e.isToday?`text-foreground`:`text-soft-foreground`),children:[e.label,(0,U.jsx)(`span`,{className:L(`rounded-full px-[7px] py-px text-[13px] font-medium tracking-normal normal-case`,e.isToday?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e.dayOfMonth??``})]},e.label))]}),(0,U.jsx)(Ii,{automations:e.automations}),(0,U.jsxs)(`div`,{className:`flex max-h-[560px] overflow-y-auto`,children:[(0,U.jsx)(Ni,{}),l.map(e=>(0,U.jsxs)(`div`,{"data-slot":`week-column`,"data-today":e.isToday?`true`:void 0,className:L(`relative min-w-0 flex-1 border-l border-border`,e.isToday&&`bg-muted/35`),style:{height:816},children:[(0,U.jsx)(Fi,{}),e.isToday?(0,U.jsx)(Pi,{minute:Oi(r)}):null,e.blocks.map(({occurrence:e,stack:t})=>(0,U.jsx)(Mi,{automation:e.automation,minute:Oi(e.parts),stack:t},`${e.automation.id}-${e.at}`))]},e.label))]})]})})}function Gi(e){return[{value:`list`,label:`List`,...e===void 0?{}:{count:e}},{value:`week`,label:`Week`},{value:`day`,label:`Day`}]}function Ki({data:e,error:t,actions:n,view:r,onViewChange:i}){let[a,o]=(0,H.useState)(!1),s=Date.now(),c=e?zi(e.automations,s,e.timeZone,12):[],l=e?e.automations.filter(e=>e.kind===`github`&&e.enabled).length:0;return(0,U.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,U.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,U.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,U.jsx)(_e,{slot:`automations-view`,label:`View`,value:r,options:Gi(e?.automations.length),onChange:i}),(0,U.jsx)(`div`,{className:`flex-1`}),e?(0,U.jsxs)(`span`,{"data-slot":`automations-status`,className:`inline-flex min-w-0 items-center gap-2 overflow-hidden text-[12.5px] text-ellipsis whitespace-nowrap text-muted-foreground max-[1280px]:hidden`,children:[(0,U.jsx)(V,{tone:e.scheduler.state===`scheduled`?`success`:`neutral`}),e.scheduler.state===`scheduled`?`Scheduler running`:`Scheduler idle`,(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),e.available?`GitHub available`:`GitHub unavailable${e.reason?` · ${e.reason}`:``}`,(0,U.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.timeZone})]}):null,(0,U.jsx)(h,{asChild:!0,className:`shrink-0`,children:(0,U.jsxs)(Ot,{to:`/automations/new`,children:[(0,U.jsx)(Vt,{className:`size-[15px]`}),`New automation`]})})]}),t===void 0?e?e.automations.length===0?(0,U.jsx)(ne,{icon:(0,U.jsx)(ut,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,U.jsx)(h,{asChild:!0,children:(0,U.jsxs)(Ot,{to:`/automations/new`,children:[(0,U.jsx)(Vt,{className:`size-[15px]`}),`New automation`]})})}):r===`week`?(0,U.jsx)(Wi,{data:e}):r===`day`?(0,U.jsx)(Ri,{data:e}):(0,U.jsxs)(`div`,{"data-slot":`automations-list`,className:`flex flex-col gap-3 p-5`,children:[(0,U.jsx)(Vi,{stats:e.stats,pollCount:l,upcoming:c,timeZone:e.timeZone,railOpen:a,onOpenRail:()=>o(!0)}),(0,U.jsx)(Ti,{data:e,actions:n,now:s}),(0,U.jsx)(Bi,{open:a,onOpenChange:o,upcoming:c,pollCount:l,timeZone:e.timeZone,now:s})]}):(0,U.jsx)(`div`,{className:`p-5`,children:(0,U.jsx)($,{text:`Loading automations…`})}):(0,U.jsx)(`div`,{className:`p-5`,children:(0,U.jsx)($,{text:t})})]})}function qi({mode:e=`list`}){let{automationId:t}=j(),n=B(),r=Fe(),i=Pe(r.known&&!r.off),a=Re(i.data),[o,s]=se(),c=Ji(o.get(`view`));if(!r.known)return(0,U.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,U.jsx)($,{text:`Loading automations…`})});if(r.off)return(0,U.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,U.jsx)(ne,{icon:(0,U.jsx)(ut,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This cockpit was started with CEZ_AUTOMATIONS=0. Unset it and restart cezar to turn automations on.`,heading:`h2`})});let l=()=>n(`/automations`);if(e===`new`)return(0,U.jsx)(pi,{data:i.data,onBack:l,onSaved:l});if(e===`edit`){let e=i.data?.automations.find(e=>e.id===t);return i.data&&!e?(0,U.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,U.jsx)($,{text:`Automation not found.`})}):e?(0,U.jsx)(pi,{data:i.data,automation:e,actions:a,onBack:l,onSaved:l,onLog:()=>n(`/automations/${encodeURIComponent(e.id)}/log`)}):(0,U.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,U.jsx)($,{text:`Loading automation…`})})}if(e===`log`){let e=i.data?.automations.find(e=>e.id===t);return t?(0,U.jsx)(_i,{automationId:t,automation:e,timeZone:i.data?.timeZone,onBack:l}):(0,U.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,U.jsx)($,{text:`Automation not found.`})})}return(0,U.jsx)(Ki,{data:i.data,error:i.error?String(i.error instanceof Error?i.error.message:i.error):void 0,actions:a,view:c,onViewChange:e=>s(t=>{let n=new URLSearchParams(t);return e===`list`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})})}function Ji(e){return e===`week`||e===`day`?e:`list`}function $({text:e}){return(0,U.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e})}export{qi as AutomationsRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$ as r,Ar as i,Cn as a,Lt as o,M as s,Pn as c,Q as l,a as u,dn as d,i as f,k as p,sn as m,t as h,vi as g,wi as _,xi as v}from"./centered-state-CLXeAT-P.js";import{t as y}from"./utils-R1j1Kev9.js";import{t as b}from"./chevron-right-Djhs_Y97.js";import{t as x}from"./search-x-CXirxMBf.js";import{n as S,r as C,t as w}from"./collapsible-BI1pq6sH.js";import{a as T,c as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./alert-dialog-BSwo0F4G.js";import{c as N,t as P}from"./project-router-CkynDkNI.js";import{n as F,t as I}from"./token-metrics-DAiDb02U.js";import{n as L,t as R}from"./pill-BQuNfP0B.js";import{t as z}from"./markdown-DkHWFqkC.js";import{H as B,_ as V}from"./index-BJMs7KMj.js";import{t as H}from"./run-diff-BXaCs_BO.js";var U=e(t(),1),W=n();function G(){let{groupId:e}=g(),t=l(e),n=I(r().data),i=_();if((0,U.useEffect)(()=>{e&&i.invalidateQueries({queryKey:s.groups.detail(e)})},[i,e,(o().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,W.jsx)(V,{});if(t.isError){let e=t.error instanceof c&&t.error.status===404;return(0,W.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,W.jsx)(h,{icon:e?(0,W.jsx)(x,{}):(0,W.jsx)(B,{}),tone:e?`neutral`:`danger`,title:e?`No such variant group`:`Could not load the variants`,subtitle:e?`No runs share this group id. The group may have been deleted, or a winner was already picked and the others removed.`:t.error.message,actions:(0,W.jsx)(u,{asChild:!0,variant:`outline`,children:(0,W.jsx)(P,{to:`/`,children:`Back to tasks`})})})})}return(0,W.jsx)(K,{groupId:e,variants:t.data.runs,showTokens:n.tokens,showCost:n.cost})}function K({groupId:e,variants:t,showTokens:n,showCost:r}){let o=N(),c=_(),[l,u]=(0,U.useState)(null),d=t.every(e=>m.has(e.status)),h=t[0]?a(t[0]):``,g=v({mutationFn:t=>i(e,t),onSuccess:(t,n)=>{c.invalidateQueries({queryKey:s.runs.all}),c.invalidateQueries({queryKey:s.groups.detail(e)}),o(`/tasks/${t.winner?.id??n}`)},onError:e=>f(e.message,{tone:`danger`})});return(0,W.jsxs)(`div`,{"data-route":`compare`,className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-4 py-5 md:px-6`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,W.jsx)(B,{className:`size-5 shrink-0 text-violet`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:h,children:h})]}),(0,W.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[t.length,` variants of the same task, each in its own worktree — pick the diff you want to keep. The others are cancelled and archived, their worktrees and branches removed.`]})]}),(0,W.jsx)(`div`,{"data-slot":`compare-columns`,className:y(`grid grid-cols-1 gap-3`,t.length>=3?`md:grid-cols-3`:`md:grid-cols-2`),children:t.map(e=>(0,W.jsx)(q,{variant:e,allTerminal:d,pickPending:g.isPending,onPick:()=>u(e),showTokens:n,showCost:r},e.id))}),(0,W.jsx)(`section`,{"aria-label":`Full diffs`,className:`flex flex-col gap-2`,children:t.map(e=>(0,W.jsx)(J,{variant:e},e.id))}),(0,W.jsx)(M,{open:l!==null,onOpenChange:e=>!e&&u(null),children:(0,W.jsxs)(D,{children:[(0,W.jsxs)(j,{children:[(0,W.jsxs)(E,{children:[`Pick variant `,l?.variant,`?`]}),(0,W.jsxs)(T,{children:[`Variant `,l?.variant,`'s changes go to the review gate. The other`,` `,t.length-1==1?`variant is`:`${t.length-1} variants are`,` `,`cancelled if still open, archived, and their worktrees and branches removed. There is no undo.`]})]}),(0,W.jsxs)(k,{children:[(0,W.jsx)(A,{children:`Keep comparing`}),(0,W.jsxs)(O,{"data-slot":`confirm-pick`,onClick:()=>{l&&g.mutate(l.id),u(null)},children:[(0,W.jsx)(p,{"aria-hidden":`true`}),`Pick variant `,l?.variant]})]})]})})]})}function q({variant:e,allTerminal:t,pickPending:n,onPick:r,showTokens:i,showCost:a}){let o=F(e),s=d(e.costUsd),c=e.inputTokens!==void 0||e.outputTokens!==void 0;return(0,W.jsxs)(`article`,{"data-slot":`variant-column`,"data-variant":e.variant,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 shadow-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{"data-slot":`variant-letter`,"aria-label":`Variant ${e.variant}`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-xs font-semibold text-violet`,children:e.variant}),(0,W.jsx)(R,{dot:o.tone,pulse:o.pulse,children:o.label}),i&&c||a&&s?(0,W.jsxs)(`span`,{"data-slot":`variant-token-metrics`,className:`ml-auto flex shrink-0 items-center gap-1.5 text-[11px] text-soft-foreground`,children:[i?(0,W.jsx)(L,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):null,i&&c&&a&&s?(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,a&&s?(0,W.jsx)(`span`,{className:`font-mono tabular-nums`,children:s}):null]}):null]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`git diff --stat`}),(0,W.jsx)(`pre`,{"data-slot":`variant-diffstat`,className:`max-h-36 overflow-auto rounded-md bg-muted/60 px-2.5 py-2 font-mono text-[11px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.diffStat.trimEnd()||`(no changes)`})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`Progress`}),e.handoffExcerpt?(0,W.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-[12.5px] text-muted-foreground [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,W.jsx)(z,{children:e.handoffExcerpt})}):(0,W.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,W.jsxs)(u,{"data-slot":`variant-pick`,title:t?`Keep variant ${e.variant}'s changes and archive the others`:`Every variant must finish before you can pick`,disabled:!t||n,onClick:r,children:[(0,W.jsx)(p,{"aria-hidden":`true`}),`Pick this one`]})]})}function J({variant:e}){let[t,n]=(0,U.useState)(!1);return(0,W.jsxs)(w,{open:t,onOpenChange:n,"data-slot":`variant-diff`,"data-variant":e.variant,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card`,children:[(0,W.jsxs)(C,{className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left text-[13px] font-medium hover:bg-muted/50`,children:[(0,W.jsx)(b,{className:y(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),`Variant `,e.variant,` — full diff`]}),(0,W.jsx)(S,{children:(0,W.jsx)(`div`,{className:`border-t border-border/50 px-3 py-3`,children:(0,W.jsx)(H,{runId:e.id})})})]})}export{G as CompareVariantsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$ as r,Ar as i,Cn as a,Lt as o,M as s,Pn as c,Q as l,a as u,dn as d,i as f,k as p,sn as m,t as h,vi as g,wi as _,xi as v}from"./centered-state-CLXeAT-P.js";import{t as y}from"./utils-R1j1Kev9.js";import{t as b}from"./chevron-right-Djhs_Y97.js";import{t as x}from"./search-x-CXirxMBf.js";import{n as S,r as C,t as w}from"./collapsible-BI1pq6sH.js";import{a as T,c as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./alert-dialog-BSwo0F4G.js";import{c as N,t as P}from"./project-router-CkynDkNI.js";import{n as F,t as I}from"./token-metrics-DAiDb02U.js";import{n as L,t as R}from"./pill-BQuNfP0B.js";import{t as z}from"./markdown-DkHWFqkC.js";import{H as B,_ as V}from"./index-CQc7jbyM.js";import{t as H}from"./run-diff-BXaCs_BO.js";var U=e(t(),1),W=n();function G(){let{groupId:e}=g(),t=l(e),n=I(r().data),i=_();if((0,U.useEffect)(()=>{e&&i.invalidateQueries({queryKey:s.groups.detail(e)})},[i,e,(o().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,W.jsx)(V,{});if(t.isError){let e=t.error instanceof c&&t.error.status===404;return(0,W.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,W.jsx)(h,{icon:e?(0,W.jsx)(x,{}):(0,W.jsx)(B,{}),tone:e?`neutral`:`danger`,title:e?`No such variant group`:`Could not load the variants`,subtitle:e?`No runs share this group id. The group may have been deleted, or a winner was already picked and the others removed.`:t.error.message,actions:(0,W.jsx)(u,{asChild:!0,variant:`outline`,children:(0,W.jsx)(P,{to:`/`,children:`Back to tasks`})})})})}return(0,W.jsx)(K,{groupId:e,variants:t.data.runs,showTokens:n.tokens,showCost:n.cost})}function K({groupId:e,variants:t,showTokens:n,showCost:r}){let o=N(),c=_(),[l,u]=(0,U.useState)(null),d=t.every(e=>m.has(e.status)),h=t[0]?a(t[0]):``,g=v({mutationFn:t=>i(e,t),onSuccess:(t,n)=>{c.invalidateQueries({queryKey:s.runs.all}),c.invalidateQueries({queryKey:s.groups.detail(e)}),o(`/tasks/${t.winner?.id??n}`)},onError:e=>f(e.message,{tone:`danger`})});return(0,W.jsxs)(`div`,{"data-route":`compare`,className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-4 py-5 md:px-6`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,W.jsx)(B,{className:`size-5 shrink-0 text-violet`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:h,children:h})]}),(0,W.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[t.length,` variants of the same task, each in its own worktree — pick the diff you want to keep. The others are cancelled and archived, their worktrees and branches removed.`]})]}),(0,W.jsx)(`div`,{"data-slot":`compare-columns`,className:y(`grid grid-cols-1 gap-3`,t.length>=3?`md:grid-cols-3`:`md:grid-cols-2`),children:t.map(e=>(0,W.jsx)(q,{variant:e,allTerminal:d,pickPending:g.isPending,onPick:()=>u(e),showTokens:n,showCost:r},e.id))}),(0,W.jsx)(`section`,{"aria-label":`Full diffs`,className:`flex flex-col gap-2`,children:t.map(e=>(0,W.jsx)(J,{variant:e},e.id))}),(0,W.jsx)(M,{open:l!==null,onOpenChange:e=>!e&&u(null),children:(0,W.jsxs)(D,{children:[(0,W.jsxs)(j,{children:[(0,W.jsxs)(E,{children:[`Pick variant `,l?.variant,`?`]}),(0,W.jsxs)(T,{children:[`Variant `,l?.variant,`'s changes go to the review gate. The other`,` `,t.length-1==1?`variant is`:`${t.length-1} variants are`,` `,`cancelled if still open, archived, and their worktrees and branches removed. There is no undo.`]})]}),(0,W.jsxs)(k,{children:[(0,W.jsx)(A,{children:`Keep comparing`}),(0,W.jsxs)(O,{"data-slot":`confirm-pick`,onClick:()=>{l&&g.mutate(l.id),u(null)},children:[(0,W.jsx)(p,{"aria-hidden":`true`}),`Pick variant `,l?.variant]})]})]})})]})}function q({variant:e,allTerminal:t,pickPending:n,onPick:r,showTokens:i,showCost:a}){let o=F(e),s=d(e.costUsd),c=e.inputTokens!==void 0||e.outputTokens!==void 0;return(0,W.jsxs)(`article`,{"data-slot":`variant-column`,"data-variant":e.variant,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 shadow-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{"data-slot":`variant-letter`,"aria-label":`Variant ${e.variant}`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-xs font-semibold text-violet`,children:e.variant}),(0,W.jsx)(R,{dot:o.tone,pulse:o.pulse,children:o.label}),i&&c||a&&s?(0,W.jsxs)(`span`,{"data-slot":`variant-token-metrics`,className:`ml-auto flex shrink-0 items-center gap-1.5 text-[11px] text-soft-foreground`,children:[i?(0,W.jsx)(L,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):null,i&&c&&a&&s?(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,a&&s?(0,W.jsx)(`span`,{className:`font-mono tabular-nums`,children:s}):null]}):null]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`git diff --stat`}),(0,W.jsx)(`pre`,{"data-slot":`variant-diffstat`,className:`max-h-36 overflow-auto rounded-md bg-muted/60 px-2.5 py-2 font-mono text-[11px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.diffStat.trimEnd()||`(no changes)`})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`Progress`}),e.handoffExcerpt?(0,W.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-[12.5px] text-muted-foreground [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,W.jsx)(z,{children:e.handoffExcerpt})}):(0,W.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,W.jsxs)(u,{"data-slot":`variant-pick`,title:t?`Keep variant ${e.variant}'s changes and archive the others`:`Every variant must finish before you can pick`,disabled:!t||n,onClick:r,children:[(0,W.jsx)(p,{"aria-hidden":`true`}),`Pick this one`]})]})}function J({variant:e}){let[t,n]=(0,U.useState)(!1);return(0,W.jsxs)(w,{open:t,onOpenChange:n,"data-slot":`variant-diff`,"data-variant":e.variant,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card`,children:[(0,W.jsxs)(C,{className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left text-[13px] font-medium hover:bg-muted/50`,children:[(0,W.jsx)(b,{className:y(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),`Variant `,e.variant,` — full diff`]}),(0,W.jsx)(S,{children:(0,W.jsx)(`div`,{className:`border-t border-border/50 px-3 py-3`,children:(0,W.jsx)(H,{runId:e.id})})})]})}export{G as CompareVariantsRoute};