@hearsay-tools/squawk 0.19.0-dev.9069 → 0.19.0-dev.9071

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/delegation/transport.d.ts +78 -78
  2. package/dist/features/hosts/routes.d.ts +44 -44
  3. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  4. package/dist/server/repo-routes.d.ts +52 -52
  5. package/dist/server/reports-api.d.ts +2 -2
  6. package/dist/server/runners-routes.d.ts +10 -10
  7. package/dist/server/runs-routes.d.ts +309 -309
  8. package/dist/server/workspace-routes.d.ts +85 -85
  9. package/package.json +4 -4
  10. package/web/dist/assets/accounts-section-DrA0kndh.js +1 -0
  11. package/web/dist/assets/activity-motion-C23PnhhH.js +1 -0
  12. package/web/dist/assets/{activity-route-D7WKghms.js → activity-route-CWGPbwtG.js} +1 -1
  13. package/web/dist/assets/{agent-config-section-DW7oAwLi.js → agent-config-section-DWZQ2DSW.js} +1 -1
  14. package/web/dist/assets/{agent-defaults-section-BsfycjfC.js → agent-defaults-section-Da4tKbp7.js} +1 -1
  15. package/web/dist/assets/{appearance-D-a_UJUm.js → appearance-Bm4ePfiH.js} +1 -1
  16. package/web/dist/assets/{archive-on-merge-field-RMn227ry.js → archive-on-merge-field-DuRmMR6k.js} +1 -1
  17. package/web/dist/assets/ask-card-vM_Z-WAg.js +9 -0
  18. package/web/dist/assets/automations-route-B8zD3wux.js +2 -0
  19. package/web/dist/assets/{badge-B6B-xYQQ.js → badge-DVxxThpb.js} +1 -1
  20. package/web/dist/assets/{button-C8jUIs8Q.js → button-B22ANdCY.js} +1 -1
  21. package/web/dist/assets/{command-BiBq24zL.js → command-B2Y0By1v.js} +1 -1
  22. package/web/dist/assets/{commit-list-FjUd56tK.js → commit-list-lwVhwbS8.js} +1 -1
  23. package/web/dist/assets/{dialog-DRZuXvul.js → dialog-rpNyAWGb.js} +1 -1
  24. package/web/dist/assets/{diff-ZyKzQmlr.js → diff-CC5UqjNZ.js} +2 -2
  25. package/web/dist/assets/diff-controls-C8KWZ5S-.js +1 -0
  26. package/web/dist/assets/{diff-view-wHArQrRv.js → diff-view-DiuQQoKq.js} +2 -2
  27. package/web/dist/assets/{discard-changes-dialog-u_8VAiFD.js → discard-changes-dialog-CX7M4k9n.js} +1 -1
  28. package/web/dist/assets/{file-preview-DbDhvIx2.js → file-preview-C_0CRYAr.js} +1 -1
  29. package/web/dist/assets/{git-toolbar-Bjvqzoo_.js → git-toolbar-PM540i_A.js} +1 -1
  30. package/web/dist/assets/github-CeBvZzjo.js +1 -0
  31. package/web/dist/assets/{global-activity-route-B20p5-qQ.js → global-activity-route-CiTt7W6o.js} +2 -2
  32. package/web/dist/assets/index-CSgBel_0.css +1 -0
  33. package/web/dist/assets/index-UFO7Bk2I.js +21 -0
  34. package/web/dist/assets/{markdown-Ce0jEzBL.js → markdown-CqzDs1kO.js} +1 -1
  35. package/web/dist/assets/{open-in-menu-Bzca0KPF.js → open-in-menu-CbQWVBD0.js} +1 -1
  36. package/web/dist/assets/{option-select-BUpASY9Q.js → option-select-CDOKbUov.js} +1 -1
  37. package/web/dist/assets/page-shell-BgabWJ3w.js +1 -0
  38. package/web/dist/assets/{page-shell-DQPYcKyL.css → page-shell-CEIoW56O.css} +1 -1
  39. package/web/dist/assets/{preferences-section-Cayq_QJk.js → preferences-section-cdbIMfEU.js} +1 -1
  40. package/web/dist/assets/preview-pane-connected-BcU9ryyW.js +3 -0
  41. package/web/dist/assets/{project-location-QEQeyIDW.js → project-location-BpBbcl3v.js} +1 -1
  42. package/web/dist/assets/{projects-section-Ws3Kp5ky.js → projects-section-CX1WJq4d.js} +1 -1
  43. package/web/dist/assets/{prompt-templates-section-CfyNaD_K.js → prompt-templates-section-DrQthAY7.js} +1 -1
  44. package/web/dist/assets/{remote-settings-notice-DEs9jV72.js → remote-settings-notice-_MtFnktv.js} +1 -1
  45. package/web/dist/assets/repo-git-5JS3oL12.js +1 -0
  46. package/web/dist/assets/{report-reader-mwLAF_a8.js → report-reader-iboN3k6l.js} +1 -1
  47. package/web/dist/assets/{reports-CN8KHXFF.js → reports-Cn3kWlK7.js} +1 -1
  48. package/web/dist/assets/{resources-section-BzYmdxRV.js → resources-section-BmDbIpaO.js} +1 -1
  49. package/web/dist/assets/{review-notes-drafts-D9s8XFRQ.js → review-notes-drafts-DXxIudVB.js} +1 -1
  50. package/web/dist/assets/{review-panel-Ds3S11Go.js → review-panel-BjWbFGev.js} +1 -1
  51. package/web/dist/assets/review-strip-QIghY88F.js +1 -0
  52. package/web/dist/assets/{run-diff-BvGvPk3g.js → run-diff-BDMdnSv7.js} +1 -1
  53. package/web/dist/assets/run-header-BWLcG57S.js +2 -0
  54. package/web/dist/assets/{select-CGjqNwut.js → select-BxuV2GlN.js} +1 -1
  55. package/web/dist/assets/{session-context-section-D0e8HLzL.js → session-context-section-OLW5UTvx.js} +2 -2
  56. package/web/dist/assets/{settings-agent-picker-hFnntaW2.js → settings-agent-picker-Dasyc6Qo.js} +1 -1
  57. package/web/dist/assets/{settings-list-detail-Dn5CWzHj.js → settings-list-detail-D3ibaYUj.js} +1 -1
  58. package/web/dist/assets/{settings-save-bar-DmONROMw.js → settings-save-bar-Mrc6Vm7P.js} +1 -1
  59. package/web/dist/assets/settings-shell-Bvje3VDf.css +1 -0
  60. package/web/dist/assets/settings-shell-DWRk12-i.js +1 -0
  61. package/web/dist/assets/sidebar-section-CVNvjM29.js +1 -0
  62. package/web/dist/assets/{skills-CFRO_xLW.js → skills-7MwCp2i_.js} +1 -1
  63. package/web/dist/assets/{status-dot-BXf-Ubd0.js → status-dot-Drd4-nfa.js} +1 -1
  64. package/web/dist/assets/{task-changes-BuNxS6PG.js → task-changes-DSZjztX7.js} +1 -1
  65. package/web/dist/assets/{task-commits--1qJdD-O.js → task-commits-P_ElCQ4M.js} +1 -1
  66. package/web/dist/assets/{task-file-scope-CFMwJrto.js → task-file-scope-B63NmSov.js} +1 -1
  67. package/web/dist/assets/{task-files-CwH0b_vv.js → task-files-CSFB6sG7.js} +1 -1
  68. package/web/dist/assets/{task-github-item-BezEGvZC.js → task-github-item-BJ1rGyc6.js} +1 -1
  69. package/web/dist/assets/task-thread-C0DbAGi_.js +2 -0
  70. package/web/dist/assets/task-thread-i16nxSQv.css +1 -0
  71. package/web/dist/assets/thread-state-B7pyjJYO.js +4 -0
  72. package/web/dist/assets/{use-finish-run-CyV1CCkZ.js → use-finish-run-B1Gy5JPt.js} +1 -1
  73. package/web/dist/assets/use-hand-to-agent-state-BSM9EGsW.css +1 -0
  74. package/web/dist/assets/use-hand-to-agent-state-CMyKCFeb.js +1 -0
  75. package/web/dist/assets/use-path-bases-wGc__G57.js +1 -0
  76. package/web/dist/assets/workflows-D7bXUmGa.css +1 -0
  77. package/web/dist/assets/workflows-seQiL2pi.js +7 -0
  78. package/web/dist/assets/workspace-tools-BDf7nsE5.js +1 -0
  79. package/web/dist/assets/{worktrees-section-D48xLdpr.js → worktrees-section-x7r5wRhx.js} +1 -1
  80. package/web/dist/index.html +10 -10
  81. package/web/dist/assets/accounts-section-CiO5OMkx.js +0 -1
  82. package/web/dist/assets/activity-motion-D2RZtcZk.js +0 -1
  83. package/web/dist/assets/ask-card-DP9b-lI-.js +0 -9
  84. package/web/dist/assets/automations-route-_Pv3FEnT.js +0 -2
  85. package/web/dist/assets/diff-controls-DHvk5BOR.js +0 -1
  86. package/web/dist/assets/github-DZyhI-94.js +0 -1
  87. package/web/dist/assets/index-C8nM086t.css +0 -1
  88. package/web/dist/assets/index-TOx-AA67.js +0 -21
  89. package/web/dist/assets/page-shell-Dky5crRl.js +0 -1
  90. package/web/dist/assets/preview-pane-connected-C6q9f2y-.js +0 -3
  91. package/web/dist/assets/repo-git-DpqwxFN6.js +0 -1
  92. package/web/dist/assets/review-strip-BFq2VP2u.js +0 -1
  93. package/web/dist/assets/run-header-Bedua8do.js +0 -2
  94. package/web/dist/assets/settings-shell-Ct_qn_MM.css +0 -1
  95. package/web/dist/assets/settings-shell-DjfeA3BW.js +0 -1
  96. package/web/dist/assets/sidebar-section-DHJR37sv.js +0 -1
  97. package/web/dist/assets/task-thread-DxVehGLy.css +0 -1
  98. package/web/dist/assets/task-thread-T_RG916v.js +0 -2
  99. package/web/dist/assets/thread-state-zzV37Hgs.js +0 -4
  100. package/web/dist/assets/use-hand-to-agent-state-Ci2rVhws.js +0 -1
  101. package/web/dist/assets/use-hand-to-agent-state-DZZUsUAd.css +0 -1
  102. package/web/dist/assets/use-path-bases-Cimv7R-0.js +0 -1
  103. package/web/dist/assets/workflows-B2Sw8qQa.css +0 -1
  104. package/web/dist/assets/workflows-B9NzpaaA.js +0 -7
  105. package/web/dist/assets/workspace-tools-C0K5dFxy.js +0 -1
