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

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 (193) hide show
  1. package/dist/built-in-cli-commands.js +1 -1
  2. package/dist/built-in-cli-commands.js.map +1 -1
  3. package/dist/cli-dispatch.d.ts +1 -1
  4. package/dist/cli-dispatch.js +19 -4
  5. package/dist/cli-dispatch.js.map +1 -1
  6. package/dist/config.d.ts +1 -1
  7. package/dist/config.js +3 -0
  8. package/dist/config.js.map +1 -1
  9. package/dist/contract/health.d.ts +2 -2
  10. package/dist/contract/hosts.d.ts +141 -0
  11. package/dist/contract/index.d.ts +1 -0
  12. package/dist/contract/index.js +140 -8
  13. package/dist/contract/projects.d.ts +8 -2
  14. package/dist/contract/workspace.d.ts +10 -0
  15. package/dist/core/cli-registry.d.ts +1 -0
  16. package/dist/core/server-hook-registry.d.ts +4 -2
  17. package/dist/core/server-hook-registry.js.map +1 -1
  18. package/dist/delegation/routes.d.ts +4 -4
  19. package/dist/delegation/transport.d.ts +92 -92
  20. package/dist/features/automations/automations-routes.js +4 -3
  21. package/dist/features/automations/automations-routes.js.map +1 -1
  22. package/dist/features/automations/tools.d.ts +8 -8
  23. package/dist/features/hosts/cli.d.ts +8 -0
  24. package/dist/features/hosts/cli.js +172 -0
  25. package/dist/features/hosts/cli.js.map +1 -0
  26. package/dist/features/hosts/index.d.ts +12 -0
  27. package/dist/features/hosts/index.js +34 -0
  28. package/dist/features/hosts/index.js.map +1 -0
  29. package/dist/features/hosts/registry.d.ts +52 -0
  30. package/dist/features/hosts/registry.js +198 -0
  31. package/dist/features/hosts/registry.js.map +1 -0
  32. package/dist/features/hosts/routes.d.ts +348 -0
  33. package/dist/features/hosts/routes.js +113 -0
  34. package/dist/features/hosts/routes.js.map +1 -0
  35. package/dist/features/hosts/ssh-config.d.ts +9 -0
  36. package/dist/features/hosts/ssh-config.js +59 -0
  37. package/dist/features/hosts/ssh-config.js.map +1 -0
  38. package/dist/home/entry-authorization.js +1 -1
  39. package/dist/home/entry-authorization.js.map +1 -1
  40. package/dist/home/home.d.ts +2 -0
  41. package/dist/home/home.js +1 -0
  42. package/dist/home/home.js.map +1 -1
  43. package/dist/home/migration-plan.js +1 -1
  44. package/dist/home/migration-plan.js.map +1 -1
  45. package/dist/index.js +2 -2
  46. package/dist/index.js.map +1 -1
  47. package/dist/runs/run-decode.d.ts +72 -72
  48. package/dist/serve-boot.d.ts +1 -1
  49. package/dist/serve-boot.js +4 -2
  50. package/dist/serve-boot.js.map +1 -1
  51. package/dist/serve-command.d.ts +2 -2
  52. package/dist/serve-command.js +47 -31
  53. package/dist/serve-command.js.map +1 -1
  54. package/dist/server/activity-routes.js +1 -1
  55. package/dist/server/activity-routes.js.map +1 -1
  56. package/dist/server/activity-sources.d.ts +1 -1
  57. package/dist/server/activity-sources.js +6 -4
  58. package/dist/server/activity-sources.js.map +1 -1
  59. package/dist/server/activity-topic.js +5 -2
  60. package/dist/server/activity-topic.js.map +1 -1
  61. package/dist/server/live-routes.d.ts +8 -7
  62. package/dist/server/live-routes.js +2 -2
  63. package/dist/server/live-routes.js.map +1 -1
  64. package/dist/server/plugin-server-hooks.js +7 -4
  65. package/dist/server/plugin-server-hooks.js.map +1 -1
  66. package/dist/server/project-context.d.ts +3 -1
  67. package/dist/server/project-context.js +5 -1
  68. package/dist/server/project-context.js.map +1 -1
  69. package/dist/server/projects-routes.d.ts +64 -2
  70. package/dist/server/projects-routes.js +15 -8
  71. package/dist/server/projects-routes.js.map +1 -1
  72. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  73. package/dist/server/providers-routes.d.ts +16 -2
  74. package/dist/server/providers-routes.js +9 -4
  75. package/dist/server/providers-routes.js.map +1 -1
  76. package/dist/server/repo-routes.d.ts +52 -52
  77. package/dist/server/reports-api.d.ts +2 -2
  78. package/dist/server/runners-routes.d.ts +10 -10
  79. package/dist/server/runs-routes.d.ts +334 -334
  80. package/dist/server/server-deps.d.ts +11 -4
  81. package/dist/server/server-deps.js +26 -9
  82. package/dist/server/server-deps.js.map +1 -1
  83. package/dist/server/server.d.ts +1752 -1651
  84. package/dist/server/server.js +23 -31
  85. package/dist/server/server.js.map +1 -1
  86. package/dist/server/start-server.js +22 -14
  87. package/dist/server/start-server.js.map +1 -1
  88. package/dist/server/workspace-identity-routes.d.ts +29 -0
  89. package/dist/server/workspace-identity-routes.js +21 -0
  90. package/dist/server/workspace-identity-routes.js.map +1 -0
  91. package/dist/server/workspace-live-routes.d.ts +28 -7
  92. package/dist/server/workspace-live-routes.js +5 -1
  93. package/dist/server/workspace-live-routes.js.map +1 -1
  94. package/dist/server/workspace-projects.d.ts +11 -8
  95. package/dist/server/workspace-projects.js +50 -12
  96. package/dist/server/workspace-projects.js.map +1 -1
  97. package/dist/server/workspace-routes.d.ts +86 -86
  98. package/dist/server/workspace-routes.js +2 -2
  99. package/dist/server/workspace-routes.js.map +1 -1
  100. package/dist/server/workspace-run-feed.d.ts +4 -4
  101. package/dist/server/workspace-run-feed.js +2 -0
  102. package/dist/server/workspace-run-feed.js.map +1 -1
  103. package/dist/task-cli/discovery.js +7 -0
  104. package/dist/task-cli/discovery.js.map +1 -1
  105. package/dist/workflows/continuation-admission.d.ts +72 -72
  106. package/dist/workflows/run/wait-engine.d.ts +72 -72
  107. package/dist/workspace/backups.d.ts +1 -1
  108. package/dist/workspace/backups.js +1 -1
  109. package/dist/workspace/backups.js.map +1 -1
  110. package/package.json +4 -4
  111. package/web/dist/assets/{accounts-section-BfswfXCZ.js → accounts-section-CiO5OMkx.js} +1 -1
  112. package/web/dist/assets/{activity-motion-CFx-RRu7.js → activity-motion-D2RZtcZk.js} +1 -1
  113. package/web/dist/assets/{activity-route-C2WO0whr.js → activity-route-D7WKghms.js} +1 -1
  114. package/web/dist/assets/{agent-accounts-BuceIkTR.js → agent-accounts-D_7QcFSx.js} +1 -1
  115. package/web/dist/assets/{agent-config-section-C7DGYIqM.js → agent-config-section-DW7oAwLi.js} +1 -1
  116. package/web/dist/assets/{agent-defaults-section-FxdpHuW8.js → agent-defaults-section-BsfycjfC.js} +1 -1
  117. package/web/dist/assets/{appearance-DAxfuDE0.js → appearance-D-a_UJUm.js} +1 -1
  118. package/web/dist/assets/{archive-on-merge-field-BpizlPUF.js → archive-on-merge-field-RMn227ry.js} +1 -1
  119. package/web/dist/assets/{ask-card-D3d4Oe4i.js → ask-card-DP9b-lI-.js} +1 -1
  120. package/web/dist/assets/attention-DnxGjw_R.js +1 -0
  121. package/web/dist/assets/{automations-route-BUoBjY9i.js → automations-route-_Pv3FEnT.js} +1 -1
  122. package/web/dist/assets/{commit-list-D2Q1MPZh.js → commit-list-FjUd56tK.js} +1 -1
  123. package/web/dist/assets/{diff-C2sbzjCh.js → diff-ZyKzQmlr.js} +2 -2
  124. package/web/dist/assets/{diff-controls-CZRDx8kC.js → diff-controls-DHvk5BOR.js} +1 -1
  125. package/web/dist/assets/{diff-view-COw1J8Ia.js → diff-view-wHArQrRv.js} +1 -1
  126. package/web/dist/assets/{discard-changes-dialog-CHo6iyVf.js → discard-changes-dialog-u_8VAiFD.js} +1 -1
  127. package/web/dist/assets/{file-preview-B0lpYpjU.js → file-preview-DbDhvIx2.js} +1 -1
  128. package/web/dist/assets/{folder-browser-CUUWpb8F.js → folder-browser-Civftk0W.js} +1 -1
  129. package/web/dist/assets/{git-toolbar-BeBHkFTl.js → git-toolbar-Bjvqzoo_.js} +1 -1
  130. package/web/dist/assets/{github-CVzbyq44.js → github-DZyhI-94.js} +1 -1
  131. package/web/dist/assets/{global-activity-route-BvvO5Ie1.js → global-activity-route-B20p5-qQ.js} +1 -1
  132. package/web/dist/assets/index-C8nM086t.css +1 -0
  133. package/web/dist/assets/index-TOx-AA67.js +21 -0
  134. package/web/dist/assets/label-feCJ3WOT.js +1 -0
  135. package/web/dist/assets/{markdown-CtFi6cFe.js → markdown-Ce0jEzBL.js} +1 -1
  136. package/web/dist/assets/{open-in-menu-CI3ceNjU.js → open-in-menu-Bzca0KPF.js} +1 -1
  137. package/web/dist/assets/{option-select-CFhKFk8u.js → option-select-BUpASY9Q.js} +1 -1
  138. package/web/dist/assets/{preferences-section-DfgoVofd.js → preferences-section-Cayq_QJk.js} +1 -1
  139. package/web/dist/assets/{preview-pane-connected-T-WG4X9k.js → preview-pane-connected-C6q9f2y-.js} +1 -1
  140. package/web/dist/assets/{project-location-0VnTd5VW.js → project-location-QEQeyIDW.js} +1 -1
  141. package/web/dist/assets/{project-router-C53GCY_8.js → project-router-j0uBi7Ep.js} +1 -1
  142. package/web/dist/assets/{projects-section-CwpogbCn.js → projects-section-Ws3Kp5ky.js} +1 -1
  143. package/web/dist/assets/{prompt-templates-section-R0rt2Tw4.js → prompt-templates-section-CfyNaD_K.js} +1 -1
  144. package/web/dist/assets/queries-CchoEEzj.js +1 -0
  145. package/web/dist/assets/{read-state-DOIKdUqa.js → read-state-c_RNJaXO.js} +1 -1
  146. package/web/dist/assets/{reference-chip-95DURw1q.js → reference-chip-z7dZJVH-.js} +1 -1
  147. package/web/dist/assets/{remote-settings-notice-BYv4X_Zz.js → remote-settings-notice-DEs9jV72.js} +1 -1
  148. package/web/dist/assets/{repo-git-j6gBX3Yk.js → repo-git-DpqwxFN6.js} +1 -1
  149. package/web/dist/assets/{report-reader-UaMV9dLk.js → report-reader-mwLAF_a8.js} +1 -1
  150. package/web/dist/assets/{report-selection-DAPzf1Aa.js → report-selection-BdGxjISG.js} +1 -1
  151. package/web/dist/assets/{reports-1A2Ciyw2.js → reports-CN8KHXFF.js} +1 -1
  152. package/web/dist/assets/{resources-section-CurFgvye.js → resources-section-BzYmdxRV.js} +1 -1
  153. package/web/dist/assets/{review-notes-drafts-19pkn2vN.js → review-notes-drafts-D9s8XFRQ.js} +1 -1
  154. package/web/dist/assets/{review-panel-DmHITJs8.js → review-panel-Ds3S11Go.js} +1 -1
  155. package/web/dist/assets/{review-strip-DbtyWCrP.js → review-strip-BFq2VP2u.js} +1 -1
  156. package/web/dist/assets/{run-detail-refresh-DYY7EWeq.js → run-detail-refresh-C5qmRdgD.js} +1 -1
  157. package/web/dist/assets/{run-diff-CMX34CW6.js → run-diff-BvGvPk3g.js} +1 -1
  158. package/web/dist/assets/run-header-788Dmvef.css +1 -0
  159. package/web/dist/assets/{run-header-BpLDqXvN.js → run-header-Bedua8do.js} +2 -2
  160. package/web/dist/assets/{select-CBMEsTi0.js → select-CGjqNwut.js} +1 -1
  161. package/web/dist/assets/{session-context-section-JUgAAE68.js → session-context-section-D0e8HLzL.js} +1 -1
  162. package/web/dist/assets/{settings-agent-picker-_38GTrVo.js → settings-agent-picker-hFnntaW2.js} +1 -1
  163. package/web/dist/assets/{settings-save-bar-Czqju-k9.js → settings-save-bar-DmONROMw.js} +1 -1
  164. package/web/dist/assets/{settings-shell-Dpp7fksb.js → settings-shell-DjfeA3BW.js} +1 -1
  165. package/web/dist/assets/{sidebar-section-DolOq65h.js → sidebar-section-DHJR37sv.js} +1 -1
  166. package/web/dist/assets/{skills-C3qgwzNL.js → skills-CFRO_xLW.js} +1 -1
  167. package/web/dist/assets/{tab-link-BGfSJ-ah.js → tab-link-BKlpD9sn.js} +1 -1
  168. package/web/dist/assets/{task-changes-BJLF9Ucs.js → task-changes-BuNxS6PG.js} +1 -1
  169. package/web/dist/assets/{task-commits-DYPpdxyk.js → task-commits--1qJdD-O.js} +1 -1
  170. package/web/dist/assets/{task-file-scope-BNDrHDCA.js → task-file-scope-CFMwJrto.js} +1 -1
  171. package/web/dist/assets/{task-files-Df7x62S3.js → task-files-CwH0b_vv.js} +1 -1
  172. package/web/dist/assets/{task-github-item-Bi0FiK3t.js → task-github-item-BezEGvZC.js} +1 -1
  173. package/web/dist/assets/{task-groups-7p6Gvpg8.js → task-groups-CGCnVqHE.js} +1 -1
  174. package/web/dist/assets/{task-thread-LZb9EWfU.js → task-thread-T_RG916v.js} +2 -2
  175. package/web/dist/assets/{thread-state-jWJlcg17.js → thread-state-zzV37Hgs.js} +1 -1
  176. package/web/dist/assets/toaster-zMN8cNZQ.js +4 -0
  177. package/web/dist/assets/{use-finish-run-jfO-hFXU.js → use-finish-run-CyV1CCkZ.js} +1 -1
  178. package/web/dist/assets/{use-hand-to-agent-state-TAYkI2TF.js → use-hand-to-agent-state-Ci2rVhws.js} +1 -1
  179. package/web/dist/assets/use-path-bases-Cimv7R-0.js +1 -0
  180. package/web/dist/assets/use-workspace-config-save-9jm9qV6u.js +1 -0
  181. package/web/dist/assets/{workflows-Ko0had3b.js → workflows-B9NzpaaA.js} +1 -1
  182. package/web/dist/assets/{workspace-tools-CtGDE8c4.js → workspace-tools-C0K5dFxy.js} +1 -1
  183. package/web/dist/assets/{worktrees-section--Q1J4xPE.js → worktrees-section-D48xLdpr.js} +1 -1
  184. package/web/dist/index.html +15 -15
  185. package/web/dist/assets/attention-xl4bwNkx.js +0 -1
  186. package/web/dist/assets/index-BUmO8olN.css +0 -1
  187. package/web/dist/assets/index-WGWSicA9.js +0 -21
  188. package/web/dist/assets/label-DRXJ8ljY.js +0 -1
  189. package/web/dist/assets/queries-jsRcJKo6.js +0 -1
  190. package/web/dist/assets/run-header-V9BxPSvn.css +0 -1
  191. package/web/dist/assets/toaster-C1BFyQ8i.js +0 -4
  192. package/web/dist/assets/use-path-bases-CeKWHR1g.js +0 -1
  193. package/web/dist/assets/use-workspace-config-save-D2fOudMd.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{f as r,o as i,p as a,u as o}from"./dist-C_rn70hE.js";import{Ut as s,Wt as c,cn as l,rn as u,yt as d}from"./queries-CchoEEzj.js";import{Er as f,Jn as p,Jr as m,Kn as h,Kr as ee,Xr as g,Yn as _,Zr as v,qn as y,ti as te,vi as b,wr as ne}from"./toaster-zMN8cNZQ.js";import{B as x,H as S,I as C,N as w,W as T,z as E}from"./live-protocol-DMhTnCmf.js";import{i as D,r as O}from"./cez-idle-CdswdDRd.js";import{n as re,r as k,t as ie}from"./run-detail-refresh-C5qmRdgD.js";import{h as ae}from"./es2015-CUEfzDjB.js";var A=class extends EventTarget{readyState=0;release;constructor(e,t){super(),this.release=this.subscribe()}subscribe(){let e=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});return g({kind:`workspace`},{ready:e,reset:()=>{this.readyState!==2&&(this.readyState=0,e())},frame:t=>{if(`data`in t&&t.event===`reconnect`){this.readyState=0,e();return}if(`data`in t&&t.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in t&&t.event===`ready`&&v(),`data`in t&&this.dispatchEvent(new MessageEvent(t.event,{data:t.data}))}})}requestReady(){return this.readyState!==2&&m()}close(){this.readyState=2,this.release()}},j=e(t(),1);x({runs:C(`summary`).optional()});var M=T().min(1),N=E().int().positive(),oe=x({project:M,seq:N,run:_,relationships:T().min(1)}),se=x({project:M,seq:N,id:T().min(1)}),ce=x({generation:T().min(1),seq:E().int().nonnegative()}),le=x({project:M,usage:S(T(),h)});x({runs:w(p),referenceStatuses:y,perProjectLimit:E(),truncated:w(T()),generation:T().min(1),eventSeq:E().int().nonnegative()});function ue(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=oe.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=se.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=le.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=ce.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}function de(){let e;return{ready(t){let n=e!==void 0&&t>e;return e=t,n},frame(t){let n=e!==void 0&&t!==e+1;return e=t,n},reset(){e=void 0}}}function P(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function fe(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var F=Object.freeze({});function pe(){let e=F,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}var I=n(),L=o(`/workspace/events?runs=summary`),R=2,z=3e3,B=[`run-summary`,`run-deleted`,`usage`,`ping`,`ready`],me=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],V=new Set;function he(e){return V.add(e),()=>{V.delete(e)}}function H(e){return e[1]===`runs`&&e[2]===`list`}function U(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function W(e){return e.invalidateQueries({predicate:e=>H(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>H(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>U(e,t.queryKey))}var ge=1e3,G=new WeakMap;function K(e){let t=s.repoBranches,n=G.get(e);if(n){n.set(JSON.stringify(t),t);return}G.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=G.get(e);G.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},ge)}function q(e,t,n=!1){if(t?.aborted)return Promise.resolve();let r=[s.runs.all,c.runsIndex,c.projects,s.health,s.worktrees,s.repoBranches,c.providerStatus],i=()=>{for(let t of r)e.cancelQueries({queryKey:t})};return t?.addEventListener(`abort`,i,{once:!0}),D(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>H(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:s.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>H(e.queryKey)}),u(e).reconcile(),e.invalidateQueries({queryKey:c.projects}),U(e,s.health),e.invalidateQueries({queryKey:s.worktrees}),e.invalidateQueries({queryKey:s.repoBranches}),e.invalidateQueries({queryKey:c.providerStatus}),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,i))}function J(e){return r()??Y(e)}function Y(e){let t=e.getQueryData(c.projects);if(t?.bootProject!==null)return typeof t?.bootProject==`string`&&t.bootProject!==``?t.bootProject:e.getQueryData(s.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject??void 0}function _e(e,t){return[l({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function ve(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},i=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),a=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},o,c,l=(i=!1)=>{c!==void 0&&clearTimeout(c),c=void 0,o!==void 0&&cancelAnimationFrame(o),o=void 0;let s=[];for(let{key:r,baseList:i,baseQuery:o,baseUpdateCount:c,runs:l}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==o||t?.state.dataUpdateCount!==c||t?.state.data!==i){s.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}a(r,s),e.setQueryData(r,e=>{let t=e;for(let e of l.values())t=P(t,e);return t})}if(t.clear(),!i)for(let e of s)r(e);return s},u=t=>{let n=[_e(t,Y(e))],r=[t,`runs`,`list`];return(t===J(e)||e.getQueryState(r))&&n.push(r),t===J(e)&&n.push(s.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,s){let d=u(i);if(s.type===`run-summary`&&s.summary.archived&&d.every(t=>!e.getQueryData(t)?.find(e=>e.id===s.summary.id)?.archived)&&s.type===`run-summary`){for(let r of d){let i=JSON.stringify(r),a=n.get(i);a?.phase===`fetching`&&(a.dirty=!0);let o=t.get(i);if(!o){let n=e.getQueryCache().find({queryKey:r,exact:!0});o={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,o)}o.runs.set(s.summary.id,s.summary)}c===void 0&&(c=setTimeout(()=>{l()},50),typeof requestAnimationFrame==`function`&&(o=requestAnimationFrame(()=>{l()})));return}let f=l(!0);for(let t of d)a(t,f),s.type===`run-summary`?e.setQueryData(t,e=>P(e,s.summary)):e.setQueryData(t,e=>fe(e,s.id));for(let e of f)r(e)},flush:l,cancel(){i(),n.clear()}}}var ye=400;function be(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},ye))};return{onSummary(e,n){let i=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,a=e.delegation?.role===`worker`?e.delegation.supervisorRunId:void 0,o=t.get(e.id);if(t.set(e.id,{shape:n,...i===void 0?{}:{parentRunId:i},...a===void 0?{}:{supervisorRunId:a}}),o?.shape!==n){r(s.runs.relationships(e.id),!0);for(let e of[i,a])e!==void 0&&r(s.runs.relationships(e),!0)}},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:s.runs.relationships(n)}),i?.supervisorRunId!==void 0&&r(s.runs.relationships(i.supervisorRunId),!0),i?.parentRunId===void 0?r([...s.runs.all,`relationships`],!1):r(s.runs.relationships(i.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var X={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function xe(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(X)){let i=r.state.data;i&&(i.pages.some(e=>e.runs.some(e=>e.id===t.id))?(e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?t:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)):t.archived&&(n=!0))}n&&e.invalidateQueries(X)}function Se(e,t,n,r,i){switch(n.type){case`run-summary`:{let t=n.summary;if(xe(e,t),i.onSummary(t,n.relationships),r.fetcher.onEvent(t.id),t.delegation?.role===`worker`){let n=t.delegation.parentRunId;k(e,s.runs.detail(n)),r.refreshParent(n)}let a=s.runs.changes(t.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:s.worktrees}),K(e);return}case`run-deleted`:i.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:s.runs.detail(n.id)}),e.removeQueries({queryKey:s.runs.diff(n.id)}),e.setQueriesData(X,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(X),e.invalidateQueries({queryKey:s.worktrees}),K(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function Z(e,t,n,r){if(n!==a()){if(r.type===`run-summary`){let i=r.summary;if(t.fetcher.onEvent(i.id,n),i.delegation?.role===`worker`){let r=i.delegation.parentRunId;k(e,[n,`runs`,`detail`,r]),t.refreshParent(r,n)}return}t.fetcher.forget(r.id,n),e.removeQueries({queryKey:[n,`runs`,`detail`,r.id]}),e.removeQueries({queryKey:[n,`runs`,`diff`,r.id]})}}function Ce(e,t=L){let n=b();(0,j.useEffect)(()=>{let r=A;if(typeof r!=`function`)return;let i=null,a=u(n);a.setUnknownGenerationHandler(()=>{let e=i?.requestReady;return typeof e==`function`&&e.call(i)});let o=re(n),l=ie(n),d={fetcher:l,refreshParent:o.refresh},p=de(),m=ve(n),h=be(n),g=!1,_,v=!1,y=!1,b=!1,x=!1,S=()=>{b=!0,x=!1;let e=c.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(y||!x){b=!1;return}S()})},C=()=>{y||_!==void 0||(_=setTimeout(()=>{_=void 0,y||w()},z))},w=()=>{i?.close(),i=new r(t,{withCredentials:!0}),i.addEventListener(`open`,()=>{g=!0,p.reset(),a.detach(),O(!1),v&&(m.flush(),q(n)),v||(D(()=>W(n)),n.cancelQueries({queryKey:s.health}).then(()=>{y||n.invalidateQueries({queryKey:s.health})}),a.reconcile()),v=!0});for(let t of B)i.addEventListener(t,r=>{let i=ue(t,r.data);if(!i)return;if(i.event.type===`ready`){let e=p.ready(i.event.seq);a.ready(i.event.generation,i.event.seq),e&&(m.flush(),q(n));return}let o=(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&p.frame(i.event.seq);i.event.type===`ping`&&g&&(g=!1,D(()=>W(n)),O(!0)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`?a.run(i.project,i.event,o):i.event.type===`usage`&&a.usage(i.project,i.event.usage)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&(m.onEvent(i.project,i.event),Z(n,d,i.project,i.event)),(i.project===null||i.project===J(n))&&Se(n,e,i.event,d,h),o&&(m.flush(),q(n))});for(let e of me)i.addEventListener(e,t=>{let r;try{r=JSON.parse(t.data)}catch{return}if(e===`project-ready`?a.reconcile({hold:!0}):e!==`checkout-progress`&&e!==`automation-change`&&n.invalidateQueries({queryKey:c.projects}),e===`project-added`){let e=r?.project?.id;typeof e==`string`&&e!==``&&a.restoreProject(e),a.reconcile({hold:!0})}if(e===`project-removed`){let e=r?.id;typeof e==`string`&&e!==``&&a.dropProject(e)}for(let t of[...V])t(e,r)});i.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=te.safeParse(t);r.success&&(n.cancelQueries({queryKey:s.health}),n.setQueryData(s.health,r.data))}),i.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=f(t);if(!r)return;let i=c.providerStatus,a=ne(n.getQueryData(i),r);if(a!==void 0){n.setQueryData(i,a);return}if(b){x=!0;return}S()}),i.addEventListener(`error`,()=>{O(!1),a.detach(),i?.readyState===R&&C()})},T=()=>{document.visibilityState===`visible`&&(m.flush(),a.flush(),(!i||i.readyState===R)&&(clearTimeout(_),_=void 0,w()))},E=()=>{clearTimeout(_),_=void 0,m.flush()};document.addEventListener(`visibilitychange`,T),window.addEventListener(`pagehide`,E);let k=ee((e,t)=>(m.flush(),q(n,e,t)));return w(),()=>{k(),y=!0,O(!1),clearTimeout(_),m.flush(),m.cancel(),a.stop(),o.cancel(),l.cancel(),a.setUnknownGenerationHandler(void 0),h.cancel(),document.removeEventListener(`visibilitychange`,T),window.removeEventListener(`pagehide`,E),i?.close(),i=null}},[n,e,t])}var Q=(0,j.createContext)(null);function we({children:e}){let[t]=(0,j.useState)(pe);return Ce(t),d(),(0,I.jsx)(Q.Provider,{value:t,children:e})}function Te(e){let t=(0,j.useContext)(Q),n=t?t.get:De;return(0,j.useSyncExternalStore)(t?t.subscribe:Ee,()=>e?n()[e]:void 0,()=>void 0)}var Ee=()=>()=>void 0,De=()=>F,Oe=`Label`,$=j.forwardRef((e,t)=>(0,I.jsx)(ae.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));$.displayName=Oe;var ke=$;function Ae({className:e,...t}){return(0,I.jsx)(ke,{"data-slot":`label`,className:i(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}export{Te as i,we as n,he as r,Ae as t};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r}from"./dist-C_rn70hE.js";import{d as i,f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{T as s,_ as c,an as l,cn as u,in as d,nn as f,on as p,rn as m,sn as h,tn as g,w as _}from"./index-WGWSicA9.js";import{i as v,n as y,s as b}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as x,o as S,r as C,t as w}from"./highlighter-Cfo7mLVB.js";var T=e(t(),1),E=n();function D({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,E.jsx)(g,{open:e,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(d,{"data-slot":`link-safety-dialog`,children:[(0,E.jsxs)(h,{children:[(0,E.jsx)(u,{children:`Open this link?`}),(0,E.jsxs)(l,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,E.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,E.jsxs)(p,{children:[(0,E.jsx)(m,{children:`Cancel`}),(0,E.jsx)(f,{onClick:n,children:`Open link`})]})]})})}var O=`text-accent-text underline underline-offset-2`;function k({href:e,children:t,internal:n,...r}){let[a,o]=(0,T.useState)(!1),s=i();return e?n?s?(0,E.jsx)(A,{...r,href:e,children:t}):(0,E.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:O,children:t}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${O}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,E.jsx)(D,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,E.jsx)(`span`,{children:t})}function A({href:e,children:t,...n}){let r=o(),i=a(),s=c();return(0,E.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:O,onClick:t=>{j(t,s,e)||N(t,r,e,i)},children:t})}function j(e,t,n){if(!t?.showing||!M(e))return!1;let r=new URL(n,window.location.origin),i=/\/files\/?$/.test(r.pathname)?r.searchParams.get(`path`):null;return!i||!t.revealChange(i)?!1:(e.preventDefault(),!0)}var M=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function N(e,t,n,r){M(e)&&(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var P={code:{name:`shiki`,type:`code-highlighter`,getThemes:()=>[w,w],getSupportedLanguages:()=>S(),supportsLanguage:e=>S().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>x(e,String(t))||(C(e,String(t)).then(e=>n?.(e)),null)}},F=[w,w],I={code:{copy:!0,download:!1},table:!1,mermaid:!1},L=[...Object.values(b),q];function R(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r}from"./dist-C_rn70hE.js";import{d as i,f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{T as s,_ as c,an as l,cn as u,in as d,nn as f,on as p,rn as m,sn as h,tn as g,w as _}from"./index-TOx-AA67.js";import{i as v,n as y,s as b}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as x,o as S,r as C,t as w}from"./highlighter-Cfo7mLVB.js";var T=e(t(),1),E=n();function D({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,E.jsx)(g,{open:e,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(d,{"data-slot":`link-safety-dialog`,children:[(0,E.jsxs)(h,{children:[(0,E.jsx)(u,{children:`Open this link?`}),(0,E.jsxs)(l,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,E.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,E.jsxs)(p,{children:[(0,E.jsx)(m,{children:`Cancel`}),(0,E.jsx)(f,{onClick:n,children:`Open link`})]})]})})}var O=`text-accent-text underline underline-offset-2`;function k({href:e,children:t,internal:n,...r}){let[a,o]=(0,T.useState)(!1),s=i();return e?n?s?(0,E.jsx)(A,{...r,href:e,children:t}):(0,E.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:O,children:t}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${O}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,E.jsx)(D,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,E.jsx)(`span`,{children:t})}function A({href:e,children:t,...n}){let r=o(),i=a(),s=c();return(0,E.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:O,onClick:t=>{j(t,s,e)||N(t,r,e,i)},children:t})}function j(e,t,n){if(!t?.showing||!M(e))return!1;let r=new URL(n,window.location.origin),i=/\/files\/?$/.test(r.pathname)?r.searchParams.get(`path`):null;return!i||!t.revealChange(i)?!1:(e.preventDefault(),!0)}var M=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function N(e,t,n,r){M(e)&&(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var P={code:{name:`shiki`,type:`code-highlighter`,getThemes:()=>[w,w],getSupportedLanguages:()=>S(),supportsLanguage:e=>S().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>x(e,String(t))||(C(e,String(t)).then(e=>n?.(e)),null)}},F=[w,w],I={code:{copy:!0,download:!1},table:!1,mermaid:!1},L=[...Object.values(b),q];function R(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
2
2
  `)){let e=r.value.split(/\r?\n/);e.forEach((t,r)=>{r>0&&!(t===``&&r===e.length-1)&&n.push({type:`break`}),t&&n.push({type:`text`,value:t})})}else e(r),n.push(r);t.children=n};return e}var z=[...Object.values(y),R],B=[`p`,`strong`,`em`,`del`,`code`,`a`],V={p:`span`,a:`span`},H={enabled:!0,renderModal:e=>(0,E.jsx)(D,{...e})},U=`https://refused.invalid/`,W=new WeakSet;function G(e){let t=e.position?.start.offset,n=e.position?.end.offset;return t===void 0||n===void 0?null:`${t}:${n}`}function K(e){return(t,n)=>{let r=new Set,i=new Map,a=t=>{if((t.type===`link`||t.type===`definition`)&&t.url){let n=s(t.url,e);if(t.type===`definition`&&t.identifier&&!i.has(t.identifier)&&i.set(t.identifier,n!==null),n){t.url=n;let e=G(t);t.type===`link`&&e!==null&&r.add(e)}}t.children?.forEach(a)};a(t);let o=e=>{let t=G(e);e.type===`linkReference`&&e.identifier&&i.get(e.identifier)&&t!==null&&r.add(t),e.children?.forEach(o)};o(t),n.data.taskLinks=r}}function q(){return(e,t)=>{let n=e=>{let r=G(e);e.tagName===`a`&&r!==null&&t.data.taskLinks instanceof Set&&t.data.taskLinks.has(r)&&W.add(e),e.children?.forEach(n)};n(e)}}var J=0,Y=(0,T.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:i=!1,imageSrc:a}){let o=(0,T.useContext)(_),s=(0,T.useMemo)(()=>{let e={instance:++J},n=new Set;function r(){let e=t=>{if(t.type===`image`&&t.url&&a){let e=a(t.url);t.url=e?new URL(e,window.location.href).href:U,e&&n.add(t.url)}t.children?.forEach(e)};return e}let s=o?[[K,o]]:[],c=i&&a?[[r,e]]:[];return{key:e.instance,remark:[...t?z:Object.values(y),...s,...c],components:{...o||i?{a:({href:e,children:t,node:n})=>i&&!o&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,E.jsx)(`span`,{children:t}):(0,E.jsx)(k,{href:e,internal:n!==void 0&&W.has(n),children:t})}:{},...i?{img:({src:e,alt:t})=>typeof e==`string`&&n.has(e)?(0,E.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,E.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[o,t,i,a]);return(0,E.jsx)(v,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:P,shikiTheme:F,...r({rehypePlugins:o?L:void 0,remarkPlugins:o||i&&a?s.remark:t?z:void 0,allowedElements:n?B:void 0,unwrapDisallowed:n||void 0,components:n?V:o||i?s.components:void 0}),linkSafety:H,controls:I,lineNumbers:!1,children:e},s.key)});export{N as n,Y as t};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{Zt as t,nn as n}from"./queries-jsRcJKo6.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{t as i}from"./bot-TkDIw4y-.js";import{t as a}from"./external-link-BE6y205O.js";import{t as o}from"./folder-o-AvL3y3.js";import{n as s,t as c}from"./smartphone-Lr8Ug2z_.js";import{t as l}from"./square-terminal-B6RYYieR.js";import{t as u}from"./button-C8jUIs8Q.js";import{i as d,l as f,p,r as m,t as h}from"./dropdown-menu-DjtKUK8F.js";import{t as g}from"./own-lookup-DS54wXvD.js";var _=r(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),v=r(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),y=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),b=r(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),x=r(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),S=r(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),C=r(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),w=r(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),T=r(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),E=r(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),D=r(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),O=r(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),k=r(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),A=r(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),j=r(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),M=e(),N={folder:o,terminal:l,vscode:y,cursor:E,zed:j,windsurf:A,sublime:S,idea:x,pycharm:T,webstorm:s,goland:O,rubymine:C,phpstorm:v,clion:b,rider:_,"android-studio":c,xcode:w,warp:D,bot:i,sparkles:k};function P(e,n){let r=F(e.id);return g(N,r===void 0?e.icon:t(n,r)?.icon)??a}function F(e){let t=e.startsWith(`cli:`)?e.slice(4):``;return t===``?void 0:t}function I({choices:e,onPick:t,label:r=`Open in…`,title:i,triggerVariant:o=`ghost`,disabled:s=!1,leading:c,trailing:l,slot:g,className:_}){let v=n().data;return(0,M.jsxs)(h,{children:[(0,M.jsx)(p,{asChild:!0,children:(0,M.jsxs)(u,{variant:o,size:`sm`,title:i,disabled:s,"data-slot":g,className:_,children:[(0,M.jsx)(a,{"aria-hidden":`true`}),r]})}),(0,M.jsxs)(m,{align:`end`,children:[c,c&&e.length>0?(0,M.jsx)(f,{}):null,e.map(({target:e,suffix:n,title:r})=>{let i=P(e,v);return(0,M.jsxs)(d,{"data-target":e.id,title:r,onSelect:()=>t(e.id),children:[(0,M.jsx)(i,{"aria-hidden":`true`}),e.label,n??``]},e.id)}),l]})]})}export{j as i,F as n,P as r,I as t};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{Zt as t,nn as n}from"./queries-CchoEEzj.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{t as i}from"./bot-TkDIw4y-.js";import{t as a}from"./external-link-BE6y205O.js";import{t as o}from"./folder-o-AvL3y3.js";import{n as s,t as c}from"./smartphone-Lr8Ug2z_.js";import{t as l}from"./square-terminal-B6RYYieR.js";import{t as u}from"./button-C8jUIs8Q.js";import{i as d,l as f,p,r as m,t as h}from"./dropdown-menu-DjtKUK8F.js";import{t as g}from"./own-lookup-DS54wXvD.js";var _=r(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),v=r(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),y=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),b=r(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),x=r(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),S=r(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),C=r(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),w=r(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),T=r(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),E=r(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),D=r(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),O=r(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),k=r(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),A=r(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),j=r(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),M=e(),N={folder:o,terminal:l,vscode:y,cursor:E,zed:j,windsurf:A,sublime:S,idea:x,pycharm:T,webstorm:s,goland:O,rubymine:C,phpstorm:v,clion:b,rider:_,"android-studio":c,xcode:w,warp:D,bot:i,sparkles:k};function P(e,n){let r=F(e.id);return g(N,r===void 0?e.icon:t(n,r)?.icon)??a}function F(e){let t=e.startsWith(`cli:`)?e.slice(4):``;return t===``?void 0:t}function I({choices:e,onPick:t,label:r=`Open in…`,title:i,triggerVariant:o=`ghost`,disabled:s=!1,leading:c,trailing:l,slot:g,className:_}){let v=n().data;return(0,M.jsxs)(h,{children:[(0,M.jsx)(p,{asChild:!0,children:(0,M.jsxs)(u,{variant:o,size:`sm`,title:i,disabled:s,"data-slot":g,className:_,children:[(0,M.jsx)(a,{"aria-hidden":`true`}),r]})}),(0,M.jsxs)(m,{align:`end`,children:[c,c&&e.length>0?(0,M.jsx)(f,{}):null,e.map(({target:e,suffix:n,title:r})=>{let i=P(e,v);return(0,M.jsxs)(d,{"data-target":e.id,title:r,onSelect:()=>t(e.id),children:[(0,M.jsx)(i,{"aria-hidden":`true`}),e.label,n??``]},e.id)}),l]})]})}export{j as i,F as n,P as r,I as t};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{a as t,i as n,n as r,r as i,t as a}from"./select-CBMEsTi0.js";var o=e(),s=`\0empty`,c=e=>e===``?s:e,l=e=>e===s?``:e;function u({value:e,onValueChange:s,options:u,disabled:d,placeholder:f,contentClassName:p,...m}){let h=String(e);return(0,o.jsxs)(a,{value:u.some(e=>e.value===h)?c(h):``,onValueChange:e=>s(l(e)),...d===void 0?{}:{disabled:d},children:[(0,o.jsx)(n,{"data-value":h,...m,children:(0,o.jsx)(t,{...f===void 0?{}:{placeholder:f}})}),(0,o.jsx)(r,{...p===void 0?{}:{className:p},children:u.map(e=>(0,o.jsx)(i,{value:c(e.value),"data-value":e.value,...e.disabled?{disabled:!0}:{},children:e.label},e.value))})]})}export{u as t};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{a as t,i as n,n as r,r as i,t as a}from"./select-CGjqNwut.js";var o=e(),s=`\0empty`,c=e=>e===``?s:e,l=e=>e===s?``:e;function u({value:e,onValueChange:s,options:u,disabled:d,placeholder:f,contentClassName:p,...m}){let h=String(e);return(0,o.jsxs)(a,{value:u.some(e=>e.value===h)?c(h):``,onValueChange:e=>s(l(e)),...d===void 0?{}:{disabled:d},children:[(0,o.jsx)(n,{"data-value":h,...m,children:(0,o.jsx)(t,{...f===void 0?{}:{placeholder:f}})}),(0,o.jsx)(r,{...p===void 0?{}:{className:p},children:u.map(e=>(0,o.jsx)(i,{value:c(e.value),"data-value":e.value,...e.disabled?{disabled:!0}:{},children:e.label},e.value))})]})}export{u as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{It as r,Wt as i}from"./queries-jsRcJKo6.js";import{dn as a,n as o,vi as s}from"./toaster-C1BFyQ8i.js";import{t as c}from"./switch-CAKeV99j.js";import{_t as l,vt as u}from"./index-WGWSicA9.js";import{n as d,t as f}from"./save-cue-CpHgT93o.js";import{n as p}from"./archive-on-merge-field-BpizlPUF.js";var m=e(t(),1),h=n();function g(){let e=s(),t=r(),[n,p]=m.useState(!1),[g,_]=m.useState(u),v=d(),y=t.data;m.useEffect(()=>{y!==void 0&&p(l(y.notifications).enabled)},[y]);let b=m.useCallback(t=>{p(t),a({notifications:{enabled:t}}).then(t=>{e.setQueryData(i.uiState,t),v.flash()}).catch(t=>{o(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:i.uiState})})},[e,v.flash]),x=m.useCallback(e=>{if(!e){b(!1);return}if(u()!=="default"){b(!0);return}b(!0),Notification.requestPermission().then(e=>_(e)).catch(()=>_(u()))},[b]),S=g===`unsupported`;return(0,h.jsxs)(`section`,{"data-slot":`notifications-section`,className:`settings-field flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,h.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,h.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default. `,(0,h.jsx)(f,{saved:v.saved})]})]}),(0,h.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:S,onCheckedChange:x})]}),S?null:(0,h.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":g,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,g===`granted`?`Allowed`:g===`denied`?`Blocked`:`Not requested`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),S?(0,h.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!S&&n&&g===`denied`?(0,h.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,h.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,h.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})}function _(){return(0,h.jsxs)(`div`,{"data-slot":`preferences-section`,className:`flex w-full flex-col gap-7`,children:[(0,h.jsx)(g,{}),(0,h.jsx)(p,{})]})}export{_ as PreferencesSection};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{It as r,Wt as i}from"./queries-CchoEEzj.js";import{dn as a,n as o,vi as s}from"./toaster-zMN8cNZQ.js";import{t as c}from"./switch-CAKeV99j.js";import{_t as l,vt as u}from"./index-TOx-AA67.js";import{n as d,t as f}from"./save-cue-CpHgT93o.js";import{n as p}from"./archive-on-merge-field-RMn227ry.js";var m=e(t(),1),h=n();function g(){let e=s(),t=r(),[n,p]=m.useState(!1),[g,_]=m.useState(u),v=d(),y=t.data;m.useEffect(()=>{y!==void 0&&p(l(y.notifications).enabled)},[y]);let b=m.useCallback(t=>{p(t),a({notifications:{enabled:t}}).then(t=>{e.setQueryData(i.uiState,t),v.flash()}).catch(t=>{o(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:i.uiState})})},[e,v.flash]),x=m.useCallback(e=>{if(!e){b(!1);return}if(u()!=="default"){b(!0);return}b(!0),Notification.requestPermission().then(e=>_(e)).catch(()=>_(u()))},[b]),S=g===`unsupported`;return(0,h.jsxs)(`section`,{"data-slot":`notifications-section`,className:`settings-field flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,h.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,h.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default. `,(0,h.jsx)(f,{saved:v.saved})]})]}),(0,h.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:S,onCheckedChange:x})]}),S?null:(0,h.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":g,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,g===`granted`?`Allowed`:g===`denied`?`Blocked`:`Not requested`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),S?(0,h.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!S&&n&&g===`denied`?(0,h.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,h.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,h.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})}function _(){return(0,h.jsxs)(`div`,{"data-slot":`preferences-section`,className:`flex w-full flex-col gap-7`,children:[(0,h.jsx)(g,{}),(0,h.jsx)(p,{})]})}export{_ as PreferencesSection};
