@hearsay-tools/squawk 0.19.0-dev.8974 → 0.19.0-dev.8977

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 (97) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/contract/index.js +24 -8
  3. package/dist/contract/query-requests.d.ts +5 -0
  4. package/dist/contract/repo.d.ts +23 -0
  5. package/dist/delegation/transport.d.ts +65 -65
  6. package/dist/server/activity-routes.d.ts +23 -23
  7. package/dist/server/git-changes.d.ts +27 -0
  8. package/dist/server/git-changes.js +47 -0
  9. package/dist/server/git-changes.js.map +1 -1
  10. package/dist/server/repo-routes.d.ts +111 -13
  11. package/dist/server/repo-routes.js +20 -3
  12. package/dist/server/repo-routes.js.map +1 -1
  13. package/dist/server/runs-routes.d.ts +86 -28
  14. package/dist/server/runs-routes.js +12 -10
  15. package/dist/server/runs-routes.js.map +1 -1
  16. package/dist/server/server.d.ts +1686 -1374
  17. package/package.json +4 -4
  18. package/web/dist/assets/{accounts-section-CwPAaLRX.js → accounts-section-Bh6Ne88P.js} +1 -1
  19. package/web/dist/assets/activity-motion-B4hhwfpy.js +1 -0
  20. package/web/dist/assets/{activity-route-BpOdhGDr.js → activity-route-XNJHWQrd.js} +1 -1
  21. package/web/dist/assets/{agent-config-section-ByS0qQmf.js → agent-config-section-oavZQZ6z.js} +2 -2
  22. package/web/dist/assets/{agent-defaults-section-DmeS7JAr.js → agent-defaults-section-Dlbff8d1.js} +1 -1
  23. package/web/dist/assets/{appearance-CVJfUYxX.js → appearance-kpegMyn3.js} +1 -1
  24. package/web/dist/assets/{archive-on-merge-field-Ba4YFn-_.js → archive-on-merge-field-Hw5MDxKb.js} +1 -1
  25. package/web/dist/assets/attention-BHNhUrnd.js +1 -0
  26. package/web/dist/assets/automations-route-DUZ4KZ71.js +2 -0
  27. package/web/dist/assets/commit-list-CHGDpN9k.js +1 -0
  28. package/web/dist/assets/{diff-DNdhxMzq.js → diff-DsPWectf.js} +2 -2
  29. package/web/dist/assets/{diff-controls-CP2nphAy.js → diff-controls-BfNiZ7m7.js} +1 -1
  30. package/web/dist/assets/{diff-view-CmpfM3xF.js → diff-view-Ds6tF4Li.js} +1 -1
  31. package/web/dist/assets/{discard-changes-dialog-BvBZrkEB.js → discard-changes-dialog-SEDH0D2b.js} +1 -1
  32. package/web/dist/assets/{file-preview-Btoe2k0y.js → file-preview-Dd4Bn_jS.js} +1 -1
  33. package/web/dist/assets/file-text-nGpo7MVd.js +1 -0
  34. package/web/dist/assets/{folder-browser-DiQGbqCN.js → folder-browser-BgGSB2gk.js} +1 -1
  35. package/web/dist/assets/{git-toolbar-BUGct09v.js → git-toolbar-CyDX0ZlL.js} +1 -1
  36. package/web/dist/assets/github-CSHuD5n6.js +1 -0
  37. package/web/dist/assets/{global-activity-route-CO5gHnfm.js → global-activity-route-BeiBJ_S6.js} +1 -1
  38. package/web/dist/assets/{index-TFU1q5Sa.js → index-D7e7hQRs.js} +6 -6
  39. package/web/dist/assets/{label-B1zf-eXb.js → label-CxJpzeLL.js} +1 -1
  40. package/web/dist/assets/{markdown-BOOMYZ7a.js → markdown-xkaHkz73.js} +1 -1
  41. package/web/dist/assets/{open-in-menu-DfTnT8YF.js → open-in-menu-CmsJeSrD.js} +1 -1
  42. package/web/dist/assets/{option-select-3qhDlvG6.js → option-select-yBRQj6E_.js} +1 -1
  43. package/web/dist/assets/{preferences-section-D3h6N_fh.js → preferences-section-37pdeCWJ.js} +1 -1
  44. package/web/dist/assets/{preview-pane-connected-ClZ67Ztq.js → preview-pane-connected-By08oMDu.js} +2 -2
  45. package/web/dist/assets/{project-location-xnTFoKUD.js → project-location-FjgEfTb0.js} +1 -1
  46. package/web/dist/assets/{project-router-onKnSy5a.js → project-router-BNcdL2CI.js} +1 -1
  47. package/web/dist/assets/{projects-section-BmyA80eB.js → projects-section-C2APAdf3.js} +1 -1
  48. package/web/dist/assets/{prompt-templates-section-Dt2aX-LZ.js → prompt-templates-section-HpQeEo4v.js} +2 -2
  49. package/web/dist/assets/queries-BSxNcgZm.js +1 -0
  50. package/web/dist/assets/{reference-chip-Cv3i1kxz.js → reference-chip-DFwi97Ps.js} +1 -1
  51. package/web/dist/assets/{remote-settings-notice-CJORtXkl.js → remote-settings-notice-CaFJB726.js} +1 -1
  52. package/web/dist/assets/repo-git-CpW0usPY.js +1 -0
  53. package/web/dist/assets/{report-reader-BCPKro-Z.js → report-reader-CmEcwfsT.js} +1 -1
  54. package/web/dist/assets/{report-selection-CmEfaDz7.js → report-selection-CaEdb2HO.js} +1 -1
  55. package/web/dist/assets/{reports-Djl8nY0A.js → reports-G5DwAoma.js} +1 -1
  56. package/web/dist/assets/{resources-section-DCETRc-9.js → resources-section-BIjd5azP.js} +1 -1
  57. package/web/dist/assets/{review-panel-CzhsQN4V.js → review-panel-CgKnI_Kf.js} +4 -4
  58. package/web/dist/assets/{run-detail-refresh-Caj4BPPd.js → run-detail-refresh-GbAx5_Mn.js} +1 -1
  59. package/web/dist/assets/{run-header-BIyS_qou.js → run-header-DRYGraQL.js} +2 -2
  60. package/web/dist/assets/{select-BoL_3H6E.js → select-akdt2vf9.js} +1 -1
  61. package/web/dist/assets/{session-context-section-ChNqEmpe.js → session-context-section-Ckddzf6W.js} +1 -1
  62. package/web/dist/assets/{settings-agent-picker-CesXF2fy.js → settings-agent-picker-Bt31ulJ9.js} +1 -1
  63. package/web/dist/assets/{settings-save-bar-BhGzX1Vj.js → settings-save-bar-BCxZrjjt.js} +1 -1
  64. package/web/dist/assets/{settings-shell-D4cNW7VG.js → settings-shell-C84UojR3.js} +1 -1
  65. package/web/dist/assets/{sidebar-section-DgOjPxdA.js → sidebar-section-Dr9ev5Vo.js} +1 -1
  66. package/web/dist/assets/{skills-D4-zEnec.js → skills-Dh6dbL6k.js} +1 -1
  67. package/web/dist/assets/{tab-link-B2k-zaeP.js → tab-link-BrzzZnhE.js} +1 -1
  68. package/web/dist/assets/task-changes-pVv5Oafz.js +1 -0
  69. package/web/dist/assets/task-commits-Bex46n4l.js +1 -0
  70. package/web/dist/assets/{task-file-scope-DEybXfMX.js → task-file-scope-DI5YpFAh.js} +1 -1
  71. package/web/dist/assets/{task-files-CVGsEv7Y.js → task-files-C1nhWf4J.js} +1 -1
  72. package/web/dist/assets/{task-github-item-BvwsdG3G.js → task-github-item-CBOKx42k.js} +1 -1
  73. package/web/dist/assets/{task-groups-dEzH1nMg.js → task-groups-CsjJ9R5Y.js} +1 -1
  74. package/web/dist/assets/task-thread-DP78hgdh.js +2 -0
  75. package/web/dist/assets/{tasks-table-CPAY1N-E.js → tasks-table--jkwCj2N.js} +1 -1
  76. package/web/dist/assets/{thread-state-BdpOuHqc.js → thread-state-CHQ0rJr9.js} +1 -1
  77. package/web/dist/assets/{toaster-Bs1mVYf9.js → toaster-BJG79kO8.js} +1 -1
  78. package/web/dist/assets/use-hand-to-agent-state-C5m1ufIR.js +1 -0
  79. package/web/dist/assets/use-path-bases-D5kpDgkA.js +1 -0
  80. package/web/dist/assets/use-workspace-config-save-DF7JuKqF.js +1 -0
  81. package/web/dist/assets/{workflows-DZyeZQyI.js → workflows-C3Q0b6rr.js} +2 -2
  82. package/web/dist/assets/{workspace-tools-CyT1P2Pd.js → workspace-tools-Bhqgjmre.js} +1 -1
  83. package/web/dist/assets/{worktrees-section-DoBhAjkj.js → worktrees-section-BDEXzzG0.js} +5 -5
  84. package/web/dist/index.html +13 -13
  85. package/web/dist/assets/activity-motion-CAoXpVXT.js +0 -1
  86. package/web/dist/assets/attention-C9zoC-gL.js +0 -1
  87. package/web/dist/assets/automations-route-CiXw_h6J.js +0 -2
  88. package/web/dist/assets/commit-list-dNvEgOHg.js +0 -1
  89. package/web/dist/assets/github-sNMaEXUl.js +0 -1
  90. package/web/dist/assets/queries-CII6fTHH.js +0 -1
  91. package/web/dist/assets/repo-git-BVxsEJ1H.js +0 -1
  92. package/web/dist/assets/task-changes-NKykdnYs.js +0 -1
  93. package/web/dist/assets/task-commits-B-VWmssz.js +0 -1
  94. package/web/dist/assets/task-thread-T66nypz9.js +0 -2
  95. package/web/dist/assets/use-hand-to-agent-state-BK-LieHJ.js +0 -1
  96. package/web/dist/assets/use-path-bases-Qp3_G7-A.js +0 -1
  97. package/web/dist/assets/use-workspace-config-save-0Mtdwfrd.js +0 -1