@@ -1,9 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{m as r,o as i}from"./dist-C_rn70hE.js";import{N as a,Yt as o,nn as s}from"./queries-CchoEEzj.js";import{mr as c}from"./toaster-zMN8cNZQ.js";import{f as l,n as u,p as d}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{J as f,Q as p,V as m,c as h,d as g,mt as _,pt as v,st as y,y as b}from"./design-icons-QbNMZniQ.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{t as S}from"./check-OP-CVgZG.js";import{t as C}from"./chevron-right-BENZ-1ZN.js";import{n as w}from"./smartphone-Lr8Ug2z_.js";import{t as T}from"./loader-circle-CPBhhDbB.js";import{t as ee}from"./message-square-B-MD-8rD.js";import{n as te,t as ne}from"./tool-display-B9NN44oU.js";import{t as E}from"./square-terminal-B6RYYieR.js";import{t as D}from"./button-C8jUIs8Q.js";import{n as O,r as k,t as A}from"./collapsible-Bx2vViFx.js";import{t as j}from"./project-router-j0uBi7Ep.js";import{a as M,c as re,i as ie,l as ae,o as oe,s as se,t as ce}from"./report-selection-BdGxjISG.js";import{r as le}from"./html-report-BX3msvci.js";import{En as ue,Sr as de,T as fe,dr as pe,fn as me,gr as N,w as he}from"./index-TOx-AA67.js";import{t as ge}from"./zoomable-image-BUTgYpld.js";import{t as P}from"./textarea-vEsJAUAV.js";import{t as F}from"./markdown-Ce0jEzBL.js";import{t as _e}from"./task-file-scope-CFMwJrto.js";import{t as ve}from"./report-title-D4Mbu2Er.js";var ye=x(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),be=x(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),xe=x(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),I=x(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Se=x(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),L=e(t(),1),R=n();function Ce(e,t){if(e.length===1)return[t.replace(RegExp(`^${we(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function we(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Te(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var Ee=`
2
-
3
- Additional comments:
4
- `;function De(e){let t=e.indexOf(Ee);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function Oe({ask:e}){let t=e.answer===void 0?void 0:De(e.answer),n=t===void 0?void 0:Ce(e.questions,t.body);return(0,R.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Te(t,i),o=i!==void 0&&a.length===0;return(0,R.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,R.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,R.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,R.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,R.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,R.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,R.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,R.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,R.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,R.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,R.jsx)(z,{text:i}):null]})]}):i===void 0?null:(0,R.jsx)(z,{text:i})]},t.id??r)}),n&&t?.comment?(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,R.jsx)(z,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,R.jsx)(z,{text:e.answer}):null]})}function z({text:e}){return(0,R.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function B(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function ke(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function Ae({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:a,hasSheetContext:o,showContextButtonRef:s,onOpenContext:c,onShowOrigin:l}){return(0,R.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,R.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:a}):null,(0,R.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[o?(0,R.jsxs)(D,{ref:s,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,onClick:c,children:[(0,R.jsx)(N,{"aria-hidden":`true`,className:`size-3.5`}),`Show context`]}):l?(0,R.jsx)(Le,{onShowOrigin:l}):null,r?(0,R.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":t===`options`,onClick:()=>n(`options`),className:i(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,R.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":t===`reply`,onClick:()=>n(`reply`),className:i(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]}):null]})]})}function je({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:a,onSelectStep:o}){let s=e.length;return(0,R.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,a)=>{let s=t===a,c=B(a,n,r);return(0,R.jsxs)(`button`,{type:`button`,"aria-current":s?`step`:void 0,onClick:()=>o(a),className:i(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,s?`border-accent-strong bg-accent-strong/15 text-foreground`:c?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:c?(0,R.jsx)(S,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${a+1}.`}),(0,R.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??a)}),(0,R.jsxs)(`button`,{type:`button`,"aria-current":t===s?`step`:void 0,onClick:()=>o(s),className:i(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===s?`border-accent-strong bg-accent-strong/15 text-foreground`:a?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(I,{"aria-hidden":`true`,className:`size-3`}),(0,R.jsx)(`span`,{children:`Comment`})]})]})}function Me({questions:e,selections:t,otherAnswers:n,comment:r,disabled:a,onCommentChange:o,onJumpToQuestion:s}){let c=(0,L.useId)();return(0,R.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,R.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let a=B(r,t,n);return(0,R.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>s(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,R.jsx)(`span`,{className:i(`min-w-0 truncate text-end`,a?`text-foreground`:`text-semantic-red`),children:ke(r,t,n)})]},e.id??r)})})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:c,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,R.jsx)(P,{id:c,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:a,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>o(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function Ne({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,L.useId)();return r?(0,R.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,R.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,R.jsx)(P,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function Pe({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:a,resuming:o,disabled:s,onBack:c,onNext:l,onOpenComment:u,onSend:d,questions:f,selections:p,otherAnswers:m,stopControl:h}){let g=e===t-1,_=e===t,v=o?`Send answer & reopen`:`Send answer`;return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,R.jsxs)(D,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:c,children:[(0,R.jsx)(de,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,R.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[f.map((t,n)=>{let r=n===e,a=B(n,p,m);return(0,R.jsx)(`span`,{className:i(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:a?`bg-success`:`bg-border`)},t.id??n)}),(0,R.jsx)(`span`,{className:i(`size-2 rounded-full motion-safe:transition-colors`,_?`bg-accent-strong`:a?`bg-success`:`bg-border/60`)})]}),(0,R.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),o?(0,R.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,(0,R.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,!g&&!_?(0,R.jsxs)(D,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:l,children:[`Next`,(0,R.jsx)(C,{"aria-hidden":`true`,className:`size-4`})]}):null,g?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:u,children:a?`Edit comment`:`+ Comment`}):null,g||_||r?(0,R.jsx)(D,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:s||!r,onClick:d,children:v}):null]})]})}function Fe({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,R.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`min-h-11 min-w-11 px-2 text-xs text-muted-foreground hover:text-foreground md:min-h-8 md:min-w-0`,onClick:s,children:[(0,R.jsx)(I,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,(0,R.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,R.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,R.jsx)(D,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function Ie({blockedBy:e,reason:t,error:n}){return(0,R.jsxs)(R.Fragment,{children:[t?(0,R.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,R.jsx)(j,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,R.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function Le({onShowOrigin:e,className:t}){return(0,R.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:i(`min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,t),children:`Show where it was asked`})}function Re({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,L.useRef)(!1);return(0,R.jsx)(ie,{open:e,onOpenChange:t,children:(0,R.jsxs)(oe,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,R.jsxs)(re,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,R.jsx)(ae,{children:`Question context`}),(0,R.jsx)(se,{children:`Your selections and drafts stay intact while you read.`}),(0,R.jsx)(M,{asChild:!0,children:(0,R.jsx)(D,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2 size-11 md:size-9`,children:(0,R.jsx)(_,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,R.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,R.jsx)(_e,{runId:n,children:(0,R.jsx)(F,{breaks:!0,children:r})})}),i?(0,R.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,className:`min-h-11 md:min-h-8`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function ze(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Be=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ve(e){return e.replaceAll(`'`,`'\\''`)}function He(e){return e===``?`''`:Be.test(e)?e:`\u0027${Ve(e)}\u0027`}function Ue(e){if(!ze(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(He).join(` `)}}function We(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Ge(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Ke(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function V(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function qe(e){let t=We(Ge(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))V(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){V(e[2])&&i.push({label:Ke(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Ke(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&V(t)&&i.push({label:t,href:t})}return i}var Je=(0,L.createContext)(void 0),Ye=(0,L.createContext)(void 0);function H(e,t){let n=new Map;for(let r of qe(e)){let e=fe(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function U(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Xe({text:e,messageKey:t}){let n=(0,L.useContext)(he),r=(0,L.useContext)(Ye),i=t??r;if(!n||i===void 0)return null;let a=H(e,n);return a.length===0?null:(0,R.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,R.jsx)(Ze,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Ze({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:o}=e,s=(0,L.useContext)(Je),c=(0,L.useContext)(ce);(0,L.useLayoutEffect)(()=>c?.register(n,r),[c,n,r]);let f=a(r,n),p=l(),m=d();if(f.isError)return(0,R.jsx)(u,{id:U(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:p.pathname+p.search},children:i});let h=f.data?.artifact;if(h&&!le(h.name))return null;let g=new URLSearchParams(p.search);g.set(`report`,n),g.set(`card`,t);let _=new URLSearchParams(p.search).has(`report`)?p.state:null,v=new URLSearchParams(p.search);v.delete(`report`),v.delete(`card`);let y=`${p.pathname}${v.size?`?${v}`:``}`,b=window.navigation,x={reportCardEntry:!0,reportReturnTo:_?.reportReturnTo??y,reportReturnKey:_?.reportReturnKey??b?.currentEntry?.key,reportScrollTop:_?.reportScrollTop},S={pathname:p.pathname,search:`?${g}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,R.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":f.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,R.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:h?ve(h):i}),(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,R.jsx)(u,{id:U(t,n),to:S,state:x,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=x.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;m(S,{state:{...x,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${f.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Qe={message:!0,reasoning:!0,tool:!0,hook:!0};function $e(e){return Object.hasOwn(Qe,e)&&Qe[e]}var W=e=>e.kind===`tool`,et=e=>e.kind===`conversation`,tt=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,nt=(e,t,n)=>`${e} ${e===1?t:n}`;function rt(e,t){let n=[];return e>0&&n.push(nt(e,`file`,`files`)),t>0&&n.push(nt(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function it(e){return`${e} earlier tool call${e===1?``:`s`}`}var at=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ot(e){for(let t of at)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var st=new WeakMap;function ct(e){let t=st.get(e);if(t)return t;let n=lt(e);return st.set(e,n),n}function lt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(W).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=$e(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:rt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of ut(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(et(e)){s(),c.push(e);continue}l(),W(e)&&tt(e)&&!r.has(e.id)?o.push(e):(s(),W(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function ut(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var G=new Map,dt=(0,L.createContext)(null);function K(){return(0,L.useContext)(dt)}function ft({runId:e,children:t}){let n=(0,L.useMemo)(()=>({get:t=>G.get(e)?.get(t),set:(t,n)=>{let r=G.get(e)??new Map;r.set(t,n),G.set(e,r)}}),[e]);return(0,R.jsx)(dt.Provider,{value:n,children:t})}function pt(e){return e.scrollTop<Math.max(600,e.clientHeight)}function mt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function ht(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function gt(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function _t(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var vt=new Map;function yt(e,t){vt.set(e,t)}function bt(e){return vt.get(e)}var q=new Map;function xt(e,t){q.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function St(e){return q.get(e)}function Ct(e,t,n){let r=q.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var wt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),Tt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Et=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Dt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Ot=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function J(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Y(e){let t=J(e);return t===void 0?void 0:wt.format(t)}function kt(e){let t=J(e);return t===void 0?void 0:Tt.format(t)}var X=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function At(e){let t=J(e);return t===void 0?void 0:X(t)}function jt(e,t=new Date){let n=J(e);if(n===void 0)return;let r=X(n);return r===X(t)?`Today`:r===X(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Et:Dt).format(n)}function Mt(e,t){let n=J(e),r=J(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Nt({ts:e}){let t=Y(e);return t===void 0?null:(0,R.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:kt(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function Pt({startedAt:e,completedAt:t}){let n=Y(t);if(n===void 0)return null;let r=Mt(e,t);return(0,R.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,R.jsx)(`time`,{dateTime:t,title:kt(t),children:n}),r===void 0?null:(0,R.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Ft({ts:e}){let t=jt(e),n=J(e);if(t===void 0||n===void 0)return null;let r=Ot.format(n);return(0,R.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,R.jsx)(`time`,{dateTime:At(e),title:r,children:t}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var It={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Lt({note:e}){return e.icon===`handoff`?(0,R.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,R.jsx)(pe,{className:`size-3`})}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,R.jsxs)(A,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,R.jsxs)(`div`,{className:i(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,R.jsxs)(k,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,R.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,R.jsx)(O,{children:(0,R.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,R.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,R.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[It[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,R.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:i(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Rt={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Z({role:e,children:t,className:n,ts:r,headerActions:a,...o}){let s=Rt[e],c=r===void 0?void 0:Y(r);return(0,R.jsxs)(`article`,{...o,"data-role":e,"aria-label":s.speaker,className:i(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,R.jsxs)(`p`,{className:i(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,R.jsx)(ee,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),a]}),c===void 0?null:(0,R.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,R.jsx)(Nt,{ts:r})})]}),(0,R.jsx)(`div`,{className:i(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var zt=[],Bt=(0,L.memo)(function({text:e,imageCount:t=0,images:n=zt,ts:i,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:l=`Remove message`,children:u}){let d=t-n.length,[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(e),[_,v]=(0,L.useState)(!1),[b,x]=(0,L.useState)(),S=()=>{g(e),x(void 0),m(!0)},C=async()=>{let t=h.trim();if(!t||t===e){m(!1);return}v(!0),x(void 0);try{await a?.(t),m(!1)}catch(e){x(e instanceof Error?e.message:`Could not save the message`)}finally{v(!1)}},w=async()=>{v(!0),x(void 0);try{await o?.()}catch(e){x(e instanceof Error?e.message:`Could not remove the message`)}finally{v(!1)}};return p?(0,R.jsxs)(Z,{role:`user`,ts:i,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,R.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),m(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,R.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>m(!1),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:_?(0,R.jsx)(T,{className:`size-3.5 animate-spin`}):`Save`})]}),b?(0,R.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:b}):null]}):(0,R.jsxs)(Z,{role:`user`,ts:i,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,R.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,R.jsx)(`button`,{type:`button`,"aria-label":s,onClick:S,disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,R.jsx)(Se,{className:`size-3.5`})}):null,o?(0,R.jsx)(`button`,{type:`button`,"aria-label":l,onClick:()=>void w(),disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,R.jsx)(y,{className:`size-3.5`})}):null]}):null,b?(0,R.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:b}):null,u??(0,R.jsx)(F,{breaks:!0,children:e}),n.length>0?(0,R.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>c(e.split(`/`).pop()??``)?(0,R.jsx)(ge,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,R.jsxs)(`a`,{href:r(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,R.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,d>0?(0,R.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[d,` image`,d>1?`s`:``,` attached`]}):null]})}),Vt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Ht=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Ut(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Ht).forEach(e=>e.remove());let r=qe(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!V(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Wt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Ut(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Gt=(0,L.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,L.useRef)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),c=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Wt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,R.jsxs)(Z,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,R.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Vt,children:[(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,R.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Vt,children:[(0,R.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,R.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,R.jsx)(`div`,{ref:r,children:(0,R.jsx)(F,{breaks:!0,children:e})}),(0,R.jsx)(Xe,{text:e,messageKey:n})]})});function Kt({incident:e}){let t=s().data;if(!t)return null;let n=o(t,e.provider);return(0,R.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,R.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,R.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,R.jsx)(j,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var qt=(0,L.memo)(function({text:e}){let t=(0,L.useId)();if(e.trim()===``)return null;let n=e.split(`
5
- `,1)[0]??``,r=n.length<e.length;return(0,R.jsxs)(A,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,R.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,R.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,R.jsx)(F,{inline:!0,children:n})}),r?(0,R.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,R.jsx)(k,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,R.jsx)(F,{children:e})})})]})});function Jt(){return(0,R.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,R.jsx)(T,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,R.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Yt={read:N,edit:Se,delete:y,move:xe,search:p,execute:E,think:be,fetch:w,task:h,plan:m,other:v},Xt=e=>e.split(`
6
- `).length;function Zt({text:e,streaming:t}){let[n,r]=(0,L.useState)(!1),a=(0,L.useRef)(null),o=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=a.current;t&&e&&o.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let s=Xt(e),c=!t&&!n&&s>12;return(0,R.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":c?`true`:void 0,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{ref:a,onScroll:t?e=>{o.current=gt(e.currentTarget)}:void 0,className:i(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,c&&`max-h-[216px] overflow-y-hidden`),children:(0,R.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),c?(0,R.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&s>12?(0,R.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-xs font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${s} lines`}):null]})}function Qt({diffs:e}){return(0,R.jsx)(R.Fragment,{children:e.map((e,t)=>(0,R.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-xs wrap-anywhere text-muted-foreground`,children:e.path}),(0,R.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...$t(e.oldText).map((e,t)=>(0,R.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...$t(e.newText).map((e,t)=>(0,R.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
7
- `).map((e,t)=>(0,R.jsx)(en,{text:e},t))})]},`${e.path}:${t}`))})}function $t(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
8
- `)}function en({text:e}){return(0,R.jsx)(`span`,{className:i(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function tn(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function nn(e){let t=e.status===`running`||e.status===`pending`,n=ot(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?Ue(e.input):te(e.name).toolKind===e.toolKind?ne(e.name,e.input):void 0)??i,Icon:Yt[e.toolKind]??v}}function rn(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function an({item:e,busy:t}){return(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,R.jsx)(T,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,R.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,R.jsx)(`span`,{"data-slot":`tool-exit`,className:i(`rounded-full px-2 py-px font-mono text-xs font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function on({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,R.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,R.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,R.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,R.jsx)(Qt,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,R.jsx)(Zt,{text:e.output,streaming:n}):null,r.length>0?(0,R.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function sn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let a=K(),[o,s]=(0,L.useState)(()=>n===void 0?null:a?.get(n)??null),c=e=>{n!==void 0&&a?.set(n,e),s(e)},{busy:l,verb:u,detail:d,expandedCommand:f,Icon:p}=nn(e),m=rn(e,t.length),h=f!==void 0||m,_=h&&(o??(m&&tn(e)));return(0,R.jsxs)(A,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:_,onOpenChange:c,className:i(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,R.jsxs)(k,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:i(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,R.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:i(`shrink-0 font-semibold`,l&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,R.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,R.jsx)(an,{item:e,busy:l})]}),(0,R.jsx)(O,{children:(0,R.jsx)(on,{item:e,command:f,busy:l,nested:t,cacheKey:n,renderNested:r})})]})}function cn(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function ln({item:e,cacheKey:t}){let n=K(),[r,a]=(0,L.useState)(()=>t===void 0?!1:n?.get(t)??!1),o=e=>{t!==void 0&&n?.set(t,e),a(e)},s=e.status!==`completed`,c=e.entries.some(e=>e.kind===`context`),l=(e.stdout??``)!==``||(e.stderr??``)!==``,u=cn(e);return(0,R.jsxs)(A,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:o,className:i(`min-w-0 overflow-hidden rounded-md border bg-card`,s?`border-danger/25`:`border-border`),children:[(0,R.jsxs)(k,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,R.jsx)(ye,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,R.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[s?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):c?(0,R.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,s&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,R.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-xs font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,R.jsx)(O,{children:(0,R.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,R.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:i(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,R.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),l?(0,R.jsxs)(A,{className:`border-t border-border`,children:[(0,R.jsxs)(k,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,R.jsxs)(O,{children:[e.stdout?(0,R.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,R.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function un({group:e,scope:t}){return(0,R.jsxs)(A,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,R.jsxs)(k,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,R.jsx)(sn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function dn({count:e,children:t}){return(0,R.jsxs)(A,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,R.jsxs)(k,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),it(e)]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function fn({image:e}){return(0,R.jsx)(ge,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}var pn={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function mn(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function hn(e,t,n,r=``){let i=e.map((e,r)=>mn(e,t[r]??[],n[r])).join(`
9
- `),a=r.trim();return a?`${i}\n\nAdditional comments:\n${a}`:i}function gn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s=!1,onFinish:c,finishing:l=!1,mode:u,onModeChange:d,hideReplyBody:f=!1,delivery:p,surface:m=`transcript`}){let h=m===`transcript`&&e.context?(0,R.jsx)(Q,{text:e.context}):null;if(e.resolved)return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.context?(0,R.jsx)(Q,{text:e.context}):null,(0,R.jsxs)(Z,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?pn[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,R.jsx)(Oe,{ask:e})]})]});let g=e.placement===`pinned`&&r?r:void 0;return e.routedToParent?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,R.jsx)(_n,{ask:e,runId:t.id,surface:m,onShowOrigin:g})]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,R.jsx)(xn,{ask:e,run:t,projectId:n,surface:m,onShowOrigin:g,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:d,hideReplyBody:f,delivery:p})]})}function Q({text:e}){return(0,R.jsx)(Z,{role:`agent`,children:(0,R.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,R.jsx)(F,{breaks:!0,children:e})})})}function _n({ask:e,runId:t,surface:n,onShowOrigin:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=n===`decision-zone`&&!!e.context;return(0,R.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-xl border border-card-edge bg-card shadow-card px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`}),s?(0,R.jsx)(D,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`ms-auto min-h-11 min-w-11 px-2 text-xs font-medium text-link-foreground underline underline-offset-4 md:min-h-8 md:min-w-0`,onClick:()=>a(!0),children:`Show context`}):null]}),(0,R.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,R.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,R.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,R.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,R.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,R.jsxs)(`li`,{className:`break-words`,children:[(0,R.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,R.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,R.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,R.jsxs)(`div`,{"data-slot":`ask-footer`,className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,R.jsx)(j,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),!s&&r?(0,R.jsx)(Le,{onShowOrigin:r,className:`ms-auto`}):null]}),s&&e.context?(0,R.jsx)(Re,{open:i,onOpenChange:a,runId:t,context:e.context,onShowOrigin:r,returnFocusRef:o}):null]})}function vn(e,t,n,r,i){let a=t.blockedBy!==void 0,o=e.questions,s=o.length>1,c=o.length,[l,u]=(0,L.useState)(`options`),d=n??l,f=e=>{u(e),r?.(e)},[p,m]=(0,L.useState)(0),[h,g]=(0,L.useState)({}),[_,v]=(0,L.useState)({}),[y,b]=(0,L.useState)(``),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(``),[T,ee]=(0,L.useState)(!1),te=s&&p===c,ne=o.length===1&&o[0]?.options!==void 0&&o[0]?.multiSelect!==!0&&!x&&y.trim()===``;ue(Object.values(h).some(e=>e.length>0)||Object.values(_).some(e=>e.trim()!==``)||y.trim()!==``||C.trim()!==``);let E=(e,t)=>g(n=>({...n,[e]:t})),D=e=>v(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),O=e=>{E(e,[]),v(t=>({...t,[e]:t[e]??``}))},k=o.some((e,t)=>!e.options||_[t]!==void 0),A=o.filter((e,t)=>B(t,h,_)).length,j=A===o.length,M=async e=>{let n=await t.send(e);return n===void 0&&i?.(),n};return{delivery:t,blocked:a,questions:o,stepped:s,commentStepIndex:c,mode:d,setMode:f,stepIndex:p,setStepIndex:m,selections:h,otherAnswers:_,setOtherAnswers:v,additionalComment:y,setAdditionalComment:b,singleCommentOpen:x,setSingleCommentOpen:S,freeTextDraft:C,setFreeTextDraft:w,contextOpen:T,setContextOpen:ee,onCommentStep:te,oneTap:ne,setQuestion:E,clearOtherAnswer:D,selectOther:O,hasOtherAnswer:k,answeredCount:A,allAnswered:j,deliver:M,sendAll:()=>void M(hn(o,h,_,y)),sendFreeText:()=>{let e=C.trim();e&&M(e).then(e=>{e===void 0&&w(``)})}}}function yn({state:e,renderFreeTextReply:t}){let n=(0,L.useId)(),r=e.delivery.isPending||e.blocked;if(e.mode===`reply`)return(0,R.jsx)(Ne,{value:e.freeTextDraft,onValueChange:e.setFreeTextDraft,disabled:r,renderFreeTextReply:t});if(e.onCommentStep)return(0,R.jsx)(Me,{questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,comment:e.additionalComment,disabled:r,onCommentChange:e.setAdditionalComment,onJumpToQuestion:e.setStepIndex});let i=e.stepped?Math.min(e.stepIndex,e.questions.length-1):0,a=e.questions[i];return a?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(wn,{question:a,disabled:r,selected:e.selections[i]??[],isOther:e.otherAnswers[i]!==void 0,otherAnswer:e.otherAnswers[i]??``,onSelect:t=>{e.blocked||(e.clearOtherAnswer(i),e.oneTap?e.deliver(mn(a,t)):e.setQuestion(i,t))},onOtherToggle:()=>{e.blocked||(e.otherAnswers[i]===void 0?e.selectOther(i):e.clearOtherAnswer(i))},onOtherChange:t=>e.setOtherAnswers(e=>({...e,[i]:t}))},a.id??i),!e.stepped&&e.singleCommentOpen?(0,R.jsxs)(`div`,{className:`pt-1`,children:[(0,R.jsx)(`label`,{htmlFor:n,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,R.jsx)(P,{id:n,"data-slot":`ask-additional-comment`,rows:2,value:e.additionalComment,disabled:r,placeholder:`Optional extra notes for the agent…`,onChange:t=>e.setAdditionalComment(t.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):null}function bn({onFinish:e,finishing:t,onStop:n,stopping:r,onActionError:i}){if(!e&&!n)return null;let a=e=>{i(void 0),Promise.resolve(e()).catch(e=>{i(e instanceof Error?e.message:String(e))})};return(0,R.jsxs)(R.Fragment,{children:[e?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-finish`,disabled:t||r,title:`Close the session and mark this task done`,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:()=>a(e),children:t?`Finishing…`:`Finish`}):null,n?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,disabled:r||t,className:`min-h-11 min-w-11 px-3 md:min-h-8 md:min-w-0`,onClick:()=>a(n),children:r?`Stopping…`:`Stop`}):null]})}function xn(e){return e.delivery===void 0?(0,R.jsx)(Sn,{...e}):(0,R.jsx)($,{...e,delivery:e.delivery})}function Sn(e){let t=me(e.run,e.projectId);return(0,R.jsx)($,{...e,delivery:t})}function $({ask:e,run:t,surface:n,onShowOrigin:r,onAnswered:a,renderFreeTextReply:o,onStop:s,stopping:c,onFinish:l,finishing:u,controlledMode:d,onModeChange:f,hideReplyBody:p,delivery:m}){let h=vn(e,m,d,f,a),[g,_]=(0,L.useState)(void 0),v=(0,L.useRef)(null),y=h.delivery.mode===`resume`,b=n===`decision-zone`||o!==void 0,x=n===`decision-zone`&&!!e.context,S=h.additionalComment.trim()!==``,C=h.mode===`reply`&&p,w=(0,R.jsx)(bn,{onFinish:l,finishing:u,onStop:s,stopping:c,onActionError:_});return(0,R.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-ask-mode":h.mode,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":h.delivery.mode,className:i(`rounded-xl border border-accent-strong/30 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card`,C&&`rounded-b-none border-b-0`),children:[(0,R.jsx)(Ae,{stepped:h.stepped,mode:h.mode,onModeChange:h.setMode,showModeSwitch:b,stepLabel:h.onCommentStep?`Comment (optional)`:`${h.stepIndex+1} of ${h.questions.length}`,hasSheetContext:x,showContextButtonRef:v,onOpenContext:()=>h.setContextOpen(!0),onShowOrigin:x?void 0:r}),h.stepped&&h.mode===`options`?(0,R.jsx)(je,{questions:h.questions,stepIndex:h.stepIndex,selections:h.selections,otherAnswers:h.otherAnswers,hasComment:S,onSelectStep:h.setStepIndex}):null,C?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-2.5 px-3 py-2.5`,children:(0,R.jsx)(yn,{state:h,renderFreeTextReply:o})}),(0,R.jsxs)(`div`,{"data-slot":`ask-footer`,className:`flex shrink-0 flex-col gap-2 border-t border-border/70 px-3 py-2`,children:[(0,R.jsx)(Cn,{state:h,hasComment:S,resuming:y,hasCustomReply:o!==void 0,stopControl:w}),(0,R.jsx)(Ie,{blockedBy:h.delivery.blockedBy,reason:h.delivery.reason,error:h.delivery.error??g})]})]}),x&&e.context?(0,R.jsx)(Re,{open:h.contextOpen,onOpenChange:h.setContextOpen,runId:t.id,context:e.context,onShowOrigin:r,returnFocusRef:v}):null]})}function Cn({state:e,hasComment:t,resuming:n,hasCustomReply:r,stopControl:i}){return e.mode===`reply`?r?null:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i,(0,R.jsx)(D,{type:`button`,size:`sm`,className:`min-h-11 min-w-11 px-3.5 md:min-h-8 md:min-w-0`,disabled:e.delivery.isPending||e.blocked||e.freeTextDraft.trim()===``,onClick:e.sendFreeText,children:`Send reply`})]}):e.stepped?(0,R.jsx)(Pe,{stepIndex:e.stepIndex,questionCount:e.questions.length,answeredCount:e.answeredCount,allAnswered:e.allAnswered,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked,onBack:()=>e.setStepIndex(e=>Math.max(0,e-1)),onNext:()=>e.setStepIndex(t=>Math.min(e.commentStepIndex,t+1)),onOpenComment:()=>e.setStepIndex(e.commentStepIndex),onSend:e.sendAll,questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,stopControl:i}):(0,R.jsx)(Fe,{oneTap:e.oneTap,hasOtherAnswer:e.hasOtherAnswer,allowComment:e.questions[0]?.allowFreeText!==!1,commentOpen:e.singleCommentOpen,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked||!e.allAnswered,onToggleComment:()=>e.setSingleCommentOpen(e=>!e),onSend:e.sendAll,stopControl:i})}function wn({question:e,disabled:t,selected:n,isOther:r,otherAnswer:a,onSelect:o,onOtherToggle:s,onOtherChange:c}){let l=(0,L.useId)(),u=(0,L.useRef)(null),d=(0,L.useRef)(r),f=e.options,p=f!==void 0,m=p&&e.multiSelect===!0;(0,L.useEffect)(()=>{let e=r&&!d.current;d.current=r,e&&p&&u.current?.focus()},[r,p]);let h=e=>{if(!m){o([e]);return}o(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,R.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,R.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),m?(0,R.jsx)(`span`,{className:`ms-auto text-xs text-soft-foreground`,children:`select all that apply`}):null]}),f?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2 sm:gap-2`,children:[f.map(e=>{let r=n.includes(e.label);return(0,R.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>h(e.label),className:i(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`:`border-border bg-card pointer-hover:border-accent-strong/50 pointer-hover:bg-accent-strong/[0.08]`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[m?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:i(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,R.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,R.jsx)(D,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?l:void 0,disabled:t,onClick:s,className:i(`h-auto min-h-11 w-full justify-start px-2.5 py-1.5 text-left`,f.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,R.jsx)(P,{ref:u,id:l,rows:2,value:a,disabled:t,placeholder:`Type your custom answer…`,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,R.jsx)(P,{id:l,rows:2,value:a,disabled:t,placeholder:`Type your answer…`,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}export{K as A,Ct as C,ht as D,yt as E,Je as F,U as I,H as L,ot as M,$e as N,_t as O,Ye as P,Oe as R,St as S,xt as T,Y as _,ln as a,gt as b,qt as c,Bt as d,Jt as f,Pt as g,Nt as h,un as i,ct as j,ft as k,sn as l,Ft as m,Q as n,fn as o,Lt as p,Gt as r,Kt as s,gn as t,dn as u,At as v,bt as w,pt as x,mt as y,I as z};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{en as i,g as a,k as o,nn as s,on as c,tn as l}from"./queries-CchoEEzj.js";import{H as u,Kr as d,Rn as f,U as p,V as m,W as h,_ as g,ai as _,ar as v,c as y,cr as b,d as x,g as ee,ii as te,o as ne,s as re,sr as ie,ur as ae,v as oe}from"./toaster-zMN8cNZQ.js";import{B as S,G as se,H as C,I as w,K as ce,N as T,P as E,V as le,W as D,j as O,z as k}from"./live-protocol-DMhTnCmf.js";import{h as ue,n as de}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as fe,t as A}from"./label-feCJ3WOT.js";import{L as pe,X as me,Z as he,b as ge,ft as _e,ht as ve,nt as ye,ot as be,u as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./check-OP-CVgZG.js";import{t as j}from"./button-C8jUIs8Q.js";import{n as Ce,r as we,t as Te}from"./collapsible-Bx2vViFx.js";import{a as M,i as N,n as P,r as Ee,t as De}from"./select-CGjqNwut.js";import{t as Oe}from"./switch-CAKeV99j.js";import{c as ke,s as Ae,t as F}from"./project-router-j0uBi7Ep.js";import{c as I,d as L,f as je,l as Me,n as Ne,o as Pe}from"./page-shell-Dky5crRl.js";import{a as Fe}from"./agent-accounts-D_7QcFSx.js";import{r as Ie}from"./agents-settings-path-7X6_cvUg.js";import{t as Le}from"./centered-state-BgSV4e79.js";import{$ as Re,Dn as ze,F as Be,I as Ve,Kn as He,P as Ue,V as We,br as Ge,et as Ke,jn as qe,nt as Je,qn as Ye,r as Xe,sr as R,t as Ze}from"./index-TOx-AA67.js";import{t as Qe}from"./textarea-vEsJAUAV.js";import{_ as $e,a as et,c as tt,d as nt,f as rt,g as it,h as at,i as ot,l as st,m as ct,n as lt,o as ut,p as dt,r as ft,s as pt,t as z,u as mt,v as ht}from"./automation-format-DB34jUyF.js";var B=e(t(),1),V=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),gt=S({includeExisting:E().optional(),authors:T(D()).optional(),assignees:T(D()).optional(),requireCurrentLabels:E().optional(),allLabels:T(D()).optional(),anyLabels:T(D()).optional(),excludeLabels:T(D()).optional(),changedLabels:T(D()).optional(),lookbackDays:k(),maxRecords:k()}),_t=O([`github`,`schedule`]),vt=v.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:D(),variants:se([w(1),w(2),w(3)]).optional(),systemPrompt:D().optional()}),yt=S({at:D(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}),H=S({id:D(),revision:k(),name:D(),description:D().optional(),enabled:E(),kind:_t,events:T(V).optional(),intervalSeconds:k().optional(),filters:gt.optional(),schedule:tt.optional(),task:vt,archived:yt.optional(),createdAt:D(),updatedAt:D()}),U=S({timestamp:D(),tieBreaker:D().optional()}),bt=S({since:D().datetime(),until:D().datetime(),source:k().int().min(0).max(2),page:k().int().min(1).max(10),item:k().int().min(0).max(100),event:k().int().min(0).max(1e3),cursor:U.optional()}),xt={lastError:D().max(1e3).optional(),lastErrorAt:D().datetime().optional()},St=S({revision:k().optional(),baselineAt:D().optional(),armedAt:D().optional(),historyScan:bt.optional(),cursor:U.optional(),frozenHighWatermark:U.extend({tieBreaker:D()}).optional(),backlogAfter:U.extend({tieBreaker:D()}).optional(),nextCheckAt:D().optional(),lastSuccessAt:D().optional(),nextRunAt:D().optional(),lastRunAt:D().optional(),etags:C(D(),D()).optional(),backoffUntil:D().optional(),consecutiveFailures:k().optional(),...xt,onceOutcome:O([`failed`,`missed`]).optional()});function Ct(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var wt=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),Tt=S({seq:k(),ts:D(),automationId:D(),revision:k(),event:V.optional(),result:wt,reason:D().optional(),durationMs:k().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().optional(),githubTitle:D().optional(),githubUrl:D().optional(),rateLimit:S({bucket:O([`core`,`search`]),remaining:k().optional(),resetAt:D().optional()}).optional()}),Et=S({matches:k(),launched:k(),duplicates:k(),errors:k()}),Dt=H.extend({state:St.optional(),latestLog:Tt.optional(),counts:Et,nextRunAt:D().optional(),onceStatus:dt.optional()});S({available:E(),reason:D().optional(),timeZone:D(),scheduler:S({state:O([`scheduled`,`idle`]),nextDue:D().optional()}),automations:T(Dt)}),S({automation:H}).extend({once:S({dueAt:D(),timeZone:D(),resolvedInstant:D(),note:D()}).optional()}),S({automation:H,state:St.optional(),latestLog:Tt.optional(),onceStatus:dt.optional()}),S({id:D(),automationId:D(),mode:O([`preview`,`execute`]),status:O([`queued`,`running`,`complete`,`error`]),createdAt:D(),completedAt:D().optional(),matches:k().optional(),truncated:E().optional(),error:D().optional()}),S({checkId:D()}),S({records:T(Tt)}),S({receiptId:D(),runId:D()}),S({runId:D()}),H.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:_t.optional(),task:vt.omit({variants:!0}).strict(),enable:E().optional()}).omit({enable:!0}).extend({enabled:E().optional(),expectedRevision:k()}),S({archived:O([`include`,`only`]).optional()}),S({mode:O([`preview`,`execute`])});var W=n();function G({text:e}){return(0,W.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var Ot={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`pending`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},kt={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function At(e){let[t,n]=(0,B.useState)(),[r,i]=(0,B.useState)(``),a=(0,B.useCallback)(t=>g(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,B.useEffect)(()=>{a()},[a]),(0,B.useEffect)(()=>d(a),[a]),(0,B.useEffect)(()=>fe((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function jt(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function Mt({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&jt(e,t),[o,s]=(0,B.useState)(),[c,l]=(0,B.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await m(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,W.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,W.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(Xe,{dot:Ot[e.result],children:kt[e.result]}),(0,W.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:lt(e.ts,n,u)})]}),e.reason?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,W.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,W.jsx)(j,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var K=`all`;function Nt({label:e,value:t,onChange:n,options:r}){return(0,W.jsxs)(De,{value:t,onValueChange:n,children:[(0,W.jsx)(N,{"aria-label":e,className:`w-full sm:w-52`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:r.map(e=>(0,W.jsx)(Ee,{value:e.value,children:e.label},e.value))})]})}function Pt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=At(e),[s,c]=(0,B.useState)(K),[l,u]=(0,B.useState)(K),d=(0,B.useMemo)(()=>(i??[]).filter(e=>(s===K||e.result===s)&&(l===K||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,W.jsx)(Me,{route:`automations`,density:i?je(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(G,{text:a}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,W.jsx)(G,{text:`Nothing has run yet.`}):(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(Nt,{label:`Result`,value:s,onChange:c,options:[{value:K,label:`All results`},...wt.options.map(e=>({value:e,label:kt[e]}))]}),f?(0,W.jsx)(Nt,{label:`Event`,value:l,onChange:u,options:[{value:K,label:`All events`},...V.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,W.jsx)(G,{text:`No rows match these filters.`}):(0,W.jsx)(Mt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,W.jsx)(G,{text:`Loading execution log…`})})}function Ft({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=At(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,W.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`flex flex-wrap items-center gap-x-2 border-t border-border pt-2.5 text-xs text-muted-foreground`,children:[(0,W.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,W.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,W.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,W.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(G,{text:o}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,W.jsx)(Mt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function It({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?ft(i):null,[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),f=(0,B.useRef)(null),p=(0,B.useRef)(null),m=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await x(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,W.jsx)(Me,{route:`automations`,density:`sparse`,header:{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`},children:(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,W.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,W.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,W.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${z(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,W.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,W.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,W.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,W.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,W.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,W.jsxs)(`section`,{className:`min-w-0`,children:[(0,W.jsx)(Ft,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,W.jsx)(j,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,W.jsx)(F,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,W.jsx)(j,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,W.jsx)(j,{variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations`,children:`Back to automations`})})]}),u?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var Lt=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),q=T(D().trim().min(1).max(200)).max(100).optional(),Rt=S({includeExisting:E().optional(),requireCurrentLabels:E().optional(),authors:q,assignees:q,allLabels:q,anyLabels:q,excludeLabels:q,changedLabels:q,lookbackDays:k().int().min(1).max(90).default(7),maxRecords:k().int().min(1).max(100).default(25)}).passthrough(),zt=S({prompt:D().min(1).max(1e5),workflow:D().trim().min(1).max(200).optional(),steps:T(ie).min(1).max(100).optional(),runner:te.optional(),model:D().trim().min(1).max(200).optional(),effort:D().trim().min(1).max(32).optional(),variants:se([w(1),w(2),w(3)]).optional(),worktree:E().optional(),autonomous:E().optional(),...b,...ae,systemPrompt:D().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),Bt=new Set(Object.keys(zt.shape).filter(e=>e!==`variants`));function Vt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>Bt.has(e)))}le(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.kind===`schedule`?e:{...t,intervalSeconds:t.intervalSeconds??300,filters:t.filters??{}}},S({id:D().min(1).max(100),revision:k().int().positive(),name:D().trim().min(1).max(200),description:D().max(2e3).optional(),enabled:E().default(!1),kind:_t.default(`github`),events:T(Lt).min(1).max(4).optional(),intervalSeconds:k().int().min(60).max(86400).optional(),filters:Rt.optional(),schedule:tt.passthrough().optional(),task:zt,archived:S({at:D().datetime(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:D().datetime(),updatedAt:D().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:_.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:_.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:_.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:_.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:_.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),S({version:w(1).default(1),automations:T(ce()).default([]),tombstones:C(D(),D().datetime()).optional()}).passthrough();var J=S({timestamp:D().datetime(),tieBreaker:D().optional()}).passthrough(),Ht=bt.extend({cursor:J.optional()}),Ut=S({revision:k().int().positive().optional(),baselineAt:D().datetime().optional(),armedAt:D().datetime().optional(),historyScan:Ht.optional(),cursor:J.optional(),frozenHighWatermark:J.extend({tieBreaker:D()}).optional(),backlogAfter:J.extend({tieBreaker:D()}).optional(),nextCheckAt:D().datetime().optional(),lastSuccessAt:D().datetime().optional(),nextRunAt:D().datetime().optional(),lastRunAt:D().datetime().optional(),etags:C(D(),D()).optional(),backoffUntil:D().datetime().optional(),consecutiveFailures:k().int().nonnegative().optional(),...xt,onceOutcome:O([`failed`,`missed`]).optional()}).passthrough();S({version:w(1).default(1),states:C(D(),Ut).default({})}).passthrough(),S({receiptId:D().min(1),receiptKey:D().min(1),eventId:D().min(1),automationId:D().min(1),revision:k().int().positive(),status:O([`reserved`,`launched`,`launch-error`,`released`]),runId:D().optional(),observedAt:D().datetime(),updatedAt:D().datetime(),error:D().max(2e3).optional(),occurrenceAt:D().datetime().optional(),candidate:S({eventId:D(),event:Lt,timestamp:D().datetime(),tieBreaker:D(),repo:D(),nodeId:D(),number:k().int().positive(),title:D().max(500),url:D().url(),author:D().max(200),assignees:T(D().max(200)).max(100),labels:T(D().max(200)).max(100),changedLabel:D().max(200).optional()}).passthrough().optional()}).passthrough();var Wt=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);S({seq:k().int().positive(),ts:D().datetime(),automationId:D().min(1),revision:k().int().positive(),event:Lt.optional(),result:Wt,reason:D().max(2e3).optional(),durationMs:k().int().nonnegative().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().int().positive().optional(),githubTitle:D().max(500).optional(),githubUrl:D().url().optional(),rateLimit:S({bucket:O([`core`,`search`]),remaining:k().int().nonnegative().optional(),resetAt:D().datetime().optional()}).passthrough().optional()}).passthrough();var Gt=`quick-task`;function Kt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Vt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:mt(e.schedule??{type:`daily`}),events:e.events??[V.options[0]],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Gt}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function qt(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function Jt(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function Yt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:qt(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:Jt(e)}}function Xt(e){return{...Yt(e),enable:e.enabled}}function Zt(e,t){return{...Yt(e),task:{...Jt(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function Y(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Qt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),$t=new Set([`anyLabels`,`authors`,`changedLabels`]);function en(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!Qt.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||$t.has(e)&&Array.isArray(t)&&t.length>0)}function tn(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function nn(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function X(e,t){return t.startsWith(`-`)?`--${e}=${Y(t)}`:`--${e} ${Y(t)}`}function rn(e){let t=[`${ze()} automation add`,X(`name`,e.name)];if(e.schedule?.type===`once`)t.push(X(`at`,e.schedule.at),X(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(X(`latest-start`,nn(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(X(`cron`,st(e.schedule)));else{t.push(X(`on`,e.events.join(`,`)),`--every ${tn(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(X(`label`,n));for(let n of e.filters?.authors??[])t.push(X(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(X(`changed-label`,n))}return t.push(...an(e.task)),e.enable===!0&&t.push(`--enable`),t.push(X(`prompt`,e.task.prompt)),t.join(` `)}function an(e){let t=[];return e.workflow&&t.push(X(`workflow`,e.workflow)),e.runner&&t.push(X(`runner`,e.runner)),e.model&&t.push(X(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function on(e,t){let n=Xt(e),r=en(n)?rn(n):`${ze()} automation create --json ${Y(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${Y(t.origin)} CEZ_PROJECT_ID=${Y(t.projectId)} HSQ_COCKPIT_URL=${Y(t.origin)} HSQ_PROJECT_ID=${Y(t.projectId)} ${r}`:r}function sn(e){let t=[],n=!1;for(let r of cn(e)){let e=t.length-1;!n&&/^[A-Z_][A-Z0-9_]*=/.test(r)?t.push(r):r.startsWith(`--`)||!n?(t.push(r),n=!0):t[e]=`${t[e]} ${r}`}return t.map((e,t)=>t===0?e:` ${e}`).join(` \\
2
- `)}function cn(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];!r&&a===`\\`&&i+1<e.length?(n+=a+e[i+1],i+=1):a===`'`?(r=!r,n+=a):a===` `&&!r?(n&&t.push(n),n=``):n+=a}return n&&t.push(n),t}function ln({draft:e,saveLabel:t,editing:n}){let i=Ae(),a=window.location.origin,o=(0,B.useMemo)(()=>{let t=on(e);return i?`HSQ_COCKPIT_URL=${Y(a)} HSQ_PROJECT_ID=${Y(i)} ${t}`:t},[e,a,i]),s=(0,B.useMemo)(()=>sn(o),[o]),[c,l]=(0,B.useState)(`idle`),[u,d]=(0,B.useState)(!1),f=(0,B.useId)(),p=(0,B.useRef)(void 0);(0,B.useEffect)(()=>()=>clearTimeout(p.current),[]),(0,B.useEffect)(()=>l(`idle`),[o]);let m=async()=>{clearTimeout(p.current);try{await navigator.clipboard.writeText(s),l(`copied`),p.current=setTimeout(()=>l(`idle`),1600)}catch{l(`failed`)}};return(0,W.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`min-w-0 max-w-full overflow-hidden rounded-xl border border-card-edge bg-card shadow-card px-4 py-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,W.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,W.jsxs)(j,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":u,"aria-controls":f,"aria-label":u?`Hide command`:`Show command`,className:`min-w-0 shrink gap-1 px-1.5 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>d(e=>!e),children:[(0,W.jsx)(`span`,{className:`truncate`,children:u?`Hide`:`Show`}),(0,W.jsx)(xe,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,u&&`rotate-180`)})]}),(0,W.jsxs)(j,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto gap-1.5 px-2 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>void m(),children:[c===`copied`?(0,W.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5`}):(0,W.jsx)(Ge,{"aria-hidden":`true`,className:`size-3.5`}),c===`copied`?`Copied`:`Copy`]})]}),(0,W.jsx)(`div`,{id:f,hidden:!u,className:`mbs-2 max-w-full rounded-lg border border-border bg-muted has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-ring`,children:(0,W.jsx)(`pre`,{"data-slot":`copy-as-cli-line`,tabIndex:0,"aria-label":`Command line`,className:`m-0 max-w-full px-3 pt-2.5 pb-3 font-mono text-xs leading-5 break-all whitespace-pre-wrap text-muted-foreground outline-none`,children:s})}),(0,W.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:c===`failed`?`Could not copy — select the line and copy it by hand.`:(0,W.jsxs)(W.Fragment,{children:[`The definition ${t} would ${n?`save`:`create`}.`,` `,(0,W.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${ze()} automation schema`}),` prints its shape.`]})})]})}function un({pressed:e,onClick:t,disabled:n,children:i}){return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:r(`inline-flex min-h-11 items-center justify-center rounded-md border px-3.5 text-[13px] font-medium transition-colors outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,e?`border-border bg-card font-semibold text-foreground shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:text-foreground`),children:i})}var dn={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},fn={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function pn(e){let t=e.map(e=>dn[e]);if(t.length===0)return`When GitHub changes`;let n=t.slice(0,-1),r=t[t.length-1];return`When ${n.length>0?`${n.join(`, `)} or ${r}`:r}`}var mn=V.options,hn=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],gn=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],_n=e=>(e??[]).join(`, `),vn=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function yn(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function bn(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${yn(e.filters.includeExisting)}`}function xn({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=vn(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=hn.some(t=>t.seconds===e.intervalSeconds)?hn:[...hn,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,W.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,W.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:mn.map(t=>(0,W.jsx)(un,{pressed:e.events.includes(t),onClick:()=>r(t),children:fn[t]},t))}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-interval`,children:`Check every`}),(0,W.jsxs)(De,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,W.jsx)(N,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:o.map(e=>(0,W.jsx)(Ee,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Oe,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,W.jsx)(`span`,{children:`Include existing items`})]}),(0,W.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:yn(e.filters.includeExisting)})]}),(0,W.jsxs)(Te,{children:[(0,W.jsxs)(we,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,W.jsx)(xe,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,W.jsx)(Ce,{children:(0,W.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[gn.map(t=>(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,W.jsx)(R,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:_n(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,W.jsx)(R,{id:`automation-filter-lookback`,className:`border-border`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,W.jsx)(R,{id:`automation-filter-max`,className:`border-border`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var Sn=e=>String(e).padStart(2,`0`);function Z({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,B.useState)(Sn(t)),o=(0,B.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${Sn(n)}.`,l=(0,B.useId)();return(0,B.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(R,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 border-border text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(Sn(t))}),s?(0,W.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var Cn=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],wn=`none`,Tn=e=>String(e).padStart(2,`0`);function En(e,t=Date.now()){let n=ht(t,e)??ht(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${Tn(r.getUTCMonth()+1)}-${Tn(r.getUTCDate())}T09:00`}function Dn(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function On({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?ct(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${Tn(t)}:${Tn(n)}`}),l=(0,B.useRef)(null),u=(0,B.useId)(),d=rt(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,B.useEffect)(()=>{l.current?.setCustomValidity(f?et:``)},[f]);let p=ft(e);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-once-date`,children:`Date`}),(0,W.jsx)(R,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full border-border`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(Z,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(Z,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,W.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:et}):null,(0,W.jsx)(An,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,W.jsx)(jn,{value:e.latestStartMinutes,onChange:t=>n(kn(e,t))}),p?(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function kn(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function An({value:e,onCommit:t}){let[n,r]=(0,B.useState)(e),i=(0,B.useRef)(null),a=(0,B.useId)(),o=(0,B.useId)(),[s]=(0,B.useState)(Dn),c=n!==e||!$e(n),l=it(n);return(0,B.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,W.jsx)(R,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full border-border sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),$e(e.target.value)&&t(e.target.value)}}),(0,W.jsx)(`datalist`,{id:a,children:s.map(e=>(0,W.jsx)(`option`,{value:e},e))}),c?(0,W.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function jn({value:e,onChange:t}){let n=Cn.some(t=>t.minutes===e)||e===void 0?Cn:[...Cn,{minutes:e,label:`${e} minutes`}];return(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,W.jsxs)(De,{value:e===void 0?wn:String(e),onValueChange:e=>t(e===wn?void 0:Number(e)),children:[(0,W.jsx)(N,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:n.map(e=>(0,W.jsx)(Ee,{value:e.minutes===void 0?wn:String(e.minutes),children:e.label},e.label))})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var Mn=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function Nn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??En(r),timeZone:e.timeZone??r}:{type:t});return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:Mn.map(t=>(0,W.jsx)(un,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,W.jsx)(On,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,W.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:pt.map((t,n)=>(0,W.jsx)(un,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-every`,children:`Run every`}),(0,W.jsxs)(De,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,W.jsx)(N,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:ut.map(e=>(0,W.jsx)(Ee,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(Z,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(Z,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,W.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,W.jsx)(`code`,{className:`font-mono text-foreground`,children:st(e)})]})]})}var Pn=40*864e5,Fn=5;function In({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,W.jsx)(Ln,{schedule:e,now:n});let r=nt(e,n+1,n+Pn,t,Fn);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,W.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,W.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,W.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:z(new Date(e).toISOString(),t)}),(0,W.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:ot(n,e)})]},e))}),(0,W.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function Ln({schedule:e,now:t}){let n=rt(e),r=ft(e);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,W.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:ot(t,n)}):null]}),r?.note?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,W.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,W.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var Rn={schedule:`On a schedule`,github:`When GitHub changes`};function zn(e){return/time zone|due time/i.test(e)?`when`:/autonomous/i.test(e)?`execution`:/placeholder|prompt|workflow|runner|model|task/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function Q({title:e,icon:t,hideLegend:n=!1,failure:r,section:i,children:a}){let o=(0,B.useId)();return(0,W.jsxs)(`section`,{role:n?void 0:`group`,"aria-labelledby":n?void 0:o,className:`grid min-w-0 gap-3.5 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[n?null:t?(0,W.jsxs)(`h2`,{id:o,className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[t,e]}):(0,W.jsx)(`h2`,{id:o,className:`text-sm font-semibold text-foreground`,children:e}),a,r?.section===i&&!r.conflict?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:r.message}):null]})}function Bn({draft:e,patch:t,forge:n,automation:r}){return(0,W.jsx)(W.Fragment,{children:r?(0,W.jsxs)(`p`,{className:`text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Rn[e.kind]]}):(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(Ze,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Rn.schedule},{value:`github`,label:Rn.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Vn({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,W.jsx)(Nn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,W.jsx)(xn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Hn({draft:e,patch:t}){let n=e.kind===`schedule`?[`date`,`time`,`project`,`automation`]:[`github.kind`,`github.number`,`github.title`,`github.url`,`github.author`,`github.assignees`,`github.labels`,`github.event`],r=[...new Set([...e.prompt.matchAll(/\{\{([^{}]+)\}\}/g)].map(e=>e[1]))].filter(e=>!n.includes(e));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,W.jsx)(A,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,W.jsx)(Qe,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:3,className:`[field-sizing:fixed] min-h-[88px] resize-none border-border bg-background`,required:!0}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),r.length?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:`Unavailable for this trigger: ${r.map(e=>`{{${e}}}`).join(`, `)}`}):null,(0,W.jsx)(Xn,{draft:e,patch:t})]})}function Un({label:e,help:t,checked:n,onChange:r}){let i=(0,B.useId)();return(0,W.jsxs)(`label`,{htmlFor:i,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,W.jsx)(`span`,{id:`${i}-label`,children:e}),(0,W.jsx)(`span`,{id:`${i}-help`,className:`completion-control-help`,children:t})]}),(0,W.jsx)(Oe,{id:i,className:`completion-switch shrink-0`,checked:n,"aria-labelledby":`${i}-label`,"aria-describedby":`${i}-help`,onCheckedChange:r})]})}function Wn({draft:e,patch:t,saving:n,automation:r}){let i=e.kind===`schedule`,a=r?`Enabled`:`Enable after saving`,o=i&&e.schedule.type===`once`?`It runs once at the time set under When, then moves to Archived with its task.`:i?`The first run is the next occurrence in Next 5 runs.`:yn(e.filters.includeExisting);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,W.jsxs)(`div`,{"data-embedded":``,className:`grid min-w-0`,children:[(0,W.jsx)(Un,{label:`Autonomous`,help:`Runs without waiting for answers.`,checked:e.autonomous,onChange:e=>t({autonomous:e})}),(0,W.jsx)(Ve,{embedded:!0,archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,W.jsx)(Be,{embedded:!0,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),(0,W.jsx)(Un,{label:a,help:o,checked:e.enabled,onChange:e=>t({enabled:e})})]}),r?(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Gn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,B.useState)(()=>Kt(e)),[s,c]=(0,B.useState)(e?.revision),[l,u]=(0,B.useState)(),[d,m]=(0,B.useState)(!1),g=e=>o(t=>({...t,...e})),_=async t=>{if(t.preventDefault(),d)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}m(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await h(e.id,Zt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await p(e.id,a.enabled))}else await y(Xt(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof f&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`execution`:zn(n),message:n})}finally{m(!1)}},v=(0,B.useId)(),b=(0,B.useId)(),x=a.kind===`schedule`;return(0,W.jsx)(Pe,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Yn({automation:e,draft:a,formId:v,saveHintId:b,saving:d}),children:(0,W.jsxs)(`form`,{id:v,className:`automation-editor grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_320px] md:grid-rows-[auto_1fr] md:items-start`,onSubmit:_,children:[(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,W.jsx)(Q,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,W.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,W.jsx)(A,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,W.jsx)(R,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>g({name:e.target.value}),required:!0})]})}),(0,W.jsxs)(Q,{title:`When`,section:`when`,failure:l,children:[(0,W.jsx)(Bn,{draft:a,patch:g,forge:t,automation:e}),(0,W.jsx)(Vn,{draft:a,patch:g,forge:t,timeZone:n,automation:e})]}),(0,W.jsx)(Q,{title:`What to run`,section:`run`,failure:l,children:(0,W.jsx)(Hn,{draft:a,patch:g})})]}),(0,W.jsxs)(`aside`,{className:`grid min-w-0 max-w-full grid-cols-[minmax(0,1fr)] gap-4 md:sticky md:top-4 md:col-start-2 md:row-span-2 md:row-start-1`,children:[(0,W.jsx)(Q,{title:`Execution settings`,icon:(0,W.jsx)(ye,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),section:`execution`,failure:l,children:(0,W.jsx)(Wn,{draft:a,patch:g,saving:d,automation:e})}),x?(0,W.jsx)(In,{schedule:a.schedule,timeZone:n}):(0,W.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,W.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,W.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:bn(a)})]}),(0,W.jsx)(ln,{draft:a,saveLabel:qn(e,a),editing:e!==void 0})]}),l?.section===`form`||e?(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-3.5 md:col-start-1`,children:[l?.section===`form`?(0,W.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,W.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,W.jsx)(j,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,W.jsx)(Kn,{automation:e,onDeleted:r}):null]}):null]})})}function Kn({automation:e,onDeleted:t}){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(``),c=async()=>{if(!i){a(!0),s(``);try{await x(e.id),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}};return(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:i,onClick:()=>void c(),children:`Delete automation`}),(0,W.jsx)(j,{type:`button`,variant:`outline`,disabled:i,onClick:()=>{r(!1),s(``)},children:`Keep`})]})]}):(0,W.jsx)(j,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>r(!0),children:`Delete`}),o?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:o}):null]})}function qn(e,t){return e?`Save changes`:t.enabled?`Save and enable`:`Save paused`}function Jn(e){let t=[!e.name.trim()&&`a name`,!e.prompt.trim()&&`a prompt`].filter(Boolean);return t.length?`Add ${t.join(` and `)} to save.`:``}function Yn({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=Jn(t),s=qn(e,t);return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:(0,W.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`min-h-[1lh] text-xs text-muted-foreground`,children:o}),secondaryActions:(0,W.jsx)(I,{type:`button`,variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,W.jsx)(I,{type:`submit`,form:n,variant:`primary`,disabled:i||a!==``,title:a?`${a} is required`:void 0,"aria-describedby":o?r:void 0,children:i?`Saving…`:s})}}function Xn({draft:e,patch:t}){let n=o(),r=Fe(),{runners:u,signedOut:d}=r.runnersOn(e=>r.repoAccount?.[e]),f=a(),p=s(),{runner:m,ready:h}=l(e.runner??f.data?.defaultRunner??`claude`),g=c(m,h,r.repoAccount?.[m]),_=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],v=[...new Set([...u,...e.runner?[e.runner]:[]])],y=We(m,p.data,g.data,[e.model]),b=y.find(t=>t.id===(e.model??``))?.label??e.model??`Runner default`,x=e=>(0,W.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,W.jsx)(Ke,{children:(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(Re,{slot:`automation-workflow-pill`,icon:x(_e),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:_.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,W.jsx)(Re,{slot:`automation-runner-pill`,icon:x(be),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?i(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},...v.map(e=>({value:e,label:i(p.data,e)}))],footer:(0,W.jsx)(Je,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,W.jsx)(Re,{slot:`automation-model-pill`,icon:x(ge),fieldLabel:!0,ariaLabel:`Model`,label:b,value:e.model??``,options:y.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Zn(e){return{text:/\bauth\b|sign.?in|\blogin\b|\btoken\b|credentials|HTTP 401/i.test(e)?`GitHub CLI is not signed in`:/ENOENT|not found.*gh|gh.*not found/i.test(e)?`GitHub CLI is not installed`:`GitHub filter check failed`,tone:`error`,details:e}}function Qn({data:e,error:t,refresh:n,archived:i=!1,onArchivedChange:a}){let[o,s]=(0,B.useState)({}),[c,l]=(0,B.useState)({}),d=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t,n=!1)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){let r=t instanceof Error?t.message:String(t);d(e,n?Zn(r):{text:r,tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},m=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await u(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),h=e=>f(e.id,async()=>{d(e.id,void 0),await p(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await ne(e.id),await n()}),_=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await re(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await ee(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`){let t=r.error??`Preview failed`;d(e.id,Zn(t));return}await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)},!0),v=e?.automations??[],y=v.filter(e=>!e.archived),b=v.filter(e=>!!e.archived),x=i?b:y;return(0,W.jsx)(L,{route:`automations`,density:e?je(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,W.jsx)(I,{variant:`primary`,asChild:!0,children:(0,W.jsxs)(F,{to:`/automations/new`,children:[(0,W.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,W.jsx)(Ne,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,W.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,W.jsx)(F,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(G,{text:t}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,W.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!i,onClick:()=>a(!1),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,!i&&`border-accent-text text-foreground`),children:[`Current`,(0,W.jsx)($n,{count:y.length})]}),(0,W.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`archived`,"aria-pressed":i,onClick:()=>a(!0),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`border-accent-text text-foreground`),children:[`Archived`,(0,W.jsx)($n,{count:b.length})]})]}):(0,W.jsx)(`span`,{}),(0,W.jsx)(`div`,{className:`pb-2.5`,children:(0,W.jsx)(er,{data:e})})]}),i&&x.length===0?(0,W.jsx)(G,{text:`No archived automations.`}):x.length===0?(0,W.jsx)(Le,{icon:(0,W.jsx)(ve,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,W.jsx)(j,{variant:`primary`,asChild:!0,children:(0,W.jsxs)(F,{to:`/automations/new`,children:[(0,W.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,W.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,W.jsx)(lr,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void m(t),onToggle:()=>void h(t),onPreview:()=>void _(t),onCancel:()=>void g(t)},t.id))})]}):(0,W.jsx)(G,{text:`Loading automations…`})})}function $n({count:e}){return e===0?null:(0,W.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function er({data:e}){return(0,W.jsx)(`p`,{"data-slot":`automation-scheduler`,className:r(`text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function tr(e){return e.kind===`schedule`&&e.schedule?at(e.schedule):`${pn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function nr({automation:e,nextRun:t}){let n=e.kind===`schedule`?he:pe,r=qe(e);return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,W.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,W.jsxs)(`p`,{"data-slot":`automation-meta`,className:`mt-1 flex flex-wrap items-baseline gap-x-1.5 ps-6 text-xs break-words text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:tr(e)}),t?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,W.jsx)(Xe,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function rr({automation:e,archive:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,W.jsx)(j,{variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations/${e.id}`,children:`Details`})})})]})}function ir({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,W.jsx)(`span`,{children:`continuous`}):r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${z(r,t)}`}),(0,W.jsx)(`span`,{children:`· ${ot(Date.now(),Date.parse(r))}`})]}):(0,W.jsx)(`span`,{children:`Next run: —`})}function ar({automation:e,timeZone:t}){let n=e.enabled?Ct(e.state):void 0;return n?(0,W.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${z(n.retryAt,t)}`}):null]}):null}var $=`h-8 px-3 max-md:h-11 no-hover:h-11`;function or({automation:e,busy:t,confirmingCancel:n,cancelRef:i,onToggle:a,onRun:o,onPreview:s,onOpenCancel:c}){let l=e.kind===`schedule`,u=e.schedule?.type===`once`;return(0,W.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,W.jsx)(F,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,W.jsx)(F,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function sr({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,W.jsx)(j,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function cr({note:e}){return(0,W.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,className:r(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.details?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(de,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:Ie(`gh`),children:`Set up`}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{className:`min-h-11 cursor-pointer`,children:`Command details`}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.details})]})]}):null,e.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function lr({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,B.useState)(!1),u=(0,B.useRef)(null),d=(0,B.useRef)(null),f=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,W.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`flex min-w-0 flex-col gap-2.5 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,W.jsx)(nr,{automation:e,nextRun:h?void 0:(0,W.jsx)(ir,{automation:e,timeZone:t})}),h?(0,W.jsx)(rr,{automation:e,archive:h}):null,h?null:(0,W.jsx)(ar,{automation:e,timeZone:t}),h?null:(0,W.jsx)(or,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,W.jsx)(sr,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,W.jsx)(cr,{note:n}):null,(0,W.jsx)(Ft,{automationId:e.id,automationName:e.name,timeZone:t})]})}function ur(e){let t=Ae(),n=Ye(),[r,i]=(0,B.useState)(),[a,o]=(0,B.useState)(``),s=(0,B.useCallback)(t=>oe({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,B.useEffect)(()=>{n&&s()},[n,s]),(0,B.useEffect)(()=>d(async e=>{n&&await s(e)}),[n,s]),(0,B.useEffect)(()=>fe((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function dr({mode:e=`list`}){let{automationId:t}=ue(),n=ke(),[r,i]=(0,B.useState)(!1),{data:a,error:o,refresh:s}=ur(`include`),[c,l]=(0,B.useState)(0),u=He();if(u===`unknown`)return(0,W.jsx)(L,{route:`automations`,density:`empty`,children:(0,W.jsx)(G,{text:`Loading automations…`})});if(u===`absent`)return(0,W.jsx)(Ue,{});if(u===`disabled`)return(0,W.jsx)(L,{route:`automations`,density:`empty`,children:(0,W.jsx)(Le,{icon:(0,W.jsx)(ve,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart Squawk to turn automations on.`,heading:`h2`})});let d=()=>{n(`/automations`),s()},f=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,W.jsx)(Qn,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,W.jsx)(L,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(G,{text:o}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,W.jsx)(L,{route:`automations`,density:`empty`,children:(0,W.jsx)(G,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,W.jsx)(Gn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,W.jsx)(It,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,W.jsx)(Gn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,W.jsx)(L,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,W.jsx)(j,{asChild:!0,variant:`outline`,children:(0,W.jsx)(F,{to:`/automations`,children:`Back to automations`})})}):t?(0,W.jsx)(Pt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,W.jsx)(G,{text:`Automation not found.`})}export{dr as AutomationsRoute};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{o as t}from"./dist-C_rn70hE.js";import{j as n,nt as r,u as i,v as a}from"./design-icons-QbNMZniQ.js";import{t as o}from"./createLucideIcon-BHp8sXmF.js";import{t as s}from"./button-C8jUIs8Q.js";import{n as c,p as l,r as u,t as d}from"./dropdown-menu-DjtKUK8F.js";import{gr as f}from"./index-TOx-AA67.js";var p=o(`rows-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]]),m=o(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),h=e();function g({mode:e,wrap:t,onModeChange:n,onWrapChange:r,disabled:i=!1}){return(0,h.jsxs)(`span`,{className:`flex items-center gap-1.5 max-md:hidden`,children:[(0,h.jsxs)(`span`,{"data-slot":`diff-mode-toggle`,role:`group`,"aria-label":`Diff layout`,className:`inline-flex items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,h.jsx)(S,{current:e,value:`unified`,onModeChange:n,disabled:i}),(0,h.jsx)(S,{current:e,value:`split`,onModeChange:n,disabled:i})]}),(0,h.jsx)(b,{wrap:t,onWrapChange:r,disabled:i,labelled:!0,className:`h-11 w-auto min-w-11 gap-1.5 rounded-lg px-3 text-xs font-medium`})]})}function _({wrap:e,onWrapChange:t,preview:n=!1,onPreviewChange:a,disabled:o=!1}){return(0,h.jsxs)(d,{children:[(0,h.jsx)(l,{asChild:!0,children:(0,h.jsxs)(s,{variant:`outline`,size:`sm`,"data-slot":`diff-view-menu`,className:`h-11 gap-1.5 rounded-lg px-3 text-xs font-medium md:hidden`,children:[(0,h.jsx)(r,{size:16,"aria-hidden":`true`,className:`size-4`}),`View`,(0,h.jsx)(i,{size:16,"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`})]})}),(0,h.jsxs)(u,{align:`end`,"data-slot":`diff-view-menu-content`,children:[(0,h.jsx)(c,{"data-slot":`diff-view-wrap`,className:`min-h-11`,checked:e,disabled:o,onCheckedChange:e=>t(e===!0),children:`Wrap long lines`}),a?(0,h.jsx)(c,{"data-slot":`diff-view-preview`,className:`min-h-11`,checked:n,onCheckedChange:e=>a(e===!0),children:`Preview Markdown`}):null]})]})}var v=`Unavailable while Markdown preview is on`;function y(){return(0,h.jsx)(`span`,{"data-slot":`markdown-preview-hint`,role:`status`,className:`text-xs text-muted-foreground max-sm:sr-only`,children:`Full-document preview — layout and wrap are off`})}function b({wrap:e,onWrapChange:n,className:r=`size-11 rounded-lg`,disabled:i=!1,labelled:a=!1}){return(0,h.jsxs)(s,{variant:`outline`,size:`icon-sm`,"data-slot":`wrap-toggle`,"aria-pressed":e,"aria-label":`Wrap long lines`,title:i?v:`Wrap long lines`,disabled:i,className:t(r,e?`border-accent-text/40 bg-muted text-accent-text`:`text-muted-foreground hover:text-foreground`),onClick:()=>n(!e),children:[(0,h.jsx)(m,{"aria-hidden":`true`}),a?(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`Wrap`}):null]})}function x({preview:e,onPreviewChange:n}){return(0,h.jsxs)(s,{variant:`outline`,size:`sm`,"data-slot":`markdown-preview-toggle`,"aria-pressed":e,"aria-label":`Preview Markdown`,title:e?`Show Markdown as a diff`:`Preview Markdown`,className:t(`h-11 min-w-11 gap-1.5 rounded-lg px-0 text-xs font-medium sm:px-3`,e?`border-accent-text/40 bg-muted text-accent-text`:`text-muted-foreground hover:text-foreground`),onClick:()=>n(!e),children:[(0,h.jsx)(f,{"aria-hidden":`true`,className:`size-4`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`max-sm:hidden`,children:`Preview MD`})]})}function S({current:e,value:n,onModeChange:r,disabled:i}){let o=e===n;return(0,h.jsxs)(`button`,{type:`button`,"data-mode":n,"aria-pressed":o,disabled:i,title:i?v:void 0,onClick:()=>r(n),className:t(`inline-flex min-h-11 items-center gap-1.5 rounded-md px-3 text-xs font-medium capitalize transition-colors outline-hidden focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50`,o?`bg-muted text-foreground`:`text-muted-foreground pointer-hover:text-foreground`),children:[n===`unified`?(0,h.jsx)(p,{"aria-hidden":`true`,className:`size-4`}):(0,h.jsx)(a,{size:16,"aria-hidden":`true`,className:`size-4`}),n]})}function C({branch:e}){return(0,h.jsxs)(`span`,{"data-slot":`branch-chip`,className:`flex min-w-0 items-center gap-1 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-xs font-medium`,children:[(0,h.jsx)(n,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,h.jsx)(`span`,{className:`truncate`,children:e})]})}export{x as a,y as i,_ as n,b as o,g as r,C as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,p as i}from"./dist-C_rn70hE.js";import{Gt as a,Kt as o,O as s,Ut as c,a as l,c as u,d,i as f,j as p,n as m,o as h,r as g,sn as _,un as v}from"./queries-CchoEEzj.js";import{G as y,J as b,Nn as x,R as S,Ti as C,Y as w,n as T,q as E,vi as D}from"./toaster-zMN8cNZQ.js";import{f as O,h as ee}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{c as te,i as k,t as ne}from"./reference-chip-z7dZJVH-.js";import{I as re,L as ie,Q as A,Z as j,ct as M,i as ae,l as N,m as P,r as oe,u as F,ut as se}from"./design-icons-QbNMZniQ.js";import{t as ce}from"./chevron-down-CHGyCDBH.js";import{t as le}from"./chevron-right-BENZ-1ZN.js";import{t as I}from"./loader-circle-CPBhhDbB.js";import{t as ue}from"./play-CmVAj_fu.js";import{t as L}from"./button-C8jUIs8Q.js";import{a as de,i as fe,n as pe,r as R,t as me}from"./select-CGjqNwut.js";import{i as z,r as B,t as V}from"./popover-CvL6hQ5c.js";import{r as he,t as H}from"./project-router-j0uBi7Ep.js";import"./attention-DnxGjw_R.js";import{f as ge,v as _e}from"./task-groups-CGCnVqHE.js";import{t as ve}from"./status-dot-BXf-Ubd0.js";import{c as U,d as W,f as ye,m as be}from"./page-shell-Dky5crRl.js";import{a as xe,o as Se,r as Ce,s as we,t as Te}from"./command-BiBq24zL.js";import{t as G}from"./centered-state-BgSV4e79.js";import{t as Ee}from"./use-search-params-writer-ClMScnNe.js";import{At as De,Ct as Oe,Dt as ke,Et as Ae,Ft as je,It as Me,Ln as Ne,Lt as Pe,Mt as K,Nt as Fe,Ot as Ie,Pt as Le,Rt as Re,Tt as ze,Vn as Be,ar as Ve,ht as He,jt as Ue,kn as q,kt as We,qn as Ge,r as Ke,s as qe,wt as Je,zt as Ye}from"./index-TOx-AA67.js";import{t as Xe}from"./markdown-Ce0jEzBL.js";import{a as Ze,c as Qe,f as $e,h as et,i as tt,l as nt,m as rt,n as it,o as at,p as J,r as ot,s as st,t as ct,u as lt}from"./use-hand-to-agent-state-Ci2rVhws.js";import{t as ut}from"./tab-link-BKlpD9sn.js";var Y=e(t(),1),X=n();function dt({number:e,repo:t}){let n=i();return(0,X.jsx)(ft,{number:e,repo:t,scope:n},JSON.stringify([n,t,e]))}function ft({number:e,repo:t,scope:n}){let i=(0,Y.useId)(),a=(0,Y.useId)(),[o,s]=(0,Y.useState)(!1),c=o?ce:le,l=_(n,!0,n==="default"),u=p(`#${e}`,!0),d=(0,Y.useMemo)(()=>je(_e(l.data??[],u.data?.pages.flatMap(e=>e.runs)??[]),e,t,n),[l.data,u.data,e,t,n]);return(0,X.jsxs)(`section`,{"aria-labelledby":i,className:r(`mt-4 min-w-0 rounded-lg border border-border`,o?`p-3`:`p-0.5`),children:[(0,X.jsx)(`h3`,{id:i,className:`text-xs font-semibold text-muted-foreground`,children:(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":a,onClick:()=>s(e=>!e),className:`flex min-h-11 w-full items-center gap-2 rounded-md px-2.5 text-left hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,X.jsx)(c,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,X.jsxs)(`span`,{children:[`Linked tasks`,l.data?` (${d.length}${u.hasNextPage||u.isError?`+`:``})`:``]})]})}),(0,X.jsx)(`div`,{id:a,children:o?(0,X.jsxs)(X.Fragment,{children:[l.isPending?(0,X.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:`Loading linked tasks…`}):null,l.isError?(0,X.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(`p`,{role:`status`,children:`Couldn’t load linked tasks. Check your connection and try again.`}),(0,X.jsx)(L,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void l.refetch(),disabled:l.isFetching,children:`Retry linked tasks`})]}):null,l.data&&d.length===0&&!l.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No linked tasks yet.`}):null,d.length>0?(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:d.map(e=>{let t=Ne(e,x(e));return(0,X.jsx)(`li`,{children:(0,X.jsxs)(H,{to:`/tasks/${encodeURIComponent(e.id)}`,className:`flex min-h-11 min-w-0 flex-col justify-center gap-1 rounded-md px-2 py-2 hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium break-words [overflow-wrap:anywhere]`,children:ge(e)}),(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(ve,{tone:t.tone,shape:t.shape,pulse:t.pulse,role:`img`,"aria-label":t.label,title:t.label}),e.archived?(0,X.jsx)(Ke,{"data-slot":`linked-task-archived`,dot:q.tone,shape:q.shape,className:`px-2 py-px`,children:q.label}):null,(0,X.jsx)(`time`,{dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleDateString()})]})]})},e.id)})}):null,u.isError?(0,X.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(`p`,{role:`status`,children:`Couldn’t load older archived linked tasks.`}),(0,X.jsx)(L,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void u.refetch(),disabled:u.isFetching,children:`Retry older linked tasks`})]}):u.hasNextPage?(0,X.jsx)(L,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void u.fetchNextPage(),disabled:u.isFetchingNextPage,children:u.isFetchingNextPage?`Loading older linked tasks…`:`Show older linked tasks`}):null]}):null})]})}var pt=`w-44 max-w-full`,Z=`min-h-11 min-w-11 rounded-md border border-input bg-card px-3 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-ring disabled:opacity-60`,Q=`__all__`;function mt(e,t){let n=new Map;for(let t of e)for(let e of t.assignees??[])n.set(e.toLowerCase(),e);for(let e of t)n.set(e.toLowerCase(),e);return[...n.values()].sort((e,t)=>e.localeCompare(t))}function ht(e,t){return!!e&&t.length===1&&t[0]?.toLowerCase()===e.toLowerCase()}function gt(e){let t=` Previous memberships are shown; issues with unknown membership remain visible.`;return e.projectsState===`refreshing`&&e.projects?`Refreshing project boards.${t}`:e.projectsState===`unavailable`&&e.projects?`${e.projectsReason}${t}`:e.projects?``:e.projectsReason??(e.projectsState===`refreshing`?`Project memberships pending.`:`Project boards unavailable.`)}function _t(e){return[e.viewerLogin?``:`GitHub login unavailable.`,gt(e)].filter(Boolean).join(` `)}function vt({options:e,assignees:t,onAssigneesChange:n}){return(0,X.jsxs)(V,{children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:`${Z} inline-flex items-center gap-1.5`,disabled:e.length===0,children:[`Assignee`,t.length?` · ${t.length}`:``,(0,X.jsx)(F,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`})]})}),(0,X.jsx)(B,{align:`start`,className:`w-64 max-w-[calc(100vw-2rem)] p-2`,children:(0,X.jsxs)(`fieldset`,{className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] overflow-y-auto`,children:[(0,X.jsx)(`legend`,{className:`px-2 text-xs text-muted-foreground`,children:`Match any selected assignee`}),e.map(e=>{let r=t.some(t=>t.toLowerCase()===e.toLowerCase());return(0,X.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded px-2 hover:bg-muted`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>n(r?t.filter(t=>t.toLowerCase()!==e.toLowerCase()):[...t,e])}),(0,X.jsx)(`span`,{className:`break-all text-sm`,children:e})]},e.toLowerCase())})]})})]})}function yt({data:e,projectId:t,onProjectChange:n,pickerRef:r}){if(e.projects?.length)return(0,X.jsxs)(me,{value:t||Q,onValueChange:e=>n(e===Q?``:e),children:[(0,X.jsx)(fe,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":t,className:`${Z} ${pt} justify-between`,children:(0,X.jsx)(de,{placeholder:`All boards`})}),(0,X.jsxs)(pe,{align:`start`,children:[(0,X.jsx)(R,{value:Q,children:`All boards`}),e.projects.map(e=>(0,X.jsx)(R,{value:e.id,"data-board":e.id,children:e.title},e.id))]})]});if(e.projects||e.projectsState){let t=e.projects?`No boards`:e.projectsState===`refreshing`?`Loading boards…`:`Boards unavailable`;return(0,X.jsxs)(me,{disabled:!0,value:Q,children:[(0,X.jsx)(fe,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":``,className:`${Z} ${pt} justify-between`,children:(0,X.jsx)(de,{placeholder:t,children:t})}),(0,X.jsx)(pe,{align:`start`,children:(0,X.jsx)(R,{value:Q,children:t})})]})}return null}function bt({data:e,message:t,lastMessage:n,hasMessage:r,statusOpen:i,setStatusOpen:a,triggerRef:o,contentRef:s}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:t}),(0,X.jsxs)(V,{open:i,onOpenChange:a,children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsx)(`button`,{ref:o,type:`button`,className:`${Z} inline-flex items-center justify-center ${t?``:`invisible`}`,"aria-label":`Project board status`,tabIndex:t?void 0:-1,children:e.projectsState===`refreshing`?(0,X.jsx)(j,{size:14,"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}):(0,X.jsx)(M,{size:14,"aria-hidden":`true`,className:`size-3.5`})})}),(0,X.jsx)(B,{ref:s,align:`start`,"data-slot":`gh-issue-status`,onCloseAutoFocus:e=>{r||e.preventDefault()},className:`w-72 max-w-[calc(100vw-2rem)] p-3 text-xs text-muted-foreground`,children:t||n.current})]})]})}function xt({data:e,assignees:t,projectId:n,onAssigneesChange:r,onProjectChange:i}){let[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=mt(e.issues,t),f=ht(e.viewerLogin,t),p=_t(e),m=p!==``,h=(0,Y.useRef)(p);m&&(h.current=p);let g=(0,Y.useRef)(!m);g.current=!m;let _=()=>(l.current&&!l.current.disabled?l.current:u.current)?.focus();return(0,Y.useEffect)(()=>{let e=s.current;if(!e)return;let t=e=>{g.current&&!e.relatedTarget&&requestAnimationFrame(()=>{(!document.activeElement||document.activeElement===document.body)&&_()})};return e.addEventListener(`blur`,t),()=>e.removeEventListener(`blur`,t)},[]),(0,Y.useEffect)(()=>{if(m)return;let e=document.activeElement,t=!!e&&(e===s.current||!!c.current?.contains(e));o(!1),t&&_()},[m]),(0,X.jsxs)(`div`,{className:`contents`,"data-slot":`gh-issue-filters`,children:[(0,X.jsx)(vt,{options:d,assignees:t,onAssigneesChange:r}),(0,X.jsxs)(`button`,{ref:u,type:`button`,"data-slot":`gh-assigned-me`,className:`${Z} inline-flex items-center gap-1.5 rounded-full aria-pressed:border-accent-strong aria-pressed:bg-accent-strong aria-pressed:text-accent-strong-foreground aria-pressed:hover:bg-accent-strong`,disabled:!e.viewerLogin,"aria-pressed":f,onClick:()=>r(f?[]:[e.viewerLogin]),children:[(0,X.jsx)(se,{size:14,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Assigned to me`]}),(0,X.jsx)(yt,{data:e,projectId:n,onProjectChange:i,pickerRef:l}),(0,X.jsx)(bt,{data:e,message:p,lastMessage:h,hasMessage:m,statusOpen:a,setStatusOpen:o,triggerRef:s,contentRef:c})]})}function St({onRefresh:e,refreshing:t}){let n=Oe(i());return(0,X.jsx)(W,{route:`github`,density:`full`,headerSpacing:`compact`,header:{title:`GitHub`,secondaryActions:(0,X.jsx)(U,{type:`button`,variant:`ghost`,"data-slot":`gh-screen-refresh`,"aria-label":`Refresh from GitHub`,title:`Refresh from GitHub`,disabled:t,onClick:e,children:(0,X.jsx)(j,{size:17,"aria-hidden":`true`,className:r(`size-[17px]`,t&&`motion-safe:animate-spin`)})})},children:(0,X.jsx)(`div`,{"data-slot":`github-filter-screen`,children:(0,X.jsx)(Je,{model:n,variant:`screen`})})})}function Ct({view:e,activeFilter:t,isDesktop:n,listInUrl:r,n:i,gh:a,actions:o}){return{headerSlot:`gh-masthead`,title:n?e===`issues`?`Issues`:`Pull requests`:`GitHub`,scope:n?ze[t]:void 0,scopeSlot:`gh-title-qualifier`,subtitle:a.repo?(0,X.jsxs)(`span`,{className:`block min-w-0 truncate`,children:[(0,X.jsx)(`span`,{"data-slot":`gh-repo`,children:a.repo}),(0,X.jsxs)(`span`,{"data-slot":`gh-synced`,title:a.syncedAt?new Date(a.syncedAt).toLocaleString():void 0,children:[` `,`· `,a.syncedAt?(0,X.jsx)(Be,{iso:a.syncedAt,prefix:`Synced `}):`Not synced yet`]})]}):void 0,secondaryActions:(0,X.jsx)(wt,{...o}),headerExtra:r&&i===void 0?(0,X.jsxs)(`div`,{"data-slot":`gh-filter-context`,className:`mt-1 flex min-w-0 items-center gap-3 md:hidden`,children:[(0,X.jsxs)(H,{to:`/github`,"data-slot":`gh-back-filters`,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to filters`]}),t===`all`?null:(0,X.jsx)(`span`,{"data-slot":`gh-active-filter`,className:`truncate text-xs text-muted-foreground`,children:[...Ie,...We].find(e=>e.id===t)?.label})]}):void 0}}function wt({automationsAvailable:e,refreshing:t,onRefresh:n}){return(0,X.jsxs)(`div`,{"data-slot":`gh-page-actions`,className:`flex shrink-0 flex-wrap items-center gap-2`,children:[e?(0,X.jsx)(U,{variant:`outline`,asChild:!0,children:(0,X.jsx)(H,{to:`/automations/new`,children:`Set up automations`})}):null,(0,X.jsxs)(U,{type:`button`,variant:`outline`,"data-slot":`gh-refresh`,title:`Refresh from GitHub`,disabled:t,onClick:n,children:[(0,X.jsx)(j,{size:16,"aria-hidden":`true`,className:r(`size-3.5`,t&&`motion-safe:animate-spin`)}),`Refresh`]})]})}function Tt({view:e,number:t}){return(0,X.jsx)(G,{icon:e===`issues`?(0,X.jsx)(P,{size:16}):(0,X.jsx)(re,{size:16}),tone:`neutral`,heading:`h2`,title:t===null?`Nothing selected`:`Not found`,subtitle:t===null?`No open ${e===`issues`?`issues`:`pull requests`} to show.`:`#${t} is not among the open ${e===`issues`?`issues`:`pull requests`}. Go back to the list and search for ${t} to look it up on GitHub, closed and merged included.`})}var Et=/^(\[[^\]\n]{1,24}\]:?)\s+(\S.*)$/s;function Dt(e){let t=Et.exec(e);return t?{prefix:t[1],rest:t[2]}:{prefix:null,rest:e}}function Ot(e,t){if(!t)return e.kind===`issue`?`open`:e.isDraft?`draft`:void 0}function kt(e){let t=e.reduce((e,t)=>Math.max(e,String(t.number).length),1);return Math.ceil(28+(t+1)*7.2)}var At=2;function jt({item:e,view:t,filter:n,narrows:i,colors:s,expanded:l,onToggle:u,queuedRunId:d,checks:f,comments:p,status:m,task:h,referenceWidth:g}){let _=D(),v=`gh-row-summary-${e.kind}-${e.number}`,y=e.kind===`pr`?`PR`:`Issue`,x=te(y,e.number),S=(y===`PR`&&x.conflicting===!0?a:o(m??x.status))?.label,C=Dt(e.title),w=()=>{_.prefetchQuery({queryKey:c.githubComments(e.kind,e.number),queryFn:({signal:t})=>b(e.kind,e.number,{},{signal:t}),staleTime:6e4})};return(0,X.jsxs)(`div`,{"data-slot":`gh-row-shell`,"data-expanded":l||void 0,style:{"--gh-ref-width":`${g}px`},className:r(`@container rounded-md`,l&&`bg-sidebar-row-selected`),children:[(0,X.jsxs)(`button`,{type:`button`,draggable:!0,onDragStart:t=>{try{t.dataTransfer.setData(`text/plain`,ot(e)),t.dataTransfer.effectAllowed=`copy`}catch{}},onMouseEnter:w,onFocus:w,onClick:u,"data-slot":`gh-row`,"data-number":e.number,"data-kind":e.kind,"aria-expanded":l,"aria-controls":l?v:void 0,title:`Drag into the composer to prefill a task`,className:`grid w-full grid-cols-[var(--gh-ref-width)_minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5 rounded-md px-3 py-2 text-left transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 @4xl:grid-cols-[var(--gh-ref-width)_minmax(0,1fr)_auto_auto]`,children:[(0,X.jsxs)(`span`,{"data-slot":`gh-row-ref`,title:S,className:`flex h-[18px] items-center`,children:[(0,X.jsx)(ne,{reference:{kind:y,number:e.number},taskTitle:e.title,status:m,compact:!0,inert:!0}),S?(0,X.jsx)(`span`,{className:`sr-only`,children:S}):null]}),(0,X.jsxs)(`span`,{"data-slot":`gh-row-title`,className:r(`line-clamp-2 min-w-0 text-[13px] leading-[18px] font-medium text-foreground [overflow-wrap:anywhere] @4xl:line-clamp-none`,l&&`font-semibold`),children:[C.prefix?(0,X.jsxs)(`span`,{"data-slot":`gh-row-title-prefix`,className:`font-normal text-soft-foreground`,children:[C.prefix,` `]}):null,C.rest]}),(0,X.jsx)(F,{"data-slot":`gh-row-cue`,"aria-hidden":`true`,className:r(`col-start-3 row-start-1 mt-px size-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none @4xl:col-start-4`,l&&`rotate-180`)}),e.labels.length>0?(0,X.jsx)(`span`,{"data-slot":`gh-row-labels`,className:`col-start-2 col-end-4 flex min-w-0 flex-wrap gap-1 @4xl:col-end-3`,children:e.labels.map(e=>(0,X.jsx)(lt,{label:e,color:s[e],className:`max-w-full truncate`},e))}):null,(0,X.jsx)(Mt,{item:e,view:t,task:h,queuedRunId:d,checks:f,comments:p})]}),l?(0,X.jsx)(Pt,{id:v,item:e,checks:f,detailPath:Ue(t,n,e.number,``,i),queuedRunId:d}):null]})}function Mt({item:e,view:t,task:n,queuedRunId:r,checks:i,comments:a}){let o=e.assignees??[];return(0,X.jsxs)(`span`,{"data-slot":`gh-row-meta`,className:`col-start-2 col-end-4 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground @4xl:col-start-3 @4xl:col-end-4 @4xl:row-start-1 @4xl:h-[18px] @4xl:flex-nowrap`,children:[(0,X.jsx)(`span`,{"data-slot":`gh-row-task`,className:$.task,children:n?(0,X.jsx)(Ke,{dot:n.status.tone,shape:n.status.shape,pulse:n.status.pulse,title:`Newest task: ${n.status.label}`,className:`max-w-full py-0.5`,children:(0,X.jsx)(`span`,{className:`truncate`,children:n.status.label})}):r?(0,X.jsx)(`span`,{"data-slot":`gh-queued-flag`,className:`shrink-0 font-sans font-medium text-accent-text`,children:`↗ run queued`}):null}),(0,X.jsx)(`span`,{"data-slot":`gh-row-assignees`,className:$.assignees,children:o.length>0?(0,X.jsx)(Nt,{logins:o}):null}),t===`prs`?(0,X.jsx)(`span`,{"data-slot":`gh-row-checks-slot`,className:$.checks,children:i?(0,X.jsx)(at,{checks:i}):null}):null,(0,X.jsx)(`span`,{"data-slot":`gh-row-comments`,className:$.comments,children:a?(0,X.jsx)(st,{count:a}):null}),(0,X.jsx)(Be,{iso:e.createdAt,className:`shrink-0 @4xl:w-9 @4xl:text-right`})]})}var $={task:`flex min-w-0 max-w-full empty:hidden @4xl:w-44 @4xl:empty:block`,assignees:`flex shrink-0 items-center empty:hidden @4xl:w-12 @4xl:justify-center @4xl:empty:block`,checks:`flex shrink-0 empty:hidden @4xl:w-4 @4xl:justify-center @4xl:empty:block`,comments:`flex shrink-0 empty:hidden @4xl:w-10 @4xl:empty:block`};function Nt({logins:e}){let t=e.join(`, `);return(0,X.jsxs)(`span`,{title:`Assigned to ${t}`,className:`flex items-center -space-x-1`,children:[e.slice(0,At).map(e=>(0,X.jsx)(tt,{login:e},e)),e.length>At?(0,X.jsxs)(`span`,{"aria-hidden":`true`,className:`pl-2 tabular-nums`,children:[`+`,e.length-At]}):null,(0,X.jsxs)(`span`,{className:`sr-only`,children:[`Assigned to `,t]})]})}function Pt({id:e,item:t,checks:n,detailPath:r,queuedRunId:i}){let a=f(t.kind,t.number),o=(a.data?.detail?.body??t.body)?.trim(),s=t.kind===`pr`?`PR`:`issue`;return(0,X.jsxs)(`div`,{id:e,"data-slot":`gh-row-summary`,className:`flex flex-col gap-3 px-3 pb-4 @4xl:pl-[calc(var(--gh-ref-width)+1.5rem)]`,children:[(0,X.jsx)(`div`,{"data-slot":`gh-row-body`,className:`text-[13px] leading-relaxed text-soft-foreground`,children:o?(0,X.jsx)(`div`,{"data-slot":`gh-row-excerpt`,inert:!0,className:Ft,children:(0,X.jsx)(Xe,{document:!0,children:o})}):a.isPending?(0,X.jsx)(Ve,{className:`h-4 w-2/3`}):a.isError||a.data?.available===!1?(0,X.jsx)(`p`,{"data-slot":`gh-row-body-unavailable`,className:`text-muted-foreground`,children:`Description unavailable. Use Refresh to try again.`}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`(no description)`})}),(0,X.jsxs)(`div`,{"data-slot":`gh-row-facts`,className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[`Opened by `,(0,X.jsx)(`span`,{"data-slot":`gh-row-author`,className:`font-medium`,children:t.author})]}),n?(0,X.jsx)(Ze,{checks:n,url:t.url}):null]}),(0,X.jsxs)(`div`,{"data-slot":`gh-row-actions`,className:`flex flex-wrap items-center gap-2`,children:[i?(0,X.jsx)(L,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11`,children:(0,X.jsxs)(H,{to:`/tasks/${i}`,"data-action":`gh-row-view-task`,children:[(0,X.jsx)(N,{size:16,"aria-hidden":`true`,className:`size-3.5 text-success`}),`Open queued task`]})}):(0,X.jsx)(L,{asChild:!0,variant:`primary`,size:`sm`,className:`max-md:h-11`,children:(0,X.jsxs)(H,{to:r,state:{focusHandoff:!0},"data-action":`gh-row-handoff`,title:`Open this ${s} and write the prompt for an agent`,children:[(0,X.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5`}),`Hand to agent`]})}),(0,X.jsx)(L,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11`,children:(0,X.jsxs)(H,{to:r,"data-action":`gh-row-open`,children:[`Open `,s,(0,X.jsx)(ae,{size:16,"aria-hidden":`true`,className:`size-3.5`})]})})]})]})}var Ft=r(`max-h-[calc(3lh)] overflow-hidden [overflow-wrap:anywhere]`,`[&_*]:!my-0 [&_p+*]:!mt-1 [&_ul]:list-inside [&_ol]:list-inside`,`[&_:is(h1,h2,h3,h4,h5,h6,pre,img,table,hr,[data-streamdown="code-block"],[data-streamdown="table-wrapper"],[data-streamdown="image-wrapper"],[data-streamdown="mermaid-block"])]:hidden`);function It(e){let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`?e:e.closest(`[data-slot="main"]`)??e}function Lt(e){let[t,n]=(0,Y.useState)(null);return(0,Y.useLayoutEffect)(()=>{if(!e){n(null);return}let t=()=>n(It(e));t();let r=typeof window.matchMedia==`function`?window.matchMedia(`(min-width: 768px)`):null;r?.addEventListener(`change`,t);let i=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return i?.observe(e),()=>{r?.removeEventListener(`change`,t),i?.disconnect()}},[e]),t}function Rt(e,t){let[n,r]=(0,Y.useState)(0);return(0,Y.useLayoutEffect)(()=>{let n=()=>{!e||!t||r(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[e,t]),n}function zt(e,t,n){let[r,i]=(0,Y.useState)(null),a=(0,Y.useRef)(n);return(0,Y.useEffect)(()=>{a.current=n}),(0,Y.useEffect)(()=>{if(!e||!r||!t||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&a.current()},{root:t.getAttribute(`data-slot`)===`main`?null:t,rootMargin:`0px 0px 600px 0px`});return n.observe(r),()=>n.disconnect()},[e,r,t]),i}function Bt(e,t,n,r,i){let[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),l=Lt(a),u=(0,Y.useRef)(null);u.current=l;let d=Rt(s,l),f=e===`issues`?n?.issues.length??0:n?.prs.length??0,p=t.hasNextPage&&r===null&&f>0;return{listEl:a,setListEl:o,setRowsEl:c,scrollOwner:l,scrollOwnerRef:u,startMargin:d,pagingAvailable:p,manualPaging:p&&i,loadMoreRef:zt(p&&!i&&!t.isFetchingNextPage&&!t.isFetchNextPageError,l,()=>void t.fetchNextPage())}}function Vt({item:e,queuedRunId:t}){return t?(0,X.jsx)(L,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11 no-hover:h-11`,children:(0,X.jsxs)(H,{to:`/tasks/${t}`,"data-action":`gh-header-view-task`,children:[(0,X.jsx)(N,{size:16,"aria-hidden":`true`,className:`size-3.5 text-success`}),`Open queued task`]})}):(0,X.jsxs)(L,{type:`button`,variant:`primary`,size:`sm`,"data-action":`gh-header-handoff`,title:`Write the prompt and pick the workflow and runner for this ${e.kind===`pr`?`PR`:`issue`}`,className:`max-md:h-11 no-hover:h-11`,onClick:Ht,children:[(0,X.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5`}),`Hand to agent`]})}function Ht(){let e=document.querySelector(`[data-slot="gh-detail-inner"] [data-slot="gh-custom-prompt"]`);e?.scrollIntoView({block:`center`}),e?.focus({preventScroll:!0})}var Ut=100;function Wt(e,t,n,r,i){if(!e?.available||t!==`prs`)return[];let a=new Set;n!==null&&Number.isInteger(n)&&a.add(n);for(let t of[...r,...i,...e.prs]){if(a.size>=Ut)break;a.add(t.number)}return[...a]}function Gt(e,t,n,r,i,a){let o=Wt(n,e,r,i,a),s=m(o,e===`prs`),c=s.data?.available?s.data.checks:void 0,l=g(e===`issues`?`issue`:`pr`,(0,Y.useMemo)(()=>(t.data?.pages??[]).map(t=>(e===`issues`?t.issues:t.prs).map(e=>e.number)),[t.data,e]),n?.available===!0&&n.commentsDeferred===!0),u=(0,Y.useMemo)(()=>new Set(n?.commentsDeferred?(e===`issues`?n.issues:n.prs).map(e=>e.number):[]),[n,e]);return{checkPrNumbers:o,checksMap:c,commentsOf:e=>l[e.number]??(u.has(e.number)?void 0:e.comments)}}function Kt(e){let t=i(),n=_(t,!0,t==="default").data,r=(0,Y.useMemo)(()=>n?Me(n,e,t):null,[n,e,t]);return(0,Y.useCallback)(e=>{let t=e.kind===`issue`?r?.get(e.number):void 0;return t?{runId:t.id,status:Ne(t)}:null},[r])}function qt(e){let[t,n]=Ee(),r=t.get(`filter`),i=Pe(e,r),a=i??`all`,o=e=>n(t=>{let n=new URLSearchParams(t);return e===null?n.delete(`filter`):n.set(`filter`,e),n}),s=K(t);return{rawFilterParam:r,filter:i,activeFilter:a,setFilterParam:o,narrows:s,url:(0,Y.useMemo)(()=>{let t=new URLSearchParams(s);return{query:t.get(`q`)??``,labels:t.getAll(`label`),assignees:e===`issues`?t.getAll(`assignee`):[],board:e===`issues`?t.get(`board`)??``:``}},[s,e]),writeNarrows:(0,Y.useCallback)(e=>n(t=>{let n=e(t);return(t.has(`filter`)||K(t)!==``)&&!n.has(`filter`)&&K(n)===``&&n.set(`filter`,`all`),n}),[n])}}function Jt(e,t){return n=>{let r=new URLSearchParams(n);r.delete(e);for(let n of t)r.append(e,n);return r}}function Yt(e,t,{rawFilterParam:n,filter:r,activeFilter:i,setFilterParam:a,narrows:o,url:s,writeNarrows:c}){let l=Zt(s.query,n!==null||o!==``,c),{query:u,setQuery:d}=l,f=s.labels,p=s.assignees,m=e=>c(Jt(`label`,e)),{setProjectFilter:h,activeProject:g}=Qt(t,s.board,c),_=e===`issues`&&i===`assigned`,v=_?t?.viewerLogin?[t.viewerLogin]:[]:p;return{query:u,setQuery:d,labelFilter:f,setLabelFilter:m,setProjectFilter:h,activeProject:g,isAssignedFilter:_,effectiveAssignees:v,changeAssignees:e=>{c(Jt(`assignee`,e)),_&&a(`all`)},clearFilters:()=>{l.clear(),c(e=>{let t=new URLSearchParams(e);for(let e of ke)t.delete(e);return r!==null&&r!==`all`&&t.set(`filter`,`all`),t})},filtering:u.trim()!==``||f.length>0||e===`issues`&&(v.length>0||g!==``)||r!==null&&r!==`all`,narrowing:u.trim()!==``||f.length>0||e===`issues`&&(!_&&p.length>0||g!==``)}}var Xt=250;function Zt(e,t,n){let r=`${O().pathname}${t?``:`#entry`}`,[i,a]=(0,Y.useState)(e),o=(0,Y.useRef)(e),s=(0,Y.useRef)(void 0),c=(0,Y.useRef)(r);return(0,Y.useEffect)(()=>{e===o.current&&r===c.current||(clearTimeout(s.current),c.current=r,o.current=e,a(e))},[e,r]),(0,Y.useEffect)(()=>()=>clearTimeout(s.current),[]),{query:i,setQuery:e=>{a(e),clearTimeout(s.current),s.current=setTimeout(()=>{let t=e.trim();o.current=t,n(e=>{let n=new URLSearchParams(e);return t===``?n.delete(`q`):n.set(`q`,t),n})},Xt)},clear:()=>{clearTimeout(s.current),o.current=``,a(``)}}}function Qt(e,t,n){let r=e=>n(t=>{let n=new URLSearchParams(t);return e===``?n.delete(`board`):n.set(`board`,e),n}),i=e?.projectsState===`refreshing`||e?.projectsState===`unavailable`,a=i||e?.projects?.some(e=>e.id===t)===!0,o=e?.available===!0&&!i&&t!==``&&!a,[s,c]=(0,Y.useState)(``);s!==``&&s!==t&&c(``),o&&s!==t&&c(t);let l=o||s!==``&&s===t,u=a&&!l?t:``;return(0,Y.useEffect)(()=>{l&&n(e=>{let t=new URLSearchParams(e);return t.delete(`board`),t})},[l,n]),{setProjectFilter:r,activeProject:u}}function $t(e,t,{filter:n,activeFilter:r},a){let o=i(),s=e===`issues`&&(r===`no-task`||r===`has-task`),c=_(o,s,o==="default"),l=(0,Y.useMemo)(()=>c.data?Le(c.data,t?.repo,o):null,[c.data,t?.repo,o]),d=Fe(e,n)?Ye(n):null,f=u(`pr`,d??``,d!==null&&t?.available===!0),p=d!==null&&f.data?.available?f.data.items:null,m=(0,Y.useMemo)(()=>t?.available?e===`issues`?t.issues:t.prs:[],[t,e]),h=(0,Y.useMemo)(()=>p?Re(p,m):null,[p,m]),g=en({view:e,gh:t,activeFilter:r,isAssignedFilter:a,taskFilter:s,taskNumbers:l,runsQuery:c,backedQuery:d,filterHits:p,filterSearch:f});return{backedQuery:d,filterSearch:f,fullList:m,filterRows:h,filterGate:g,openItems:(0,Y.useMemo)(()=>g?[]:h??m,[g,h,m]),narrow:(0,Y.useMemo)(()=>e===`issues`?r===`no-task`&&l?{excludeNumbers:l}:r===`has-task`&&l?{includeNumbers:l}:{}:r===`mine`&&t?.viewerLogin?{author:t.viewerLogin}:p?{includeNumbers:new Set(p.map(e=>e.number))}:{},[e,r,l,t?.viewerLogin,p])}}function en({view:e,gh:t,activeFilter:n,isAssignedFilter:r,taskFilter:i,taskNumbers:a,runsQuery:o,backedQuery:s,filterHits:c,filterSearch:l}){return t?.available?(r||e===`prs`&&n===`mine`)&&!t.viewerLogin?{kind:`blocked`,message:`GitHub login unavailable, so this filter cannot be applied.`}:i&&!a?o.isError?{kind:`blocked`,message:`The task list is unavailable, so this filter cannot be applied.`}:{kind:`loading`,message:`Loading tasks…`}:s!==null&&!c?l.data?.available===!1?{kind:`blocked`,message:`GitHub could not be searched: ${l.data.reason??`unknown reason`}.`}:l.isError?{kind:`blocked`,message:`GitHub could not be searched: ${l.error instanceof Error?l.error.message:`the search request failed`}.`}:{kind:`loading`,message:`Searching GitHub…`}:null:null}function tn(e,t){return t?w(t.kind,t.number,{refresh:!0}).then(n=>(e.setQueryData(t.key,n),!0)).catch(()=>!1):Promise.resolve(!0)}function nn(e,t,n,{filterGate:r,filterRows:i,fullList:a}){let o=c.github()[0],s=t===void 0?null:Number.parseInt(t,10),l=!r&&n.data?.available?n.data.items.find(e=>e.number===s):void 0,u=i&&s!==null&&!a.some(e=>e.number===s)?i.find(e=>e.number===s):void 0,d=l??u,[f,p]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{d&&p({scope:o,view:e,item:d})},[o,e,d]),{selectedNumber:s,remoteDetail:d??(f?.scope===o&&f.view===e&&f.item.number===s?f.item:null)}}function rn(e,t,n,{fullList:r,filterRows:i},a){let o=D(),s=(0,Y.useRef)(null),u=e===`issues`?`issue`:`pr`,d=t?.available===!0&&n!==null&&Number.isSafeInteger(n)&&n>0&&!r.some(e=>e.number===n)&&!i?.some(e=>e.number===n)&&a===null,f=l(u,n??0,d),p=d&&f.data?.available&&f.data.item?.kind===u?f.data.item:null;s.current=d&&n!==null?{kind:u,number:n,key:c.githubItem(u,n)}:null;let[m,h]=(0,Y.useState)(!1);return{exactWanted:d,exactItem:f,exactDetail:p,exactTargetRef:s,retryingExact:m,retryExact:()=>{h(!0),tn(o,s.current).then(e=>{h(!1),e||T(`Could not reach GitHub for #${n}`,{tone:`danger`})})}}}function an(e,t,n){let r=D(),i=(0,Y.useRef)(null);return{refresh:v({mutationFn:e=>(tn(r,e),y({refresh:!0,limit:50})),onSuccess:async a=>{await r.cancelQueries({queryKey:c.githubPages(50),exact:!0}),r.setQueryData(c.githubPages(50),{pages:[a],pageParams:[{}]}),r.invalidateQueries({queryKey:c.githubChecks(t)});let o=e===`issues`?`issue`:`pr`,s=(e===`issues`?a.issues:a.prs).map(e=>e.number),l=c.githubCommentCounts(o,s);r.removeQueries({queryKey:c.githubCommentCounts(o,[]).slice(0,4),predicate:e=>e.queryHash!==C(l)}),a.available&&a.commentsDeferred&&s.length>0&&E(o,s,{refresh:!0}).then(e=>r.setQueryData(l,e)).catch(()=>{}),r.invalidateQueries({queryKey:c.githubSearch(e===`issues`?`issue`:`pr`,n)}),r.invalidateQueries({queryKey:c.githubSearch(`pr`,De)}),r.invalidateQueries({queryKey:c.githubSearch(`pr`,Ae)});let u=i.current,d=c.githubComments(`issue`,0).slice(0,3);if(!u){r.removeQueries({queryKey:d});return}let f=c.githubComments(u.kind,u.number);b(u.kind,u.number,{refresh:!0}).then(e=>r.setQueryData(f,e)).catch(()=>{}),r.removeQueries({queryKey:d,predicate:e=>e.queryHash!==C(f)})},onError:e=>T(e.message,{tone:`danger`})}),openThreadRef:i}}var on=350;function sn(e,t){let[n,r]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function cn(e,t,{query:n,labelFilter:r,effectiveAssignees:i,activeProject:a},{openItems:o,narrow:s,filterGate:c}){let l=sn(n,on),d=(0,Y.useMemo)(()=>J(o,{query:l,labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}),[o,l,r,e,i,a,s]),f=n.trim()===l.trim(),p=t?.available===!0&&!c&&f&&et(l,d),m=u(e===`issues`?`issue`:`pr`,l,p),h=J(o,{query:n,labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}),g=p&&m.data?.available?m.data:null,_=new Set(h.map(e=>e.number)),v=ln(e,g,a,i);return{debouncedQuery:l,searchWanted:p,forgeSearch:m,items:h,searchPayload:g,metadataFailure:v,searchHits:g&&!v?J(g.items,{labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}).filter(e=>!_.has(e.number)):[],...un(n,f,p,m)}}function ln(e,t,n,r){return e===`issues`&&t?n&&t.items.some(e=>e.projectIds===void 0)?t.projectsReason??`Project board data is incomplete. Refresh to try again.`:r.length&&t.items.some(e=>e.assignees===void 0)?`Assignee data is incomplete. Refresh to try again.`:null:null}function un(e,t,n,r){return{searching:e.trim()!==``&&!t||n&&r.isPending,searchFailed:n&&(r.data?.available===!1||r.isError),searchFailureReason:r.data?.available===!1?r.data.reason??`unknown reason`:r.error instanceof Error?r.error.message:`the search request failed`}}function dn({view:e,changes:t=!1,index:n=!1}){let{n:r}=ee(),i=qt(e),{rawFilterParam:a,activeFilter:o,narrows:c}=i,l=a!==null||c!==``,u=be(),{pages:d,data:f}=h(50),p=Ge(),m=pn(),g=ct(),_=fn({index:n,isDesktop:u,listInUrl:l,n:r,rememberedView:s().data?.githubView}),[v,y]=(0,Y.useState)(null),b=Yt(e,f,i),x=$t(e,f,i,b.isAssignedFilter),S=cn(e,f,b,x),C=nn(e,r,S.forgeSearch,x),w=rn(e,f,C.selectedNumber,x,C.remoteDetail),T=Gt(e,d,f,C.selectedNumber,S.searchHits,x.openItems),{refresh:E,openThreadRef:D}=an(e,T.checkPrNumbers,S.debouncedQuery),O=Bt(e,d,f,x.backedQuery,b.narrowing),te=Kt(f?.available?f.repo:void 0);if(_.restorePrs)return(0,X.jsx)(he,{to:`/github/prs`,replace:!0});if(!f)return d.isError?(0,X.jsx)(W,{route:`github`,density:`empty`,children:(0,X.jsx)(G,{icon:(0,X.jsx)(M,{size:16}),tone:`danger`,title:`Could not load GitHub`,subtitle:d.error.message})}):(0,X.jsx)(He,{});D.current=null;let k=()=>E.mutate(w.exactTargetRef.current);if(_.filterScreen&&f.available)return(0,X.jsx)(St,{onRefresh:k,refreshing:E.isPending});if(!f.available)return(0,X.jsx)(vn,{reason:f.reason,refreshing:E.isPending,onRetry:k});let{labelColors:ne,labelOptions:re}=mn(f,S.searchPayload,x.openItems,x.fullList),ie=hn({number:C.selectedNumber,fullList:x.fullList,filterRows:x.filterRows,remoteDetail:C.remoteDetail,exactDetail:w.exactDetail}),A=r===void 0?[...S.items,...S.searchHits].find(e=>e.url===v)??null:null,j=ie??A;D.current=j?{kind:j.kind,number:j.number}:null;let{linkFilter:ae,listPath:N}=gn(e,a,o,u,c),P={view:e,filter:ae,narrows:c,colors:ne,expandedUrl:A?.url??null,onToggle:e=>y(t=>t===e.url?null:e.url),queued:g.queued,checksMap:T.checksMap,commentsOf:T.commentsOf,taskOf:te,referenceWidth:kt([...S.items,...S.searchHits])},oe=_n(e,b,x.filterGate,S),F=Ct({view:e,activeFilter:o,isDesktop:u,listInUrl:l,n:r,gh:f,actions:{automationsAvailable:p,refreshing:E.isPending,onRefresh:k}});return r===void 0?(0,X.jsxs)(W,{route:`github`,density:ye(S.items.length+S.searchHits.length),headerSpacing:`compact`,className:`pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-4`,bodyClassName:`gap-2.5`,header:F,children:[(0,X.jsxs)(`header`,{"data-slot":`gh-header`,className:`flex shrink-0 flex-col gap-3 bg-background md:gap-4`,children:[(0,X.jsx)(yn,{view:e,isDesktop:u,gh:f,onSaveView:m}),(0,X.jsx)(bn,{view:e,gh:f,filters:b,labelOptions:re,labelColors:ne,searchPayload:S.searchPayload})]}),(0,X.jsx)(Cn,{view:e,rows:P,verdict:oe,search:S,sidebar:x,list:d,paging:O})]}):(0,X.jsx)(W,{route:`github`,density:`full`,headerSpacing:`compact`,className:`pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-4`,header:F,children:(0,X.jsx)(On,{view:e,selected:ie,selectedNumber:C.selectedNumber,exact:w,repo:f.repo,rows:P,listPath:N,changes:t,handToAgent:g})})}function fn({index:e,isDesktop:t,listInUrl:n,n:r,rememberedView:i}){return{filterScreen:e&&!t&&!n&&r===void 0,restorePrs:e&&t&&!n&&i===`prs`}}function pn(){let e=D();return t=>{e.setQueryData(c.uiState,e=>({...e,githubView:t})),S({githubView:t}).then(t=>e.setQueryData(c.uiState,t)).catch(t=>{T(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:c.uiState})})}}function mn(e,t,n,r){return{labelColors:{...t?.labelColors,...e.labelColors},labelOptions:$e([...n,...r,...t?.items??[]])}}function hn({number:e,fullList:t,filterRows:n,remoteDetail:r,exactDetail:i}){return e===null?null:t.find(t=>t.number===e)??n?.find(t=>t.number===e)??r??i??null}function gn(e,t,n,r,i){let a=t===null?null:n;return{linkFilter:a,listPath:Ue(e,a??(e===`issues`&&!r?`all`:null),void 0,``,i)}}function _n(e,{query:t,filtering:n},r,{searching:i,searchFailed:a,searchFailureReason:o,metadataFailure:s,searchHits:c,searchPayload:l,items:u}){let d=e===`issues`?`issues`:`pull requests`;return r?(0,X.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5`,"data-slot":`gh-filter-gate`,"data-kind":r.kind,children:[r.kind===`loading`?(0,X.jsx)(I,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}):null,r.message]}):n?i?(0,X.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(I,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}),`Searching GitHub for “`,t.trim(),`”…`]}):a?c.length>0?(0,X.jsxs)(`p`,{role:`status`,children:[`Showing previous results. GitHub could not be refreshed: `,o,`. Use Refresh to try again.`]}):u.length>0?(0,X.jsxs)(`p`,{children:[`GitHub could not be searched: `,o,`.`]}):(0,X.jsxs)(`p`,{children:[`No open `,d,` match your filter, and GitHub could not be searched: `,o,`.`]}):s?(0,X.jsxs)(`p`,{role:`status`,children:[`Cannot apply the selected filters to GitHub results: `,s]}):c.length>0?null:l?.truncated?(0,X.jsx)(`p`,{children:`No matches within GitHub’s first matches. Narrow your search to check more specific results.`}):l&&u.length>0?(0,X.jsxs)(`p`,{children:[`No additional `,d,` match your filter on GitHub.`]}):l?(0,X.jsxs)(`p`,{children:[`No `,d,` match your filter — open, closed or merged.`]}):(0,X.jsxs)(`p`,{children:[`No open `,d,` match your filter.`]}):(0,X.jsxs)(`p`,{children:[`No open `,d,`.`]})}function vn({reason:e,refreshing:t,onRetry:n}){return(0,X.jsx)(W,{route:`github`,density:`empty`,children:(0,X.jsx)(G,{icon:(0,X.jsx)(ie,{}),tone:`neutral`,title:`GitHub is unavailable here`,subtitle:e??`unknown reason`,actions:(0,X.jsx)(L,{variant:`outline`,"data-action":`gh-retry`,disabled:t,onClick:n,children:`Try again`}),children:(0,X.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`The tab needs the `,(0,X.jsx)(`span`,{className:`font-mono`,children:`gh`}),` CLI, logged in (`,(0,X.jsx)(`span`,{className:`font-mono`,children:`gh auth login`}),`), and a repo with a GitHub remote. Everything else in Squawk works without it.`]})})})}function yn({view:e,isDesktop:t,gh:n,onSaveView:r}){return(0,X.jsxs)(`div`,{"data-slot":`gh-tabs`,className:`flex min-h-11 flex-wrap items-center gap-3`,children:[(0,X.jsxs)(ut,{to:t?`/github`:`/github?filter=all`,active:e===`issues`,onClick:()=>r(`issues`),children:[`Issues · `,n.issuesTotal??n.issues.length]}),(0,X.jsxs)(ut,{to:`/github/prs`,active:e===`prs`,onClick:()=>r(`prs`),children:[`Pull requests · `,n.prsTotal??n.prs.length]})]})}function bn({view:e,gh:t,filters:n,labelOptions:r,labelColors:i,searchPayload:a}){return(0,X.jsxs)(`div`,{"data-slot":`gh-filter-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`relative min-w-0 basis-full md:flex-1 md:basis-auto`,children:[(0,X.jsx)(A,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,X.jsx)(`input`,{type:`search`,"data-slot":`gh-search`,"aria-label":`Search ${e}`,placeholder:e===`issues`?`Filter issues…`:`Filter pull requests…`,value:n.query,onChange:e=>n.setQuery(e.target.value),className:`min-h-11 w-full rounded-lg border border-card-edge bg-card shadow-card py-1 pr-2.5 pl-8 text-[13px] text-foreground outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),(0,X.jsx)(jn,{options:r,colors:i,selected:n.labelFilter,onChange:n.setLabelFilter}),e===`issues`?(0,X.jsx)(xt,{data:{...t,issues:[...t.issues,...a?.items??[]]},assignees:n.effectiveAssignees,projectId:n.activeProject,onAssigneesChange:n.changeAssignees,onProjectChange:n.setProjectFilter}):null,(0,X.jsx)(`button`,{type:`button`,disabled:!n.filtering,"data-slot":`gh-clear-filters`,className:`min-h-11 min-w-11 rounded-md border border-input bg-card px-3 text-sm font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:border-border disabled:bg-transparent disabled:text-muted-foreground`,onClick:n.clearFilters,children:`Clear filters`})]})}function xn(e,t){return e.kind===`pr`?t?.[e.number]??e.checks:e.checks}function Sn(e,t,n=!1){return(0,X.jsx)(jt,{item:e,view:t.view,filter:t.filter,narrows:t.narrows,colors:t.colors,expanded:t.expandedUrl===e.url,onToggle:()=>t.onToggle(e),queuedRunId:t.queued.get(e.url)??null,checks:xn(e,t.checksMap),comments:t.commentsOf(e),status:Ot(e,n),task:t.taskOf(e),referenceWidth:t.referenceWidth})}function Cn({view:e,rows:t,verdict:n,search:r,sidebar:i,list:a,paging:o}){let{items:s,searchHits:c}=r;return(0,X.jsxs)(`section`,{ref:o.setListEl,"data-slot":`gh-list`,className:`relative flex w-full min-w-0 flex-col rounded-lg border border-card-edge bg-card shadow-card p-3`,children:[s.length===0?n&&(0,X.jsx)(`div`,{"data-slot":`gh-empty`,className:`px-4 py-4 text-sm text-muted-foreground`,children:n}):(0,X.jsx)(wn,{items:s,rows:t,paging:o}),o.pagingAvailable?(0,X.jsx)(Tn,{view:e,list:a,paging:o}):null,(0,X.jsx)(En,{backedQuery:i.backedQuery,filterSearch:i.filterSearch}),s.length>0&&r.searchWanted&&n?(0,X.jsx)(`div`,{"data-slot":`gh-search-status`,role:`status`,className:`px-4 py-4 text-sm text-muted-foreground`,children:n}):null,c.length>0?(0,X.jsx)(Dn,{hits:c,searchPayload:r.searchPayload,rows:t}):null]})}function wn({items:e,rows:t,paging:n}){let{setRowsEl:r,scrollOwner:i,listEl:a,scrollOwnerRef:o,startMargin:s}=n,c=(0,Y.useRef)(null),l=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{if(l.current||!i)return;l.current=!0;let n=e.findIndex(e=>e.url===t.expandedUrl);n>=0&&c.current?.scrollToIndex(n,{align:`start`})},[i,e,t.expandedUrl]);let u=e.map((e,n)=>(0,X.jsx)(`div`,{role:`listitem`,"data-slot":`gh-row-item`,"data-divided":n>0||void 0,children:Sn(e,t)},e.url));return(0,X.jsx)(`div`,{ref:r,"data-slot":`gh-rows`,"data-virtualized":i?`true`:void 0,role:`list`,children:i?(0,X.jsx)(qe,{ref:c,scrollRef:o,startMargin:s,children:u},i===a?`list`:`main`):u})}function Tn({view:e,list:t,paging:n}){return(0,X.jsx)(`div`,{ref:n.loadMoreRef,"data-slot":`gh-load-more`,className:`flex min-h-6 items-center justify-center gap-1.5 px-4 pb-3 text-xs text-muted-foreground`,children:t.isFetchingNextPage?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}),`Loading more…`]}):t.isFetchNextPageError?(0,X.jsxs)(X.Fragment,{children:[`Could not load more.`,(0,X.jsx)(`button`,{type:`button`,"data-slot":`gh-load-more-retry`,onClick:()=>void t.fetchNextPage(),className:`font-medium text-accent-text hover:underline`,children:`Retry`})]}):n.manualPaging?(0,X.jsxs)(X.Fragment,{children:[`Filters cover the loaded `,e===`issues`?`issues`:`pull requests`,`.`,(0,X.jsx)(`button`,{type:`button`,"data-slot":`gh-load-more-manual`,onClick:()=>void t.fetchNextPage(),className:`font-medium text-accent-text hover:underline`,children:`Load more`})]}):null})}function En({backedQuery:e,filterSearch:t}){return e!==null&&t.data?.available&&t.data.truncated?(0,X.jsxs)(`div`,{"data-slot":`gh-filter-note`,role:`status`,className:`px-4 py-3 text-xs text-muted-foreground`,children:[`Showing the first `,t.data.items.length,` matches from GitHub search; more may exist.`]}):null}function Dn({hits:e,searchPayload:t,rows:n}){let r=(0,Y.useRef)(null),i=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{i.current||(i.current=!0,(r.current?.querySelector(`[data-slot="gh-row"][aria-expanded="true"]`))?.scrollIntoView({block:`start`}))},[]);let a=d();return(0,X.jsx)(k,{projectId:a,requests:a?e.map(e=>({projectId:a,kind:e.kind===`pr`?`PR`:`Issue`,number:e.number})):[],children:(0,X.jsxs)(`div`,{"data-slot":`gh-search-hits`,children:[(0,X.jsxs)(`p`,{className:`px-4 pt-2 pb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:[`Found on GitHub`,t?.truncated?` (first matches)`:``]}),(0,X.jsx)(`ul`,{ref:r,className:`flex flex-col gap-0.5 px-2 pb-2`,children:e.map(e=>(0,X.jsx)(`li`,{children:Sn(e,n,!0)},e.url))})]})})}function On({view:e,selected:t,selectedNumber:n,exact:r,repo:i,rows:a,listPath:o,changes:s,handToAgent:c}){let{exactWanted:l,exactItem:u}=r;return(0,X.jsxs)(`section`,{"data-slot":`gh-detail`,className:`flex w-full min-w-0 flex-col rounded-lg border border-card-edge bg-card shadow-card`,children:[t?null:(0,X.jsx)(`div`,{className:`px-4 pt-4 md:px-7 md:pt-5`,children:(0,X.jsx)(Qe,{backLink:{to:o}})}),t?(0,X.jsx)(kn,{item:t,repo:i,rows:a,listPath:o,changes:s,handToAgent:c}):l&&u.isPending?(0,X.jsx)(`div`,{"data-slot":`gh-detail-loading`,className:`flex flex-1 flex-col`,children:(0,X.jsx)(G,{icon:(0,X.jsx)(I,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:`h2`,title:`Loading #${n}…`,subtitle:`It is not among the open items, so the tab is asking GitHub for it.`})}):l&&(u.isError||u.data?.available===!1)?(0,X.jsx)(An,{number:n,exact:r}):(0,X.jsx)(Tt,{view:e,number:n})]})}function kn({item:e,repo:t,rows:n,listPath:r,changes:i,handToAgent:a}){let{workflows:o,skillList:s,workflow:c,setWorkflow:l,selectedSkills:u,setSelectedSkills:d,engine:f,setEngine:p,queued:m,onQueued:h}=a,g=O().state?.focusHandoff===!0;return(0,Y.useEffect)(()=>{g&&Ht()},[g,e.url]),(0,X.jsx)(nt,{item:e,comments:n.commentsOf(e),afterHeading:e.kind===`issue`?(0,X.jsx)(dt,{number:e.number,repo:t},e.url):void 0,backLink:{to:r},subNav:{filter:n.filter,narrows:n.narrows,changes:i},onRunAgent:Ht,headerAction:(0,X.jsx)(Vt,{item:e,queuedRunId:m.get(e.url)??null}),colors:n.colors,checks:xn(e,n.checksMap),children:(0,X.jsx)(it,{item:e,workflows:o.data?.workflows??[],skills:s,workflow:c,onWorkflowChange:l,selectedSkills:u,onSkillsChange:d,engine:f,onEngineChange:p,queuedRunId:m.get(e.url)??null,onQueued:h},e.url)})}function An({number:e,exact:t}){let{exactItem:n,retryingExact:r,retryExact:i}=t;return(0,X.jsx)(G,{icon:(0,X.jsx)(M,{size:16}),tone:n.isError?`danger`:`neutral`,heading:`h2`,title:`Could not load #${e}`,subtitle:n.data?.available===!1?n.data.reason:n.error instanceof Error?n.error.message:`The request failed.`,actions:(0,X.jsx)(L,{variant:`outline`,disabled:r,onClick:i,children:`Retry`})})}function jn({options:e,colors:t,selected:n,onChange:i}){let[a,o]=(0,Y.useState)(!1),s=e=>i(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,X.jsxs)(V,{open:a,onOpenChange:o,children:[(0,X.jsx)(z,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`gh-label-filter`,disabled:e.length===0,className:r(`inline-flex min-h-11 min-w-11 shrink-0 items-center gap-1.5 rounded-md border border-input bg-card px-3 text-sm font-medium text-foreground transition-colors hover:bg-muted disabled:opacity-60`,n.length>0&&`border-accent-strong/60 text-foreground`),children:[n.length>0?`Labels · ${n.length}`:`Labels`,(0,X.jsx)(F,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`})]})}),(0,X.jsx)(B,{align:`end`,sideOffset:6,className:`w-60 p-0`,children:(0,X.jsxs)(Te,{children:[(0,X.jsx)(xe,{placeholder:`Filter labels…`}),(0,X.jsxs)(we,{className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,X.jsx)(Ce,{children:`No labels.`}),n.length>0?(0,X.jsxs)(Se,{value:`__clear__`,onSelect:()=>i([]),className:`min-h-11 text-soft-foreground`,children:[`Clear `,n.length,` filter`,n.length>1?`s`:``]}):null,e.map(e=>{let r=n.includes(e);return(0,X.jsxs)(Se,{value:e,onSelect:()=>s(e),className:`min-h-11`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`gh-label-dot`,className:`size-2.5 shrink-0 rounded-full ring-1 ring-foreground/30`,style:rt(t[e])}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,X.jsx)(N,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e)})]})]})})]})}export{dn as GithubRoute};