@@ -1,3 +1,3 @@
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{$r as i,Qr as a,_r as o,ei as s,n as c}from"./toaster-C1BFyQ8i.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{t as d}from"./check-OP-CVgZG.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,t as m}from"./circle-x-7nTlobAF.js";import{n as h,t as g}from"./smartphone-Lr8Ug2z_.js";import{t as _}from"./info-DA1x_4bz.js";import{t as v}from"./loader-circle-CPBhhDbB.js";import{n as y,t as ee}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-B9NN44oU.js";import{n as te,o as S,s as C}from"./thread-state-jWJlcg17.js";import{t as ne}from"./square-terminal-B6RYYieR.js";import{t as w}from"./button-C8jUIs8Q.js";import{a as T,c as re,i as E,l as D,p as O,r as k,s as ie,t as A}from"./dropdown-menu-DjtKUK8F.js";import{s as ae}from"./project-router-C53GCY_8.js";import{t as j}from"./status-dot-BXf-Ubd0.js";import{Qn as oe,Sr as se,Xn as ce,Yn as le,Zn as ue,b as de,br as M,c as fe,f as pe,h as me,l as he,m as N,p as ge,pr as _e,ur as ve,x as ye,y as be,yr as xe}from"./index-WGWSicA9.js";var Se=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),P=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Ce=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),F=l(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),I=l(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),L=l(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),we=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),R=l(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),z=l(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Te=l(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Ee=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),B=l(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),V=l(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),H=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),U=l(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),W=l(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),G=l(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),K=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),q=l(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),De=l(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,s=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||a(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,s=n,n.addEventListener(`open`,()=>{n===s&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==s)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=o.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==s||l)return;if(s=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)s||m();else{clearTimeout(c),c=void 0;let e=s;s=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),m(),{send(e){s?.readyState===Ae&&s.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=s;s=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(ue,{children:(0,Y.jsxs)(le,{children:[(0,Y.jsx)(oe,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[860px]:gap-1.5 @min-[860px]:px-2.5`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[860px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):e?(0,Y.jsx)(ue,{children:(0,Y.jsxs)(le,{children:[(0,Y.jsx)(oe,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function X({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
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{$r as i,Qr as a,_r as o,ei as s,n as c}from"./toaster-zMN8cNZQ.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{t as d}from"./check-OP-CVgZG.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,t as m}from"./circle-x-7nTlobAF.js";import{n as h,t as g}from"./smartphone-Lr8Ug2z_.js";import{t as _}from"./info-DA1x_4bz.js";import{t as v}from"./loader-circle-CPBhhDbB.js";import{n as y,t as ee}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-B9NN44oU.js";import{n as te,o as S,s as C}from"./thread-state-zzV37Hgs.js";import{t as ne}from"./square-terminal-B6RYYieR.js";import{t as w}from"./button-C8jUIs8Q.js";import{a as T,c as re,i as E,l as D,p as O,r as k,s as ie,t as A}from"./dropdown-menu-DjtKUK8F.js";import{s as ae}from"./project-router-j0uBi7Ep.js";import{t as j}from"./status-dot-BXf-Ubd0.js";import{Qn as oe,Sr as se,Xn as ce,Yn as le,Zn as ue,b as de,br as M,c as fe,f as pe,h as me,l as he,m as N,p as ge,pr as _e,ur as ve,x as ye,y as be,yr as xe}from"./index-TOx-AA67.js";var Se=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),P=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Ce=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),F=l(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),I=l(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),L=l(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),we=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),R=l(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),z=l(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Te=l(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Ee=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),B=l(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),V=l(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),H=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),U=l(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),W=l(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),G=l(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),K=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),q=l(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),De=l(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,s=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||a(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,s=n,n.addEventListener(`open`,()=>{n===s&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==s)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=o.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==s||l)return;if(s=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)s||m();else{clearTimeout(c),c=void 0;let e=s;s=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),m(),{send(e){s?.readyState===Ae&&s.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=s;s=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(ue,{children:(0,Y.jsxs)(le,{children:[(0,Y.jsx)(oe,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[860px]:gap-1.5 @min-[860px]:px-2.5`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[860px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):e?(0,Y.jsx)(ue,{children:(0,Y.jsxs)(le,{children:[(0,Y.jsx)(oe,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ce,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function X({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
2
2
  `);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(M,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Ne=/^([a-z][a-z0-9+.-]*):/i;function Pe(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Ne.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Fe(n):Fe(`http://${n}`)}function Fe(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Ie(e){return e.replace(/^https?:\/\//i,``)}var Le=`https://github.com/hearsay-tools/squawk#environment-variables`;function Re({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(He,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(We,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(Ge,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(qe,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Xe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)(Ze,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(tt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(rt,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(it,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(at,{actions:t});case`taken-over`:return(0,Y.jsx)(st,{state:e,actions:t})}}function Z({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Q=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),$=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function ze({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ne,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${N(e.command)} in this task's worktree, on the host.`})]})}function Be({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ve({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(ze,{server:e})})]})}function He({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Q,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ue(e){return Math.round(e/1e6)}function We({state:e,actions:t}){let n=(0,J.useRef)(null);n.current??={at:Date.now(),received:e.received};let r=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,i=(Date.now()-n.current.at)/1e3,a=i>=1?(e.received-n.current.received)/i:0,o=a>0?Math.ceil((e.total-e.received)/a):void 0;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Q,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ue(e.received)} of ${Ue(e.total)} MB · ${r}%`}),o===void 0?null:(0,Y.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ge({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Q,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Ke({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(W,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsx)(Q,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function qe({state:e,actions:t}){let n=e.reason===`timeout`,r=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,i=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,a=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Q,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Je=2;function Ye(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Xe({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:r?(0,Y.jsx)(q,{className:`text-pending-strong`}):(0,Y.jsx)(b,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,Y.jsx)(Q,{children:r?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ve,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(b,{"aria-hidden":`true`}),`Run and open`]})})]})}function Ze({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,Y.jsx)(Q,{children:`Task "${r}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function Qe({state:e,actions:t}){let{server:n}=e,r=Ye(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Je-(r-a)/1e3));return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(b,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Q,{children:`Squawk ran ${N(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(v,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),s>0?`Attempt ${e.attempt} · next try in ${s} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(X,{text:e.logTail.join(`