@@ -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{A as i,_ as a,nn as o,rn as s,sn as c,tn as l}from"./queries-CII6fTHH.js";import{B as u,Fn as d,H as f,Ur as p,V as m,_ as h,ar as g,c as ee,d as _,g as v,ir as y,ni as b,nr as x,o as te,s as ne,sr as re,ti as ie,v as ae,z as oe}from"./toaster-Bs1mVYf9.js";import{B as S,G as se,H as ce,I as C,K as le,N as w,P as T,V as ue,W as E,j as D,z as O}from"./live-protocol-DMhTnCmf.js";import{h as de,n as fe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as pe,t as k}from"./label-B1zf-eXb.js";import{L as me,X as he,Z as ge,b as _e,ft as ve,ht as ye,nt as be,ot as xe,u as Se}from"./design-icons-QbNMZniQ.js";import{t as Ce}from"./check-OP-CVgZG.js";import{t as A}from"./button-C8jUIs8Q.js";import{n as we,r as Te,t as Ee}from"./collapsible-Bx2vViFx.js";import{a as j,i as M,n as N,r as P,t as F}from"./select-BoL_3H6E.js";import{t as De}from"./switch-CAKeV99j.js";import{c as Oe,s as ke,t as I}from"./project-router-onKnSy5a.js";import{c as L,d as R,f as Ae,l as je,n as Me,o as Ne}from"./page-shell-Dky5crRl.js";import{r as Pe}from"./agents-settings-path-7X6_cvUg.js";import{t as Fe}from"./centered-state-BgSV4e79.js";import{Cn as Ie,D as Le,Dn as Re,Hn as ze,K as Be,O as Ve,P as He,Un as Ue,Y as We,gr as Ge,k as Ke,q as qe,r as Je,rr as z,t as Ye,yn as Xe}from"./index-TFU1q5Sa.js";import{t as Ze}from"./textarea-vEsJAUAV.js";import{_ as Qe,a as $e,c as et,d as tt,f as nt,g as rt,h as it,i as at,l as ot,m as st,n as ct,o as lt,p as ut,r as dt,s as ft,t as B,u as pt,v as mt}from"./automation-format-DB34jUyF.js";var V=e(t(),1),H=D([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),ht=S({includeExisting:T().optional(),authors:w(E()).optional(),assignees:w(E()).optional(),requireCurrentLabels:T().optional(),allLabels:w(E()).optional(),anyLabels:w(E()).optional(),excludeLabels:w(E()).optional(),changedLabels:w(E()).optional(),lookbackDays:O(),maxRecords:O()}),gt=D([`github`,`schedule`]),_t=x.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:E(),variants:se([C(1),C(2),C(3)]).optional(),systemPrompt:E().optional()}),vt=S({at:E(),outcome:D([`launched`,`cancelled`]),runId:E().optional(),receiptId:E().optional(),trigger:D([`schedule`,`late`,`manual`,`retry`]).optional()}),U=S({id:E(),revision:O(),name:E(),description:E().optional(),enabled:T(),kind:gt,events:w(H).optional(),intervalSeconds:O().optional(),filters:ht.optional(),schedule:et.optional(),task:_t,archived:vt.optional(),createdAt:E(),updatedAt:E()}),W=S({timestamp:E(),tieBreaker:E().optional()}),yt=S({since:E().datetime(),until:E().datetime(),source:O().int().min(0).max(2),page:O().int().min(1).max(10),item:O().int().min(0).max(100),event:O().int().min(0).max(1e3),cursor:W.optional()}),bt={lastError:E().max(1e3).optional(),lastErrorAt:E().datetime().optional()},xt=S({revision:O().optional(),baselineAt:E().optional(),armedAt:E().optional(),historyScan:yt.optional(),cursor:W.optional(),frozenHighWatermark:W.extend({tieBreaker:E()}).optional(),backlogAfter:W.extend({tieBreaker:E()}).optional(),nextCheckAt:E().optional(),lastSuccessAt:E().optional(),nextRunAt:E().optional(),lastRunAt:E().optional(),etags:ce(E(),E()).optional(),backoffUntil:E().optional(),consecutiveFailures:O().optional(),...bt,onceOutcome:D([`failed`,`missed`]).optional()});function St(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 Ct=D([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),wt=S({seq:O(),ts:E(),automationId:E(),revision:O(),event:H.optional(),result:Ct,reason:E().optional(),durationMs:O().optional(),receiptId:E().optional(),runId:E().optional(),githubNumber:O().optional(),githubTitle:E().optional(),githubUrl:E().optional(),rateLimit:S({bucket:D([`core`,`search`]),remaining:O().optional(),resetAt:E().optional()}).optional()}),Tt=S({matches:O(),launched:O(),duplicates:O(),errors:O()}),Et=U.extend({state:xt.optional(),latestLog:wt.optional(),counts:Tt,nextRunAt:E().optional(),onceStatus:ut.optional()});S({available:T(),reason:E().optional(),timeZone:E(),scheduler:S({state:D([`scheduled`,`idle`]),nextDue:E().optional()}),automations:w(Et)}),S({automation:U}).extend({once:S({dueAt:E(),timeZone:E(),resolvedInstant:E(),note:E()}).optional()}),S({automation:U,state:xt.optional(),latestLog:wt.optional(),onceStatus:ut.optional()}),S({id:E(),automationId:E(),mode:D([`preview`,`execute`]),status:D([`queued`,`running`,`complete`,`error`]),createdAt:E(),completedAt:E().optional(),matches:O().optional(),truncated:T().optional(),error:E().optional()}),S({checkId:E()}),S({records:w(wt)}),S({receiptId:E(),runId:E()}),S({runId:E()}),U.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:gt.optional(),task:_t.omit({variants:!0}).strict(),enable:T().optional()}).omit({enable:!0}).extend({enabled:T().optional(),expectedRevision:O()}),S({archived:D([`include`,`only`]).optional()}),S({mode:D([`preview`,`execute`])});var G=n();function K({text:e}){return(0,G.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var Dt={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`},Ot={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 kt(e){let[t,n]=(0,V.useState)(),[r,i]=(0,V.useState)(``),a=(0,V.useCallback)(t=>h(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,V.useEffect)(()=>{a()},[a]),(0,V.useEffect)(()=>p(a),[a]),(0,V.useEffect)(()=>pe((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function At(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 jt({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&At(e,t),[o,s]=(0,V.useState)(),[c,l]=(0,V.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await oe(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,G.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,G.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(Je,{dot:Dt[e.result],children:Ot[e.result]}),(0,G.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:ct(e.ts,n,u)})]}),e.reason?(0,G.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,G.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,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,G.jsx)(A,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var q=`all`;function Mt({label:e,value:t,onChange:n,options:r}){return(0,G.jsxs)(F,{value:t,onValueChange:n,children:[(0,G.jsx)(M,{"aria-label":e,className:`w-full sm:w-52`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:r.map(e=>(0,G.jsx)(P,{value:e.value,children:e.label},e.value))})]})}function Nt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=kt(e),[s,c]=(0,V.useState)(q),[l,u]=(0,V.useState)(q),d=(0,V.useMemo)(()=>(i??[]).filter(e=>(s===q||e.result===s)&&(l===q||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,G.jsx)(je,{route:`automations`,density:i?Ae(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,G.jsx)(L,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:a}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,G.jsx)(K,{text:`Nothing has run yet.`}):(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Mt,{label:`Result`,value:s,onChange:c,options:[{value:q,label:`All results`},...Ct.options.map(e=>({value:e,label:Ot[e]}))]}),f?(0,G.jsx)(Mt,{label:`Event`,value:l,onChange:u,options:[{value:q,label:`All events`},...H.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,G.jsx)(K,{text:`No rows match these filters.`}):(0,G.jsx)(jt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,G.jsx)(K,{text:`Loading execution log…`})})}function Pt({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=kt(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,G.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,G.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,G.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,G.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,G.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(K,{text:o}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,G.jsx)(jt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function Ft({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?dt(i):null,[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(``),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(null);(0,V.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 _(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,G.jsx)(je,{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,G.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,G.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,G.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${B(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,G.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,G.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,G.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`grid gap-1`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,G.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,G.jsxs)(`div`,{className:`grid gap-1`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,G.jsxs)(`section`,{className:`min-w-0`,children:[(0,G.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,G.jsx)(A,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,G.jsx)(I,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,G.jsx)(A,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,G.jsx)(A,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})]}),u?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var It=D([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),J=w(E().trim().min(1).max(200)).max(100).optional(),Lt=S({includeExisting:T().optional(),requireCurrentLabels:T().optional(),authors:J,assignees:J,allLabels:J,anyLabels:J,excludeLabels:J,changedLabels:J,lookbackDays:O().int().min(1).max(90).default(7),maxRecords:O().int().min(1).max(100).default(25)}).passthrough(),Rt=S({prompt:E().min(1).max(1e5),workflow:E().trim().min(1).max(200).optional(),steps:w(y).min(1).max(100).optional(),runner:ie.optional(),model:E().trim().min(1).max(200).optional(),effort:E().trim().min(1).max(32).optional(),variants:se([C(1),C(2),C(3)]).optional(),worktree:T().optional(),autonomous:T().optional(),...g,...re,systemPrompt:E().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),zt=new Set(Object.keys(Rt.shape).filter(e=>e!==`variants`));function Bt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>zt.has(e)))}ue(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:E().min(1).max(100),revision:O().int().positive(),name:E().trim().min(1).max(200),description:E().max(2e3).optional(),enabled:T().default(!1),kind:gt.default(`github`),events:w(It).min(1).max(4).optional(),intervalSeconds:O().int().min(60).max(86400).optional(),filters:Lt.optional(),schedule:et.passthrough().optional(),task:Rt,archived:S({at:E().datetime(),outcome:D([`launched`,`cancelled`]),runId:E().optional(),receiptId:E().optional(),trigger:D([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:E().datetime(),updatedAt:E().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:b.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:b.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:b.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:b.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:b.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),S({version:C(1).default(1),automations:w(le()).default([]),tombstones:ce(E(),E().datetime()).optional()}).passthrough();var Y=S({timestamp:E().datetime(),tieBreaker:E().optional()}).passthrough(),Vt=yt.extend({cursor:Y.optional()}),Ht=S({revision:O().int().positive().optional(),baselineAt:E().datetime().optional(),armedAt:E().datetime().optional(),historyScan:Vt.optional(),cursor:Y.optional(),frozenHighWatermark:Y.extend({tieBreaker:E()}).optional(),backlogAfter:Y.extend({tieBreaker:E()}).optional(),nextCheckAt:E().datetime().optional(),lastSuccessAt:E().datetime().optional(),nextRunAt:E().datetime().optional(),lastRunAt:E().datetime().optional(),etags:ce(E(),E()).optional(),backoffUntil:E().datetime().optional(),consecutiveFailures:O().int().nonnegative().optional(),...bt,onceOutcome:D([`failed`,`missed`]).optional()}).passthrough();S({version:C(1).default(1),states:ce(E(),Ht).default({})}).passthrough(),S({receiptId:E().min(1),receiptKey:E().min(1),eventId:E().min(1),automationId:E().min(1),revision:O().int().positive(),status:D([`reserved`,`launched`,`launch-error`,`released`]),runId:E().optional(),observedAt:E().datetime(),updatedAt:E().datetime(),error:E().max(2e3).optional(),occurrenceAt:E().datetime().optional(),candidate:S({eventId:E(),event:It,timestamp:E().datetime(),tieBreaker:E(),repo:E(),nodeId:E(),number:O().int().positive(),title:E().max(500),url:E().url(),author:E().max(200),assignees:w(E().max(200)).max(100),labels:w(E().max(200)).max(100),changedLabel:E().max(200).optional()}).passthrough().optional()}).passthrough();var Ut=D([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);S({seq:O().int().positive(),ts:E().datetime(),automationId:E().min(1),revision:O().int().positive(),event:It.optional(),result:Ut,reason:E().max(2e3).optional(),durationMs:O().int().nonnegative().optional(),receiptId:E().optional(),runId:E().optional(),githubNumber:O().int().positive().optional(),githubTitle:E().max(500).optional(),githubUrl:E().url().optional(),rateLimit:S({bucket:D([`core`,`search`]),remaining:O().int().nonnegative().optional(),resetAt:E().datetime().optional()}).passthrough().optional()}).passthrough();var Wt=`quick-task`;function Gt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Bt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:pt(e.schedule??{type:`daily`}),events:e.events??[H.options[0]],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Wt}:{}:{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 Kt(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 qt(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 Jt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Kt(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:qt(e)}}function Yt(e){return{...Jt(e),enable:e.enabled}}function Xt(e,t){return{...Jt(e),task:{...qt(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function X(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Zt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Qt=new Set([`anyLabels`,`authors`,`changedLabels`]);function $t(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=>!Zt.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||Qt.has(e)&&Array.isArray(t)&&t.length>0)}function en(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function tn(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function Z(e,t){return t.startsWith(`-`)?`--${e}=${X(t)}`:`--${e} ${X(t)}`}function nn(e){let t=[`${Xe()} automation add`,Z(`name`,e.name)];if(e.schedule?.type===`once`)t.push(Z(`at`,e.schedule.at),Z(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(Z(`latest-start`,tn(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Z(`cron`,ot(e.schedule)));else{t.push(Z(`on`,e.events.join(`,`)),`--every ${en(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(Z(`label`,n));for(let n of e.filters?.authors??[])t.push(Z(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(Z(`changed-label`,n))}return t.push(...rn(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Z(`prompt`,e.task.prompt)),t.join(` `)}function rn(e){let t=[];return e.workflow&&t.push(Z(`workflow`,e.workflow)),e.runner&&t.push(Z(`runner`,e.runner)),e.model&&t.push(Z(`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 an(e,t){let n=Yt(e),r=$t(n)?nn(n):`${Xe()} automation create --json ${X(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${X(t.origin)} CEZ_PROJECT_ID=${X(t.projectId)} HSQ_COCKPIT_URL=${X(t.origin)} HSQ_PROJECT_ID=${X(t.projectId)} ${r}`:r}function on(e){let t=[],n=!1;for(let r of sn(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 sn(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 cn({draft:e,saveLabel:t,editing:n}){let i=ke(),a=window.location.origin,o=(0,V.useMemo)(()=>{let t=an(e);return i?`HSQ_COCKPIT_URL=${X(a)} HSQ_PROJECT_ID=${X(i)} ${t}`:t},[e,a,i]),s=(0,V.useMemo)(()=>on(o),[o]),[c,l]=(0,V.useState)(`idle`),[u,d]=(0,V.useState)(!1),f=(0,V.useId)(),p=(0,V.useRef)(void 0);(0,V.useEffect)(()=>()=>clearTimeout(p.current),[]),(0,V.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,G.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,G.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,G.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,G.jsxs)(A,{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,G.jsx)(`span`,{className:`truncate`,children:u?`Hide`:`Show`}),(0,G.jsx)(Se,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,u&&`rotate-180`)})]}),(0,G.jsxs)(A,{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,G.jsx)(Ce,{"aria-hidden":`true`,className:`size-3.5`}):(0,G.jsx)(Ge,{"aria-hidden":`true`,className:`size-3.5`}),c===`copied`?`Copied`:`Copy`]})]}),(0,G.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,G.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,G.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,G.jsxs)(G.Fragment,{children:[`The definition ${t} would ${n?`save`:`create`}.`,` `,(0,G.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${Xe()} automation schema`}),` prints its shape.`]})})]})}function ln({pressed:e,onClick:t,disabled:n,children:i}){return(0,G.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 un={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},dn={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function fn(e){let t=e.map(e=>un[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 pn=H.options,mn=[{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`}],hn=[{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.`}],gn=e=>(e??[]).join(`, `),_n=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function vn(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 yn(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`}. ${vn(e.filters.includeExisting)}`}function bn({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=_n(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=mn.some(t=>t.seconds===e.intervalSeconds)?mn:[...mn,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,G.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,G.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:pn.map(t=>(0,G.jsx)(ln,{pressed:e.events.includes(t),onClick:()=>r(t),children:dn[t]},t))}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-interval`,children:`Check every`}),(0,G.jsxs)(F,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,G.jsx)(M,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:o.map(e=>(0,G.jsx)(P,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,G.jsx)(De,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,G.jsx)(`span`,{children:`Include existing items`})]}),(0,G.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:vn(e.filters.includeExisting)})]}),(0,G.jsxs)(Ee,{children:[(0,G.jsxs)(Te,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,G.jsx)(Se,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,G.jsx)(we,{children:(0,G.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[hn.map(t=>(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,G.jsx)(z,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:gn(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,G.jsx)(z,{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,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,G.jsx)(z,{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 xn=e=>String(e).padStart(2,`0`);function Q({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,V.useState)(xn(t)),o=(0,V.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${xn(n)}.`,l=(0,V.useId)();return(0,V.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(z,{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(xn(t))}),s?(0,G.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var Sn=[{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`}],Cn=`none`,wn=e=>String(e).padStart(2,`0`);function Tn(e,t=Date.now()){let n=mt(t,e)??mt(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${wn(r.getUTCMonth()+1)}-${wn(r.getUTCDate())}T09:00`}function En(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function Dn({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?st(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${wn(t)}:${wn(n)}`}),l=(0,V.useRef)(null),u=(0,V.useId)(),d=nt(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,V.useEffect)(()=>{l.current?.setCustomValidity(f?$e:``)},[f]);let p=dt(e);return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-date`,children:`Date`}),(0,G.jsx)(z,{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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,G.jsx)(Q,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,G.jsx)(Q,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,G.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:$e}):null,(0,G.jsx)(kn,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,G.jsx)(An,{value:e.latestStartMinutes,onChange:t=>n(On(e,t))}),p?(0,G.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 On(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function kn({value:e,onCommit:t}){let[n,r]=(0,V.useState)(e),i=(0,V.useRef)(null),a=(0,V.useId)(),o=(0,V.useId)(),[s]=(0,V.useState)(En),c=n!==e||!Qe(n),l=rt(n);return(0,V.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,G.jsx)(z,{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),Qe(e.target.value)&&t(e.target.value)}}),(0,G.jsx)(`datalist`,{id:a,children:s.map(e=>(0,G.jsx)(`option`,{value:e},e))}),c?(0,G.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function An({value:e,onChange:t}){let n=Sn.some(t=>t.minutes===e)||e===void 0?Sn:[...Sn,{minutes:e,label:`${e} minutes`}];return(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,G.jsxs)(F,{value:e===void 0?Cn:String(e),onValueChange:e=>t(e===Cn?void 0:Number(e)),children:[(0,G.jsx)(M,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:n.map(e=>(0,G.jsx)(P,{value:e.minutes===void 0?Cn:String(e.minutes),children:e.label},e.label))})]}),(0,G.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 jn=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function Mn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??Tn(r),timeZone:e.timeZone??r}:{type:t});return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.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:jn.map(t=>(0,G.jsx)(ln,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,G.jsx)(Dn,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,G.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:ft.map((t,n)=>(0,G.jsx)(ln,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-every`,children:`Run every`}),(0,G.jsxs)(F,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,G.jsx)(M,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:lt.map(e=>(0,G.jsx)(P,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,G.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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,G.jsx)(Q,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,G.jsx)(Q,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,G.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,G.jsx)(`code`,{className:`font-mono text-foreground`,children:ot(e)})]})]})}var Nn=40*864e5,Pn=5;function Fn({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,G.jsx)(In,{schedule:e,now:n});let r=tt(e,n+1,n+Nn,t,Pn);return(0,G.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,G.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,G.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,G.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:B(new Date(e).toISOString(),t)}),(0,G.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:at(n,e)})]},e))}),(0,G.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function In({schedule:e,now:t}){let n=nt(e),r=dt(e);return(0,G.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,G.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,G.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,G.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:at(t,n)}):null]}),r?.note?(0,G.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,G.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 Ln={schedule:`On a schedule`,github:`When GitHub changes`};function Rn(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 zn({title:e,icon:t,hideLegend:n=!1,failure:r,section:i,children:a}){let o=(0,V.useId)();return(0,G.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,G.jsxs)(`h2`,{id:o,className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[t,e]}):(0,G.jsx)(`h2`,{id:o,className:`text-sm font-semibold text-foreground`,children:e}),a,r?.section===i&&!r.conflict?(0,G.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,G.jsx)(G.Fragment,{children:r?(0,G.jsxs)(`p`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Ln[e.kind]]}):(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(Ye,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Ln.schedule},{value:`github`,label:Ln.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,G.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,G.jsx)(Mn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,G.jsx)(bn,{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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(k,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,G.jsx)(Ze,{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,G.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,G.jsxs)(G.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,G.jsxs)(G.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),r.length?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:`Unavailable for this trigger: ${r.map(e=>`{{${e}}}`).join(`, `)}`}):null,(0,G.jsx)(Xn,{draft:e,patch:t})]})}function Un({label:e,help:t,checked:n,onChange:r}){let i=(0,V.useId)();return(0,G.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,G.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,G.jsx)(`span`,{id:`${i}-label`,children:e}),(0,G.jsx)(`span`,{id:`${i}-help`,className:`completion-control-help`,children:t})]}),(0,G.jsx)(De,{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.`:vn(e.filters.includeExisting);return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`div`,{"data-embedded":``,className:`grid min-w-0`,children:[(0,G.jsx)(Un,{label:`Autonomous`,help:`Runs without waiting for answers.`,checked:e.autonomous,onChange:e=>t({autonomous:e})}),(0,G.jsx)(Ke,{embedded:!0,archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,G.jsx)(Ve,{embedded:!0,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),(0,G.jsx)(Un,{label:a,help:o,checked:e.enabled,onChange:e=>t({enabled:e})})]}),r?(0,G.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,V.useState)(()=>Gt(e)),[s,c]=(0,V.useState)(e?.revision),[l,u]=(0,V.useState)(),[p,h]=(0,V.useState)(!1),g=e=>o(t=>({...t,...e})),_=async t=>{if(t.preventDefault(),p)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}h(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await f(e.id,Xt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await m(e.id,a.enabled))}else await ee(Yt(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof d&&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`:Rn(n),message:n})}finally{h(!1)}},v=(0,V.useId)(),y=(0,V.useId)(),b=a.kind===`schedule`;return(0,G.jsx)(Ne,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Yn({automation:e,draft:a,formId:v,saveHintId:y,saving:p}),children:(0,G.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,G.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,G.jsx)(zn,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(k,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,G.jsx)(z,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>g({name:e.target.value}),required:!0})]})}),(0,G.jsxs)(zn,{title:`When`,section:`when`,failure:l,children:[(0,G.jsx)(Bn,{draft:a,patch:g,forge:t,automation:e}),(0,G.jsx)(Vn,{draft:a,patch:g,forge:t,timeZone:n,automation:e})]}),(0,G.jsx)(zn,{title:`What to run`,section:`run`,failure:l,children:(0,G.jsx)(Hn,{draft:a,patch:g})})]}),(0,G.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,G.jsx)(zn,{title:`Execution settings`,icon:(0,G.jsx)(be,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),section:`execution`,failure:l,children:(0,G.jsx)(Wn,{draft:a,patch:g,saving:p,automation:e})}),b?(0,G.jsx)(Fn,{schedule:a.schedule,timeZone:n}):(0,G.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,G.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,G.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:yn(a)})]}),(0,G.jsx)(cn,{draft:a,saveLabel:qn(e,a),editing:e!==void 0})]}),l?.section===`form`||e?(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-3.5 md:col-start-1`,children:[l?.section===`form`?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,G.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,G.jsx)(A,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,G.jsx)(Kn,{automation:e,onDeleted:r}):null]}):null]})})}function Kn({automation:e,onDeleted:t}){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(``),c=async()=>{if(!i){a(!0),s(``);try{await _(e.id),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}};return(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:i,onClick:()=>void c(),children:`Delete automation`}),(0,G.jsx)(A,{type:`button`,variant:`outline`,disabled:i,onClick:()=>{r(!1),s(``)},children:`Keep`})]})]}):(0,G.jsx)(A,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>r(!0),children:`Delete`}),o?(0,G.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,G.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`min-h-[1lh] text-xs text-muted-foreground`,children:o}),secondaryActions:(0,G.jsx)(L,{type:`button`,variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,G.jsx)(L,{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=i(),r=Ie(),{runners:u,signedOut:d}=r.runnersOn(e=>r.repoAccount?.[e]),f=a(),p=s(),{runner:m,ready:h}=o(e.runner??f.data?.defaultRunner??`claude`),g=c(m,h,r.repoAccount?.[m]),ee=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],_=[...new Set([...u,...e.runner?[e.runner]:[]])],v=He(m,p.data,g.data,[e.model]),y=v.find(t=>t.id===(e.model??``))?.label??e.model??`Runner default`,b=e=>(0,G.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,G.jsx)(qe,{children:(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Be,{slot:`automation-workflow-pill`,icon:b(ve),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:ee.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,G.jsx)(Be,{slot:`automation-runner-pill`,icon:b(xe),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?l(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},..._.map(e=>({value:e,label:l(p.data,e)}))],footer:(0,G.jsx)(We,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,G.jsx)(Be,{slot:`automation-model-pill`,icon:b(_e),fieldLabel:!0,ariaLabel:`Model`,label:y,value:e.model??``,options:v.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,V.useState)({}),[c,l]=(0,V.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}))}},p=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 m(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await te(e.id),await n()}),ee=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await ne(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await v(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),_=e?.automations??[],y=_.filter(e=>!e.archived),b=_.filter(e=>!!e.archived),x=i?b:y;return(0,G.jsx)(R,{route:`automations`,density:e?Ae(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,G.jsx)(L,{variant:`primary`,asChild:!0,children:(0,G.jsxs)(I,{to:`/automations/new`,children:[(0,G.jsx)(he,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,G.jsx)(Me,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,G.jsx)(A,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,G.jsx)(I,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:t}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,G.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,G.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,G.jsx)($n,{count:y.length})]}),(0,G.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,G.jsx)($n,{count:b.length})]})]}):(0,G.jsx)(`span`,{}),(0,G.jsx)(`div`,{className:`pb-2.5`,children:(0,G.jsx)(er,{data:e})})]}),i&&x.length===0?(0,G.jsx)(K,{text:`No archived automations.`}):x.length===0?(0,G.jsx)(Fe,{icon:(0,G.jsx)(ye,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,G.jsx)(A,{variant:`primary`,asChild:!0,children:(0,G.jsxs)(I,{to:`/automations/new`,children:[(0,G.jsx)(he,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,G.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,G.jsx)(lr,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void p(t),onToggle:()=>void h(t),onPreview:()=>void ee(t),onCancel:()=>void g(t)},t.id))})]}):(0,G.jsx)(K,{text:`Loading automations…`})})}function $n({count:e}){return e===0?null:(0,G.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function er({data:e}){return(0,G.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?it(e.schedule):`${fn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function nr({automation:e,nextRun:t}){let n=e.kind===`schedule`?ge:me,r=Re(e);return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,G.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,G.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,G.jsx)(`span`,{children:tr(e)}),t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,G.jsx)(Je,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function rr({automation:e,archive:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,G.jsx)(A,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{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,G.jsx)(`span`,{children:`continuous`}):r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${B(r,t)}`}),(0,G.jsx)(`span`,{children:`· ${at(Date.now(),Date.parse(r))}`})]}):(0,G.jsx)(`span`,{children:`Next run: —`})}function ar({automation:e,timeZone:t}){let n=e.enabled?St(e.state):void 0;return n?(0,G.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,G.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${B(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,G.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function sr({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,G.jsx)(A,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function cr({note:e}){return(0,G.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,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(fe,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:Pe(`gh`),children:`Set up`}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{className:`min-h-11 cursor-pointer`,children:`Command details`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.details})]})]}):null,e.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{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,V.useState)(!1),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null);(0,V.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,G.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,G.jsx)(nr,{automation:e,nextRun:h?void 0:(0,G.jsx)(ir,{automation:e,timeZone:t})}),h?(0,G.jsx)(rr,{automation:e,archive:h}):null,h?null:(0,G.jsx)(ar,{automation:e,timeZone:t}),h?null:(0,G.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,G.jsx)(sr,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,G.jsx)(cr,{note:n}):null,(0,G.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t})]})}function ur(e){let t=ke(),n=Ue(),[r,i]=(0,V.useState)(),[a,o]=(0,V.useState)(``),s=(0,V.useCallback)(t=>ae({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,V.useEffect)(()=>{n&&s()},[n,s]),(0,V.useEffect)(()=>p(async e=>{n&&await s(e)}),[n,s]),(0,V.useEffect)(()=>pe((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}=de(),n=Oe(),[r,i]=(0,V.useState)(!1),{data:a,error:o,refresh:s}=ur(`include`),[c,l]=(0,V.useState)(0),u=ze();if(u===`unknown`)return(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(K,{text:`Loading automations…`})});if(u===`absent`)return(0,G.jsx)(Le,{});if(u===`disabled`)return(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(Fe,{icon:(0,G.jsx)(ye,{}),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,G.jsx)(Qn,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,G.jsx)(R,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:o}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(K,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,G.jsx)(Gn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,G.jsx)(Ft,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,G.jsx)(Gn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,G.jsx)(R,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,G.jsx)(A,{asChild:!0,variant:`outline`,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})}):t?(0,G.jsx)(Nt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,G.jsx)(K,{text:`Automation not found.`})}export{dr as AutomationsRoute};
@@ -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}from"./dist-C_rn70hE.js";import{Fn as i}from"./toaster-Bs1mVYf9.js";import{M as a,Q as o,ct as s,r as c}from"./design-icons-QbNMZniQ.js";import{n as l}from"./diff-controls-CP2nphAy.js";import{l as u}from"./reference-chip-Cv3i1kxz.js";import{t as d}from"./button-C8jUIs8Q.js";import{t as f}from"./project-router-onKnSy5a.js";import{m as p}from"./page-shell-Dky5crRl.js";import{t as m}from"./centered-state-BgSV4e79.js";import{Fn as h,Rn as g,Ut as _,Wt as v,rr as y,s as b}from"./index-TFU1q5Sa.js";import{t as x}from"./diff-DNdhxMzq.js";var S=e(t(),1),C=n();function w({commit:e,sha:t,slot:n,heading:o=`h2`,diffRef:c,className:d}){let f=p(),[v,y]=(0,S.useState)(`unified`),[b,w]=(0,S.useState)(!0),E=(0,S.useRef)(null);T(E,t);let D=e.isError&&e.error instanceof i&&e.error.status===409;return(0,C.jsx)(`section`,{ref:E,"data-slot":n,"data-sha":t,"aria-label":`Selected commit`,className:r(`min-w-0 flex-1 scroll-mt-4 overflow-clip rounded-xl border border-border bg-card`,d),children:e.isPending?(0,C.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-8 text-center text-xs text-muted-foreground`,children:`Loading commit diff…`}):e.isError?(0,C.jsx)(m,{icon:D?(0,C.jsx)(u,{}):(0,C.jsx)(s,{size:16}),tone:D?`neutral`:`danger`,heading:`h2`,title:D?`Commit not found`:`Could not load commit diff`,subtitle:e.error.message}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{"data-slot":`commit-meta`,className:`flex flex-wrap items-start gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(o,{className:`break-words text-sm leading-snug font-semibold text-foreground`,children:e.data.subject}),(0,C.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:e.data.author}),(0,C.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,C.jsx)(`span`,{title:e.data.when,children:_(e.data.when)}),(0,C.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,C.jsx)(g,{sha:e.data.sha,variant:`inline`}),(0,C.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,C.jsx)(`span`,{"data-slot":`commit-stat`,children:(0,C.jsx)(h,{stat:e.data.stat})})]})]}),(0,C.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:(0,C.jsx)(l,{mode:v,wrap:b,onModeChange:y,onWrapChange:w})})]}),e.data.files.length===0?(0,C.jsx)(m,{icon:(0,C.jsx)(a,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,C.jsx)(`div`,{className:`p-4 [--diff-sticky-top:0px]`,children:(0,C.jsx)(x,{...c?{viewRef:c}:{},files:e.data.files,mode:f?v:`unified`,wrap:b,totals:!1,className:`min-w-0`})})]})})}function T(e,t){let n=(0,S.useRef)(t);(0,S.useLayoutEffect)(()=>{if(n.current===t)return;n.current=``;let r=e.current,i=r?.closest(`[data-slot="main"]`);if(!(!r||!i)&&r.getBoundingClientRect().top<i.getBoundingClientRect().top){let e=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollIntoView?.({block:`start`,behavior:e?`auto`:`smooth`})}},[e,t])}function E({commit:e,sha:t,backTo:n,backLabel:r,slot:i}){return(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,C.jsx)(`div`,{className:`mx-4 border-b border-border py-2`,children:(0,C.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,C.jsxs)(f,{to:n,children:[(0,C.jsx)(c,{size:16,"aria-hidden":`true`}),r]})})}),(0,C.jsx)(w,{commit:e,sha:t,slot:i,className:`rounded-none border-0 bg-transparent`})]})}var D=56;function O({slot:e,commits:t,selectedSha:n,className:i,heading:a}){let[s,c]=(0,S.useState)(``),l=s.trim().toLowerCase(),u=l?t.filter(e=>e.subject.toLowerCase().includes(l)):t,d=u.length>150,f=(0,S.useRef)(null),p=(0,S.useRef)(null),[m,h]=(0,S.useState)(0);(0,S.useLayoutEffect)(()=>{if(!d)return;let e=()=>{let e=f.current,t=p.current;!e||!t||h(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[d]);let g=u.map(e=>(0,C.jsx)(k,{commit:e,selected:n!==void 0&&e.sha===n},e.sha));return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`label`,{className:`relative mb-3 block`,children:[(0,C.jsx)(o,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3 left-3 size-4 text-muted-foreground`}),(0,C.jsx)(y,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:s,onChange:e=>c(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,C.jsxs)(`div`,{ref:e=>{f.current=e,e&&(p.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":d,className:r(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-3 py-1 md:px-4`,i),children:[a?(0,C.jsx)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-2 py-2.5`,children:a}):null,u.length===0?(0,C.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,d?(0,C.jsx)(b,{scrollRef:p,startMargin:m,itemSize:D,children:g}):g]})]})}function k({commit:e,selected:t}){return(0,C.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_56px] [content-visibility:auto]`,children:(0,C.jsxs)(f,{"data-slot":`commit-row`,"data-sha":e.sha,"data-selected":t?`true`:void 0,"aria-current":t?`true`:void 0,to:e.href,className:r(`flex min-h-11 min-w-0 items-start gap-2.5 rounded-md px-2 py-2.5 transition-colors hover:bg-muted`,t&&`bg-muted/70`),children:[(0,C.jsx)(a,{size:16,"aria-hidden":`true`,className:`mt-px size-4 shrink-0 text-accent-text`}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{"data-slot":`commit-row-subject`,title:e.subject,className:`line-clamp-2 text-[13px] leading-snug font-medium break-words text-foreground`,children:e.subject}),(0,C.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,C.jsx)(A,{sha:e.sha}),(0,C.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.author,` · `,(0,C.jsx)(`span`,{title:v(e.when,e.at),children:_(e.when,e.at)})]}),e.stat?(0,C.jsx)(h,{stat:e.stat}):null]})]})]})})}function A({sha:e}){return(0,C.jsx)(g,{"data-slot":`commit-sha`,sha:e,variant:`chip`})}export{w as i,A as n,E as r,O 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{M as a,Wt as o,a as s,cn as c,dn as l,i as u,k as d,l as f,o as p,r as m,s as h}from"./queries-CII6fTHH.js";import{An as g,G as _,I as v,K as y,Si as b,U as x,hi as S,n as C,q as w}from"./toaster-Bs1mVYf9.js";import{f as T,h as ee}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{I as E,L as te,Q as ne,Z as D,ct as O,i as re,l as k,m as A,r as j,u as M,ut as ie}from"./design-icons-QbNMZniQ.js";import{t as ae}from"./chevron-down-CHGyCDBH.js";import{t as N}from"./chevron-right-BENZ-1ZN.js";import{t as P}from"./loader-circle-CPBhhDbB.js";import{t as F}from"./play-CmVAj_fu.js";import{t as I}from"./button-C8jUIs8Q.js";import{a as oe,i as se,n as ce,r as L,t as le}from"./select-BoL_3H6E.js";import{i as R,r as z,t as B}from"./popover-CvL6hQ5c.js";import{r as ue,t as V}from"./project-router-onKnSy5a.js";import"./attention-C9zoC-gL.js";import{f as de,v as fe}from"./task-groups-dEzH1nMg.js";import{t as pe}from"./status-dot-BXf-Ubd0.js";import{c as H,d as U,f as me,m as he}from"./page-shell-Dky5crRl.js";import{a as ge,o as _e,r as ve,s as ye,t as be}from"./command-BiBq24zL.js";import{t as W}from"./centered-state-BgSV4e79.js";import{t as xe}from"./use-search-params-writer-ClMScnNe.js";import{At as Se,Ct as Ce,Dt as we,Et as Te,Ln as Ee,Nn as De,Ot as Oe,St as ke,Tn as G,Tt as K,Un as Ae,_t as je,bt as Me,ct as Ne,gt as Pe,jt as Fe,kt as Ie,r as Le,s as Re,tr as ze,vt as Be,wt as Ve,xt as He,yt as Ue}from"./index-TFU1q5Sa.js";import{t as We}from"./markdown-BOOMYZ7a.js";import{a as Ge,c as Ke,d as qe,f as q,i as Je,l as Ye,m as Xe,n as Ze,o as Qe,p as $e,r as et,s as tt,t as nt}from"./use-hand-to-agent-state-BK-LieHJ.js";import{t as rt}from"./tab-link-B2k-zaeP.js";var J=e(t(),1),Y=n();function it({number:e,repo:t}){let n=i();return(0,Y.jsx)(at,{number:e,repo:t,scope:n},JSON.stringify([n,t,e]))}function at({number:e,repo:t,scope:n}){let i=(0,J.useId)(),o=(0,J.useId)(),[s,l]=(0,J.useState)(!1),u=s?ae:N,d=c(n,!0,n==="default"),f=a(`#${e}`,!0),p=(0,J.useMemo)(()=>Oe(fe(d.data??[],f.data?.pages.flatMap(e=>e.runs)??[]),e,t,n),[d.data,f.data,e,t,n]);return(0,Y.jsxs)(`section`,{"aria-labelledby":i,className:r(`mt-4 min-w-0 rounded-lg border border-border`,s?`p-3`:`p-0.5`),children:[(0,Y.jsx)(`h3`,{id:i,className:`text-xs font-semibold text-muted-foreground`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":s,"aria-controls":o,onClick:()=>l(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,Y.jsx)(u,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Y.jsxs)(`span`,{children:[`Linked tasks`,d.data?` (${p.length}${f.hasNextPage||f.isError?`+`:``})`:``]})]})}),(0,Y.jsx)(`div`,{id:o,children:s?(0,Y.jsxs)(Y.Fragment,{children:[d.isPending?(0,Y.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:`Loading linked tasks…`}):null,d.isError?(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`p`,{role:`status`,children:`Couldn’t load linked tasks. Check your connection and try again.`}),(0,Y.jsx)(I,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void d.refetch(),disabled:d.isFetching,children:`Retry linked tasks`})]}):null,d.data&&p.length===0&&!d.isError?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No linked tasks yet.`}):null,p.length>0?(0,Y.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:p.map(e=>{let t=De(e,g(e));return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(V,{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,Y.jsx)(`span`,{className:`text-sm font-medium break-words [overflow-wrap:anywhere]`,children:de(e)}),(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(pe,{tone:t.tone,shape:t.shape,pulse:t.pulse,role:`img`,"aria-label":t.label,title:t.label}),e.archived?(0,Y.jsx)(Le,{"data-slot":`linked-task-archived`,dot:G.tone,shape:G.shape,className:`px-2 py-px`,children:G.label}):null,(0,Y.jsx)(`time`,{dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleDateString()})]})]})},e.id)})}):null,f.isError?(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`p`,{role:`status`,children:`Couldn’t load older archived linked tasks.`}),(0,Y.jsx)(I,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void f.refetch(),disabled:f.isFetching,children:`Retry older linked tasks`})]}):f.hasNextPage?(0,Y.jsx)(I,{variant:`outline`,className:`mt-2 min-h-11`,onClick:()=>void f.fetchNextPage(),disabled:f.isFetchingNextPage,children:f.isFetchingNextPage?`Loading older linked tasks…`:`Show older linked tasks`}):null]}):null})]})}var ot=`w-44 max-w-full`,X=`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`,Z=`__all__`;function st(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 ct(e,t){return!!e&&t.length===1&&t[0]?.toLowerCase()===e.toLowerCase()}function lt(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 ut(e){return[e.viewerLogin?``:`GitHub login unavailable.`,lt(e)].filter(Boolean).join(` `)}function dt({options:e,assignees:t,onAssigneesChange:n}){return(0,Y.jsxs)(B,{children:[(0,Y.jsx)(R,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`${X} inline-flex items-center gap-1.5`,disabled:e.length===0,children:[`Assignee`,t.length?` · ${t.length}`:``,(0,Y.jsx)(M,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`})]})}),(0,Y.jsx)(z,{align:`start`,className:`w-64 max-w-[calc(100vw-2rem)] p-2`,children:(0,Y.jsxs)(`fieldset`,{className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] overflow-y-auto`,children:[(0,Y.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,Y.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded px-2 hover:bg-muted`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>n(r?t.filter(t=>t.toLowerCase()!==e.toLowerCase()):[...t,e])}),(0,Y.jsx)(`span`,{className:`break-all text-sm`,children:e})]},e.toLowerCase())})]})})]})}function ft({data:e,projectId:t,onProjectChange:n,pickerRef:r}){if(e.projects?.length)return(0,Y.jsxs)(le,{value:t||Z,onValueChange:e=>n(e===Z?``:e),children:[(0,Y.jsx)(se,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":t,className:`${X} ${ot} justify-between`,children:(0,Y.jsx)(oe,{placeholder:`All boards`})}),(0,Y.jsxs)(ce,{align:`start`,children:[(0,Y.jsx)(L,{value:Z,children:`All boards`}),e.projects.map(e=>(0,Y.jsx)(L,{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,Y.jsxs)(le,{disabled:!0,value:Z,children:[(0,Y.jsx)(se,{ref:r,"aria-label":`Project board`,"data-slot":`gh-board-filter`,"data-value":``,className:`${X} ${ot} justify-between`,children:(0,Y.jsx)(oe,{placeholder:t,children:t})}),(0,Y.jsx)(ce,{align:`start`,children:(0,Y.jsx)(L,{value:Z,children:t})})]})}return null}function pt({data:e,message:t,lastMessage:n,hasMessage:r,statusOpen:i,setStatusOpen:a,triggerRef:o,contentRef:s}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{role:`status`,className:`sr-only`,children:t}),(0,Y.jsxs)(B,{open:i,onOpenChange:a,children:[(0,Y.jsx)(R,{asChild:!0,children:(0,Y.jsx)(`button`,{ref:o,type:`button`,className:`${X} inline-flex items-center justify-center ${t?``:`invisible`}`,"aria-label":`Project board status`,tabIndex:t?void 0:-1,children:e.projectsState===`refreshing`?(0,Y.jsx)(D,{size:14,"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}):(0,Y.jsx)(O,{size:14,"aria-hidden":`true`,className:`size-3.5`})})}),(0,Y.jsx)(z,{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 mt({data:e,assignees:t,projectId:n,onAssigneesChange:r,onProjectChange:i}){let[a,o]=(0,J.useState)(!1),s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=st(e.issues,t),f=ct(e.viewerLogin,t),p=ut(e),m=p!==``,h=(0,J.useRef)(p);m&&(h.current=p);let g=(0,J.useRef)(!m);g.current=!m;let _=()=>(l.current&&!l.current.disabled?l.current:u.current)?.focus();return(0,J.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,J.useEffect)(()=>{if(m)return;let e=document.activeElement,t=!!e&&(e===s.current||!!c.current?.contains(e));o(!1),t&&_()},[m]),(0,Y.jsxs)(`div`,{className:`contents`,"data-slot":`gh-issue-filters`,children:[(0,Y.jsx)(dt,{options:d,assignees:t,onAssigneesChange:r}),(0,Y.jsxs)(`button`,{ref:u,type:`button`,"data-slot":`gh-assigned-me`,className:`${X} 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,Y.jsx)(ie,{size:14,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Assigned to me`]}),(0,Y.jsx)(ft,{data:e,projectId:n,onProjectChange:i,pickerRef:l}),(0,Y.jsx)(pt,{data:e,message:p,lastMessage:h,hasMessage:m,statusOpen:a,setStatusOpen:o,triggerRef:s,contentRef:c})]})}function ht({onRefresh:e,refreshing:t}){let n=Pe(i());return(0,Y.jsx)(U,{route:`github`,density:`full`,headerSpacing:`compact`,header:{title:`GitHub`,secondaryActions:(0,Y.jsx)(H,{type:`button`,variant:`ghost`,"data-slot":`gh-screen-refresh`,"aria-label":`Refresh from GitHub`,title:`Refresh from GitHub`,disabled:t,onClick:e,children:(0,Y.jsx)(D,{size:17,"aria-hidden":`true`,className:r(`size-[17px]`,t&&`motion-safe:animate-spin`)})})},children:(0,Y.jsx)(`div`,{"data-slot":`github-filter-screen`,children:(0,Y.jsx)(je,{model:n,variant:`screen`})})})}function gt({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?Be[t]:void 0,scopeSlot:`gh-title-qualifier`,subtitle:a.repo?(0,Y.jsxs)(`span`,{className:`block min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{"data-slot":`gh-repo`,children:a.repo}),(0,Y.jsxs)(`span`,{"data-slot":`gh-synced`,title:a.syncedAt?new Date(a.syncedAt).toLocaleString():void 0,children:[` `,`· `,a.syncedAt?(0,Y.jsx)(Ee,{iso:a.syncedAt,prefix:`Synced `}):`Not synced yet`]})]}):void 0,secondaryActions:(0,Y.jsx)(_t,{...o}),headerExtra:r&&i===void 0?(0,Y.jsxs)(`div`,{"data-slot":`gh-filter-context`,className:`mt-1 flex min-w-0 items-center gap-3 md:hidden`,children:[(0,Y.jsxs)(V,{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,Y.jsx)(j,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to filters`]}),t===`all`?null:(0,Y.jsx)(`span`,{"data-slot":`gh-active-filter`,className:`truncate text-xs text-muted-foreground`,children:[...He,...ke].find(e=>e.id===t)?.label})]}):void 0}}function _t({automationsAvailable:e,refreshing:t,onRefresh:n}){return(0,Y.jsxs)(`div`,{"data-slot":`gh-page-actions`,className:`flex shrink-0 flex-wrap items-center gap-2`,children:[e?(0,Y.jsx)(H,{variant:`outline`,asChild:!0,children:(0,Y.jsx)(V,{to:`/automations/new`,children:`Set up automations`})}):null,(0,Y.jsxs)(H,{type:`button`,variant:`outline`,"data-slot":`gh-refresh`,title:`Refresh from GitHub`,disabled:t,onClick:n,children:[(0,Y.jsx)(D,{size:16,"aria-hidden":`true`,className:r(`size-3.5`,t&&`motion-safe:animate-spin`)}),`Refresh`]})]})}function vt({view:e,number:t}){return(0,Y.jsx)(W,{icon:e===`issues`?(0,Y.jsx)(A,{size:16}):(0,Y.jsx)(E,{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.`})}function yt({item:e,view:t,filter:n,narrows:i,colors:a,expanded:s,onToggle:c,queuedRunId:l,checks:u,comments:d}){let f=e.kind===`issue`?A:E,p=S(),m=`gh-row-summary-${e.kind}-${e.number}`,h=()=>{p.prefetchQuery({queryKey:o.githubComments(e.kind,e.number),queryFn:({signal:t})=>y(e.kind,e.number,{},{signal:t}),staleTime:6e4})};return(0,Y.jsxs)(`div`,{"data-slot":`gh-row-shell`,"data-expanded":s||void 0,className:r(`rounded-md`,s&&`bg-sidebar-row-selected`),children:[(0,Y.jsxs)(`button`,{type:`button`,draggable:!0,onDragStart:t=>{try{t.dataTransfer.setData(`text/plain`,et(e)),t.dataTransfer.effectAllowed=`copy`}catch{}},onMouseEnter:h,onFocus:h,onClick:c,"data-slot":`gh-row`,"data-number":e.number,"data-kind":e.kind,"aria-expanded":s,"aria-controls":s?m:void 0,title:`Drag into the composer to prefill a task`,className:`flex w-full flex-col gap-2 rounded-md px-3 py-4 text-left transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2`,children:[(0,Y.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-2 md:items-center`,children:[(0,Y.jsx)(f,{"aria-hidden":`true`,"data-slot":`gh-row-icon`,className:r(`mt-0.5 size-3.5 shrink-0 md:mt-0`,e.kind===`issue`?`text-success`:`text-accent-icon`)}),(0,Y.jsx)(`span`,{"data-slot":`gh-row-title`,className:r(`line-clamp-2 min-w-0 flex-1 text-[13px] font-medium md:block md:truncate`,s&&`font-semibold`),children:e.title}),(0,Y.jsx)(M,{"data-slot":`gh-row-cue`,"aria-hidden":`true`,className:r(`mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none md:mt-0`,s&&`rotate-180`)})]}),(0,Y.jsxs)(`span`,{"data-slot":`gh-row-meta`,className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 pl-[22px] text-xs text-muted-foreground md:flex-nowrap md:gap-y-0`,children:[(0,Y.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[`#`,e.number]}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(`span`,{"data-slot":`gh-row-author`,className:`max-w-full shrink-0 truncate md:min-w-0 md:shrink`,children:e.author}),(0,Y.jsx)(Q,{}),(0,Y.jsx)(Ee,{iso:e.createdAt,className:`shrink-0`}),d?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(Qe,{count:d})]}):null,u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(Ge,{checks:u})]}):null,l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(`span`,{"data-slot":`gh-queued-flag`,className:`shrink-0 font-sans font-medium text-accent-text`,children:`↗ run queued`})]}):null]}),e.labels.length>0&&!s?(0,Y.jsx)(`span`,{"data-slot":`gh-row-labels`,className:`flex flex-wrap gap-1 pl-[22px]`,children:e.labels.map(e=>(0,Y.jsx)(Ye,{label:e,color:a[e],plain:!0},e))}):null]}),s?(0,Y.jsx)(bt,{id:m,item:e,colors:a,checks:u,detailPath:Ve(t,n,e.number,``,i),queuedRunId:l}):null]})}function bt({id:e,item:t,colors:n,checks:r,detailPath:i,queuedRunId:a}){let o=s(t.kind,t.number),c=(o.data?.detail?.body??t.body)?.trim(),l=t.kind===`pr`?`PR`:`issue`;return(0,Y.jsxs)(`div`,{id:e,"data-slot":`gh-row-summary`,className:`flex flex-col gap-3 px-3 pb-4 md:pl-[34px]`,children:[(0,Y.jsx)(`div`,{"data-slot":`gh-row-body`,className:`text-[13px] leading-relaxed text-soft-foreground`,children:c?(0,Y.jsx)(`div`,{"data-slot":`gh-row-excerpt`,inert:!0,className:xt,children:(0,Y.jsx)(We,{document:!0,children:c})}):o.isPending?(0,Y.jsx)(ze,{className:`h-4 w-2/3`}):o.isError||o.data?.available===!1?(0,Y.jsx)(`p`,{"data-slot":`gh-row-body-unavailable`,className:`text-muted-foreground`,children:`Description unavailable. Use Refresh to try again.`}):(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`(no description)`})}),t.labels.length>0||r?(0,Y.jsxs)(`div`,{"data-slot":`gh-row-facts`,className:`flex flex-wrap items-center gap-1.5`,children:[t.labels.map(e=>(0,Y.jsx)(Ye,{label:e,color:n[e]},e)),r?(0,Y.jsx)(Je,{checks:r,url:t.url}):null]}):null,(0,Y.jsxs)(`div`,{"data-slot":`gh-row-actions`,className:`flex flex-wrap items-center gap-2`,children:[a?(0,Y.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11`,children:(0,Y.jsxs)(V,{to:`/tasks/${a}`,"data-action":`gh-row-view-task`,children:[(0,Y.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 text-success`}),`Open queued task`]})}):(0,Y.jsx)(I,{asChild:!0,variant:`primary`,size:`sm`,className:`max-md:h-11`,children:(0,Y.jsxs)(V,{to:i,state:{focusHandoff:!0},"data-action":`gh-row-handoff`,title:`Open this ${l} and write the prompt for an agent`,children:[(0,Y.jsx)(F,{"aria-hidden":`true`,className:`size-3.5`}),`Hand to agent`]})}),(0,Y.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11`,children:(0,Y.jsxs)(V,{to:i,"data-action":`gh-row-open`,children:[`Open `,l,(0,Y.jsx)(re,{size:16,"aria-hidden":`true`,className:`size-3.5`})]})})]})]})}var xt=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 Q(){return(0,Y.jsx)(`span`,{"data-slot":`gh-row-dot`,"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function St(e){let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`?e:e.closest(`[data-slot="main"]`)??e}function Ct(e){let[t,n]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{if(!e){n(null);return}let t=()=>n(St(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 wt(e,t){let[n,r]=(0,J.useState)(0);return(0,J.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 Tt(e,t,n){let[r,i]=(0,J.useState)(null),a=(0,J.useRef)(n);return(0,J.useEffect)(()=>{a.current=n}),(0,J.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 Et(e,t,n,r,i){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),l=Ct(a),u=(0,J.useRef)(null);u.current=l;let d=wt(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:Tt(p&&!i&&!t.isFetchingNextPage&&!t.isFetchNextPageError,l,()=>void t.fetchNextPage())}}function Dt({item:e,queuedRunId:t}){return t?(0,Y.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,className:`max-md:h-11 no-hover:h-11`,children:(0,Y.jsxs)(V,{to:`/tasks/${t}`,"data-action":`gh-header-view-task`,children:[(0,Y.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 text-success`}),`Open queued task`]})}):(0,Y.jsxs)(I,{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:$,children:[(0,Y.jsx)(F,{"aria-hidden":`true`,className:`size-3.5`}),`Hand to agent`]})}function $(){let e=document.querySelector(`[data-slot="gh-detail-inner"] [data-slot="gh-custom-prompt"]`);e?.scrollIntoView({block:`center`}),e?.focus({preventScroll:!0})}var Ot=100;function kt(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>=Ot)break;a.add(t.number)}return[...a]}function At(e,t,n,r,i,a){let o=kt(n,e,r,i,a),s=m(o,e===`prs`),c=s.data?.available?s.data.checks:void 0,l=u(e===`issues`?`issue`:`pr`,(0,J.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),d=(0,J.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]??(d.has(e.number)?void 0:e.comments)}}function jt(e){let[t,n]=xe(),r=t.get(`filter`),i=Ie(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,J.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,J.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 Mt(e,t){return n=>{let r=new URLSearchParams(n);r.delete(e);for(let n of t)r.append(e,n);return r}}function Nt(e,t,{rawFilterParam:n,filter:r,activeFilter:i,setFilterParam:a,narrows:o,url:s,writeNarrows:c}){let l=Ft(s.query,n!==null||o!==``,c),{query:u,setQuery:d}=l,f=s.labels,p=s.assignees,m=e=>c(Mt(`label`,e)),{setProjectFilter:h,activeProject:g}=It(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(Mt(`assignee`,e)),_&&a(`all`)},clearFilters:()=>{l.clear(),c(e=>{let t=new URLSearchParams(e);for(let e of Me)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 Pt=250;function Ft(e,t,n){let r=`${T().pathname}${t?``:`#entry`}`,[i,a]=(0,J.useState)(e),o=(0,J.useRef)(e),s=(0,J.useRef)(void 0),c=(0,J.useRef)(r);return(0,J.useEffect)(()=>{e===o.current&&r===c.current||(clearTimeout(s.current),c.current=r,o.current=e,a(e))},[e,r]),(0,J.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})},Pt)},clear:()=>{clearTimeout(s.current),o.current=``,a(``)}}}function It(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)?t:``,o=e?.available===!0&&!i&&t!==``&&a===``;return(0,J.useEffect)(()=>{o&&n(e=>{let t=new URLSearchParams(e);return t.delete(`board`),t})},[o,n]),{setProjectFilter:r,activeProject:a}}function Lt(e,t,{filter:n,activeFilter:r},a){let o=i(),s=e===`issues`&&(r===`no-task`||r===`has-task`),l=c(o,s,o==="default"),u=(0,J.useMemo)(()=>l.data?we(l.data,t?.repo,o):null,[l.data,t?.repo,o]),d=Te(e,n)?Fe(n):null,p=f(`pr`,d??``,d!==null&&t?.available===!0),m=d!==null&&p.data?.available?p.data.items:null,h=(0,J.useMemo)(()=>t?.available?e===`issues`?t.issues:t.prs:[],[t,e]),g=(0,J.useMemo)(()=>m?Se(m,h):null,[m,h]),_=Rt({view:e,gh:t,activeFilter:r,isAssignedFilter:a,taskFilter:s,taskNumbers:u,runsQuery:l,backedQuery:d,filterHits:m,filterSearch:p});return{backedQuery:d,filterSearch:p,fullList:h,filterRows:g,filterGate:_,openItems:(0,J.useMemo)(()=>_?[]:g??h,[_,g,h]),narrow:(0,J.useMemo)(()=>e===`issues`?r===`no-task`&&u?{excludeNumbers:u}:r===`has-task`&&u?{includeNumbers:u}:{}:r===`mine`&&t?.viewerLogin?{author:t.viewerLogin}:m?{includeNumbers:new Set(m.map(e=>e.number))}:{},[e,r,u,t?.viewerLogin,m])}}function Rt({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 zt(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 Bt(e,t,n,{filterGate:r,filterRows:i,fullList:a}){let s=o.github()[0],c=t===void 0?null:Number.parseInt(t,10),l=!r&&n.data?.available?n.data.items.find(e=>e.number===c):void 0,u=i&&c!==null&&!a.some(e=>e.number===c)?i.find(e=>e.number===c):void 0,d=l??u,[f,p]=(0,J.useState)(null);return(0,J.useEffect)(()=>{d&&p({scope:s,view:e,item:d})},[s,e,d]),{selectedNumber:c,remoteDetail:d??(f?.scope===s&&f.view===e&&f.item.number===c?f.item:null)}}function Vt(e,t,n,{fullList:r,filterRows:i},a){let s=S(),c=(0,J.useRef)(null),l=e===`issues`?`issue`:`pr`,u=t?.available===!0&&n!==null&&Number.isSafeInteger(n)&&n>0&&!r.some(e=>e.number===n)&&!i?.some(e=>e.number===n)&&a===null,d=p(l,n??0,u),f=u&&d.data?.available&&d.data.item?.kind===l?d.data.item:null;c.current=u&&n!==null?{kind:l,number:n,key:o.githubItem(l,n)}:null;let[m,h]=(0,J.useState)(!1);return{exactWanted:u,exactItem:d,exactDetail:f,exactTargetRef:c,retryingExact:m,retryExact:()=>{h(!0),zt(s,c.current).then(e=>{h(!1),e||C(`Could not reach GitHub for #${n}`,{tone:`danger`})})}}}function Ht(e,t,n){let r=S(),i=(0,J.useRef)(null);return{refresh:l({mutationFn:e=>(zt(r,e),x({refresh:!0,limit:50})),onSuccess:async a=>{await r.cancelQueries({queryKey:o.githubPages(50),exact:!0}),r.setQueryData(o.githubPages(50),{pages:[a],pageParams:[{}]}),r.invalidateQueries({queryKey:o.githubChecks(t)});let s=e===`issues`?`issue`:`pr`,c=(e===`issues`?a.issues:a.prs).map(e=>e.number),l=o.githubCommentCounts(s,c);r.removeQueries({queryKey:o.githubCommentCounts(s,[]).slice(0,4),predicate:e=>e.queryHash!==b(l)}),a.available&&a.commentsDeferred&&c.length>0&&_(s,c,{refresh:!0}).then(e=>r.setQueryData(l,e)).catch(()=>{}),r.invalidateQueries({queryKey:o.githubSearch(e===`issues`?`issue`:`pr`,n)}),r.invalidateQueries({queryKey:o.githubSearch(`pr`,Ce)}),r.invalidateQueries({queryKey:o.githubSearch(`pr`,Ue)});let u=i.current,d=o.githubComments(`issue`,0).slice(0,3);if(!u){r.removeQueries({queryKey:d});return}let f=o.githubComments(u.kind,u.number);y(u.kind,u.number,{refresh:!0}).then(e=>r.setQueryData(f,e)).catch(()=>{}),r.removeQueries({queryKey:d,predicate:e=>e.queryHash!==b(f)})},onError:e=>C(e.message,{tone:`danger`})}),openThreadRef:i}}var Ut=350;function Wt(e,t){let[n,r]=(0,J.useState)(e);return(0,J.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function Gt(e,t,{query:n,labelFilter:r,effectiveAssignees:i,activeProject:a},{openItems:o,narrow:s,filterGate:c}){let l=Wt(n,Ut),u=(0,J.useMemo)(()=>q(o,{query:l,labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}),[o,l,r,e,i,a,s]),d=n.trim()===l.trim(),p=t?.available===!0&&!c&&d&&Xe(l,u),m=f(e===`issues`?`issue`:`pr`,l,p),h=q(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=Kt(e,g,a,i);return{debouncedQuery:l,searchWanted:p,forgeSearch:m,items:h,searchPayload:g,metadataFailure:v,searchHits:g&&!v?q(g.items,{labels:r,...s,...e===`issues`?{assignees:i,projectId:a}:{}}).filter(e=>!_.has(e.number)):[],...qt(n,d,p,m)}}function Kt(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 qt(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 Jt({view:e,changes:t=!1,index:n=!1}){let{n:r}=ee(),i=jt(e),{rawFilterParam:a,activeFilter:o,narrows:s}=i,c=a!==null||s!==``,l=he(),{pages:u,data:f}=h(50),p=Ae(),m=Xt(),g=nt(),_=Yt({index:n,isDesktop:l,listInUrl:c,n:r,rememberedView:d().data?.githubView}),[v,y]=(0,J.useState)(null),b=Nt(e,f,i),x=Lt(e,f,i,b.isAssignedFilter),S=Gt(e,f,b,x),C=Bt(e,r,S.forgeSearch,x),w=Vt(e,f,C.selectedNumber,x,C.remoteDetail),T=At(e,u,f,C.selectedNumber,S.searchHits,x.openItems),{refresh:E,openThreadRef:te}=Ht(e,T.checkPrNumbers,S.debouncedQuery),ne=Et(e,u,f,x.backedQuery,b.narrowing);if(_.restorePrs)return(0,Y.jsx)(ue,{to:`/github/prs`,replace:!0});if(!f)return u.isError?(0,Y.jsx)(U,{route:`github`,density:`empty`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(O,{size:16}),tone:`danger`,title:`Could not load GitHub`,subtitle:u.error.message})}):(0,Y.jsx)(Ne,{});te.current=null;let D=()=>E.mutate(w.exactTargetRef.current);if(_.filterScreen&&f.available)return(0,Y.jsx)(ht,{onRefresh:D,refreshing:E.isPending});if(!f.available)return(0,Y.jsx)(tn,{reason:f.reason,refreshing:E.isPending,onRetry:D});let{labelColors:re,labelOptions:k}=Zt(f,S.searchPayload,x.openItems,x.fullList),A=Qt({number:C.selectedNumber,fullList:x.fullList,filterRows:x.filterRows,remoteDetail:C.remoteDetail,exactDetail:w.exactDetail}),j=r===void 0?[...S.items,...S.searchHits].find(e=>e.url===v)??null:null,M=A??j;te.current=M?{kind:M.kind,number:M.number}:null;let{linkFilter:ie,listPath:ae}=$t(e,a,o,l,s),N={view:e,filter:ie,narrows:s,colors:re,expandedUrl:j?.url??null,onToggle:e=>y(t=>t===e.url?null:e.url),queued:g.queued,checksMap:T.checksMap,commentsOf:T.commentsOf},P=en(e,b,x.filterGate,S),F=gt({view:e,activeFilter:o,isDesktop:l,listInUrl:c,n:r,gh:f,actions:{automationsAvailable:p,refreshing:E.isPending,onRefresh:D}});return r===void 0?(0,Y.jsxs)(U,{route:`github`,density:me(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,Y.jsxs)(`header`,{"data-slot":`gh-header`,className:`flex shrink-0 flex-col gap-3 bg-background md:gap-4`,children:[(0,Y.jsx)(nn,{view:e,isDesktop:l,gh:f,onSaveView:m}),(0,Y.jsx)(rn,{view:e,gh:f,filters:b,labelOptions:k,labelColors:re,searchPayload:S.searchPayload})]}),(0,Y.jsx)(sn,{view:e,rows:N,verdict:P,search:S,sidebar:x,list:u,paging:ne})]}):(0,Y.jsx)(U,{route:`github`,density:`full`,headerSpacing:`compact`,className:`pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-4`,header:F,children:(0,Y.jsx)(fn,{view:e,selected:A,selectedNumber:C.selectedNumber,exact:w,repo:f.repo,rows:N,listPath:ae,changes:t,handToAgent:g})})}function Yt({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 Xt(){let e=S();return t=>{e.setQueryData(o.uiState,e=>({...e,githubView:t})),v({githubView:t}).then(t=>e.setQueryData(o.uiState,t)).catch(t=>{C(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:o.uiState})})}}function Zt(e,t,n,r){return{labelColors:{...t?.labelColors,...e.labelColors},labelOptions:qe([...n,...r,...t?.items??[]])}}function Qt({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 $t(e,t,n,r,i){let a=t===null?null:n;return{linkFilter:a,listPath:Ve(e,a??(e===`issues`&&!r?`all`:null),void 0,``,i)}}function en(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,Y.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,Y.jsx)(P,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}):null,r.message]}):n?i?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(P,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}),`Searching GitHub for “`,t.trim(),`”…`]}):a?c.length>0?(0,Y.jsxs)(`p`,{role:`status`,children:[`Showing previous results. GitHub could not be refreshed: `,o,`. Use Refresh to try again.`]}):u.length>0?(0,Y.jsxs)(`p`,{children:[`GitHub could not be searched: `,o,`.`]}):(0,Y.jsxs)(`p`,{children:[`No open `,d,` match your filter, and GitHub could not be searched: `,o,`.`]}):s?(0,Y.jsxs)(`p`,{role:`status`,children:[`Cannot apply the selected filters to GitHub results: `,s]}):c.length>0?null:l?.truncated?(0,Y.jsx)(`p`,{children:`No matches within GitHub’s first matches. Narrow your search to check more specific results.`}):l&&u.length>0?(0,Y.jsxs)(`p`,{children:[`No additional `,d,` match your filter on GitHub.`]}):l?(0,Y.jsxs)(`p`,{children:[`No `,d,` match your filter — open, closed or merged.`]}):(0,Y.jsxs)(`p`,{children:[`No open `,d,` match your filter.`]}):(0,Y.jsxs)(`p`,{children:[`No open `,d,`.`]})}function tn({reason:e,refreshing:t,onRetry:n}){return(0,Y.jsx)(U,{route:`github`,density:`empty`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(te,{}),tone:`neutral`,title:`GitHub is unavailable here`,subtitle:e??`unknown reason`,actions:(0,Y.jsx)(I,{variant:`outline`,"data-action":`gh-retry`,disabled:t,onClick:n,children:`Try again`}),children:(0,Y.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`The tab needs the `,(0,Y.jsx)(`span`,{className:`font-mono`,children:`gh`}),` CLI, logged in (`,(0,Y.jsx)(`span`,{className:`font-mono`,children:`gh auth login`}),`), and a repo with a GitHub remote. Everything else in Squawk works without it.`]})})})}function nn({view:e,isDesktop:t,gh:n,onSaveView:r}){return(0,Y.jsxs)(`div`,{"data-slot":`gh-tabs`,className:`flex min-h-11 flex-wrap items-center gap-3`,children:[(0,Y.jsxs)(rt,{to:t?`/github`:`/github?filter=all`,active:e===`issues`,onClick:()=>r(`issues`),children:[`Issues · `,n.issuesTotal??n.issues.length]}),(0,Y.jsxs)(rt,{to:`/github/prs`,active:e===`prs`,onClick:()=>r(`prs`),children:[`Pull requests · `,n.prsTotal??n.prs.length]})]})}function rn({view:e,gh:t,filters:n,labelOptions:r,labelColors:i,searchPayload:a}){return(0,Y.jsxs)(`div`,{"data-slot":`gh-filter-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`relative min-w-0 basis-full md:flex-1 md:basis-auto`,children:[(0,Y.jsx)(ne,{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,Y.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,Y.jsx)(hn,{options:r,colors:i,selected:n.labelFilter,onChange:n.setLabelFilter}),e===`issues`?(0,Y.jsx)(mt,{data:{...t,issues:[...t.issues,...a?.items??[]]},assignees:n.effectiveAssignees,projectId:n.activeProject,onAssigneesChange:n.changeAssignees,onProjectChange:n.setProjectFilter}):null,(0,Y.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 an(e,t){return e.kind===`pr`?t?.[e.number]??e.checks:e.checks}function on(e,t){return(0,Y.jsx)(yt,{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:an(e,t.checksMap),comments:t.commentsOf(e)})}function sn({view:e,rows:t,verdict:n,search:r,sidebar:i,list:a,paging:o}){let{items:s,searchHits:c}=r;return(0,Y.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,Y.jsx)(`div`,{"data-slot":`gh-empty`,className:`px-4 py-4 text-sm text-muted-foreground`,children:n}):(0,Y.jsx)(cn,{items:s,rows:t,paging:o}),o.pagingAvailable?(0,Y.jsx)(ln,{view:e,list:a,paging:o}):null,(0,Y.jsx)(un,{backedQuery:i.backedQuery,filterSearch:i.filterSearch}),s.length>0&&r.searchWanted&&n?(0,Y.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,Y.jsx)(dn,{hits:c,searchPayload:r.searchPayload,rows:t}):null]})}function cn({items:e,rows:t,paging:n}){let{setRowsEl:r,scrollOwner:i,listEl:a,scrollOwnerRef:o,startMargin:s}=n,c=(0,J.useRef)(null),l=(0,J.useRef)(!1);(0,J.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,Y.jsx)(`div`,{role:`listitem`,"data-slot":`gh-row-item`,"data-divided":n>0||void 0,children:on(e,t)},e.url));return(0,Y.jsx)(`div`,{ref:r,"data-slot":`gh-rows`,"data-virtualized":i?`true`:void 0,role:`list`,children:i?(0,Y.jsx)(Re,{ref:c,scrollRef:o,startMargin:s,children:u},i===a?`list`:`main`):u})}function ln({view:e,list:t,paging:n}){return(0,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(P,{"aria-hidden":`true`,className:`size-3.5 motion-safe:animate-spin`}),`Loading more…`]}):t.isFetchNextPageError?(0,Y.jsxs)(Y.Fragment,{children:[`Could not load more.`,(0,Y.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,Y.jsxs)(Y.Fragment,{children:[`Filters cover the loaded `,e===`issues`?`issues`:`pull requests`,`.`,(0,Y.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 un({backedQuery:e,filterSearch:t}){return e!==null&&t.data?.available&&t.data.truncated?(0,Y.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,J.useRef)(null),i=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{i.current||(i.current=!0,(r.current?.querySelector(`[data-slot="gh-row"][aria-expanded="true"]`))?.scrollIntoView({block:`start`}))},[]),(0,Y.jsxs)(`div`,{"data-slot":`gh-search-hits`,children:[(0,Y.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,Y.jsx)(`ul`,{ref:r,className:`flex flex-col gap-0.5 px-2 pb-2`,children:e.map(e=>(0,Y.jsx)(`li`,{children:on(e,n)},e.url))})]})}function fn({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,Y.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,Y.jsx)(`div`,{className:`px-4 pt-4 md:px-7 md:pt-5`,children:(0,Y.jsx)(tt,{backLink:{to:o}})}),t?(0,Y.jsx)(pn,{item:t,repo:i,rows:a,listPath:o,changes:s,handToAgent:c}):l&&u.isPending?(0,Y.jsx)(`div`,{"data-slot":`gh-detail-loading`,className:`flex flex-1 flex-col`,children:(0,Y.jsx)(W,{icon:(0,Y.jsx)(P,{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,Y.jsx)(mn,{number:n,exact:r}):(0,Y.jsx)(vt,{view:e,number:n})]})}function pn({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=T().state?.focusHandoff===!0;return(0,J.useEffect)(()=>{g&&$()},[g,e.url]),(0,Y.jsx)(Ke,{item:e,comments:n.commentsOf(e),afterHeading:e.kind===`issue`?(0,Y.jsx)(it,{number:e.number,repo:t},e.url):void 0,backLink:{to:r},subNav:{filter:n.filter,narrows:n.narrows,changes:i},onRunAgent:$,headerAction:(0,Y.jsx)(Dt,{item:e,queuedRunId:m.get(e.url)??null}),colors:n.colors,checks:an(e,n.checksMap),children:(0,Y.jsx)(Ze,{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 mn({number:e,exact:t}){let{exactItem:n,retryingExact:r,retryExact:i}=t;return(0,Y.jsx)(W,{icon:(0,Y.jsx)(O,{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,Y.jsx)(I,{variant:`outline`,disabled:r,onClick:i,children:`Retry`})})}function hn({options:e,colors:t,selected:n,onChange:i}){let[a,o]=(0,J.useState)(!1),s=e=>i(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,Y.jsxs)(B,{open:a,onOpenChange:o,children:[(0,Y.jsx)(R,{asChild:!0,children:(0,Y.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,Y.jsx)(M,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`})]})}),(0,Y.jsx)(z,{align:`end`,sideOffset:6,className:`w-60 p-0`,children:(0,Y.jsxs)(be,{children:[(0,Y.jsx)(ge,{placeholder:`Filter labels…`}),(0,Y.jsxs)(ye,{className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Y.jsx)(ve,{children:`No labels.`}),n.length>0?(0,Y.jsxs)(_e,{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,Y.jsxs)(_e,{value:e,onSelect:()=>s(e),className:`min-h-11`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`gh-label-dot`,className:`size-2.5 shrink-0 rounded-full ring-1 ring-foreground/30`,style:$e(t[e])}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),r?(0,Y.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e)})]})]})})]})}export{Jt as GithubRoute};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{d as n,p as r}from"./dist-C_rn70hE.js";import{$t as i,At as a,Bn as o,Br as s,C as c,Ct as l,D as u,Di as d,E as f,Et as p,F as m,Fi as h,Fn as g,G as _,Gt as v,In as y,J as ee,Jt as te,K as ne,Kr as re,Kt as ie,Ln as ae,Mi as oe,N as se,Nt as ce,O as le,Q as ue,Qt as de,Rn as fe,Rr as pe,Rt as me,S as he,Si as ge,Sr as _e,St as ve,T as ye,Tt as be,U as xe,Ut as Se,Vn as Ce,Vr as we,Vt as Te,W as Ee,Wt as De,X as Oe,Xt as ke,Yt as Ae,Z as je,Zt as Me,_n as Ne,_r as Pe,_t as Fe,a as Ie,ai as Le,an as Re,b as ze,bt as Be,ci as Ve,di as He,dn as Ue,dt as We,fi as Ge,fn as Ke,gi as qe,gn as Je,gt as Ye,h as Xe,hi as b,ht as Ze,ii as x,in as Qe,j as $e,ji as et,jt as tt,ki as nt,kt as rt,li as it,ln as at,m as ot,mn as st,mt as ct,n as lt,nn as ut,oi as dt,on as ft,ot as pt,pn as mt,q as ht,qr as gt,qt as _t,ri as vt,rn as yt,si as bt,ti as xt,tn as St,ui as Ct,un as wt,v as Tt,vi as Et,vn as Dt,vt as Ot,w as kt,wi as At,wt as jt,x as Mt,xt as Nt,y as Pt,yi as Ft,yn as It,yt as Lt,zn as Rt,zt}from"./toaster-Bs1mVYf9.js";import{A as Bt,B as S,F as C,H as w,I as T,N as E,P as D,W as O,Z as k,a as Vt,j as A,z as j}from"./live-protocol-DMhTnCmf.js";function Ht(e,t){return e??t}function Ut(e,t){let n=Ht(e,t);return n===`1`||n===`true`}function Wt(e,t,n){return e?.trim()||Ht(t,n)||``}var Gt=class extends Et{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Kt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Ft({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),k.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Kt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var qt=class extends h{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),et(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ge(t.mutationKey)!==ge(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Kt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){k.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Jt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Yt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Xt=class extends h{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,k.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!et(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Jt(e,n).forEach(e=>{e.destroy()}),Jt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=nt(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new qe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Yt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=b(n),i=Ge(),a=He(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Le(e);let t=r.getQueryCache().get(e.queryHash);Ve(e,a,t)}),Ct(a);let[s]=M.useState(()=>new Xt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?s.subscribe(k.batchCalls(e)):d,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),M.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>bt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&bt(n,e)?dt(n,new qe(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&it({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function P(e,t){let n=b(t),[r]=M.useState(()=>new qt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(k.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(d)},[r]);if(i.error&&oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Zt(e,t=!0,n=!1,r){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>a(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:G.models(t),refetchType:n})}function Qt(e,t=!0,n){return x({...$t(e,n),enabled:t})}var $t=(e,t)=>({queryKey:G.models(e,t),queryFn:({signal:n})=>Ce(e,{signal:n},t),staleTime:300*1e3});function en(e,t=!0){let n=N({queries:e.map(e=>({...$t(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function tn(e,t){return JSON.stringify([e,t])}function nn(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function rn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var an=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(tn(e.projectId,e.id),t))}at(e,t){return this.positions.get(tn(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function on(e,t,n){let r=new an(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=fn(i,e.project,e.usage,r);else{let t=ln(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function sn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function cn(e,t,n){return ln(e,t,n,new an(e.runs))}function ln(e,t,n,r){let{project:i}=t,a=r.at(i,nn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:R(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!sn(e,i,n))return{index:e,reconcile:!0};let l=nt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||rn(t,i)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return dn(e,l,r);let u=r.insert(l);return{index:R(e,u),reconcile:l.archived&&rn(u,i)>e.perProjectLimit}}function un(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function dn(e,t,n){let r=un(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:R(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function fn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=nt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?R(e,r.runs):e}function pn(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function mn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function hn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function gn(e){e.stream=void 0}function _n(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,nn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function vn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function yn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function bn(e,t,n){if(!yn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=cn(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var z=[`workspace`,`runs-index`],xn=[`workspace`,`projects`],Sn=6e4,Cn=100,wn=new WeakMap;function Tn(e){let t=wn.get(e);return t||(t=An(e),wn.set(e,t)),t}function En(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Tn(t).merge(e)}function Dn(e){let t=e.getQueryData(xn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function On(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function kn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function An(e){let t=mn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=Dn(e),{index:s,reconcile:c}=on(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,Cn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){hn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){gn(t)},run(e,r,i=!1){if(l.has(e))return;let a=kn(e,r);if(!_n(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),vn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=pn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=bn(t,n,Dn(e));for(let e of l)i.index=pn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),On(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var jn=A([`own`,`provider-spanning`]),Mn=S({suggested:E(S({id:O(),label:O(),desc:O()})),retired:E(O())}),Nn=S({id:A([`settings`,`mcp`,`memory`]),label:O(),note:O().optional(),empty:O().optional(),showsUserMcp:T(!0).optional()}),Pn=S({label:O(),note:O().optional(),groups:E(Nn)}),Fn=S({runners:E(S({id:xt,displayName:O(),modelListName:O(),modelIdScope:jn,pickerLabel:O(),pickerDescription:O(),icon:O(),installHint:O(),loginCommand:O(),terminalLogin:D().optional(),browserLogin:D().optional(),managedInstall:T(!0).optional(),accountFolderExample:O().optional(),models:Mn,agentConfig:Pn}))}),In=[`workspace`,`runners`];async function Ln(e){return o(await y.api.v1.runners.$get({},ae(e)),`/runners`,Fn)}var Rn={queryKey:In,queryFn:({signal:e})=>Ln({signal:e}),staleTime:1/0};function zn(){return x(Rn)}function Bn(e){return e?.runners??[]}function Vn(e){return Bn(e).map(e=>e.id)}function Hn(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Un(e){let t=zn();return{runner:t.isSuccess?Hn(e,Vn(t.data))??e:e,ready:!t.isPending}}function B(e,t){return e?.runners.find(e=>e.id===t)}function Wn(e,t){return B(e,t)?.displayName??t}function Gn(e,t){return B(e,t)?.pickerLabel??t}function Kn(e,t){return B(e,t)?.modelListName}function qn(e,t,n=!0){let i=Ii(),a=Ur(),{runner:o,ready:s}=Un(e??i.data?.defaultRunner??`claude`),c=a.data?.capabilities?.localHandoff===!1?null:t,l=r(),u=x({queryKey:W.runnerSkills(o,c),queryFn:({signal:e})=>kt(o,c,{signal:e,projectId:l}),enabled:n&&s&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...u,runner:o,account:c,data:u.data?.skills,list:u.data,unchecked:u.isError||!u.data||u.data.source===`unavailable`}}var Jn={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},Yn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Xn(e){return typeof e==`string`&&Object.hasOwn(Jn,e)}function Zn(e){return e!==void 0&&Xn(e)?Jn[e]:void 0}var Qn=`cez.reference-statuses.v1`,$n=`cez.reference-conflicts.v1`,V=new Map(rr()),er=1e3;function tr(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>er;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}or()}}var H=new Set(ir());function nr(e,t){if(H.has(e)!==t){if(t)for(H.add(e);H.size>er;){let e=H.values().next().value;if(e===void 0)break;H.delete(e)}else H.delete(e);or()}}function rr(){try{let e=globalThis.sessionStorage?.getItem(Qn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&Xn(e[1])):[]}catch{return[]}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var ar;function or(){ar===void 0&&(ar=setTimeout(()=>{ar=void 0;try{globalThis.sessionStorage?.setItem(Qn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem($n,JSON.stringify([...H]))}catch{}},250))}var U=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function sr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function cr(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function lr(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;tr(t,o),s!==void 0&&nr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function ur(e,t,n){let r=U(t),i=V.get(r),a=H.has(r)?!0:void 0,o=n.data;if(o?.available){lr(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...sr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...sr(i,a)});return}e.set(r,{state:`loading`,...sr(i,a)})}function dr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of cr(i))ur(n,e,t)}),n}var W={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t)=>[r(),`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},get uiState(){return[r(),`ui-state`]},get config(){return[r(),`config`]},get agentConfig(){return[r(),`agent-config`]},agentConfigFile:e=>[r(),`agent-config`,`file`,e],get sessionContext(){return[r(),`session-context`]},sessionContextPreview:(e,t,n=``)=>[r(),`session-context`,`preview`,t,e,n],get worktrees(){return[r(),`worktrees`]},github:(e={})=>[r(),`github`,e.limit??null],githubPages:e=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[r(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[r(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[r(),`github`,`comments`,e,t],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},G={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...G.fsBrowseRoot,e,t]};function fr(){return Ut(void 0,void 0)}function K(e){return!fr()&&e}function pr(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function mr(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function hr(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function gr(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function _r(e,t){return gt({kind:`topic`,topic:e},{value:t})}function vr(){let e=b();return x({queryKey:G.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(G.providerStatus),r=await Qe(!1,{signal:t});return _e(n,e.getQueryData(G.providerStatus),r)},staleTime:5*6e4,refetchInterval:K(!1),refetchOnWindowFocus:!0})}function yr(){let e=b();return P({mutationFn:()=>Qe(!0),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t)),L(e)}})}function br(){let e=b();return P({mutationFn:({provider:e,authFailureId:t})=>mt(e,t),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t,n.authFailureId)),L(e,n.provider)}})}function xr(e={}){return x({queryKey:G.projects,queryFn:({signal:e})=>yt({signal:e}),...e})}function Sr(e,t=!1){return x({queryKey:G.fsBrowse(e,t),queryFn:({signal:n})=>ie(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Cr(){let e=b();return P({mutationFn:e=>at(e),onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function wr(){let e=b();return P({mutationFn:e=>Ue(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:G.projects})}})}function Tr(){let e=b();return P({mutationFn:e=>{let{id:t,...n}=e;return Dt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:G.projects});let r=e.getQueryData(G.projects);return e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Er(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(G.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:G.projects})})}function Er(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:gr(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Dr(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(G.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:G.projects})})}function Or(){return Dr(e=>{let{projectId:t,...n}=e;return Me(t,n)})}function kr(){return Dr(e=>{let{projectId:t,webhookId:n,...r}=e;return It(t,n,r)})}function Ar(){return Dr(({projectId:e,webhookId:t})=>Ke(e,t))}function jr(){return P({mutationFn:({projectId:e,webhookId:t})=>Je(e,t),retry:!1})}function q(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:G.agentProfiles}),t.invalidateQueries({queryKey:G.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])},onError:()=>{t.invalidateQueries({queryKey:W.health}),t.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Mr(){return q(e=>Ae(e))}function Nr(){return q(e=>{let{id:t,...n}=e;return Ne(t,n)})}function Pr(){return q(e=>wt(e))}function Fr(){return q(e=>st(e))}function Ir(e,t){return x({queryKey:G.agentAccountStatus(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Lr(){let e=b();return P({mutationFn:({provider:e,profileId:t})=>te(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:G.agentProfiles}),e.invalidateQueries({queryKey:G.providerStatus}),L(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:W.health}),e.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Rr(){let e=b();return P({mutationFn:e=>de(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(G.agentAccountStatus(n),t),e.invalidateQueries({queryKey:G.agentProfiles}),L(e,t.status.provider)}})}function zr(){let e=b();return P({mutationFn:e=>_t(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Br(){let e=b();return P({mutationFn:e=>ke(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Vr({enabled:e}){return x({queryKey:G.githubOwners,queryFn:({signal:e})=>St({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Hr(){let e=b();(0,M.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(W.health);r&&(s({bootProject:r.bootProject??`default`,apiBase:n()}),t??=_r(`health`,t=>{e.setQueryData(W.health,t)}))};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),re()}},[e])}function Ur(){return x({queryKey:W.health,queryFn:({signal:e})=>ut({signal:e})})}function Wr(e,t){let n=Ur().data,r=xr(t).data?.projects,i=Ie(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?pr(n?.repo?.remote):void 0}function Gr(){return x({queryKey:G.uiState,queryFn:({signal:e})=>ft({signal:e})})}function Kr(){return x({queryKey:G.config,queryFn:({signal:e})=>Re({signal:e})})}function qr(){return x({queryKey:G.agentProfiles,queryFn:({signal:e})=>i({signal:e})})}var J=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>[e.cacheScope,`runs`,`detail`,e.runId],Z=e=>typeof e==`function`?e():e;function Jr(e){let{seenAt:t,...n}=e;return n}function Yr(e,t){let n=Jr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Xr(e,t,n){return t?{...e,seenAt:n}:Jr(e)}function Zr(e){let t=()=>{e.invalidateQueries({queryKey:J})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=we(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:Y(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let i=e.getQueryData(Y(Z(n))),a=e.getQueryData(X(Z(n))),o=Z(n).runId,s=new Date().toISOString();return e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Xr(e,r,s):e)),e.setQueryData(X(Z(n)),e=>e&&Xr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(Y(Z(n)),i),a&&e.setQueryData(X(Z(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Yr(e,t):e)),a&&e.setQueryData(X(Z(n)),e=>e&&Yr(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Xr(e,r,i.seenAt):e;e.setQueryData(Y(Z(n)),e=>e?.map(a));let s={...Z(n),runId:r?o:i.id};e.setQueryData(X(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:J});let i=e.getQueryData(J),a=r();return e.setQueryData(J,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(J,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function Q(){let e=b();return(0,M.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Vt(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),gt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function $(e,t,n,r){let i=b(),a=JSON.stringify(t),o=(0,M.useMemo)(()=>JSON.parse(a),[a]);(0,M.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=Qr({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function $r(e,t=!1){return Rt(await y.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),fe(e,`/worker-destroy`))}function ei(){return x({queryKey:W.openTargets,queryFn:({signal:e})=>Lt({signal:e}),staleTime:5*6e4})}function ti(){return x({queryKey:W.runs.list(),queryFn:({signal:e})=>a(F(),{signal:e})})}function ni(e,t){return vt({queryKey:W.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ct({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function ri(e){let t=e.trim();return x({queryKey:G.runsSearch(t),queryFn:({signal:e})=>Se(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function ii(e=!0,t=Sn,n){let r=Tn(b());return $(`/api/v1/workspace/runs-index`,G.runsIndex,K(e?t:!1),En),x({queryKey:G.runsIndex,queryFn:({signal:e})=>tt({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return P({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:W.runs.relationships(e)})})}function oi(e,t={}){return x({queryKey:W.runs.relationships(e),queryFn:({signal:t})=>rt(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return x({queryKey:W.runs.detail(e??``),queryFn:({signal:t})=>Be(I(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return x({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Be(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function li(e,t){return x({queryKey:t?[t,`runs`,`diff`,e??``]:W.runs.diff(e??``),queryFn:({signal:n})=>jt(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ui(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,W.runs.changes(e??``),K(t?4e3:!1)),x({queryKey:W.runs.changes(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return x({queryKey:W.runs.file(e??``,t??``),queryFn:({signal:n})=>be(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return x({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Ot(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return x({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ze(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return x({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Ye(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return x({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Fe(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function gi(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,W.runs.commits(e??``),K(t?5e3:!1)),x({queryKey:W.runs.commits(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return x({queryKey:W.runs.commit(e??``,t??``),queryFn:({signal:n})=>ve(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return x({queryKey:W.runs.handoff(e??``),queryFn:({signal:t})=>p(I(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return x({queryKey:e===void 0?W.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>p(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let n=[...new Set(e)],i=N({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>Tt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function xi(e){let t=b();return P({mutationFn:t=>ce(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Si(e){let t=b();return P({mutationFn:t=>me(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>v(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function wi(){let e=Q();return P({mutationFn:e=>v(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return P({mutationFn:({id:t,pinned:n})=>zt(I(t,e),n),onError:e=>lt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return P({mutationFn:n=>De(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof g&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return P({mutationFn:(n={})=>pt(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return P({mutationFn:({msgId:t,message:n})=>We(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function ki(e){let t=b();return P({mutationFn:t=>Te(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ai(){return x({queryKey:W.workflows,queryFn:({signal:e})=>u({signal:e})})}function ji(e){return x({queryKey:e?[e,`repo`]:W.repo,queryFn:({signal:t})=>ze({signal:t},e)})}function Mi(e){return x({queryKey:[e,`repo`],queryFn:({signal:t})=>ze({signal:t},e)})}function Ni(){return x({queryKey:W.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return x({queryKey:W.repoChanges,queryFn:({signal:e})=>he({signal:e}),retry:!1})}function Fi(e){return x({queryKey:W.repoCommit(e??``),queryFn:({signal:t})=>c(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e){return x({queryKey:e?[e,`config`]:W.config,queryFn:({signal:t})=>Pt({signal:t,...e?{projectId:e}:{}})})}function Li(){return x({queryKey:W.worktrees,queryFn:({signal:e})=>le({signal:e})})}function Ri(e){return x({queryKey:[e,`worktrees`],queryFn:({signal:t})=>le({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>f({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:pe(e.sidebarLimits)},enabled:t})}function Bi(){return zi(r())}function Vi(){return x({queryKey:W.agentConfig,queryFn:({signal:e})=>ot({signal:e})})}function Hi(e){return x({queryKey:W.agentConfigFile(e??``),queryFn:({signal:t})=>Xe(e,{signal:t}),enabled:e!==null})}function Ui(){return x({queryKey:W.sessionContext,queryFn:({signal:e})=>ye({signal:e})})}function Wi(e,t,n=``){return x({queryKey:W.sessionContextPreview(e,t,n),queryFn:({signal:n})=>$e({content:e,role:t},{signal:n}),placeholderData:At,staleTime:0,retry:!1})}function Gi(){let e=b();return P({onMutate:()=>({fileKey:W.sessionContext}),mutationFn:e=>m(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=W.agentConfig,r=W.agentConfigFile(e);return P({mutationFn:t=>se(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=A([`passing`,`failing`,`pending`]).nullable(),Ji=S({kind:A([`issue`,`pr`]),number:j(),title:O(),author:O(),createdAt:O(),labels:E(O()),body:O().optional(),url:O(),comments:j(),assignees:E(O()).optional(),projectIds:E(O()).optional(),isDraft:D().optional(),additions:j().optional(),deletions:j().optional(),checks:qi.optional()});C(`available`,[S({available:T(!0),item:Ji.nullable(),labelColors:w(O(),O()).optional()}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),number:Bt().int().positive().safe()});var Yi=S({id:O(),title:O(),url:O()});S({available:D(),reason:O().optional(),repo:O().optional(),syncedAt:O().optional(),issues:E(Ji),prs:E(Ji),labelColors:w(O(),O()).optional(),viewerLogin:O().optional(),projects:E(Yi).optional(),projectsReason:O().optional(),projectsState:A([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:O().optional(),issuesTotal:j().int().nonnegative().optional(),prsTotal:j().int().nonnegative().optional(),issuesNextCursor:O().nullable().optional(),prsNextCursor:O().nullable().optional(),commentsDeferred:T(!0).optional()});var Xi=O().min(1).max(2e3).optional();S({limit:O().optional(),refresh:O().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),S({kind:A([`issue`,`pr`]),numbers:O().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),C(`available`,[S({available:T(!0),counts:w(j(),j().int().nonnegative())}),S({available:T(!1),reason:O()})]),C(`available`,[S({available:T(!0),checks:w(j(),qi)}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),q:O().trim().min(1).max(256),limit:Bt().int().positive().max(50).optional()}),S({available:D(),projectsReason:O().optional(),reason:O().optional(),items:E(Ji),truncated:D().optional(),labelColors:w(O(),O()).optional()});var Zi=j().nullable();C(`available`,[S({available:T(!0),prs:w(j(),Pe),issues:w(j(),Pe),conflicts:E(j()).optional(),recheckAfterMs:Zi}),S({available:T(!1),reason:O(),recheckAfterMs:Zi})]);var Qi=S({id:j(),author:O(),avatarUrl:O().optional(),createdAt:O(),body:O(),kind:A([`comment`,`review`]),reviewState:A([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:O()}),$i=A([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=S({id:O(),kind:$i,actor:O(),avatarUrl:O().optional(),createdAt:O(),url:O().optional(),sha:O().optional(),message:O().optional(),checks:qi.optional(),label:S({name:O(),color:O().optional()}).optional(),subject:O().optional(),refNumber:j().optional(),refTitle:O().optional(),refIsPr:D().optional()});S({available:D(),reason:O().optional(),comments:E(Qi),truncated:D().optional(),events:E(ea).optional(),detail:S({body:O(),additions:j().int().nonnegative().optional(),deletions:j().int().nonnegative().optional()}).optional()});var ta=A([`merge`,`squash`,`rebase`]),na=S({name:O(),state:A([`passing`,`failing`,`pending`,`unknown`]),required:D().nullable(),url:O().optional()}),ra=S({number:j(),title:O(),url:O(),state:A([`open`,`closed`,`merged`]),isDraft:D(),headRef:O(),baseRef:O(),headSha:O(),mergeable:A([`mergeable`,`conflicting`,`unknown`]),reviewDecision:A([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:E(na),methods:E(ta),defaultMethod:ta.nullable(),eligibility:A([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:E(S({code:O(),message:O()})),canMerge:D(),canOverride:D()});C(`available`,[S({available:T(!0),mergeState:ra}),S({available:T(!1),reason:O()})]),S({merged:T(!0),number:j(),url:O(),method:ta,mergeCommitSha:O().optional()});var ia=S({path:O(),previousPath:O().optional(),status:A([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:j(),deletions:j(),patch:O().optional(),patchUnavailableReason:A([`binary`,`too-large`,`not-provided`]).optional(),truncated:D().optional()});C(`available`,[S({available:T(!0),number:j(),headSha:O(),files:E(ia),additions:j(),deletions:j(),truncated:D(),reason:O().optional()}),S({available:T(!1),reason:O()})]),S({generation:O().uuid()}),C(`state`,[S({generation:O().uuid(),state:T(`ready`),projects:E(Yi),membership:w(O(),E(O()))}),S({generation:O().uuid(),state:T(`unavailable`),reason:O()})]);function aa(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function oa(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function sa(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function ca(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){sa(t.issues,a,r),sa(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var la=e=>e.map(e=>e.number).join(`,`);function ua(e,t){let n=e[0];if(e.length>1&&n&&(la(n.issues)!==la(t.issues)||la(n.prs)!==la(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function da(e={},t=!0){let n=b(),i=W.github(e);$(`/api/v1/p/${r()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,K(t?6e4:!1));let a=x({queryKey:W.github(e),queryFn:({signal:t})=>xe({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),o=a.data?.projectsGeneration,s=x({queryKey:[...i,`projects`,o],queryFn:({signal:e})=>Oe(o,{signal:e}),enabled:t&&a.data?.projectsState===`refreshing`&&!!o,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!o||!s.data&&!s.error||n.setQueryData(i,e=>{if(!e||e.projectsGeneration!==o||e.projectsState!==`refreshing`)return e;let t=s.data;return t?.generation&&t.generation!==o?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[n,o,s.data,s.error,i]),a}var fa=class extends Error{};function pa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await xe({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new fa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof fa)&&!(t instanceof g&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ma(e=50,t=!0){let n=b(),i=W.githubPages(e),a=W.githubPagesHead(e);$(`/api/v1/p/${r()}/github?limit=${e}`,a,K(t?6e4:!1));let o=vt({...pa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=x({queryKey:a,queryFn:({signal:t})=>xe({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,M.useEffect)(()=>{if(!s.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=ua(e.pages,s.data);t===`refetch`?c():n.setQueryData(i,{...e,pages:t})},[n,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=N({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Oe(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{u.forEach((e,t)=>{let r=l[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return n?{...t,pages:i}:t})})},[n,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,M.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ha(e,t=50,n=!0){let r=vt({...pa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ga(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:W.githubCommentCounts(e,t),queryFn:({signal:n})=>_(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function _a(e,t,n,r=!0){return x({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ue(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function va(e,t=!0){return x({queryKey:W.githubChecks(e),queryFn:({signal:t})=>Ee(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function ya(e,t,n=!0){return x({queryKey:W.githubSearch(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ba=100;function xa(e){return[...e].sort((e,t)=>t-e).slice(0,ba).sort((e,t)=>e-t)}function Sa(){let e=Ie(),t=Ur();return e.projectId??t.data?.bootProject}function Ca(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))tr(U({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))tr(U({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var wa=5*6e4;function Ta(e){return e?e.recheckAfterMs:wa}function Ea(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:xa(t.prs),issues:xa(t.issues)}))},[e.map(U).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:W.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>je(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ta(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),i=b(),a=JSON.stringify(n.map((e,t)=>({...e,interval:Ta(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||fr())return;let e=!0,n=JSON.parse(a).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=W.githubRefStatus(t.projectId,t.prs,t.issues);return Qr({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,a,i]);let o=(0,M.useMemo)(()=>dr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=U(e),n=o.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...H.has(t)?{conflicting:!0}:{}}},[o])}function Da(e,t,n=!0){return x({queryKey:W.githubComments(e,t),queryFn:({signal:n})=>ne(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e,t,n=!0){return x({queryKey:W.githubItem(e,t),queryFn:({signal:n})=>ht(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ka(e){return x({queryKey:W.githubPrChanges(e??0),queryFn:({signal:t})=>ee(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{li as $,Vn as $t,Ai as A,br as At,fi as B,hr as Bt,ji as C,vr as Ct,Ui as D,Pr as Dt,Fi as E,Cr as Et,hi as F,kr as Ft,Si as G,G as Gt,wi as H,K as Ht,bi as I,Kr as It,ki as J,qn as Jt,Ti as K,Yn as Kt,Di as L,Gr as Lt,ni as M,jr as Mt,pi as N,Nr as Nt,Wi as O,wr as Ot,mi as P,Tr as Pt,gi as Q,B as Qt,ai as R,_r as Rt,Gi as S,xr as St,Pi as T,yr as Tt,xi as U,fr as Ut,Ci as V,pr as Vt,ei as W,W as Wt,ui as X,Wn as Xt,si as Y,Hn as Yt,_i as Z,Bn as Zt,Ii as _,Sr as _t,Da as a,L as an,ri as at,Ri as b,Hr as bt,ka as c,Zt as cn,Qr as ct,_a as d,P as dn,qr as dt,Kn as en,di as et,Sa as f,N as fn,zr as ft,Hi as g,Or as gt,Vi as h,Br as ht,ga as i,Tn as in,ii as it,Li as j,Fr as jt,Bi as k,Ar as kt,ya as l,F as ln,Q as lt,oa as m,Wt as mn,Mr as mt,da as n,Un as nn,oi as nt,Oa as o,en as on,Ei as ot,Ea as p,Gt as pn,Lr as pt,ci as q,Zn as qt,va as r,zn as rn,ti as rt,ma as s,Qt as sn,yi as st,Ca as t,Gn as tn,vi as tt,ha as u,I as un,Ir as ut,Mi as v,Vr as vt,Ni as w,Rr as wt,Ki as x,Wr as xt,zi as y,Ur as yt,Oi as z,mr as zt};
@@ -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,s as a}from"./dist-C_rn70hE.js";import{C as o,E as s,T as c,W as l,Wt as u,dn as d,j as f,n as p,qt as m,rt as h,w as g,xt as _,yt as ee}from"./queries-CII6fTHH.js";import{Fn as v,It as y,L as b,R as x,ct as S,f as C,hi as w,l as T,n as E}from"./toaster-Bs1mVYf9.js";import{Z as D}from"./live-protocol-DMhTnCmf.js";import{g as O,h as k}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as A}from"./tasks-table-CPAY1N-E.js";import{D as te,I as ne,M as re,N as j,Q as M,S as ie,X as ae,Z as oe,c as se,ct as N,d as ce,j as le,l as ue,n as de,st as fe,w as pe,y as me}from"./design-icons-QbNMZniQ.js";import{t as he}from"./createLucideIcon-BHp8sXmF.js";import{n as ge,t as _e}from"./circle-x-7nTlobAF.js";import{_ as ve}from"./nav-row-styles-CgP5uNp4.js";import{i as ye,r as be,t as xe}from"./git-toolbar-BUGct09v.js";import{t as P}from"./info-DA1x_4bz.js";import{t as Se}from"./loader-circle-CPBhhDbB.js";import{i as Ce,n as we,r as Te}from"./diff-controls-CP2nphAy.js";import{c as Ee,i as De,t as Oe}from"./reference-chip-Cv3i1kxz.js";import{t as F}from"./button-C8jUIs8Q.js";import{i as I,l as ke,p as Ae,r as je,t as Me}from"./dropdown-menu-DjtKUK8F.js";import{t as L}from"./project-router-onKnSy5a.js";import{t as Ne}from"./status-dot-BXf-Ubd0.js";import{c as Pe,d as Fe,f as Ie,m as R,n as Le,s as Re,t as ze}from"./page-shell-Dky5crRl.js";import{a as Be,o as Ve}from"./format-BU7D3IfE.js";import{t as z}from"./centered-state-BgSV4e79.js";import{$t as B,Bt as V,E as H,Ft as He,Gt as Ue,Ht as We,In as Ge,It as Ke,Jt as U,Kt as W,Ln as qe,Lt as Je,Mn as Ye,Mt as Xe,Nt as Ze,Pt as Qe,Qt as G,Rn as $e,Rt as et,T as tt,Ut as nt,Vt as rt,Wt as it,Xt as K,Yt as q,Zt as J,_r as at,gn as ot,qt as Y,rr as st,ur as ct,yr as lt,zt as ut}from"./index-TFU1q5Sa.js";import{t as dt}from"./markdown-BBDDg-4t.js";import{t as ft}from"./diff-DNdhxMzq.js";import{t as pt}from"./change-counts-wqSYI3W8.js";import{t as mt}from"./code-workbench-CUkiQ1pF.js";import{i as ht,n as gt,r as _t}from"./commit-list-dNvEgOHg.js";var X=e(t(),1);function vt(e,t){let n=w(t),r=n.getQueryCache();return X.useSyncExternalStore(X.useCallback(e=>r.subscribe(D.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var yt=he(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),bt=he(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Z=n();function xt(){let e=i(),t=o(),n=w(),a=vt({queryKey:u.repo})>0,s=t.data?.info?t.data:null,c=Xe(e,s,`screen`);return(0,Z.jsx)(Fe,{route:`repo-git`,density:s?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,Z.jsx)(Pe,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:a,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,Z.jsx)(oe,{size:17,"aria-hidden":`true`,className:r(`size-[17px]`,a&&`motion-safe:animate-spin`)})})},children:(0,Z.jsxs)(`div`,{"data-slot":`git-screen`,children:[s?.info?(0,Z.jsx)(`div`,{className:`mb-[16px]`,children:(0,Z.jsx)(He,{scope:e,repo:s,info:s.info,variant:`screen`},e)}):t.isPending?(0,Z.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,Z.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,Z.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,Z.jsx)(Ze,{branch:s?.info?.branch??null,counts:c,variant:`screen`})]})})}function St({entry:e}){return e.keptReason?(0,Z.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Ct(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function wt({repo:e,info:t}){let n=i(),a=[n,`repo`],o=[n,`health`],s=ee(),c=g(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=w(),f=d({mutationFn:e=>T({name:e},n),onSuccess:async e=>{E(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:a}),u.invalidateQueries({queryKey:o})]),u.setQueryData(a,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>Je(t,n,e.branch))},onError:e=>E(e.message,{tone:`danger`})}),[p,m]=(0,X.useState)(``),[h,_]=(0,X.useState)(``),v=h.trim().toLowerCase(),y=At(e,c.data?.branches),b=v?y.filter(e=>e.toLowerCase().includes(v)):y,x=p.trim(),S=Ct(x);return(0,Z.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,Z.jsxs)(`label`,{className:`relative block`,children:[(0,Z.jsx)(M,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,Z.jsx)(st,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>_(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,Z.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[b.map(e=>{let n=e===t.branch,i=l.get(e);return(0,Z.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[i?.runId?(0,Z.jsx)(L,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,Z.jsx)(`span`,{className:r(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,Z.jsx)(kt,{entry:i}):null]}),i?(0,Z.jsx)(St,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,Z.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,Z.jsxs)(F,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:f.isPending,onClick:()=>f.mutate(e),children:[(0,Z.jsx)(le,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),b.length===0?(0,Z.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,h.trim(),`”.`]}):null]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,Z.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=x;!t||S||f.mutate(t,{onSuccess:()=>m(``)})},children:[(0,Z.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,Z.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,Z.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:t.branch}),`.`]}),(0,Z.jsx)(st,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-soft-foreground`,value:p,"aria-invalid":S?!0:void 0,"aria-describedby":S?`new-branch-name-hint`:void 0,onChange:e=>m(e.target.value)}),S?(0,Z.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":`branch-name-hint`,role:`alert`,className:`-mt-1 text-xs text-danger`,children:S}):null,(0,Z.jsxs)(F,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!x||S!==null||f.isPending,children:[(0,Z.jsx)(ae,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,Z.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,Z.jsx)(Tt,{}):null]})}function Tt(){let e=p({limit:20});return(0,Z.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,Z.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,Z.jsx)(Et,{pr:e},e.number))}):(0,Z.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function Et({pr:e}){let t=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[`#`,e.number]}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,Z.jsx)(Dt,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,Z.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:a(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:r(n,`hover:bg-muted`),children:t}):(0,Z.jsx)(`span`,{className:n,children:t})})}function Dt({checks:e}){let t=e===`passing`?ge:e===`failing`?_e:at;return(0,Z.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:r(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,Z.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ot={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function kt({entry:e}){return(0,Z.jsx)(`span`,{"data-slot":`branch-class`,className:r(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ot[e.class]})}function At(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function jt(){let e=c(),t=R(),[n,r]=(0,X.useState)(`unified`),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),d=(0,X.useRef)(null),f=e.isError&&e.error instanceof v&&e.error.status===409,p=e.data?.files??[],m=(0,X.useMemo)(()=>be(p),[p]),h=(0,X.useMemo)(()=>p.some(dt),[p]),g=t?n:`unified`;return(0,Z.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(z,{icon:f?(0,Z.jsx)(pe,{size:16}):(0,Z.jsx)(N,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,Z.jsx)(z,{icon:(0,Z.jsx)(pe,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,Z.jsx)(xe,{stat:e.data.stat}):null,(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,Z.jsx)(Te,{}):null,h?(0,Z.jsx)(Ce,{preview:o,onPreviewChange:s}):null,(0,Z.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,Z.jsx)(we,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o})})]})]}),(0,Z.jsx)(mt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(ye,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),children:(0,Z.jsx)(ft,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})})]})})}function Mt({repo:e,info:t}){let{sha:n}=k(),r=R(),i=e.log,a=(0,X.useMemo)(()=>Ue(i),[i]);if(n&&(!r||i.length===0))return(0,Z.jsx)(Lt,{sha:n});let o=rt(e,t),s=o&&o.behind>0?(0,Z.jsx)(Ft,{info:t,tracking:o}):null;if(i.length===0)return(0,Z.jsxs)(Z.Fragment,{children:[s?(0,Z.jsx)(`div`,{children:s}):null,(0,Z.jsx)(z,{icon:(0,Z.jsx)(re,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,Z.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,Z.jsx)(Nt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,Z.jsx)(mt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,Z.jsx)(It,{sha:n??i[0]?.hash})}):c}function Nt({commit:e,selected:t,stacked:n}){return(0,Z.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:r(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,Z.jsxs)(L,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Z.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(gt,{sha:e.hash}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,Z.jsx)(`span`,{title:it(e.when,e.at),children:nt(e.when,e.at)})]})]})]}),(0,Z.jsx)(Pt,{source:e.source,stacked:n})]})}function Pt({source:e,stacked:t}){let n=r(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,Z.jsxs)(L,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:r(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,Z.jsx)(se,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,Z.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Ft({info:e,tracking:t}){let n=et(i(),e),r=(0,X.useRef)(null);return(0,Z.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,Z.jsx)(yt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,Z.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,Z.jsx)(Se,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Z.jsx)(de,{"aria-hidden":`true`}),`Pull`]}),(0,Z.jsx)(Ke,{checkout:n,returnFocus:r})]})}function It({sha:e}){return(0,Z.jsx)(ht,{commit:s(e),sha:e,slot:`repo-commit-preview`})}function Lt({sha:e}){return(0,Z.jsx)(_t,{commit:s(e),sha:e,backTo:ut,backLabel:`All recent commits`,slot:`repo-commit`})}var Rt=`Squash-merged branches may show as not landed without GitHub`;function zt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function Bt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function Vt(){let e=g(),t=h(),n=i(),r=_(),[a,o]=(0,X.useState)(null);if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,Z.jsx)(z,{icon:(0,Z.jsx)(N,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=zt(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=Bt(e.data.branches),u=l>0?(0,Z.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,Z.jsx)(P,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,Z.jsx)(L,{to:V.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,Z.jsxs)(De,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,Z.jsx)(Ht,{}),u,s.length===0?(0,Z.jsx)(ze,{icon:(0,Z.jsx)(ct,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:V.cleanup,children:`Check cleanup`})}),(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:`/`,children:`View tasks`})})]})}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{children:e.note})]}):null]}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,Z.jsx)(Ut,{entry:e,finishedAt:e.runId?d.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,Z.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,Z.jsx)(P,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,Z.jsx)(Le,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,Z.jsx)(F,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(L,{to:V.cleanup,children:`Open cleanup`})})}):null]})]}),(0,Z.jsx)(Jt,{entry:a,onClose:()=>o(null)})]})}function Ht({className:e}){return(0,Z.jsxs)(`p`,{"data-slot":`git-no-forge`,className:r(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,Z.jsx)(P,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),Rt,`.`]})}function Ut({entry:e,finishedAt:t,onDelete:n}){return(0,Z.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Z.jsx)(Kt,{entry:e,finishedAt:t}),(0,Z.jsx)(Wt,{entry:e}),(0,Z.jsx)(Gt,{entry:e,onDelete:n})]})}function Wt({entry:e}){return(0,Z.jsx)(Z.Fragment,{children:e.pr?(0,Z.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,Z.jsx)(Oe,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,Z.jsx)(qt,{entry:e})]}):null})}function Gt({entry:e,onDelete:t}){let n=w(),i=e.class===`orphan`,a=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!i&&e.runId!==null&&!a,s=d({mutationFn:()=>S(e.runId),onSuccess:e=>{E(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>E(e instanceof v&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,X.useState)(!1),f=(0,X.useRef)(null);(0,X.useEffect)(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]);let p=()=>void navigator.clipboard.writeText(e.name).then(()=>{E(`Copied ${e.name}`),f.current!==null&&clearTimeout(f.current),l(!0),f.current=setTimeout(()=>l(!1),2e3)},()=>E(`Could not copy the branch name`,{tone:`danger`})),m=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,Z.jsxs)(Z.Fragment,{children:[e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:r(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:r(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,Z.jsx)(bt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,i?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:p,className:r(m,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,Z.jsx)(ue,{"aria-hidden":`true`}):(0,Z.jsx)(me,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,Z.jsxs)(Me,{children:[(0,Z.jsx)(Ae,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,Z.jsx)(ie,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,Z.jsxs)(je,{align:`end`,className:`w-52`,children:[e.runId?(0,Z.jsx)(I,{asChild:!0,className:`md:hidden`,children:(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,Z.jsx)(I,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,Z.jsx)(I,{className:r(!i&&`md:hidden`),onSelect:p,children:`Copy branch`}),(0,Z.jsx)(ke,{className:`md:hidden`}),(0,Z.jsx)(I,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Kt({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Be(i),o=e.runStatus?Ye(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,Z.jsx)(ve,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,Z.jsx)(Ne,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,Z.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,Z.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,Z.jsx)(Q,{}),(0,Z.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(pt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,Z.jsx)(L,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,Z.jsx)(St,{entry:e})]})]})}function Q(){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function qt({entry:e}){let t=m(Ee(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Q,{}),(0,Z.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Jt({entry:e,onClose:t}){let n=w(),[r,i]=(0,X.useState)(``),a=(0,X.useId)(),o=d({mutationFn:e=>C({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;E(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:u.repo}),s()},onError:e=>E(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,Z.jsx)(W,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,Z.jsxs)(q,{"data-slot":`delete-branch-dialog`,children:[(0,Z.jsxs)(G,{children:[(0,Z.jsxs)(B,{children:[`Delete `,e?.name,`?`]}),(0,Z.jsx)(K,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,Z.jsxs)(Z.Fragment,{children:[`This drops the work of `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,Z.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,Z.jsxs)(Z.Fragment,{children:[` (`,(0,Z.jsx)($e,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,Z.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,Z.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,Z.jsx)(st,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(U,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,Z.jsx)(Y,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Yt({base:e}){let t=g(),n=w(),[r,i]=(0,X.useState)({merged:!1,empty:!1}),[a,o]=(0,X.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],f=d({mutationFn:e=>C({names:e}),onSuccess:e=>{let t=e.refused.length;E(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:u.repo})},onError:e=>{n.invalidateQueries({queryKey:u.repo}),E(e.message,{tone:`danger`})}});if(t.isPending)return(0,Z.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,Z.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,Z.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,Z.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(fe,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,Z.jsx)(Xt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:Rt.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,Z.jsx)(Xt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,Z.jsx)(W,{open:a,onOpenChange:o,children:(0,Z.jsxs)(q,{children:[(0,Z.jsxs)(G,{children:[(0,Z.jsxs)(B,{children:[`Delete `,p,` `,m,`?`]}),(0,Z.jsxs)(K,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(U,{children:`Keep them`}),(0,Z.jsxs)(Y,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Xt({kind:e,title:t,hint:n,rows:i,open:a,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,Z.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":s,disabled:i.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,i.length]}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),i.length>0?(0,Z.jsx)(ce,{"aria-hidden":`true`,className:r(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,a&&`rotate-90`)}):null]}),a?(0,Z.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:i.map(e=>(0,Z.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,Z.jsx)(Ge,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,Z.jsx)(L,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,Z.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,Z.jsx)(qe,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function Zt(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function Qt(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function $t(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function en(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function tn(e,t){return e===0?`Reclaim now`:t?`Reclaim ${A(t)} now`:`Reclaim ${e} now`}function nn(e,t,n){let r=t?A(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function rn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function an(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function on({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,Z.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${A(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,$t(e),`.`]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?nn(o.length,f,m):``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(W,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(q,{children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(B,{children:`Reclaim old worktrees?`}),(0,Z.jsxs)(K,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${A(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(U,{children:`Keep them`}),(0,Z.jsx)(Y,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,Z.jsx)(W,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,Z.jsxs)(q,{children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(B,{children:`Discard changes and reclaim worktrees?`}),(0,Z.jsx)(K,{children:o?(0,Z.jsxs)(Z.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${A(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(U,{children:`Keep them`}),(0,Z.jsx)(Y,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,Z.jsx)(W,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(q,{children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(B,{children:`Discard changes and reclaim worktree?`}),(0,Z.jsx)(K,{children:l?.reclaimBlocker?(0,Z.jsxs)(Z.Fragment,{children:[l.title,` has `,Qt(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(U,{children:`Keep it`}),(0,Z.jsx)(Y,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function cn(){let e=f(),t=l().data?.targets.find(e=>e.id===`finder`),n=d({mutationFn:e=>y(e,t.id),onError:e=>E(e.message,{tone:`danger`})}),r=w(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),[c,p]=(0,X.useState)(null),m=()=>Promise.all([r.invalidateQueries({queryKey:u.worktrees}),r.invalidateQueries({queryKey:u.repoBranches})]),h=d({mutationFn:({runIds:e})=>x(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),E(en(e.reclaimed.length,t,!!n))},onError:e=>E(e.message,{tone:`danger`})}),g=d({mutationFn:({worktree:e,discardWork:t})=>b(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),E(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),E(e.message,{tone:`danger`})}});if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,Z.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:_,totalBytes:ee,keep:v}=e.data,S=h.isPending||g.isPending,C=_.filter(e=>e.pastKeep),T=C.filter(e=>!e.reclaimBlocker),D=C.filter(e=>e.reclaimBlocker!==null),O=T.length>0,k=$(T),te=$(C),ne=tn(T.length,k),re=nn(C.length,te,O),j=ee?A(ee):null,M=an(v);return(0,Z.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,j?` · ${j}`:``]}),(0,Z.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[M.prefix,(0,Z.jsx)(L,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ot(`worktrees`,` › `)}),M.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:S||!O,title:rn(O,D.length),onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[12px]`}),ne]})]}),D.length>0?(0,Z.jsx)(on,{blocked:D,discardLabel:re,disabled:S,onDiscard:()=>s(C)}):null,_.length===0?(0,Z.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,Z.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:_.map(e=>(0,Z.jsx)(dn,{worktree:e,keep:v,disabled:S,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,Z.jsx)(sn,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:T.length,cleanBytes:k,reclaimLabel:ne,onConfirmClean:()=>{h.mutate({expected:T.length}),a(!1)},discardBatch:o,onCloseDiscardBatch:()=>s(null),onConfirmDiscardBatch:e=>{h.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:c,onCloseRow:()=>p(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var ln=new Set([`queued`,`running`,`waiting`,`review`]);function un(e,t){return ln.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:Zt(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function dn({worktree:e,keep:t,disabled:n,onOpen:i,opening:a,onReclaim:o}){let s=un(e,t),c=Be(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Ve(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${Qt(e.reclaimBlocker)}`:void 0,f=(0,Z.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:r(`text-xs`,u),children:s.label}),p=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,Z.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,Z.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,Z.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:A(e.sizeBytes)||`0 kB`}),(0,Z.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),i?(0,Z.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:a,onClick:i,children:(0,Z.jsx)(te,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,Z.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:r(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,Z.jsx)(lt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function fn(e){return e===`main`||e===`changes`?`Split`:`Table`}function pn({section:e,index:t=!1}){let n=o(),r=R(),[i]=O(),a=fn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,Z.jsx)(xt,{});if(n.isPending)return(0,Z.jsx)(tt,{});if(n.isError)return(0,Z.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(H,{}),children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(N,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,Z.jsx)(mn,{repo:n.data,info:s,section:e}):(0,Z.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(H,{}),children:(0,Z.jsx)(z,{icon:(0,Z.jsx)(le,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function mn({repo:e,info:t,section:n}){let r=fn(n),i=g(),a=hn(n),o=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?At(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,Z.jsx)(Re,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Ie(o),rootProps:{"data-git-section":n},beforeHeader:(0,Z.jsx)(H,{}),header:{title:a?.title??Qe(n,t.branch),headerSlot:`repo-header`,subtitle:a?(0,Z.jsxs)(Z.Fragment,{children:[`Commit `,a.shortSha,` on `,t.branch]}):(0,Z.jsx)(gn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,Z.jsx)(Mt,{repo:e,info:t}):n===`not-landed`?(0,Z.jsx)(Vt,{}):n===`cleanup`?(0,Z.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,Z.jsx)(cn,{}),(0,Z.jsx)(Yt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,Z.jsx)(wt,{repo:e,info:t}):(0,Z.jsx)(jt,{})})}function hn(e){let{sha:t}=k(),n=R(),r=e===`main`&&!n?t:void 0,i=s(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function gn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,Z.jsxs)(Z.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${We(e.tracking)}`:``]});case`not-landed`:return(0,Z.jsxs)(Z.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,Z.jsx)(_n,{repo:e,info:t});case`changes`:return(0,Z.jsxs)(Z.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,Z.jsxs)(Z.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function _n({repo:e,info:t}){let n=At(e,g().data?.branches).length;return(0,Z.jsxs)(Z.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{pn as RepoGitRoute};
@@ -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}from"./dist-C_rn70hE.js";import{C as i,Wt as a,X as o,Y as s,dn as c,yt as l}from"./queries-CII6fTHH.js";import{Bt as u,Fn as d,Ft as f,Ht as p,Lt as m,Tt as h,at as g,ct as _,hi as v,n as y,tr as b}from"./toaster-Bs1mVYf9.js";import{h as x}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{M as S,u as C,w}from"./design-icons-QbNMZniQ.js";import{t as ee}from"./run-header-BIyS_qou.js";import{i as T,n as E,r as D}from"./git-toolbar-BUGct09v.js";import{t as O}from"./button-C8jUIs8Q.js";import{a as k,i as A,o as j,r as M,s as N,t as P}from"./dialog-DRZuXvul.js";import{b as F,f as I}from"./task-groups-dEzH1nMg.js";import{f as L,l as R,m as z}from"./page-shell-Dky5crRl.js";import{t as B}from"./centered-state-BgSV4e79.js";import{C as V,Q as H,S as U,ln as te,zn as W}from"./index-TFU1q5Sa.js";import{t as ne}from"./markdown-BBDDg-4t.js";import{t as G}from"./textarea-vEsJAUAV.js";import{t as K}from"./diff-DNdhxMzq.js";import{t as q}from"./code-workbench-CUkiQ1pF.js";var J=e(t(),1),Y=`no worktree — this task ran directly in the repo working tree`;function X(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.run.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${Y}`)}function Z(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.run.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${Y}`)}function re(e){let t=e=>({id:`create-pr`,label:`Draft PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Draft PR unavailable — ${Y}`):e.forge===null?t(`Draft PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?b(e.run)?t(`Draft PR unavailable — the run is waiting on a usage-limit hold; choose Don’t resume first`):F(e.run)?t(`Draft PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Draft PR`,enabled:!0}:t(`Draft PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function ie(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:X(e),n=e.prUrl?[X(e),Z(e)]:[Z(e),re(e)],r=[];if(e.localHandoff&&e.cliHandoff!==!1){let t=e.hasSession?F(e.run)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var Q=n();function $({run:e,open:t,onOpenChange:n}){let r=v(),[i,o]=(0,J.useState)(``),s=I(e),l=(0,J.useRef)(s);l.current=s,(0,J.useEffect)(()=>{t&&o(l.current)},[t]);let u=c({mutationFn:t=>g(e.id,t),onSuccess:t=>{y(`Committed ${W(t.sha)}`),n(!1),r.invalidateQueries({queryKey:a.runs.changes(e.id)}),r.invalidateQueries({queryKey:a.runs.all})},onError:e=>y(e.message,{tone:`danger`})}),d=()=>{let e=i.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Q.jsx)(P,{open:t,onOpenChange:n,children:(0,Q.jsxs)(M,{"data-slot":`commit-dialog`,children:[(0,Q.jsxs)(j,{children:[(0,Q.jsx)(N,{children:`Commit changes`}),(0,Q.jsxs)(A,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Q.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Q.jsx)(G,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{H({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())}}),(0,Q.jsxs)(k,{children:[(0,Q.jsx)(O,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,Q.jsx)(O,{"data-slot":`commit-confirm`,disabled:i.trim().length===0||u.isPending,onClick:d,children:u.isPending?`Committing…`:`Commit`})]})]})})}function ae(){let{id:e}=x(),t=s(e);return t.isPending?(0,Q.jsx)(V,{tab:`changes`}):t.isError?(0,Q.jsx)(U,{tab:`changes`,error:t.error}):(0,Q.jsx)(oe,{run:t.data})}function oe({run:e}){let t=l(),n=i(),r=o(e.id,F(e)),s=z(),[p,h]=(0,J.useState)(`unified`),[g,b]=(0,J.useState)(!0),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),[T,O]=(0,J.useState)(!1),k=(0,J.useRef)(null),A=v(),j=()=>A.invalidateQueries({queryKey:a.runs.all}),M=e=>y(e.message,{tone:`danger`}),N=c({mutationFn:()=>u(e.id),onSuccess:e=>y(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:M}),P=c({mutationFn:()=>_(e.id),onSuccess:e=>{y(`Draft PR created — ${e.url}`),j()},onError:M}),I=c({mutationFn:()=>m(e.id),onError:e=>{if(e instanceof d&&e.command){navigator.clipboard.writeText(e.command).then(()=>y(`No terminal found — command copied to clipboard.`)).catch(()=>y(`Run manually: ${e.command}`));return}M(e)}}),B=c({mutationFn:t=>f(e.id,t),onError:M}),V=r.isError&&r.error instanceof d&&r.error.status===409,H=ie({run:e,cliHandoff:e.cliHandoff,hasWorktree:!!e.worktreePath&&!V,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:te(e)!==void 0,prUrl:e.pullRequestUrl}),U=e=>{switch(e){case`commit`:O(!0);break;case`push`:N.mutate();break;case`create-pr`:P.mutate();break;case`open-terminal`:I.mutate();break;case`view-pr`:break}},W=r.data?.files??[],G=(0,J.useMemo)(()=>D(W),[W]),K=(0,J.useMemo)(()=>W.some(ne),[W]),q=s?p:`unified`;return(0,Q.jsxs)(R,{route:`task-changes`,density:L(W.length),flushPadding:!0,children:[(0,Q.jsx)(ee,{run:e,tab:`changes`}),(0,Q.jsx)(E,{bar:H,healthReady:t.data!==void 0,branch:e.branch,stat:r.data?.stat,mode:q,wrap:g,preview:x,onModeChange:h,onWrapChange:b,onPreviewChange:K?S:void 0,onAction:U}),r.data?.repointedHead?(0,Q.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,Q.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Q.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,(0,Q.jsx)(se,{changes:r,changesRefused:V,fileCount:W.length,children:(0,Q.jsx)(ce,{runId:e.id,files:W,tree:G,selected:C,selectFile:e=>{w(e),k.current?.scrollToPath(e)},diffRef:k,effectiveMode:q,effectiveWrap:g,preview:x,localHandoff:t.data?.capabilities.localHandoff,onOpenInApp:B.mutate})}),(0,Q.jsx)($,{run:e,open:T,onOpenChange:O})]})}function se({changes:e,changesRefused:t,fileCount:n,children:r}){return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,Q.jsx)(B,{icon:t?(0,Q.jsx)(w,{size:16}):(0,Q.jsx)(S,{size:16}),tone:t?`neutral`:`danger`,heading:`h2`,title:t?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):n===0?(0,Q.jsx)(B,{icon:(0,Q.jsx)(w,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):r}function ce({runId:e,files:t,tree:n,selected:i,selectFile:a,diffRef:o,effectiveMode:s,effectiveWrap:c,preview:l,localHandoff:u,onOpenInApp:d}){let[f,m]=(0,J.useState)(!1);return(0,Q.jsx)(q,{className:`px-4 pb-9 pt-0 [--diff-sticky-top:0px] md:px-9`,treeSlot:`changes-tree-pane`,treeClassName:`rounded-xl border border-border bg-card md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)] md:overflow-y-auto md:overscroll-contain md:p-3.5`,tree:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`changes-tree-toggle`,"aria-expanded":f,onClick:()=>m(e=>!e),className:`flex min-h-11 w-full items-center justify-between gap-2 px-3.5 py-2 text-left text-xs font-semibold text-foreground md:hidden`,children:[(0,Q.jsxs)(`span`,{children:[`Changed files`,` `,(0,Q.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]}),(0,Q.jsx)(C,{size:16,"aria-hidden":`true`,className:r(`size-4 shrink-0 text-muted-foreground motion-safe:transition-transform`,f&&`rotate-180`)})]}),(0,Q.jsx)(`h2`,{className:`mb-3 hidden border-b border-border pb-3 text-xs font-semibold md:block`,children:`Changed files`}),(0,Q.jsx)(`div`,{className:r(f?`border-t border-border px-3.5 py-3 md:border-t-0 md:p-0`:`hidden md:block`),children:(0,Q.jsx)(T,{root:n,selected:i,onSelect:e=>{a(e),m(!1)}})})]}),children:(0,Q.jsx)(K,{files:t,viewRef:o,mode:s,wrap:c,preview:l,loadFileText:t=>le(e,t),imageSrc:t=>p(e,t),onOpenInApp:u?e=>d(e):void 0,totals:!1,className:`min-w-0 flex-1`})})}async function le(e,t){try{let n=await h(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{ae as TaskChangesRoute};
@@ -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{Q as r,Wt as i,Y as a,Z as o,fn as s}from"./queries-CII6fTHH.js";import{Fn as c,St as l}from"./toaster-Bs1mVYf9.js";import{h as u}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{C as d,M as f}from"./design-icons-QbNMZniQ.js";import{t as p}from"./run-header-BIyS_qou.js";import{t as m}from"./project-router-onKnSy5a.js";import{b as h}from"./task-groups-dEzH1nMg.js";import{f as g,l as _,m as v}from"./page-shell-Dky5crRl.js";import{t as y}from"./centered-state-BgSV4e79.js";import{C as b,Rn as x,S}from"./index-TFU1q5Sa.js";import{t as C}from"./change-counts-wqSYI3W8.js";import{t as w}from"./code-workbench-CUkiQ1pF.js";import{i as T,r as E,t as D}from"./commit-list-dNvEgOHg.js";var O=e(t(),1),k=n();function A(){let{id:e}=u(),t=a(e);return t.isPending?(0,k.jsx)(b,{tab:`changes`}):t.isError?(0,k.jsx)(S,{tab:`changes`,error:t.error}):(0,k.jsx)(j,{run:t.data})}function j({run:e}){let{sha:t}=u(),n=r(e.id,h(e)),i=v(),a=t??n.data?.commits[0]?.sha,o=t!==void 0&&(!i||n.isError||n.data?.commits.length===0);return(0,k.jsxs)(_,{route:`task-commits`,density:g(n.data?.commits.length??0),flushPadding:!0,children:[(0,k.jsx)(p,{run:e,tab:`commits`}),o?(0,k.jsx)(N,{runId:e.id,sha:t}):n.isPending?(0,k.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading commits…`}):n.isError?(0,k.jsx)(y,{icon:(0,k.jsx)(f,{size:16}),tone:n.error instanceof c&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof c&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,k.jsx)(y,{icon:(0,k.jsx)(f,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,k.jsx)(M,{run:e,commits:n.data.commits,selectedSha:a})]})}function M({run:e,commits:t,selectedSha:n}){let r=o(e.id,n),i=F(e.id,t),a=(0,O.useRef)(null);return(0,k.jsx)(w,{className:`px-4 py-5 md:px-9`,treeSlot:`task-commits-pane`,tree:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(D,{slot:`task-commits`,selectedSha:n,heading:(0,k.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[t.length,` `,t.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:t.map(t=>({...t,href:`/tasks/${e.id}/commits/${t.sha}`,stat:i.get(t.sha)}))}),n&&r.data&&r.data.files.length>0?(0,k.jsx)(I,{runId:e.id,sha:n,files:r.data.files,onPick:e=>a.current?.scrollToPath(e)}):null]}),children:n?(0,k.jsx)(T,{commit:r,sha:n,slot:`task-commit-preview`,heading:`h3`,diffRef:a}):null})}function N({runId:e,sha:t}){return(0,k.jsx)(E,{commit:o(e,t),sha:t,backTo:`/tasks/${e}/commits`,backLabel:`All commits`,slot:`task-commit`})}var P=12;function F(e,t){let n=t.length<=P,r=s({queries:t.map(t=>({queryKey:i.runs.commit(e,t.sha),queryFn:({signal:n})=>l(e,t.sha,{signal:n}),enabled:n,retry:!1}))}),a=new Map;return r.forEach((e,n)=>{let r=t[n]?.sha;r&&e.data?.stat&&a.set(r,e.data.stat)}),a}function I({runId:e,sha:t,files:n,onPick:r}){return(0,k.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-4 rounded-xl border border-border bg-card p-4`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,k.jsxs)(`h2`,{className:`text-sm font-semibold text-foreground`,children:[n.length,` `,n.length===1?`file`:`files`,` in`,` `,(0,k.jsx)(x,{sha:t,variant:`inline`,className:`text-[13px] font-medium`})]}),(0,k.jsx)(m,{to:`/tasks/${e}/changes`,className:`text-xs text-muted-foreground hover:text-foreground`,children:`All task changes ›`})]}),(0,k.jsx)(`ul`,{className:`space-y-1`,children:n.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,"data-slot":`task-commit-file`,title:e.oldPath?`${e.oldPath} → ${e.path}`:e.path,onClick:()=>r(e.path),className:`flex min-h-11 w-full items-center gap-2 rounded-md px-2 text-left text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,k.jsx)(d,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 break-all`,children:e.path}),(0,k.jsx)(C,{adds:e.adds,dels:e.dels,className:`font-mono text-xs`})]})},e.path))})]})}export{A as TaskCommitsRoute};