3
3
  `),source:N(n.command),onCopy:t.copy}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function $e({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(R,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,Y.jsx)(Q,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(X,{text:e.logTail,source:N(n.command),onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Q,{children:`${N(n.command)} stopped.`}),(0,Y.jsx)(X,{text:e.logTail,source:N(n.command),onCopy:t.copy}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}function tt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(ee,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,Y.jsx)(Q,{children:r?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Ie(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Ie(e.lastUrl)}.`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}var nt=[`browser`,`page`,`frame`];function rt({step:e,url:t}){let n=nt.indexOf(e),i=t?Ie(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(p,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(v,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(Ce,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function it({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(L,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Q,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(S,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function at({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Me,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(V,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsx)(Q,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ot(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function st({state:e,actions:t}){let n=ot(e.by);return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Q,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ct({attempt:e,exhausted:t,onReconnect:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(w,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function lt({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":i?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Q,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),i?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(q,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:a,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let r=pe(e,t),i=me(r);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>n(e.port),children:ge(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(_,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ut({dialog:e,onResult:t}){let[n,r]=(0,J.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,J.useRef)(null),o=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,J.useRef)(t);s.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),s.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let c=()=>t(e.type===`prompt`?{accept:!0,text:n}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-card-edge bg-card p-4 shadow-modal`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(i?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,Y.jsx)(w,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var dt=10,ft=500,pt=500,mt=4,ht=16,gt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function _t(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function vt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var yt=[`left`,`middle`,`right`];function bt(e,t,n,r){let i=_t(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:yt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:gt(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=_t(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:xt(r/e.scale),deltaY:xt(i/e.scale),modifiers:0}}function Ct(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=dt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[St(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=ft;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[bt(`mouseMoved`,t,a,{button:`none`,buttons:0}),bt(`mousePressed`,t,a,{button:`left`,buttons:1}),bt(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function wt(e,t){if(e.pointerType===`touch`)return Ct(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=pt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=mt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[bt(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[bt(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[bt(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Tt(e,t,n){let r=_t(e.clientX,e.clientY,t,n),i=e.deltaMode===1?ht:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:gt(e)}}var Et={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Dt(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:gt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Et[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:gt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function Ot(e){return e?{t:`insertText`,text:e}:void 0}var kt=e=>e,At=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function jt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(vt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of wt(kt(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Tt(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=Ot(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(At(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Dt(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Mt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Nt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:o,renderInput:s,children:c}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(o);m.current=o,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!a()))try{let i=await Mt(e);try{if(t!==l.current||!a()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Pt=`cez-preview-quality`,Ft=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function It(e){return Ft.find(t=>t.value===e)?.value??`normal`}var Lt=e=>Ft.find(t=>t.value===e)?.label??`Normal`;function Rt(){try{return It(localStorage.getItem(Pt))}catch{return`normal`}}function zt(e){try{localStorage.setItem(Pt,e)}catch{}}var Bt=[{w:390,h:844,icon:g},{w:820,h:1180,icon:G},{w:1440,h:900,icon:y}],Vt=`size-8 shrink-0 max-md:size-11`,Ht=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Ut(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Wt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Gt({stats:e,shrunk:t}){let n=Ut(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[960px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`max-w-[9rem] min-w-0 gap-1.5 @min-[760px]:max-w-[11rem] max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(C,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]})}function Jt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Yt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Xt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,J.useRef)(null),a=e.urlInputRef??i,o=(0,J.useRef)(!1),[s,c]=(0,J.useState)(null),[l,d]=(0,J.useState)(!1),f=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(Se,{"aria-hidden":`true`})}),p=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),m=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(U,{"aria-hidden":`true`})}),h=e.onSession?(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(se,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,Y.jsx)(Qt,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:d}),{agentListed:v}=Yt(e),y=e.servers.length+ +!!v>=2,ee=y||e.adopted,b={back:f,forward:p,reload:m,address:_,more:(0,Y.jsx)(rn,{props:e,compact:t}),session:h,progress:g};return t?(0,Y.jsx)(an,{props:e,elements:b}):(0,Y.jsx)(on,{props:e,elements:b,switcher:y,crowded:ee,input:a,focusUrlAfterMenu:o})}function Zt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Yt(e);return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=me(pe(t,e.serverStates));return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(h,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function Qt({props:e,input:t,draft:n,setDraft:i,focused:a,setFocused:o}){let{url:s,adopted:c}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-20 flex-1 items-center`,children:[(0,Y.jsx)(h,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(a?s:Ie(s)),title:s||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,c?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;o(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{o(!1),i(null)},onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??s),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),c&&!a?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(z,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(Ee,{"aria-hidden":`true`}):(0,Y.jsx)(y,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[620px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(E,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(Ee,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(E,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(d,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ie,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(re,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(we,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[680px]:inline`,children:Lt(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Gt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,role:`img`,"aria-label":t.label,title:t.label,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:t.tone,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[760px]:inline`,children:t.label})]}):null}function rn({props:e,compact:t}){let{stats:n,navEnabled:r,url:i,current:a,adopted:o}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(xe,{"aria-hidden":`true`})})}),(0,Y.jsxs)(k,{align:`end`,className:`min-w-64`,children:[n&&!t?(0,Y.jsx)(T,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(n)}):null,(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!r,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:i===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(_e,{"aria-hidden":`true`}),`Copy page URL`]}),a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),o?(0,Y.jsxs)(E,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(Te,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${a.label} :${a.port}`}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,Y.jsxs)(E,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(a.port),children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Stop server · ${a.label} :${a.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(ve,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function an({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Yt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Jt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function on({props:e,elements:t,switcher:n,crowded:r,input:i,focusUrlAfterMenu:a}){let{badge:o=!0,stats:s,status:c}=e,{back:l,forward:u,reload:d,address:f,more:p,session:m,progress:h}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1 border-b border-border bg-background px-2 py-2 @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,children:[m,l,u,d,n?(0,Y.jsx)(Zt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:s,status:c,crowded:r}),o?(0,Y.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(ve,{"aria-hidden":`true`})}),h]})}function sn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function cn(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(Re,{...n,actions:o})}case`empty`:return(0,Y.jsx)(lt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function ln(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function un(){let[e,t]=(0,J.useState)(ln);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(ln());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var dn=2e3,fn=500,pn=1e3;function mn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function hn(e){navigator.clipboard?.writeText(e).then(()=>c(`Copied`),()=>c(`Couldn't copy to the clipboard`,{tone:`danger`}))}var gn=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function _n(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function vn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function yn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:o}){let l=un(),u=(0,J.useRef)(l);u.current=l;let d=s(),f=(0,J.useRef)(crypto.randomUUID()),p=(0,J.useRef)(!1),m=ae(),h=de(be,!1),[g,_]=(0,J.useState)(0),[v,y]=(0,J.useState)({state:`connecting`,attempt:0}),[ee,b]=(0,J.useState)(!1),[x,te]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[ne,w]=(0,J.useState)(``),[T,re]=(0,J.useState)(void 0),[E,D]=(0,J.useState)(!1),[O,k]=(0,J.useState)(void 0),[ie,A]=(0,J.useState)(!1),[j,oe]=(0,J.useState)(!1),[se,ce]=(0,J.useState)(void 0),[le,ue]=(0,J.useState)(void 0),[M,fe]=(0,J.useState)(void 0),[pe,me]=(0,J.useState)(`fit`),[he,N]=(0,J.useState)(Rt),[ge,_e]=(0,J.useState)(null),[ve,ye]=(0,J.useState)(void 0),[xe,Se]=(0,J.useState)(0),P=(0,J.useRef)(void 0),Ce=(0,J.useRef)(null),F=(0,J.useRef)(null),I=(0,J.useRef)(void 0),L=(0,J.useRef)(void 0),we=(0,J.useRef)(he);we.current=he;let R=(0,J.useRef)({port:T,stage:S,agent:E});R.current={port:T,stage:S,agent:E};let z=(0,J.useRef)([]),Te=(0,J.useRef)(void 0),Ee=(0,J.useRef)(!1),B=(0,J.useRef)(!1),V=(0,J.useCallback)(e=>{B.current&&P.current?.send(e)},[]),H=(0,J.useRef)([]),U=(0,J.useCallback)(e=>{B.current?P.current?.send(e):H.current.push(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:m??`default`,runId:e.id},{onFrame(e){if(!a())return;let n=Date.now();z.current.push({at:n,bytes:e.size}),Ee.current||(Ee.current=!0,oe(!0)),(Ce.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&Se(e=>e+1),L.current!==void 0&&mn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return w(e.url);case`cursor`:return ce(e.cursor);case`dialog`:return ue(e);case`pong`:Te.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:te(e.by),B.current=!1,H.current=[],t?.close();return}},onTransport(e,n){if(B.current=e===`open`,y({state:e,attempt:n??0}),(e===`blocked`||e===`closed`)&&(H.current=[]),e===`open`){b(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:f.current,resume:p.current,quality:we.current,dpr:u.current}),p.current=!0);for(let e of H.current.splice(0))t?.send(e)}}}),P.current=t,()=>{B.current=!1,H.current=[],t?.close(),P.current===t&&(P.current=void 0)}},[m,e.id,g]);let W=d&&v.state===`open`&&x===void 0,G=h||pe===`fit`?ge:pe;(0,J.useEffect)(()=>{G&&W&&(S?.stage===`streaming`||S?.stage===`loading`)&&V({t:`resize`,w:G.w,h:G.h,...l===1?{}:{dpr:l}})},[G?.w,G?.h,l,W,S?.stage,xe,V]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>V({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[W,V]);let K=W&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){fe(void 0);return}let e=setInterval(()=>{let e=Date.now();z.current=z.current.filter(t=>e-t.at<=pn);let t={fps:z.current.length,kbps:Math.round(z.current.reduce((e,t)=>e+t.bytes,0)/1024),...Te.current===void 0?{}:{rttMs:Te.current},...z.current.length>0?{lastFrameAt:z.current.at(-1).at}:{}};fe(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},fn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{O&&r?.(O)},[O,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,A(!0),C(void 0),te(void 0),ye(void 0),w(t),re(`port`in e?e.port:void 0),D(`agent`in e),k(vn(e)),V({t:`open`,target:e,viewerId:f.current,quality:we.current,dpr:u.current}),p.current=B.current},[V]),De=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,q]),Oe=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(R.current.agent&&R.current.stage?.stage===`streaming`)return;Oe();return}if(n?.url!==void 0){let e=Pe(n.url,t);e.kind===`server`?De(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||R.current.port===n.port&&R.current.stage?.stage===`streaming`&&n.run!==!0||De(n.port,n.run===!0))},[n]);let ke=!ie&&!x&&v.state!==`blocked`,Ae=_n(n,t);(0,J.useEffect)(()=>{ke&&!Ae&&F.current?.focus()},[ke,Ae]);let Y=e=>{let n=Pe(e,t);if(n.kind===`error`)return ye(n.message);if(n.kind===`server`)return De(n.port);if(R.current.stage?.stage===`streaming`&&!R.current.agent)return I.current={url:n.url},L.current=void 0,re(void 0),k({url:n.url}),ye(void 0),w(n.url),V({t:`nav`,url:n.url});q({url:n.url},n.url)},Me=(0,J.useCallback)(e=>{we.current=e,N(e),zt(e),V({t:`quality`,quality:e})},[V]),X=()=>{p.current=!1,te(void 0),y({state:`connecting`,attempt:0}),Ee.current=!1,_(e=>e+1)};return{compact:h,transport:v,everOpened:ee,takenOver:x,stage:S,url:ne,port:T,agent:E,hasFrame:j,cursor:se,dialog:le,setDialog:ue,stats:M,viewport:pe,setViewport:me,quality:he,chooseQuality:Me,setStageSize:_e,addressError:ve,stageHandle:Ce,urlInput:F,send:V,connected:W,streaming:K,openServer:De,openAgent:Oe,empty:ke,navigate:Y,reconnect:X,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>{B.current?V({t:`run`,port:e}):c(`The preview is reconnecting. Run the server again once it is back.`,{tone:`danger`})},stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:o,useHere:X,copy:hn}),[V,U,o])}}function bn(e){return(0,Y.jsx)(ye,{onClose:e.onClose,children:(0,Y.jsx)(Cn,{...e})})}function xn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Sn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Sn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function Cn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=yn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:b,addressError:x,urlInput:te,send:S,streaming:C,openServer:ne,openAgent:w,empty:T,navigate:re,actions:E}=s,D=n.find(e=>e.port===m),O=f?.stage===`streaming`&&f.adopted,k=u&&(l.state===`reconnecting`||l.state===`closed`),{content:ie,dim:A}=sn({transport:l.state,takenOver:d,empty:T,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),ae=cn(ie,{servers:n,serverStates:r,agentLive:i,openServer:ne,openAgent:w,actions:E});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Xt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:D,agentLive:i===!0,agentShown:h,adopted:O,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:C,loading:f?.stage===`loading`,stats:C?_??{fps:0,kbps:0}:void 0,status:C?void 0:xn(l,u,d!==void 0,f),urlInputRef:te,onSession:a,onNavigate:re,onBack:()=>S({t:`back`}),onForward:()=>S({t:`forward`}),onReload:e=>S({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>ne(e),onPickAgent:w,onViewport:y,onQuality:b,onCopyUrl:()=>hn(p),onStop:E.stop,onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(wn,{transportState:s,overlay:ae,dim:A,lost:k})]})}function wn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ct,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(ut,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=he(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of te(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=fe(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{Ft as t,U as n,un as r,xt as i}from"./queries-jsRcJKo6.js";import{Lt as a,n as o}from"./toaster-C1BFyQ8i.js";import{y as s}from"./design-icons-QbNMZniQ.js";import{n as c,t as l}from"./open-in-menu-CI3ceNjU.js";import{s as u}from"./project-router-C53GCY_8.js";import{Bn as d}from"./index-WGWSicA9.js";import{n as f}from"./settings-field-Bhh8I9fJ.js";var p=e();function m(){let e=u(),t=i().data;return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function h(e){navigator.clipboard.writeText(e).then(()=>o(`Project folder copied`)).catch(()=>o(e))}function g(){let e=m(),n=t().data?.homeDir??null;return e===null?null:(0,p.jsx)(f,{wide:!0,title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,p.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,p.jsx)(d,{"data-slot":`project-location-path`,value:e,bases:{home:n,root:null},wrap:!0,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] text-foreground`}),(0,p.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>h(e),className:`inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-card px-3 text-xs text-foreground transition-colors hover:bg-muted`,children:[(0,p.jsx)(s,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,p.jsx)(_,{root:e})]})]})})}function _({root:e}){let t=n(),i=r({mutationFn:e=>a(e),onError:e=>o(e.message,{tone:`danger`})}),s=(t.data?.targets??[]).filter(e=>c(e.id)===void 0).map(e=>({target:e}));return s.length===0?null:(0,p.jsx)(l,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:i.isPending,choices:s,onPick:e=>i.mutate(e,{onSuccess:()=>o(`Opening the project folder in ${s.find(t=>t.target.id===e)?.target.label??e}`)})})}export{m as n,g as t};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{Ft as t,U as n,un as r,xt as i}from"./queries-CchoEEzj.js";import{Lt as a,n as o}from"./toaster-zMN8cNZQ.js";import{y as s}from"./design-icons-QbNMZniQ.js";import{n as c,t as l}from"./open-in-menu-Bzca0KPF.js";import{s as u}from"./project-router-j0uBi7Ep.js";import{Bn as d}from"./index-TOx-AA67.js";import{n as f}from"./settings-field-Bhh8I9fJ.js";var p=e();function m(){let e=u(),t=i().data;return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function h(e){navigator.clipboard.writeText(e).then(()=>o(`Project folder copied`)).catch(()=>o(e))}function g(){let e=m(),n=t().data?.homeDir??null;return e===null?null:(0,p.jsx)(f,{wide:!0,title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,p.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,p.jsx)(d,{"data-slot":`project-location-path`,value:e,bases:{home:n,root:null},wrap:!0,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] text-foreground`}),(0,p.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>h(e),className:`inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-card px-3 text-xs text-foreground transition-colors hover:bg-muted`,children:[(0,p.jsx)(s,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,p.jsx)(_,{root:e})]})]})})}function _({root:e}){let t=n(),i=r({mutationFn:e=>a(e),onError:e=>o(e.message,{tone:`danger`})}),s=(t.data?.targets??[]).filter(e=>c(e.id)===void 0).map(e=>({target:e}));return s.length===0?null:(0,p.jsx)(l,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:i.isPending,choices:s,onPick:e=>i.mutate(e,{onSuccess:()=>o(`Opening the project folder in ${s.find(t=>t.target.id===e)?.target.label??e}`)})})}export{m as n,g as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{a as r}from"./toaster-C1BFyQ8i.js";import{f as i,i as a,l as o,n as s,p as c,r as l}from"./chunk-KS7C4IRE-Cg8l-LDN.js";var u=e(t(),1),d=n(),f=/^\/p\/([^/]+)(?=\/|$)/;function p(e){let t=f.exec(e)?.[1];return t===void 0?null:decodeURIComponent(t)}function m(e){let t=f.exec(e);if(!t)return e;let n=e.slice(t[0].length);return n===``?`/`:n}function h(e,t){return!t.startsWith(`/`)||t===`/p`||t.startsWith(`/p/`)?t:`/p/${encodeURIComponent(e)}${t}`}function g(e,t){return e===null?t:typeof t==`string`?h(e,t):t.pathname===void 0?t:{...t,pathname:h(e,t.pathname)}}function _(){let{projectId:e}=r(),{pathname:t}=i();return e??p(t)}function v(){let e=_();return(0,u.useCallback)(t=>g(e,t),[e])}function y(e){let{pathname:t}=i();return(0,u.useMemo)(()=>o(e,m(t)),[e,t])}function b({to:e,...t}){let n=v();return(0,d.jsx)(s,{...t,to:n(e)})}function x({to:e,...t}){let n=v();return(0,d.jsx)(l,{...t,to:n(e)})}function S({to:e,...t}){let n=v();return(0,d.jsx)(a,{...t,to:n(e)})}function C(){let e=c(),t=v();return(0,u.useMemo)(()=>((n,r)=>typeof n==`number`?e(n):e(t(n),r)),[e,t])}export{g as a,C as c,p as i,y as l,x as n,m as o,S as r,_ as s,b as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{a as r}from"./toaster-zMN8cNZQ.js";import{f as i,i as a,l as o,n as s,p as c,r as l}from"./chunk-KS7C4IRE-Cg8l-LDN.js";var u=e(t(),1),d=n(),f=/^\/p\/([^/]+)(?=\/|$)/;function p(e){let t=f.exec(e)?.[1];return t===void 0?null:decodeURIComponent(t)}function m(e){let t=f.exec(e);if(!t)return e;let n=e.slice(t[0].length);return n===``?`/`:n}function h(e,t){return!t.startsWith(`/`)||t===`/p`||t.startsWith(`/p/`)?t:`/p/${encodeURIComponent(e)}${t}`}function g(e,t){return e===null?t:typeof t==`string`?h(e,t):t.pathname===void 0?t:{...t,pathname:h(e,t.pathname)}}function _(){let{projectId:e}=r(),{pathname:t}=i();return e??p(t)}function v(){let e=_();return(0,u.useCallback)(t=>g(e,t),[e])}function y(e){let{pathname:t}=i();return(0,u.useMemo)(()=>o(e,m(t)),[e,t])}function b({to:e,...t}){let n=v();return(0,d.jsx)(s,{...t,to:n(e)})}function x({to:e,...t}){let n=v();return(0,d.jsx)(l,{...t,to:n(e)})}function S({to:e,...t}){let n=v();return(0,d.jsx)(a,{...t,to:n(e)})}function C(){let e=c(),t=v();return(0,u.useMemo)(()=>((n,r)=>typeof n==`number`?e(n):e(t(n),r)),[e,t])}export{g as a,C as c,p as i,y as l,x as n,m as o,S as r,_ as s,b as t};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{o as i}from"./dist-C_rn70hE.js";import{Dt as a,Ft as o,Nt as s,Rt as c,Wt as l,un as u,xt as d,zt as f}from"./queries-jsRcJKo6.js";import{n as p,un as m,vi as h}from"./toaster-C1BFyQ8i.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{k as _,mt as ee}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-C8jUIs8Q.js";import{n as y,r as b,t as x}from"./popover-CvL6hQ5c.js";import{t as S}from"./centered-state-BgSV4e79.js";import{Bn as C,an as w,cn as T,cr as E,in as D,nn as O,on as k,rn as A,sn as j,tn as M}from"./index-WGWSicA9.js";import{t as te}from"./option-select-CFhKFk8u.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-Bhh8I9fJ.js";import{t as L}from"./use-path-bases-CeKWHR1g.js";import{r as R}from"./settings-save-bar-Czqju-k9.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-Dn5CWzHj.js";var V=t(n(),1),H=r();function U(){let e=a();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{p(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>p(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:o().data?.homeDir??null,root:null};return(0,H.jsx)(M,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(j,{children:[(0,H.jsxs)(T,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(w,{children:[`This only unregisters the project — `,(0,H.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,e?(0,H.jsx)(C,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(k,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(O,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=o(),t=d();return e.isPending||t.isPending?(0,H.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,H.jsx)(S,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(v,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(E,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,footer:o,refreshProjects:s=!1}){let c=h(),d=u({mutationFn:t=>m(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{c.setQueryData(l.config,t),e===`browseRoot`?c.invalidateQueries({queryKey:l.fsBrowseRoot}):s&&c.invalidateQueries({queryKey:l.projects})}}),[f,p]=z(t),g=f.trim();R({dirty:g!==t,invalid:g===``,save:()=>d.mutateAsync(g),discard:()=>{p(t),d.reset()}});let _=d.isError?d.error.message:null;return(0,H.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${a}-root`,value:f,disabled:d.isPending,placeholder:i,onChange:e=>{p(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:o}):(0,H.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=U(),s=(0,V.useMemo)(()=>c(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:s,disabled:o.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),o.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(C,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(C,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(v,{asChild:!0,variant:`outline`,children:(0,H.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function Q({project:e,vocabulary:t,onSaved:n}){let r=s(),[a,o]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(-1),m=(0,V.useRef)(null),h=e.tags??[],g=f(t,h,a),_=c&&g.length>0,v=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},S=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(h.some(e=>e.toLowerCase()===n.toLowerCase())){o(``);return}if(h.length>=20){p(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}o(``),v([...h,n])}},C=e=>{v(h.filter(t=>t!==e))},w=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[h.map(t=>(0,H.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(ee,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(x,{open:_,onOpenChange:l,children:[(0,H.jsx)(y,{asChild:!0,children:(0,H.jsx)(`input`,{ref:m,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&u>=0?`${w}-${u}`:void 0,placeholder:h.length===0?`Add tag…`:`+`,value:a,maxLength:32,disabled:r.isPending,onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:e=>{if(l(!0),d(-1),e.target.value.includes(`,`)){o(e.target.value.replace(/,/g,``));return}o(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(g.length===0)return;e.preventDefault(),l(!0);let t=e.key===`ArrowDown`?1:-1,n=u+t;d(n>=g.length?-1:n<-1?g.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),l(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),S(u>=0?g[u]??a:a);return}if(e.key===`Tab`){l(!1);return}if(e.key===`Backspace`&&a===``&&h.length>0){e.preventDefault();let t=h[h.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,H.jsxs)(b,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,H.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),g.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===u,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{S(e),m.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===u&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=s(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(te,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
1
+ import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{o as i}from"./dist-C_rn70hE.js";import{Dt as a,Ft as o,Nt as s,Rt as c,Wt as l,un as u,xt as d,zt as f}from"./queries-CchoEEzj.js";import{n as p,un as m,vi as h}from"./toaster-zMN8cNZQ.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{k as _,mt as ee}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-C8jUIs8Q.js";import{n as y,r as b,t as x}from"./popover-CvL6hQ5c.js";import{t as S}from"./centered-state-BgSV4e79.js";import{Bn as C,an as w,cn as T,cr as E,in as D,nn as O,on as k,rn as A,sn as j,tn as M}from"./index-TOx-AA67.js";import{t as te}from"./option-select-BUpASY9Q.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-Bhh8I9fJ.js";import{t as L}from"./use-path-bases-Cimv7R-0.js";import{r as R}from"./settings-save-bar-DmONROMw.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-Dn5CWzHj.js";var V=t(n(),1),H=r();function U(){let e=a();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{p(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>p(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:o().data?.homeDir??null,root:null};return(0,H.jsx)(M,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(j,{children:[(0,H.jsxs)(T,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(w,{children:[`This only unregisters the project — `,(0,H.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,e?(0,H.jsx)(C,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(k,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(O,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=o(),t=d();return e.isPending||t.isPending?(0,H.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,H.jsx)(S,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(v,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(E,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,footer:o,refreshProjects:s=!1}){let c=h(),d=u({mutationFn:t=>m(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{c.setQueryData(l.config,t),e===`browseRoot`?c.invalidateQueries({queryKey:l.fsBrowseRoot}):s&&c.invalidateQueries({queryKey:l.projects})}}),[f,p]=z(t),g=f.trim();R({dirty:g!==t,invalid:g===``,save:()=>d.mutateAsync(g),discard:()=>{p(t),d.reset()}});let _=d.isError?d.error.message:null;return(0,H.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${a}-root`,value:f,disabled:d.isPending,placeholder:i,onChange:e=>{p(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:o}):(0,H.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=U(),s=(0,V.useMemo)(()=>c(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:s,disabled:o.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),o.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(C,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(C,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(v,{asChild:!0,variant:`outline`,children:(0,H.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function Q({project:e,vocabulary:t,onSaved:n}){let r=s(),[a,o]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(-1),m=(0,V.useRef)(null),h=e.tags??[],g=f(t,h,a),_=c&&g.length>0,v=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},S=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(h.some(e=>e.toLowerCase()===n.toLowerCase())){o(``);return}if(h.length>=20){p(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}o(``),v([...h,n])}},C=e=>{v(h.filter(t=>t!==e))},w=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[h.map(t=>(0,H.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(ee,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(x,{open:_,onOpenChange:l,children:[(0,H.jsx)(y,{asChild:!0,children:(0,H.jsx)(`input`,{ref:m,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&u>=0?`${w}-${u}`:void 0,placeholder:h.length===0?`Add tag…`:`+`,value:a,maxLength:32,disabled:r.isPending,onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:e=>{if(l(!0),d(-1),e.target.value.includes(`,`)){o(e.target.value.replace(/,/g,``));return}o(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(g.length===0)return;e.preventDefault(),l(!0);let t=e.key===`ArrowDown`?1:-1,n=u+t;d(n>=g.length?-1:n<-1?g.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),l(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),S(u>=0?g[u]??a:a);return}if(e.key===`Tab`){l(!1);return}if(e.key===`Backspace`&&a===``&&h.length>0){e.preventDefault();let t=h[h.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,H.jsxs)(b,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,H.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),g.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===u,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{S(e),m.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===u&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=s(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(te,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
@@ -1,2 +1,2 @@
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{O as i,Ut as a,qt as o,un as s}from"./queries-jsRcJKo6.js";import{R as c,n as l,vi as u}from"./toaster-C1BFyQ8i.js";import{K as d,X as f,l as p,mt as m,rt as h,st as g,u as _}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-C8jUIs8Q.js";import{i as y,r as b,t as x}from"./popover-CvL6hQ5c.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-BiBq24zL.js";import{f as O,i as k,p as A,u as j}from"./skills-pM_PouEs.js";import{t as M}from"./centered-state-BgSV4e79.js";import{dt as N,mt as P,sr as F,st as I,ut as L}from"./index-WGWSicA9.js";import{t as R}from"./textarea-vEsJAUAV.js";import{n as z,t as B}from"./settings-field-Bhh8I9fJ.js";import{r as V}from"./settings-save-bar-Czqju-k9.js";import{n as H,t as U}from"./saved-draft-BwzBc-_Y.js";import{t as W}from"./settings-list-detail-Dn5CWzHj.js";var G=e(t(),1),K=n();function q({template:e}){let t=e.text.trim().split(`
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{O as i,Ut as a,qt as o,un as s}from"./queries-CchoEEzj.js";import{R as c,n as l,vi as u}from"./toaster-zMN8cNZQ.js";import{K as d,X as f,l as p,mt as m,rt as h,st as g,u as _}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-C8jUIs8Q.js";import{i as y,r as b,t as x}from"./popover-CvL6hQ5c.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-BiBq24zL.js";import{f as O,i as k,p as A,u as j}from"./skills-pM_PouEs.js";import{t as M}from"./centered-state-BgSV4e79.js";import{dt as N,mt as P,sr as F,st as I,ut as L}from"./index-TOx-AA67.js";import{t as R}from"./textarea-vEsJAUAV.js";import{n as z,t as B}from"./settings-field-Bhh8I9fJ.js";import{r as V}from"./settings-save-bar-DmONROMw.js";import{n as H,t as U}from"./saved-draft-BwzBc-_Y.js";import{t as W}from"./settings-list-detail-Dn5CWzHj.js";var G=e(t(),1),K=n();function q({template:e}){let t=e.text.trim().split(`
2
2
  `)[0]??``,n=e.skills?.length??0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`settings-list-row-title`,children:e.label.trim()||`Untitled template`}),(0,K.jsxs)(`span`,{className:`settings-list-row-meta`,children:[t||`No instructions yet`,n>0?` · ${n} skill${n===1?``:`s`}`:``]})]})}function J(){let e=i();return e.isPending?(0,K.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,K.jsx)(M,{icon:(0,K.jsx)(d,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,K.jsx)(Y,{initial:N(e.data.promptTemplates)})}function Y({initial:e}){let t=u(),n=o(),r=i(),[d,p]=H(e,U),[h,_]=(0,G.useState)(null),y=s({mutationFn:e=>c({promptTemplates:e}),onSuccess:(e,n)=>{t.setQueryData(a.uiState,e),p(t=>U(t,n)?N(e.promptTemplates):t)},onError:e=>l(e.message,{tone:`danger`})}),b=JSON.stringify(d)!==JSON.stringify(e),x=d.some(e=>e.label.trim()===``||e.text.trim()===``);V({dirty:b,invalid:x,save:()=>y.mutateAsync(d),discard:()=>p(e)});let S=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),C=(e,t)=>p(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),w=e=>{let t=d.findIndex(t=>t.id===e),n=d.filter(t=>t.id!==e);p(n),_(n[Math.min(t,n.length-1)]?.id??null)};return(0,K.jsx)(`div`,{"data-slot":`prompt-templates-section`,"data-reports-dirty":``,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,K.jsxs)(z,{wide:!0,title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,K.jsx)(W,{slot:`prompt-template-list`,label:`Prompt templates`,items:d,itemKey:e=>e.id,selectedKey:h,onSelect:_,empty:(0,K.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one, or reset to the built-ins.`}),row:e=>(0,K.jsx)(q,{template:e}),detail:e=>(0,K.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:B,children:`Template label`}),(0,K.jsx)(F,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>S(e.id,{label:t.target.value}),className:`flex-1 border-border bg-background`})]}),(0,K.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:B,children:`Instructions`}),(0,K.jsx)(R,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>S(e.id,{text:t.target.value}),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,K.jsx)(`p`,{className:B,children:`Apply automatically with skills`}),(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(X,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>C(e.id,t)}),(e.skills??[]).map(t=>(0,K.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>C(e.id,t),className:`inline-flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,K.jsx)(m,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,K.jsxs)(v,{type:`button`,className:`self-start`,variant:`danger-ghost`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>w(e.id),children:[(0,K.jsx)(g,{"aria-hidden":`true`,className:`size-3`}),`Delete template`]})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,K.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,onClick:()=>{let e=L();p(t=>[...t,{id:e,label:``,text:``}]),_(e)},children:[(0,K.jsx)(f,{"aria-hidden":`true`,className:`size-3.5`}),`New template`]}),(0,K.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:y.isPending,onClick:()=>p(I.map(e=>({...e}))),children:`Reset to defaults`}),x?(0,K.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-xs text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function X({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),u=(0,G.useRef)(null),{mostUsed:d,project:f,global:m,ranked:g}=j(t,c,n),v=(e,t)=>{let n=i.includes(e.id);return(0,K.jsxs)(w,{value:O(e),keywords:A(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,K.jsx)(P,{skill:e,emphasized:t}),n?(0,K.jsx)(p,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},O(e))};return(0,K.jsxs)(x,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,K.jsx)(y,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`text-foreground`),children:[(0,K.jsx)(h,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`Add skill`,(0,K.jsx)(_,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsx)(b,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,K.jsxs)(D,{shouldFilter:!1,children:[(0,K.jsx)(S,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,K.jsxs)(E,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,K.jsx)(C,{children:(0,K.jsxs)(w,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(g?g.length===0:d.length===0&&f.length===0&&m.length===0)?(0,K.jsx)(T,{children:`Nothing matches.`}):null,g?g.length>0?(0,K.jsx)(C,{children:g.map(e=>v(e,k(e)))}):null:(0,K.jsxs)(K.Fragment,{children:[d.length>0?(0,K.jsx)(C,{heading:`Most used`,children:d.map(e=>v(e,k(e)))}):null,f.length>0?(0,K.jsx)(C,{heading:`Project skills`,children:f.map(e=>v(e,!0))}):null,m.length>0?(0,K.jsx)(C,{heading:`Global`,children:m.map(e=>v(e,!1))}):null]})]})]})})]})}export{J as PromptTemplatesSection};
@@ -0,0 +1 @@
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{$ as i,$t as a,A as o,Ai as s,Bn as c,C as l,Ct as u,D as d,Di as f,Dt as p,E as m,Et as h,F as g,Fi as _,G as v,Hn as ee,Ht as te,It as ne,J as re,Jt as ie,K as ae,Kt as oe,L as se,Mi as ce,Mt as le,N as ue,Nt as de,O as fe,Ot as pe,Pi as me,Pt as he,Q as ge,Qt as _e,Ri as ve,Rn as ye,S as be,Si as xe,Sn as Se,St as Ce,Ti as we,Tr as Te,Un as Ee,Ur as De,Vn as Oe,Vr as ke,Vt as Ae,Wn as je,Wr as Me,Wt as Ne,X as Pe,Xr as Fe,Xt as Ie,Y as Le,Yr as Re,Yt as ze,Zt as Be,_n as Ve,_t as He,a as Ue,an as We,b as Ge,bn as Ke,br as qe,bt as Je,ci as Ye,cn as Xe,ct as Ze,di as Qe,en as $e,et,fi as tt,fn as nt,gn as rt,gt as it,h as at,hi as ot,hn as st,ii as ct,in as lt,k as ut,kt as dt,li as ft,ln as pt,m as mt,mi as ht,mn as gt,n as _t,nn as vt,oi as yt,on as bt,pi as xt,pn as St,pt as Ct,q as wt,qt as Tt,si as y,sn as Et,tn as Dt,ui as Ot,v as kt,vi as b,vt as At,wt as jt,x as Mt,xi as Nt,xn as Pt,xt as Ft,y as It,yi as Lt,yn as Rt,yt as zt,zn as Bt}from"./toaster-zMN8cNZQ.js";import{A as Vt,B as x,F as S,H as C,I as w,N as T,P as E,W as D,Z as O,a as Ht,j as k,z as A}from"./live-protocol-DMhTnCmf.js";function Ut(e,t){return e??t}function Wt(e,t){let n=Ut(e,t);return n===`1`||n===`true`}function Gt(e,t,n){return e?.trim()||Ut(t,n)||``}var Kt=class extends Nt{#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||qt(),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=xe({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),O.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function qt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Jt=class extends ve{#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),me(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&we(t.mutationKey)!==we(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??qt();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){O.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 Yt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Xt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Zt=class extends ve{#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,O.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||!me(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Yt(e,n).forEach(e=>{e.destroy()}),Yt(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=ce(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 Lt(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Xt(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)&&O.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},j=e(t(),1);function M({queries:e,...t},n){let r=b(n),i=ot(),a=ht(),o=j.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ye(e);let t=r.getQueryCache().get(e.queryHash);Qe(e,a,t)}),xt(a);let[c]=j.useState(()=>new Zt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(e=>f?c.subscribe(O.batchCalls(e)):s,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>Ot(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&Ot(n,e)?ft(n,new Lt(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&tt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function N(e,t){let n=b(t),[r]=j.useState(()=>new Jt(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);let i=j.useSyncExternalStore(j.useCallback(e=>r.subscribe(O.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((e,t)=>{r.mutate(e,t).catch(s)},[r]);if(i.error&&_(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function P(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function F(e,t={}){return{...P(t),runId:e}}function Qt(e,t=!0,n=!1,r){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>de(P({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function I(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:W.models(t),refetchType:n})}function $t(e,t=!0,n){return y({...en(e,n),enabled:t})}var en=(e,t)=>({queryKey:W.models(e,t),queryFn:({signal:n})=>je(e,{signal:n},t),staleTime:300*1e3});function tn(e,t=!0){let n=M({queries:e.map(e=>({...en(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function nn(e,t){return JSON.stringify([e,t])}function rn(e){return e.type===`run`?e.run.id:e.id}function L(e,t){return{...e,runs:t}}function an(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var on=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(nn(e.projectId,e.id),t))}at(e,t){return this.positions.get(nn(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 sn(e,t,n){let r=new on(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=pn(i,e.project,e.usage,r);else{let t=un(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function cn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function ln(e,t,n){return un(e,t,n,new on(e.runs))}function un(e,t,n,r){let{project:i}=t,a=r.at(i,rn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:L(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:L(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!cn(e,i,n))return{index:e,reconcile:!0};let l=ce(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||an(t,i)>e.perProjectLimit);return{index:L(e,t),reconcile:n}}if(s)return fn(e,l,r);let u=r.insert(l);return{index:L(e,u),reconcile:l.archived&&an(u,i)>e.perProjectLimit}}function dn(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 fn(e,t,n){let r=dn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:L(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function pn(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=ce(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?L(e,r.runs):e}function mn(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 hn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function gn(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 _n(e){e.stream=void 0}function vn(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,rn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function yn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function bn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function xn(e,t,n){if(!bn(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=ln(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 R=[`workspace`,`runs-index`],Sn=[`workspace`,`projects`],Cn=6e4,wn=100,Tn=new WeakMap;function En(e){let t=Tn.get(e);return t||(t=jn(e),Tn.set(e,t)),t}function Dn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:En(t).merge(e)}function On(e){let t=e.getQueryData(Sn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function kn(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 An(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 jn(e){let t=hn(),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(R,t)},h=()=>e.getQueryData(R),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:R,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:R,exact:!0}).then(()=>e.invalidateQueries({queryKey:R})):e.invalidateQueries({queryKey:R})).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=On(e),{index:s,reconcile:c}=sn(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})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,wn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){gn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){_n(t)},run(e,r,i=!1){if(l.has(e))return;let a=An(e,r);if(!vn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},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}),ee()}},dropProject(e){l.add(e),yn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=mn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=xn(t,n,On(e));for(let e of l)i.index=mn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),kn(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 Mn=k([`own`,`provider-spanning`]),Nn=x({suggested:T(x({id:D(),label:D(),desc:D()})),retired:T(D())}),Pn=x({id:k([`settings`,`mcp`,`memory`]),label:D(),note:D().optional(),empty:D().optional(),showsUserMcp:w(!0).optional()}),Fn=x({label:D(),note:D().optional(),groups:T(Pn)}),In=x({runners:T(x({id:ct,displayName:D(),modelListName:D(),modelIdScope:Mn,pickerLabel:D(),pickerDescription:D(),icon:D(),installHint:D(),loginCommand:D(),terminalLogin:E().optional(),browserLogin:E().optional(),managedInstall:w(!0).optional(),accountFolderExample:D().optional(),models:Nn,agentConfig:Fn}))}),Ln=[`workspace`,`runners`];async function Rn(e){return Ee(await Bt.api.v1.runners.$get({},c(e)),`/runners`,In)}var zn={queryKey:Ln,queryFn:({signal:e})=>Rn({signal:e}),staleTime:1/0};function Bn(){return y(zn)}function Vn(e){return e?.runners??[]}function Hn(e){return Vn(e).map(e=>e.id)}function Un(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Wn(e){let t=Bn();return{runner:t.isSuccess?Un(e,Hn(t.data))??e:e,ready:!t.isPending}}function z(e,t){return e?.runners.find(e=>e.id===t)}function Gn(e,t){return z(e,t)?.displayName??t}function Kn(e,t){return z(e,t)?.pickerLabel??t}function qn(e,t){return z(e,t)?.modelListName}function Jn(e,t,n=!0,i){let a=Ii(i,n),o=q(),{runner:s,ready:c}=Wn(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??r(),d=y({queryKey:U.runnerSkills(s,l,u),queryFn:({signal:e})=>m(s,l,{signal:e,projectId:u}),enabled:n&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...d,runner:s,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var Yn={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`}},Xn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Zn(e){return typeof e==`string`&&Object.hasOwn(Yn,e)}function Qn(e){return e!==void 0&&Zn(e)?Yn[e]:void 0}var $n=`cez.reference-statuses.v1`,er=`cez.reference-conflicts.v1`,B=new Map(ir()),tr=1e3;function nr(e,t){if(B.get(e)!==t){for(B.delete(e),B.set(e,t);B.size>tr;){let e=B.keys().next().value;if(e===void 0)break;B.delete(e)}sr()}}var V=new Set(ar());function rr(e,t){if(V.has(e)!==t){if(t)for(V.add(e);V.size>tr;){let e=V.values().next().value;if(e===void 0)break;V.delete(e)}else V.delete(e);sr()}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);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`&&Zn(e[1])):[]}catch{return[]}}function ar(){try{let e=globalThis.sessionStorage?.getItem(er);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var or;function sr(){or===void 0&&(or=setTimeout(()=>{or=void 0;try{globalThis.sessionStorage?.setItem($n,JSON.stringify([...B])),globalThis.sessionStorage?.setItem(er,JSON.stringify([...V]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function cr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function lr(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 ur(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;nr(t,o),s!==void 0&&rr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function dr(e,t,n){let r=H(t),i=B.get(r),a=V.has(r)?!0:void 0,o=n.data;if(o?.available){ur(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...cr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...cr(i,a)});return}e.set(r,{state:`loading`,...cr(i,a)})}function fr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of lr(i))dr(n,e,t)}),n}var U={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,n=r())=>[n,`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`]}},W={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:R,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)=>[...W.fsBrowseRoot,e,t]};function pr(){return Wt(void 0,void 0)}function G(e){return!pr()&&e}function mr(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 hr(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 gr(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 _r(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 vr(e,t){return Fe({kind:`topic`,topic:e},{value:t})}function yr(){let e=b();return y({queryKey:W.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(W.providerStatus),r=await Et(!1,{signal:t});return Te(n,e.getQueryData(W.providerStatus),r)},staleTime:5*6e4,refetchInterval:G(!1),refetchOnWindowFocus:!0})}function br(){let e=b();return N({mutationFn:()=>Et(!0),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t)),I(e)}})}function xr(){let e=b();return N({mutationFn:({provider:e,authFailureId:t})=>rt(e,t),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t,n.authFailureId)),I(e,n.provider)}})}function Sr(e={}){return y({queryKey:W.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function Cr(e,t=!1){return y({queryKey:W.fsBrowse(e,t),queryFn:({signal:n})=>ze(e??void 0,{signal:n,showHidden:t}),retry:!1})}function wr(){let e=b();return N({mutationFn:e=>nt(e),onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Tr(){let e=b();return N({mutationFn:e=>gt(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:W.projects})}})}function Er(){let e=b();return N({mutationFn:e=>{let{id:t,...n}=e;return Pt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:W.projects});let r=e.getQueryData(W.projects);return e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Dr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(W.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:W.projects})})}function Dr(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?[]:_r(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 Or(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(W.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:W.projects})})}function kr(){return Or(e=>{let{projectId:t,...n}=e;return $e(t,n)})}function Ar(){return Or(e=>{let{projectId:t,webhookId:n,...r}=e;return Se(t,n,r)})}function jr(){return Or(({projectId:e,webhookId:t})=>st(e,t))}function Mr(){return N({mutationFn:({projectId:e,webhookId:t})=>Rt(e,t),retry:!1})}function K(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:W.agentProfiles}),t.invalidateQueries({queryKey:W.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),I(t)])},onError:()=>{t.invalidateQueries({queryKey:U.health}),t.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function Nr(){return K(e=>_e(e))}function Pr(){return K(e=>{let{id:t,...n}=e;return Ke(t,n)})}function Fr(){return K(e=>St(e))}function Ir(){return K(e=>Ve(e))}function Lr(e,t){return y({queryKey:W.agentAccountStatus(e),queryFn:({signal:t})=>Dt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Rr(){let e=b();return N({mutationFn:({provider:e,profileId:t})=>Be(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:W.agentProfiles}),e.invalidateQueries({queryKey:W.providerStatus}),I(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:U.health}),e.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function zr(){let e=b();return N({mutationFn:e=>Dt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.agentAccountStatus(n),t),e.invalidateQueries({queryKey:W.agentProfiles}),I(e,t.status.provider)}})}function Br(){let e=b();return N({mutationFn:e=>Ie(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Vr(){let e=b();return N({mutationFn:e=>a(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Hr({enabled:e}){return y({queryKey:W.githubOwners,queryFn:({signal:e})=>lt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Ur(){let e=b();(0,j.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(U.health);r&&(De({bootProject:r.bootProject===void 0?`default`:r.bootProject,apiBase:n()}),t??=vr(`health`,t=>{e.setQueryData(U.health,t)}))};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),Re()}},[e])}function q(){return y({queryKey:U.health,queryFn:({signal:e})=>We({signal:e})})}function Wr(e,t){let n=q().data,r=Sr(t).data?.projects,i=Ue(),a=e??i.projectId,o=a??n?.bootProject??void 0,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:n?.bootProject!==null&&(a===null||a===n?.bootProject)?mr(n?.repo?.remote):void 0}function Gr(){return y({queryKey:W.uiState,queryFn:({signal:e})=>pt({signal:e})})}function Kr(){return y({queryKey:W.config,queryFn:({signal:e})=>Xe({signal:e})})}function qr(){return y({queryKey:W.agentProfiles,queryFn:({signal:e})=>vt({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=Me(),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,j.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Ht(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),Fe({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,j.useMemo)(()=>JSON.parse(a),[a]);(0,j.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 ee(await Bt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),Oe(e,`/worker-destroy`))}function ei(){return y({queryKey:U.openTargets,queryFn:({signal:e})=>Ft({signal:e}),staleTime:5*6e4})}function ti(e=!0,t){return y({queryKey:t?U.runs.list(t):U.runs.list(),queryFn:({signal:e})=>de(P(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function ni(e,t){return yt({queryKey:U.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>it({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 y({queryKey:W.runsSearch(t),queryFn:({signal:e})=>oe(t,{signal:e}),enabled:t.length>=2,placeholderData:f,staleTime:1e4})}function ii(e=!0,t=Cn,n){let r=En(b());return $(`/api/v1/workspace/runs-index`,W.runsIndex,G(e?t:!1),Dn),y({queryKey:W.runsIndex,queryFn:({signal:e})=>he({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return N({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:U.runs.relationships(e)})})}function oi(e,t={}){return y({queryKey:U.runs.relationships(e),queryFn:({signal:t})=>le(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return y({queryKey:U.runs.detail(e??``),queryFn:({signal:t})=>Ce(F(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return y({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Ce(F(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 y({queryKey:t?[t,`runs`,`diff`,e??``]:U.runs.diff(e??``),queryFn:({signal:n})=>p(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,U.runs.changes(e??``),G(t?4e3:!1)),y({queryKey:U.runs.changes(e??``),queryFn:({signal:t})=>u(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return y({queryKey:U.runs.file(e??``,t??``),queryFn:({signal:n})=>pe(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return y({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Je(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return y({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>He(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return y({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>At(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return y({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>zt(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,U.runs.commits(e??``),G(t?5e3:!1)),y({queryKey:U.runs.commits(e??``),queryFn:({signal:t})=>h(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return y({queryKey:U.runs.commit(e??``,t??``),queryFn:({signal:n})=>jt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return y({queryKey:U.runs.handoff(e??``),queryFn:({signal:t})=>dt(F(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return y({queryKey:e===void 0?U.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>dt(F(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let n=[...new Set(e)],i=M({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>kt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,j.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 N({mutationFn:t=>ne(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Si(e){let t=b();return N({mutationFn:t=>Ae(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=N({mutationFn:e=>ie(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,j.useCallback)(e=>({...F(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,j.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,j.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,j.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 N({mutationFn:e=>ie(F(e),!1),onMutate:t=>e.patchRead(()=>F(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return N({mutationFn:({id:t,pinned:n})=>te(F(t,e),n),onError:e=>_t(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??P(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return N({mutationFn:n=>Tt(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof ye&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return N({mutationFn:(n={})=>Ze(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return N({mutationFn:({msgId:t,message:n})=>Ct(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ki(e){let t=b();return N({mutationFn:t=>Ne(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ai(){return y({queryKey:U.workflows,queryFn:({signal:e})=>ut({signal:e})})}function ji(e){return y({queryKey:e?[e,`repo`]:U.repo,queryFn:({signal:t})=>Ge({signal:t},e)})}function Mi(e){return y({queryKey:[e,`repo`],queryFn:({signal:t})=>Ge({signal:t},e)})}function Ni(){return y({queryKey:U.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return y({queryKey:U.repoChanges,queryFn:({signal:e})=>be({signal:e}),retry:!1})}function Fi(e){return y({queryKey:U.repoCommit(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e,t=!0){return y({queryKey:e?[e,`config`]:U.config,queryFn:({signal:t})=>It({signal:t,...e?{projectId:e}:{}}),enabled:t})}function Li(){return y({queryKey:U.worktrees,queryFn:({signal:e})=>o({signal:e})})}function Ri(e){return y({queryKey:[e,`worktrees`],queryFn:({signal:t})=>o({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>fe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ke(e.sidebarLimits)},enabled:t})}function Bi(e=!0,t){return zi(t??r(),e)}function Vi(){return y({queryKey:U.agentConfig,queryFn:({signal:e})=>mt({signal:e})})}function Hi(e){return y({queryKey:U.agentConfigFile(e??``),queryFn:({signal:t})=>at(e,{signal:t}),enabled:e!==null})}function Ui(){return y({queryKey:U.sessionContext,queryFn:({signal:e})=>d({signal:e})})}function Wi(e,t,n=``){return y({queryKey:U.sessionContextPreview(e,t,n),queryFn:({signal:n})=>ue({content:e,role:t},{signal:n}),placeholderData:f,staleTime:0,retry:!1})}function Gi(){let e=b();return N({onMutate:()=>({fileKey:U.sessionContext}),mutationFn:e=>se(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=U.agentConfig,r=U.agentConfigFile(e);return N({mutationFn:t=>g(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=k([`passing`,`failing`,`pending`]).nullable(),Ji=x({kind:k([`issue`,`pr`]),number:A(),title:D(),author:D(),createdAt:D(),labels:T(D()),body:D().optional(),url:D(),comments:A(),assignees:T(D()).optional(),projectIds:T(D()).optional(),isDraft:E().optional(),additions:A().optional(),deletions:A().optional(),checks:qi.optional()});S(`available`,[x({available:w(!0),item:Ji.nullable(),labelColors:C(D(),D()).optional()}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),number:Vt().int().positive().safe()});var Yi=x({id:D(),title:D(),url:D()});x({available:E(),reason:D().optional(),repo:D().optional(),syncedAt:D().optional(),issues:T(Ji),prs:T(Ji),labelColors:C(D(),D()).optional(),viewerLogin:D().optional(),projects:T(Yi).optional(),projectsReason:D().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:D().optional(),issuesTotal:A().int().nonnegative().optional(),prsTotal:A().int().nonnegative().optional(),issuesNextCursor:D().nullable().optional(),prsNextCursor:D().nullable().optional(),commentsDeferred:w(!0).optional()});var Xi=D().min(1).max(2e3).optional();x({limit:D().optional(),refresh:D().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:w(`1`).optional(),prsDone:w(`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`})}),x({kind:k([`issue`,`pr`]),numbers:D().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:w(`1`).optional()}),S(`available`,[x({available:w(!0),counts:C(A(),A().int().nonnegative())}),x({available:w(!1),reason:D()})]),S(`available`,[x({available:w(!0),checks:C(A(),qi)}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),q:D().trim().min(1).max(256),limit:Vt().int().positive().max(50).optional()}),x({available:E(),projectsReason:D().optional(),reason:D().optional(),items:T(Ji),truncated:E().optional(),labelColors:C(D(),D()).optional()});var Zi=A().nullable();S(`available`,[x({available:w(!0),prs:C(A(),qe),issues:C(A(),qe),conflicts:T(A()).optional(),recheckAfterMs:Zi}),x({available:w(!1),reason:D(),recheckAfterMs:Zi})]);var Qi=x({id:A(),author:D(),avatarUrl:D().optional(),createdAt:D(),body:D(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:D()}),$i=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=x({id:D(),kind:$i,actor:D(),avatarUrl:D().optional(),createdAt:D(),url:D().optional(),sha:D().optional(),message:D().optional(),checks:qi.optional(),label:x({name:D(),color:D().optional()}).optional(),subject:D().optional(),refNumber:A().optional(),refTitle:D().optional(),refIsPr:E().optional()});x({available:E(),reason:D().optional(),comments:T(Qi),truncated:E().optional(),events:T(ea).optional(),detail:x({body:D(),additions:A().int().nonnegative().optional(),deletions:A().int().nonnegative().optional()}).optional()});var ta=k([`merge`,`squash`,`rebase`]),na=x({name:D(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:E().nullable(),url:D().optional()}),ra=x({number:A(),title:D(),url:D(),state:k([`open`,`closed`,`merged`]),isDraft:E(),headRef:D(),baseRef:D(),headSha:D(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:T(na),methods:T(ta),defaultMethod:ta.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:T(x({code:D(),message:D()})),canMerge:E(),canOverride:E()});S(`available`,[x({available:w(!0),mergeState:ra}),x({available:w(!1),reason:D()})]),x({merged:w(!0),number:A(),url:D(),method:ta,mergeCommitSha:D().optional()});var ia=x({path:D(),previousPath:D().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:A(),deletions:A(),patch:D().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:E().optional()});S(`available`,[x({available:w(!0),number:A(),headSha:D(),files:T(ia),additions:A(),deletions:A(),truncated:E(),reason:D().optional()}),x({available:w(!1),reason:D()})]),x({generation:D().uuid()}),S(`state`,[x({generation:D().uuid(),state:w(`ready`),projects:T(Yi),membership:C(D(),T(D()))}),x({generation:D().uuid(),state:w(`unavailable`),reason:D()})]);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)]}var da=class extends Error{};function fa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await v({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new da(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof da)&&!(t instanceof ye&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function pa(e=50,t=!0){let n=b(),i=U.githubPages(e),a=U.githubPagesHead(e);$(`/api/v1/p/${r()}/github?limit=${e}`,a,G(t?6e4:!1));let o=yt({...fa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=y({queryKey:a,queryFn:({signal:t})=>v({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,j.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=M({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,j.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,j.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ma(e,t=50,n=!0){let r=yt({...fa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,j.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ha(e,t,n=!0){let r=M({queries:t.filter(e=>e.length>0).map(t=>({queryKey:U.githubCommentCounts(e,t),queryFn:({signal:n})=>wt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,j.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 ga(e,t,n,r=!0){return y({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>et(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function _a(e,t=!0){return y({queryKey:U.githubChecks(e),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function va(e,t,n=!0){return y({queryKey:U.githubSearch(e,t),queryFn:({signal:n})=>et(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ya=100;function ba(e){return[...e].sort((e,t)=>t-e).slice(0,ya).sort((e,t)=>e-t)}function xa(){let e=Ue(),t=q();return e.projectId??t.data?.bootProject??void 0}function Sa(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))nr(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))nr(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Ca=5*6e4;function wa(e){return e?e.recheckAfterMs:Ca}function Ta(e,t=!0){let n=(0,j.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:ba(t.prs),issues:ba(t.issues)}))},[e.map(H).sort().join(`|`)]),r=M({queries:n.map(e=>({queryKey:U.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>i(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>wa(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:wa(r[t]?.data)??!1})));(0,j.useEffect)(()=>{if(!t||pr())return;let e=!0,n=JSON.parse(o).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=U.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||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,j.useMemo)(()=>fr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,j.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=B.get(t);return{state:`idle`,...r?{status:r}:{},...V.has(t)?{conflicting:!0}:{}}},[s])}function Ea(e,t,n=!0){return y({queryKey:U.githubComments(e,t),queryFn:({signal:n})=>re(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Da(e,t,n=!0){return y({queryKey:U.githubItem(e,t),queryFn:({signal:n})=>Le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e){return y({queryKey:U.githubPrChanges(e??0),queryFn:({signal:t})=>Pe(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{di as $,qn as $t,Li as A,Ir as At,Ci as B,mr as Bt,Ni as C,zr as Ct,Wi as D,Tr as Dt,Ui as E,Fr as Et,bi as F,Kr as Ft,Ti as G,Xn as Gt,xi as H,pr as Ht,Di as I,Gr as It,si as J,Un as Jt,ci as K,Qn as Kt,ai as L,vr as Lt,pi as M,Pr as Mt,mi as N,Er as Nt,Bi as O,jr as Ot,hi as P,Ar as Pt,li as Q,Hn as Qt,Oi as R,hr as Rt,ji as S,yr as St,Fi as T,wr as Tt,ei as U,U as Ut,wi as V,G as Vt,Si as W,W as Wt,_i as X,Vn as Xt,ui as Y,Gn as Yt,gi as Z,z as Zt,Mi as _,Hr as _t,Da as a,tn as an,Ei as at,Ki as b,Wr as bt,va as c,P as cn,Q as ct,xa as d,M as dn,Br as dt,Kn as en,vi as et,Ta as f,Kt as fn,Rr as ft,Ii as g,Cr as gt,Hi as h,kr as ht,Ea as i,I as in,ri as it,ni as j,Mr as jt,Ai as k,xr as kt,ma as l,F as ln,Lr as lt,Vi as m,Vr as mt,_a as n,Bn as nn,ti as nt,pa as o,$t as on,yi as ot,oa as p,Gt as pn,Nr as pt,ki as q,Jn as qt,ha as r,En as rn,ii as rt,Oa as s,Qt as sn,Qr as st,Sa as t,Wn as tn,oi as tt,ga as u,N as un,qr as ut,zi as v,q as vt,Pi as w,br as wt,Gi as x,Sr as xt,Ri as y,Ur as yt,fi as z,gr as zt};
@@ -1 +1 @@
1
- import{ir as e}from"./toaster-C1BFyQ8i.js";import{o as t,w as n}from"./task-groups-7p6Gvpg8.js";var r=[`done`,`failed`,`cancelled`];function i(e){return r.includes(e)}function a(t){return!e(t)&&i(t.status)&&!n(t)}function o(e){return e.reduce((e,r)=>t(r)||!n(r)?e:e+1,0)}function s(e){return e.status===`failed`?`danger`:`success`}export{o as n,s as r,a as t};
1
+ import{ir as e}from"./toaster-zMN8cNZQ.js";import{o as t,w as n}from"./task-groups-CGCnVqHE.js";var r=[`done`,`failed`,`cancelled`];function i(e){return r.includes(e)}function a(t){return!e(t)&&i(t.status)&&!n(t)}function o(e){return e.reduce((e,r)=>t(r)||!n(r)?e:e+1,0)}function s(e){return e.status===`failed`?`danger`:`success`}export{o as n,s as r,a as t};