cezarion 0.19.0-dev.8699 → 0.19.0-dev.8714

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 (116) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/accounts-section-CQAZjNMH.js +1 -0
  3. package/web/dist/assets/activity-motion-Cjk0Ozs9.js +1 -0
  4. package/web/dist/assets/activity-route-DQ2vQVUG.js +1 -0
  5. package/web/dist/assets/agent-config-section-6tcXGdqh.js +7 -0
  6. package/web/dist/assets/agent-defaults-section-DHdrzX19.js +1 -0
  7. package/web/dist/assets/{appearance-Ew3vb_-K.js → appearance-CxkUoLLY.js} +1 -1
  8. package/web/dist/assets/archive-on-merge-field-D7-FuLiL.js +1 -0
  9. package/web/dist/assets/attention--Y0CyzCN.js +1 -0
  10. package/web/dist/assets/automations-route-BFaRgLxq.js +2 -0
  11. package/web/dist/assets/commit-list-Ca61W21s.js +1 -0
  12. package/web/dist/assets/diff-B5yQN9UD.js +3 -0
  13. package/web/dist/assets/{diff-controls-CmYvdEGt.js → diff-controls-_6OoQImc.js} +1 -1
  14. package/web/dist/assets/{diff-view-DV6muJdZ.js → diff-view-DFiA3y5a.js} +1 -1
  15. package/web/dist/assets/file-preview-v5_F5k3C.js +2 -0
  16. package/web/dist/assets/folder-browser-CZiaPNK7.js +1 -0
  17. package/web/dist/assets/{git-toolbar-Dc_o1nrh.js → git-toolbar-C33icZYQ.js} +1 -1
  18. package/web/dist/assets/github-DAftYTLP.js +1 -0
  19. package/web/dist/assets/global-activity-route-Dc0oqViK.js +2 -0
  20. package/web/dist/assets/index-1TLdjVro.css +1 -0
  21. package/web/dist/assets/index-7M_Uae0m.js +21 -0
  22. package/web/dist/assets/label-BKUl84DF.js +1 -0
  23. package/web/dist/assets/{markdown-CJzxFk0P.js → markdown-nyVMLqM-.js} +1 -1
  24. package/web/dist/assets/notifications-section-oiF-HLRZ.js +1 -0
  25. package/web/dist/assets/open-in-menu-N8rXgYSG.js +1 -0
  26. package/web/dist/assets/preview-pane-connected-DgRQbaVm.js +3 -0
  27. package/web/dist/assets/project-location-CcmuGA5W.js +1 -0
  28. package/web/dist/assets/project-router-CT6gVIcC.js +1 -0
  29. package/web/dist/assets/projects-section-DtL1VsXT.js +1 -0
  30. package/web/dist/assets/prompt-templates-section-qK5TH9GX.js +1 -0
  31. package/web/dist/assets/queries-ClkIgWFx.js +1 -0
  32. package/web/dist/assets/reference-chip-bAUYx-Fl.js +1 -0
  33. package/web/dist/assets/remote-settings-notice-KN0zBmre.js +1 -0
  34. package/web/dist/assets/repo-git-BY2jC4L2.js +1 -0
  35. package/web/dist/assets/report-reader-CeBbC_Jy.js +1 -0
  36. package/web/dist/assets/report-selection-D9xJZoKb.js +1 -0
  37. package/web/dist/assets/reports-B-hz_AlB.js +1 -0
  38. package/web/dist/assets/resources-section-BywQtsIL.js +1 -0
  39. package/web/dist/assets/review-panel-DV9yD5Zl.js +8 -0
  40. package/web/dist/assets/run-detail-refresh-Bo51TspT.js +1 -0
  41. package/web/dist/assets/run-header-CZjnjsNk.js +2 -0
  42. package/web/dist/assets/{select-D3snxxoD.js → select-ETUx1MVz.js} +1 -1
  43. package/web/dist/assets/{session-context-section-esqZfONg.js → session-context-section-2B1lqgAc.js} +2 -2
  44. package/web/dist/assets/settings-agent-picker-BdoxLNMP.js +1 -0
  45. package/web/dist/assets/settings-shell-BIhAcEF4.js +1 -0
  46. package/web/dist/assets/sidebar-section-Bamq8P_D.js +1 -0
  47. package/web/dist/assets/skills-BIhWfWYY.js +1 -0
  48. package/web/dist/assets/{tab-link-BGXFZZ_Z.js → tab-link-DE6t7XkG.js} +1 -1
  49. package/web/dist/assets/task-changes-CBuihPwR.js +1 -0
  50. package/web/dist/assets/task-commits-BKHSmTUJ.js +1 -0
  51. package/web/dist/assets/task-files-CAPgay7C.js +1 -0
  52. package/web/dist/assets/task-github-item-BhIl0YRe.js +1 -0
  53. package/web/dist/assets/task-groups-aquji1Kv.js +1 -0
  54. package/web/dist/assets/task-thread-DwqQN87Q.js +2 -0
  55. package/web/dist/assets/tasks-table-BkjZYg2J.js +1 -0
  56. package/web/dist/assets/thread-state-C8v4gnTh.js +4 -0
  57. package/web/dist/assets/toaster-C-xqAWVX.js +4 -0
  58. package/web/dist/assets/tool-display-B9NN44oU.js +1 -0
  59. package/web/dist/assets/use-hand-to-agent-state-P0PYtQDy.js +1 -0
  60. package/web/dist/assets/use-search-params-writer-ClMScnNe.js +1 -0
  61. package/web/dist/assets/workflows-Cp5n5AnS.js +7 -0
  62. package/web/dist/assets/workspace-tools-CsubVxbO.js +1 -0
  63. package/web/dist/assets/worktrees-section-w7yDtBtW.js +4 -0
  64. package/web/dist/index.html +15 -14
  65. package/web/dist/assets/accounts-section-CzFhdKWy.js +0 -1
  66. package/web/dist/assets/activity-motion-D0Fch0mc.js +0 -2
  67. package/web/dist/assets/activity-route-Cvw0jXpy.js +0 -1
  68. package/web/dist/assets/agent-config-section-BCzxsvys.js +0 -7
  69. package/web/dist/assets/agent-defaults-section-DMRK-Qlp.js +0 -1
  70. package/web/dist/assets/archive-on-merge-field-g87CG6RL.js +0 -1
  71. package/web/dist/assets/attention-80jX8HhC.js +0 -1
  72. package/web/dist/assets/automations-route-CRBtWEo1.js +0 -2
  73. package/web/dist/assets/commit-list-Cd14tNSj.js +0 -1
  74. package/web/dist/assets/diff-D55N_7Ul.js +0 -3
  75. package/web/dist/assets/file-preview-CTPfK-oR.js +0 -2
  76. package/web/dist/assets/folder-browser-DnSFycbU.js +0 -1
  77. package/web/dist/assets/github-WYk7bQID.js +0 -1
  78. package/web/dist/assets/global-activity-route-Dvx2uk8w.js +0 -1
  79. package/web/dist/assets/hourglass-CikYdGGQ.js +0 -1
  80. package/web/dist/assets/index-CGdnowj-.js +0 -21
  81. package/web/dist/assets/index-DAxuDJAo.css +0 -1
  82. package/web/dist/assets/label-o_DsEmPt.js +0 -1
  83. package/web/dist/assets/live-reads-Cgk2XbiP.js +0 -1
  84. package/web/dist/assets/notifications-section-DNYO4sd4.js +0 -1
  85. package/web/dist/assets/open-in-menu-Bzae69TK.js +0 -1
  86. package/web/dist/assets/preview-pane-connected-CRooCkyb.js +0 -3
  87. package/web/dist/assets/project-location-D6riKh0Z.js +0 -1
  88. package/web/dist/assets/project-router-CZ89wg-5.js +0 -1
  89. package/web/dist/assets/project-scope-context-DIcqj4jJ.js +0 -4
  90. package/web/dist/assets/projects-section-4rsb8E52.js +0 -1
  91. package/web/dist/assets/prompt-templates-section-G3dlAOXt.js +0 -1
  92. package/web/dist/assets/queries-DZhNVAD_.js +0 -1
  93. package/web/dist/assets/reference-chip-DSJSqjmO.js +0 -1
  94. package/web/dist/assets/remote-settings-notice-GNs7i0kP.js +0 -1
  95. package/web/dist/assets/repo-git-CvZTTKFl.js +0 -1
  96. package/web/dist/assets/report-reader-CLlNdsZG.js +0 -1
  97. package/web/dist/assets/reports-sl2SMDG1.js +0 -1
  98. package/web/dist/assets/resources-section-DhEoaA0K.js +0 -1
  99. package/web/dist/assets/run-header-DZoOLIBZ.js +0 -2
  100. package/web/dist/assets/settings-agent-picker-Dso2TmRM.js +0 -1
  101. package/web/dist/assets/settings-shell-UO_0dSGl.js +0 -1
  102. package/web/dist/assets/sidebar-section-pp7e3AZa.js +0 -1
  103. package/web/dist/assets/skills-B99glme7.js +0 -1
  104. package/web/dist/assets/task-changes-Tn9M2OPH.js +0 -1
  105. package/web/dist/assets/task-commits-BHDMp1sO.js +0 -1
  106. package/web/dist/assets/task-files-Csx1Bonx.js +0 -1
  107. package/web/dist/assets/task-github-item-D0kQ0K4S.js +0 -1
  108. package/web/dist/assets/task-groups-DK0I9p71.js +0 -1
  109. package/web/dist/assets/task-thread-DsMuGSug.js +0 -9
  110. package/web/dist/assets/tasks-table-BNFYIwtc.js +0 -1
  111. package/web/dist/assets/thread-state-DMWi6eLk.js +0 -4
  112. package/web/dist/assets/toaster-0sM0sfWx.js +0 -1
  113. package/web/dist/assets/use-hand-to-agent-state-DqCW8Giu.js +0 -1
  114. package/web/dist/assets/workflows-CxJvAn6z.js +0 -7
  115. package/web/dist/assets/workspace-tools-DqJ8akIy.js +0 -1
  116. package/web/dist/assets/worktrees-section-DBZZlAe0.js +0 -4
@@ -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{a as r,c as i,s as a,t as o}from"./utils-DSMR_WLb.js";import{Gt as s,Wt as c,bt as l,in as u,ln as d}from"./queries-ClkIgWFx.js";import{Cr as f,Gn as p,Gr as m,Jr as h,Kn as g,Qr as ee,Un as _,Ur as te,Wn as v,hi as y,qr as b,xr as ne}from"./toaster-C-xqAWVX.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-Bo51TspT.js";import{a as ae}from"./dist-C5mlVBmd.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 b({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`&&h(),`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:g,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(),_)});x({runs:w(p),referenceStatuses:v,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=r(`/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=c.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=[c.runs.all,s.runsIndex,s.projects,c.health,c.worktrees,c.repoBranches,s.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:c.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:s.projects}),U(e,c.health),e.invalidateQueries({queryKey:c.worktrees}),e.invalidateQueries({queryKey:c.repoBranches}),e.invalidateQueries({queryKey:s.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 a()??Y(e)}function Y(e){let t=e.getQueryData(s.projects)?.bootProject;return typeof t==`string`&&t!==``?t:e.getQueryData(c.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject}function _e(e,t){return[d({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,s,l=(i=!1)=>{s!==void 0&&clearTimeout(s),s=void 0,o!==void 0&&cancelAnimationFrame(o),o=void 0;let c=[];for(let{key:r,baseList:i,baseQuery:o,baseUpdateCount:s,runs:l}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==o||t?.state.dataUpdateCount!==s||t?.state.data!==i){c.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}a(r,c),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 c)r(e);return c},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(c.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,c){let d=u(i);if(c.type===`run-summary`&&c.summary.archived&&d.every(t=>!e.getQueryData(t)?.find(e=>e.id===c.summary.id)?.archived)&&c.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(c.summary.id,c.summary)}s===void 0&&(s=setTimeout(()=>{l()},50),typeof requestAnimationFrame==`function`&&(o=requestAnimationFrame(()=>{l()})));return}let f=l(!0);for(let t of d)a(t,f),c.type===`run-summary`?e.setQueryData(t,e=>P(e,c.summary)):e.setQueryData(t,e=>fe(e,c.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(c.runs.relationships(e.id),!0);for(let e of[i,a])e!==void 0&&r(c.runs.relationships(e),!0)}},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:c.runs.relationships(n)}),i?.supervisorRunId!==void 0&&r(c.runs.relationships(i.supervisorRunId),!0),i?.parentRunId===void 0?r([...c.runs.all,`relationships`],!1):r(c.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,c.runs.detail(n)),r.refreshParent(n)}let a=c.runs.changes(t.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:c.worktrees}),K(e);return}case`run-deleted`:i.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:c.runs.detail(n.id)}),e.removeQueries({queryKey:c.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:c.worktrees}),K(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function Z(e,t,n,r){if(n!==i()){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=y();(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=s.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:c.health}).then(()=>{y||n.invalidateQueries({queryKey:c.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:s.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=ee.safeParse(t);r.success&&(n.cancelQueries({queryKey:c.health}),n.setQueryData(c.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=s.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=te((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),l(),(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:o(`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{r}from"./utils-DSMR_WLb.js";import{d as i,f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{Gt as s,Ht as c,Jt as l,Kt as u,Ut as d,Wt as f,Yt as p,qt as m}from"./index-CGdnowj-.js";import{i as h,n as g,s as _}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as v,o as y,r as b,t as x}from"./highlighter-DvLzHjjY.js";import{r as S}from"./html-report-BX3msvci.js";var C=e(t(),1),w=n();function T({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,w.jsx)(c,{open:e,onOpenChange:e=>{e||t()},children:(0,w.jsxs)(s,{"data-slot":`link-safety-dialog`,children:[(0,w.jsxs)(l,{children:[(0,w.jsx)(p,{children:`Open this link?`}),(0,w.jsxs)(u,{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,w.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,w.jsxs)(m,{children:[(0,w.jsx)(f,{children:`Cancel`}),(0,w.jsx)(d,{onClick:n,children:`Open link`})]})]})})}var E=(0,C.createContext)(null),D=/^[0-9a-f-]{36}$/i,O=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function k(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&D.test(t.get(`artifact`)??``)}function A(e,t,n){if(e.startsWith(`${t}?artifact=`))return k(e.slice(t.length+1))?n+e.slice(t.length):null;let r=O.exec(e);return r&&k(r[2])?`${r[1]}/report?${r[2]}`:void 0}var j=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function M(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function N(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=A(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(j.test(r))return null;let l=M(r,t.basePath);return l===null?null:`${a}${S(l)?s:o}?path=${encodeURIComponent(l)}${i}`}var P=`text-accent-text underline underline-offset-2`;function F({href:e,children:t,internal:n,...r}){let[a,o]=(0,C.useState)(!1),s=i();return e?n?s?(0,w.jsx)(I,{...r,href:e,children:t}):(0,w.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:P,children:t}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${P}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,w.jsx)(T,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,w.jsx)(`span`,{children:t})}function I({href:e,children:t,...n}){let r=o(),i=a();return(0,w.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:P,onClick:t=>L(t,r,e,i),children:t})}function L(e,t,n,r){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var R={code:{name:`shiki`,type:`code-highlighter`,getThemes:()=>[x,x],getSupportedLanguages:()=>y(),supportsLanguage:e=>y().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>v(e,String(t))||(b(e,String(t)).then(e=>n?.(e)),null)}},z=[x,x],B={code:{copy:!0,download:!1},table:!1,mermaid:!1},V=[...Object.values(_),Z];function H(){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{r}from"./utils-DSMR_WLb.js";import{d as i,f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{Bt as s,Gt as c,Ht as l,Kt as u,Ut as d,Vt as f,Wt as p,qt as m}from"./index-7M_Uae0m.js";import{i as h,n as g,s as _}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as v,o as y,r as b,t as x}from"./highlighter-DvLzHjjY.js";import{r as S}from"./html-report-BX3msvci.js";var C=e(t(),1),w=n();function T({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,w.jsx)(s,{open:e,onOpenChange:e=>{e||t()},children:(0,w.jsxs)(d,{"data-slot":`link-safety-dialog`,children:[(0,w.jsxs)(u,{children:[(0,w.jsx)(m,{children:`Open this link?`}),(0,w.jsxs)(p,{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,w.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,w.jsxs)(c,{children:[(0,w.jsx)(l,{children:`Cancel`}),(0,w.jsx)(f,{onClick:n,children:`Open link`})]})]})})}var E=(0,C.createContext)(null),D=/^[0-9a-f-]{36}$/i,O=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function k(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&D.test(t.get(`artifact`)??``)}function A(e,t,n){if(e.startsWith(`${t}?artifact=`))return k(e.slice(t.length+1))?n+e.slice(t.length):null;let r=O.exec(e);return r&&k(r[2])?`${r[1]}/report?${r[2]}`:void 0}var j=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function M(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function N(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=A(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(j.test(r))return null;let l=M(r,t.basePath);return l===null?null:`${a}${S(l)?s:o}?path=${encodeURIComponent(l)}${i}`}var P=`text-accent-text underline underline-offset-2`;function F({href:e,children:t,internal:n,...r}){let[a,o]=(0,C.useState)(!1),s=i();return e?n?s?(0,w.jsx)(I,{...r,href:e,children:t}):(0,w.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:P,children:t}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${P}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,w.jsx)(T,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,w.jsx)(`span`,{children:t})}function I({href:e,children:t,...n}){let r=o(),i=a();return(0,w.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:P,onClick:t=>L(t,r,e,i),children:t})}function L(e,t,n,r){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var R={code:{name:`shiki`,type:`code-highlighter`,getThemes:()=>[x,x],getSupportedLanguages:()=>y(),supportsLanguage:e=>y().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>v(e,String(t))||(b(e,String(t)).then(e=>n?.(e)),null)}},z=[x,x],B={code:{copy:!0,download:!1},table:!1,mermaid:!1},V=[...Object.values(_),Z];function H(){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 U=[...Object.values(g),H],W=[`p`,`strong`,`em`,`del`,`code`,`a`],G={p:`span`,a:`span`},K={enabled:!0,renderModal:e=>(0,w.jsx)(T,{...e})},q=`https://refused.invalid/`,J=new WeakSet;function Y(e){let t=e.position?.start.offset,n=e.position?.end.offset;return t===void 0||n===void 0?null:`${t}:${n}`}function X(e){return(t,n)=>{let r=new Set,i=new Map,a=t=>{if((t.type===`link`||t.type===`definition`)&&t.url){let n=N(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=Y(t);t.type===`link`&&e!==null&&r.add(e)}}t.children?.forEach(a)};a(t);let o=e=>{let t=Y(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 Z(){return(e,t)=>{let n=e=>{let r=Y(e);e.tagName===`a`&&r!==null&&t.data.taskLinks instanceof Set&&t.data.taskLinks.has(r)&&J.add(e),e.children?.forEach(n)};n(e)}}var Q=0,$=(0,C.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:i=!1,imageSrc:a}){let o=(0,C.useContext)(E),s=(0,C.useMemo)(()=>{let e={instance:++Q},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:q,e&&n.add(t.url)}t.children?.forEach(e)};return e}let s=o?[[X,o]]:[],c=i&&a?[[r,e]]:[];return{key:e.instance,remark:[...t?U:Object.values(g),...s,...c],components:{...o||i?{a:({href:e,children:t,node:n})=>i&&!o&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,w.jsx)(`span`,{children:t}):(0,w.jsx)(F,{href:e,internal:n!==void 0&&J.has(n),children:t})}:{},...i?{img:({src:e,alt:t})=>typeof e==`string`&&n.has(e)?(0,w.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[o,t,i,a]);return(0,w.jsx)(h,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:R,shikiTheme:z,...r({rehypePlugins:o?V:void 0,remarkPlugins:o||i&&a?s.remark:t?U:void 0,allowedElements:n?W:void 0,unwrapDisallowed:n||void 0,components:n?G:o||i?s.components:void 0}),linkSafety:K,controls:B,lineNumbers:!1,children:e},s.key)});export{N as i,L as n,E as r,$ as t};
@@ -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{Gt as r,Lt as i}from"./queries-ClkIgWFx.js";import{cn as a,hi as o,n as s}from"./toaster-C-xqAWVX.js";import{r as c}from"./switch-SP8pw5uU.js";import{ot as l,st as u}from"./index-7M_Uae0m.js";var d=e(t(),1),f=n();function p(){let e=o(),t=i(),[n,p]=d.useState(!1),[m,h]=d.useState(u),g=t.data;d.useEffect(()=>{g!==void 0&&p(l(g.notifications).enabled)},[g]);let _=d.useCallback(t=>{p(t),a({notifications:{enabled:t}}).then(t=>e.setQueryData(r.uiState,t)).catch(t=>{s(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:r.uiState})})},[e]),v=d.useCallback(e=>{if(!e){_(!1);return}if(u()!=="default"){_(!0);return}_(!0),Notification.requestPermission().then(e=>h(e)).catch(()=>h(u()))},[_]),y=m===`unsupported`;return(0,f.jsx)(`div`,{"data-slot":`notifications-section`,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,f.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,f.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,f.jsx)(`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,f.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:y,onCheckedChange:v})]}),y?null:(0,f.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":m,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,m===`granted`?`Allowed`:m===`denied`?`Blocked`:`Not requested`]}),(0,f.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),y?(0,f.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,!y&&n&&m===`denied`?(0,f.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,f.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,f.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,f.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})})}export{p as NotificationsSection};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{Qt as t,rn as n}from"./queries-ClkIgWFx.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-B7MKxYjT.js";import{i as d,l as f,p,r as m,t as h}from"./dropdown-menu-4e2iKSMT.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};
@@ -0,0 +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{t as r}from"./utils-DSMR_WLb.js";import{Xr as i,Yr as a,Zr as o,mr as s,n as c}from"./toaster-C-xqAWVX.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-C8v4gnTh.js";import{t as ne}from"./square-terminal-B6RYYieR.js";import{t as w}from"./button-B7MKxYjT.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 ae}from"./dropdown-menu-4e2iKSMT.js";import{s as oe}from"./project-router-CT6gVIcC.js";import{t as A}from"./status-dot-BRzVlF2X.js";import{$n as se,An as ce,Mn as le,Wn as ue,_ as de,c as fe,d as pe,er as j,f as M,g as me,jn as he,kn as ge,l as _e,nr as ve,p as ye,qn as be,u as xe,v as Se}from"./index-7M_Uae0m.js";var Ce=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),N=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`}]]),we=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),P=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`}]]),F=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`}]]),I=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`}]]),Te=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),L=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`}]]),R=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`}]]),Ee=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`}]]),De=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`}]]),z=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`}]]),B=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`}]]),V=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`}]]),H=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`}]]),U=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`}]]),W=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`}]]),G=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`}]]),K=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`}]]),Oe=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`}]]),q=e(t(),1),ke=1e3,Ae=[500,1e3,2e3,4e3,8e3],je=1;function Me(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}`,o=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`,o=n,n.addEventListener(`open`,()=>{n===o&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==o)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=s.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!==o||l)return;if(o=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,ke);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=Ae[Math.min(f,Ae.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)o||m();else{clearTimeout(c),c=void 0;let e=o;o=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),m(),{send(e){o?.readyState===je&&o.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=o;o=null,e?.close()}}}var J=n();function Ne({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,J.jsx)(he,{children:(0,J.jsxs)(ge,{children:[(0,J.jsx)(le,{asChild:!0,children:(0,J.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-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,J.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,J.jsx)(ce,{children:`Experimental`})]})}):e?(0,J.jsx)(he,{children:(0,J.jsxs)(ge,{children:[(0,J.jsx)(le,{asChild:!0,children:(0,J.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,J.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,J.jsx)(ce,{children:`Experimental`})]})}):(0,J.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,J.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Y({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
2
+ `);return(0,J.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,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,J.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,J.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,J.jsx)(j,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,J.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Pe=/^([a-z][a-z0-9+.-]*):/i;function Fe(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=Pe.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.`}:Ie(n):Ie(`http://${n}`)}function Ie(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 Le(e){return e.replace(/^https?:\/\//i,``)}var Re=`https://github.com/hearsay-tools/squawk#environment-variables`;function ze({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,J.jsx)(Ue,{state:e,actions:t});case`downloading`:return(0,J.jsx)(Ge,{state:e,actions:t});case`download-failed`:return(0,J.jsx)(Ke,{state:e,actions:t});case`sandbox-failed`:return(0,J.jsx)(qe,{state:e,actions:t});case`browser-exited`:return(0,J.jsx)(Je,{state:e,actions:t});case`needs-approval`:return(0,J.jsx)(Ze,{state:e,actions:t});case`port-held`:return(0,J.jsx)(Qe,{state:e,actions:t});case`server-starting`:return(0,J.jsx)($e,{state:e,actions:t});case`server-stalled`:return(0,J.jsx)(et,{state:e,actions:t});case`server-exited`:return(0,J.jsx)(tt,{state:e,actions:t});case`server-stopped`:return(0,J.jsx)(nt,{state:e,actions:t});case`loading`:return(0,J.jsx)(it,{step:e.step,url:n});case`worktree-removed`:return(0,J.jsx)(at,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,J.jsx)(ot,{actions:t});case`taken-over`:return(0,J.jsx)(ct,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,J.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,J.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,J.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Be({server:e}){return(0,J.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(ne,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:`Runs ${M(e.command)} in this task's worktree, on the host.`})]})}function Ve({copy:e,command:t,label:n}){return(0,J.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,J.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,J.jsx)(`span`,{children:n}),(0,J.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,J.jsx)(j,{className:`size-4`,"aria-hidden":`true`})})]}),(0,J.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function He({server:e,status:t}){return(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,J.jsx)(A,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,J.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,J.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,J.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,J.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,J.jsx)(`span`,{children:`cwd`}),(0,J.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,J.jsx)(`div`,{className:`mt-2.5`,children:(0,J.jsx)(Be,{server:e})})]})}function Ue({state:e,actions:t}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(P,{}),title:`This host has no browser yet`,children:[(0,J.jsx)(Z,{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,J.jsx)(Q,{children:(0,J.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,J.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function We(e){return Math.round(e/1e6)}function Ge({state:e,actions:t}){let n=(0,q.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,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(P,{}),title:`Downloading Chromium`,children:[(0,J.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.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,J.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:`${We(e.received)} of ${We(e.total)} MB · ${r}%`}),o===void 0?null:(0,J.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,J.jsx)(Q,{children:(0,J.jsx)(w,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ke({state:e,actions:t}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(G,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,J.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,J.jsx)(Ve,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,J.jsx)(x,{"aria-hidden":`true`}),`Retry download`]}),(0,J.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,J.jsx)(j,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function qe({state:e,actions:t}){return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(U,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,J.jsx)(Z,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,J.jsx)(Y,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,J.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,J.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,J.jsx)(j,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,J.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Je({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,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(m,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,J.jsx)(Z,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,J.jsx)(Y,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,J.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,J.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,J.jsx)(j,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Ye=2;function Xe(e){let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Ze({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,J.jsxs)(X,{state:e.stage,icon:r?(0,J.jsx)(K,{className:`text-pending-strong`}):(0,J.jsx)(b,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,J.jsx)(Z,{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,J.jsx)(He,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,J.jsx)(Q,{children:(0,J.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,J.jsx)(b,{"aria-hidden":`true`}),`Run and open`]})})]})}function Qe({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(G,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,J.jsx)(Z,{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,J.jsx)(Q,{children:(0,J.jsx)(w,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function $e({state:e,actions:t}){let{server:n}=e,r=Xe(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,q.useState)(()=>Date.now());(0,q.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Ye-(r-a)/1e3));return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(b,{}),title:`Starting ${n.label}`,children:[(0,J.jsx)(Z,{children:`Squawk ran ${M(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,J.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,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,J.jsx)(Y,{text:e.logTail.join(`
3
+ `),source:M(n.command),onCopy:t.copy}):null,(0,J.jsx)(Q,{children:(0,J.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(L,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,J.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,J.jsx)(Y,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,J.jsxs)(Q,{children:[(0,J.jsx)(w,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,J.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function tt({state:e,actions:t}){let{server:n}=e;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.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,J.jsx)(Z,{children:`${M(n.command)} stopped.`}),(0,J.jsx)(Y,{text:e.logTail,source:M(n.command),onCopy:t.copy}),(0,J.jsx)(Q,{children:(0,J.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,J.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,J.jsx)(Be,{server:n})]})}function nt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(ee,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,J.jsx)(Z,{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 ${Le(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Le(e.lastUrl)}.`}),(0,J.jsx)(Q,{children:(0,J.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,J.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,J.jsx)(Be,{server:n})]})}var rt=[`browser`,`page`,`frame`];function it({step:e,url:t}){let n=rt.indexOf(e),i=t?Le(t):`the page`;return(0,J.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,J.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,J.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,J.jsx)(p,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,J.jsx)(v,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,J.jsx)(we,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function at({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(I,{}),title:`This task's worktree is gone`,children:[(0,J.jsx)(Z,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,J.jsx)(S,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,J.jsx)(Q,{children:(0,J.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function ot({actions:e}){return(0,J.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,J.jsx)(`div`,{children:(0,J.jsx)(Ne,{})}),(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,J.jsx)(B,{})}),(0,J.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,J.jsx)(Z,{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,J.jsxs)(Q,{children:[(0,J.jsx)(w,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,J.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Re,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function st(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 ct({state:e,actions:t}){let n=st(e.by);return(0,J.jsxs)(X,{state:e.stage,icon:(0,J.jsx)(z,{}),title:`Preview is open somewhere else`,children:[(0,J.jsx)(Z,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,J.jsxs)(Q,{children:[(0,J.jsxs)(w,{variant:`contrast`,onClick:t.useHere,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),`Use it here`]}),(0,J.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function lt({attempt:e,exhausted:t,onReconnect:n}){return(0,J.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,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,J.jsx)(Oe,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,J.jsx)(w,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function ut({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,J.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,J.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,J.jsx)(Z,{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,J.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,J.jsx)(K,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,J.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,J.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,J.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,J.jsx)(A,{tone:`success`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,J.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,J.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,J.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,J.jsx)(`ul`,{children:e.map(e=>{let r=xe(e,t),i=ye(r);return(0,J.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,J.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,J.jsx)(A,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,J.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,J.jsx)(w,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>n(e.port),children:pe(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,J.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(_,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,J.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 dt({dialog:e,onResult:t}){let[n,r]=(0,q.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,q.useRef)(null),o=(0,q.useRef)(null);(0,q.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,q.useRef)(t);s.current=t,(0,q.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,J.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,J.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,J.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,J.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,J.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,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,J.jsx)(w,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,J.jsx)(w,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var ft=10,pt=500,mt=500,ht=4,gt=16,_t=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function vt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function yt(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 bt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=vt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:bt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:_t(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=vt(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)<=ft)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<=pt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`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<=mt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=ht;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Tt(e,t,n){let r=vt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?gt: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:_t(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:_t(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:_t(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,q.useRef)(null),i=(0,q.useRef)(yt({left:0,top:0},e)),a=(0,q.useRef)(e);a.current=e;let o=(0,q.useRef)(t);o.current=t;let s=(0,q.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,q.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,q.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,q.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,q.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,J.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,q.useRef)(0),u=(0,q.useRef)(null),d=(0,q.useRef)(null),[f,p]=(0,q.useState)(null),m=(0,q.useRef)(o);m.current=o,(0,q.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,q.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,J.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,J.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,J.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:W},{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,q.useState)(()=>Date.now());return(0,q.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,J.jsx)(A,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,J.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,J.jsx)(A,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`hidden @min-[640px]: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,J.jsxs)(w,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,J.jsx)(A,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,J.jsx)(C,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`truncate`,children:r}),e?(0,J.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,J.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,J.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,J.jsx)(A,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,J.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,J.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,q.useRef)(null),a=e.urlInputRef??i,o=(0,q.useRef)(!1),[s,c]=(0,q.useState)(null),[l,d]=(0,q.useState)(!1),f=(0,J.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,J.jsx)(Ce,{"aria-hidden":`true`})}),p=(0,J.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,J.jsx)(u,{"aria-hidden":`true`})}),m=(0,J.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,J.jsx)(H,{"aria-hidden":`true`})}),h=e.onSession?(0,J.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,J.jsx)(ve,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,J.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,J.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,J.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,J.jsx)(rn,{props:e,compact:t,crowded:ee}),session:h,progress:g};return t?(0,J.jsx)(an,{props:e,elements:b}):(0,J.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,J.jsxs)(ae,{children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsx)(Kt,{current:i,agentShown:o})}),(0,J.jsxs)(k,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,J.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=ye(xe(t,e.serverStates));return(0,J.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,J.jsx)(A,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,J.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,J.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,J.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,J.jsx)(D,{}),(0,J.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,J.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,J.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,J.jsx)(h,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,J.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:Le(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,J.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,J.jsx)(R,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,J.jsxs)(ae,{children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,J.jsx)(De,{"aria-hidden":`true`}):(0,J.jsx)(y,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,J.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,J.jsxs)(k,{align:`start`,className:`min-w-56`,children:[(0,J.jsxs)(E,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,J.jsx)(De,{"aria-hidden":`true`}),`Fit`,(0,J.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,J.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,J.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,J.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,J.jsx)(d,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,J.jsx)(ie,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,J.jsx)(re,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.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,J.jsxs)(ae,{children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,J.jsx)(Te,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Lt(t)}),(0,J.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,J.jsxs)(k,{align:`start`,className:`w-64`,children:[(0,J.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,J.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,J.jsx)(Gt,{stats:e,shrunk:n}):t?(0,J.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,J.jsx)(A,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function rn({props:e,compact:t,crowded:n}){let{stats:r,navEnabled:i,url:a,current:o,adopted:s}=e;return(0,J.jsxs)(ae,{children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,J.jsx)(se,{"aria-hidden":`true`})})}),(0,J.jsxs)(k,{align:`end`,className:`min-w-64`,children:[n&&r&&!t?(0,J.jsx)(T,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(r)}):null,(0,J.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!i,onSelect:()=>e.onReload(!0),children:[(0,J.jsx)(V,{"aria-hidden":`true`}),`Reload without cache`]}),(0,J.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:a===``,onSelect:e.onCopyUrl,children:[(0,J.jsx)(be,{"aria-hidden":`true`}),`Copy page URL`]}),o?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(D,{}),s?(0,J.jsxs)(E,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,J.jsx)(Ee,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${o.label} :${o.port}`}),(0,J.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,J.jsxs)(E,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(o.port),children:[(0,J.jsx)(N,{"aria-hidden":`true`}),`Stop server · ${o.label} :${o.port}`]})]}):null,t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(D,{}),(0,J.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,J.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,J.jsx)(D,{}),(0,J.jsxs)(E,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,J.jsx)(ue,{"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,J.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,J.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,J.jsx)(A,{tone:`success`,"aria-hidden":`true`}):null,(0,J.jsx)(`span`,{className:`truncate`,children:Jt(r,a)})]}),i?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,J.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,J.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[m,l,u,d,n?(0,J.jsx)(Zt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,J.jsx)($t,{props:e}),(0,J.jsx)(tn,{props:e}),(0,J.jsx)(nn,{stats:s,status:c,crowded:r}),o?(0,J.jsx)(Ne,{iconOnly:r,responsive:!r}):null,(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,J.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,J.jsx)(ue,{"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,J.jsx)(ze,{...n,actions:o})}case`empty`:return(0,J.jsx)(ut,{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,q.useState)(ln);return(0,q.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:s}){let l=un(),u=(0,q.useRef)(l);u.current=l;let d=o(),f=(0,q.useRef)(crypto.randomUUID()),p=(0,q.useRef)(!1),m=oe(),h=de(me,!1),[g,_]=(0,q.useState)(0),[v,y]=(0,q.useState)({state:`connecting`,attempt:0}),[ee,b]=(0,q.useState)(!1),[x,te]=(0,q.useState)(void 0),[S,C]=(0,q.useState)(void 0),[ne,w]=(0,q.useState)(``),[T,re]=(0,q.useState)(void 0),[E,D]=(0,q.useState)(!1),[O,k]=(0,q.useState)(void 0),[ie,ae]=(0,q.useState)(!1),[A,se]=(0,q.useState)(!1),[ce,le]=(0,q.useState)(void 0),[ue,fe]=(0,q.useState)(void 0),[pe,j]=(0,q.useState)(void 0),[M,he]=(0,q.useState)(`fit`),[ge,_e]=(0,q.useState)(Rt),[ve,ye]=(0,q.useState)(null),[be,xe]=(0,q.useState)(void 0),[Se,Ce]=(0,q.useState)(0),N=(0,q.useRef)(void 0),we=(0,q.useRef)(null),P=(0,q.useRef)(null),F=(0,q.useRef)(void 0),I=(0,q.useRef)(void 0),Te=(0,q.useRef)(ge);Te.current=ge;let L=(0,q.useRef)({port:T,stage:S,agent:E});L.current={port:T,stage:S,agent:E};let R=(0,q.useRef)([]),Ee=(0,q.useRef)(void 0),De=(0,q.useRef)(!1),z=(0,q.useRef)(!1),B=(0,q.useCallback)(e=>{z.current&&N.current?.send(e)},[]),V=(0,q.useRef)([]),H=(0,q.useCallback)(e=>{z.current?N.current?.send(e):V.current.push(e)},[]);(0,q.useEffect)(()=>{let t;return t=Me({projectId:m??`default`,runId:e.id},{onFrame(e){if(!a())return;let n=Date.now();R.current.push({at:n,bytes:e.size}),De.current||(De.current=!0,se(!0)),(we.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`)&&Ce(e=>e+1),I.current!==void 0&&mn(e,I.current)){let n=I.current;I.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 le(e.cursor);case`dialog`:return fe(e);case`pong`:Ee.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),z.current=!1,V.current=[],t?.close();return}},onTransport(e,n){if(z.current=e===`open`,y({state:e,attempt:n??0}),(e===`blocked`||e===`closed`)&&(V.current=[]),e===`open`){b(!0),F.current&&(t?.send({t:`open`,target:F.current,viewerId:f.current,resume:p.current,quality:Te.current,dpr:u.current}),p.current=!0);for(let e of V.current.splice(0))t?.send(e)}}}),N.current=t,()=>{z.current=!1,V.current=[],t?.close(),N.current===t&&(N.current=void 0)}},[m,e.id,g]);let U=d&&v.state===`open`&&x===void 0,W=h||M===`fit`?ve:M;(0,q.useEffect)(()=>{W&&U&&(S?.stage===`streaming`||S?.stage===`loading`)&&B({t:`resize`,w:W.w,h:W.h,...l===1?{}:{dpr:l}})},[W?.w,W?.h,l,U,S?.stage,Se,B]),(0,q.useEffect)(()=>{if(!U)return;let e=setInterval(()=>B({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[U,B]);let G=U&&S?.stage===`streaming`;(0,q.useEffect)(()=>{if(!G){j(void 0);return}let e=setInterval(()=>{let e=Date.now();R.current=R.current.filter(t=>e-t.at<=pn);let t={fps:R.current.length,kbps:Math.round(R.current.reduce((e,t)=>e+t.bytes,0)/1024),...Ee.current===void 0?{}:{rttMs:Ee.current},...R.current.length>0?{lastFrameAt:R.current.at(-1).at}:{}};j(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)},[G]),(0,q.useEffect)(()=>(i?.(G),()=>i?.(!1)),[G,i]),(0,q.useEffect)(()=>{O&&r?.(O)},[O,r]);let K=(0,q.useCallback)((e,t,n=!1)=>{F.current=e,I.current=n&&`port`in e?e.port:void 0,ae(!0),C(void 0),te(void 0),xe(void 0),w(t),re(`port`in e?e.port:void 0),D(`agent`in e),k(vn(e)),B({t:`open`,target:e,viewerId:f.current,quality:Te.current,dpr:u.current}),p.current=z.current},[B]),Oe=(0,q.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);K({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,K]),ke=(0,q.useCallback)(()=>K({agent:!0},``),[K]);(0,q.useEffect)(()=>{if(n?.agent){if(L.current.agent&&L.current.stage?.stage===`streaming`)return;ke();return}if(n?.url!==void 0){let e=Fe(n.url,t);e.kind===`server`?Oe(e.port):e.kind===`url`&&K({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||L.current.port===n.port&&L.current.stage?.stage===`streaming`&&n.run!==!0||Oe(n.port,n.run===!0))},[n]);let Ae=!ie&&!x&&v.state!==`blocked`,je=_n(n,t);(0,q.useEffect)(()=>{Ae&&!je&&P.current?.focus()},[Ae,je]);let J=e=>{let n=Fe(e,t);if(n.kind===`error`)return xe(n.message);if(n.kind===`server`)return Oe(n.port);if(L.current.stage?.stage===`streaming`&&!L.current.agent)return F.current={url:n.url},I.current=void 0,re(void 0),k({url:n.url}),xe(void 0),w(n.url),B({t:`nav`,url:n.url});K({url:n.url},n.url)},Ne=(0,q.useCallback)(e=>{Te.current=e,_e(e),zt(e),B({t:`quality`,quality:e})},[B]),Y=()=>{p.current=!1,te(void 0),y({state:`connecting`,attempt:0}),De.current=!1,_(e=>e+1)};return{compact:h,transport:v,everOpened:ee,takenOver:x,stage:S,url:ne,port:T,agent:E,hasFrame:A,cursor:ce,dialog:ue,setDialog:fe,stats:pe,viewport:M,setViewport:he,quality:ge,chooseQuality:Ne,setStageSize:ye,addressError:be,stageHandle:we,urlInput:P,send:B,connected:U,streaming:G,openServer:Oe,openAgent:ke,empty:Ae,navigate:J,reconnect:Y,actions:(0,q.useMemo)(()=>({download:()=>H({t:`download`}),cancelDownload:()=>H({t:`cancelDownload`}),retryBrowser:()=>H({t:`retryBrowser`}),run:e=>{z.current?B({t:`run`,port:e}):c(`The preview is reconnecting. Run the server again once it is back.`,{tone:`danger`})},stop:e=>H({t:`stop`,port:e}),keepWaiting:e=>H({t:`keepWaiting`,port:e}),close:s,useHere:Y,copy:hn}),[B,H,s])}}function bn(e){return(0,J.jsx)(Se,{onClose:e.onClose,children:(0,J.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:ae}=sn({transport:l.state,takenOver:d,empty:T,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),oe=cn(ie,{servers:n,serverStates:r,agentLive:i,openServer:ne,openAgent:w,actions:E});return(0,J.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,J.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,J.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,J.jsx)(wn,{transportState:s,overlay:oe,dim:ae,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,J.jsxs)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,J.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,J.jsx)(lt,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,J.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,J.jsx)(dt,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=_e(e);return(0,q.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,J.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{St as t,W as n,dn as r}from"./queries-ClkIgWFx.js";import{Pt as i,n as a}from"./toaster-C-xqAWVX.js";import{v as o}from"./design-icons-CzEoMH9c.js";import{n as s,t as c}from"./open-in-menu-N8rXgYSG.js";import{s as l}from"./project-router-CT6gVIcC.js";import{n as u}from"./settings-field-DP9sYv5a.js";var d=e();function f(){let e=l(),n=t().data;return e===null?null:n?.projects.find(t=>t.id===e)?.root??null}function p(e){navigator.clipboard.writeText(e).then(()=>a(`Project folder copied`)).catch(()=>a(e))}function m(){let e=f();return e===null?null:(0,d.jsx)(u,{title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,d.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,d.jsx)(`span`,{"data-slot":`project-location-path`,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] break-all text-foreground`,children:e}),(0,d.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>p(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,d.jsx)(o,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,d.jsx)(h,{root:e})]})]})})}function h({root:e}){let t=n(),o=r({mutationFn:e=>i(e),onError:e=>a(e.message,{tone:`danger`})}),l=(t.data?.targets??[]).filter(e=>s(e.id)===void 0).map(e=>({target:e}));return l.length===0?null:(0,d.jsx)(c,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:o.isPending,choices:l,onPick:e=>o.mutate(e,{onSuccess:()=>a(`Opening the project folder in ${l.find(t=>t.target.id===e)?.target.label??e}`)})})}export{f as n,m as t};
@@ -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{a as r}from"./toaster-C-xqAWVX.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};
@@ -0,0 +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{t as i}from"./utils-DSMR_WLb.js";import{Bt as a,Gt as o,It as s,Ot as c,Pt as l,St as u,dn as d,zt as f}from"./queries-ClkIgWFx.js";import{hi as p,n as m,sn as h}from"./toaster-C-xqAWVX.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-B7MKxYjT.js";import{n as b,r as x,t as S}from"./popover-BPgUYFyu.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Bt as w,Gt as T,Hn as E,Ht as D,Kt as O,Ut as k,Vt as A,Wt as j,qt as M}from"./index-7M_Uae0m.js";import{t as N}from"./settings-select-CCIMGnyA.js";import{t as P}from"./save-cue-Cd3ZAPBS.js";import{n as F,t as I}from"./settings-field-DP9sYv5a.js";var L=t(n(),1),R=r();function z(){let e=c();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{m(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>m(e.message,{tone:`danger`})})}}function B({project:e,onOpenChange:t,onConfirm:n}){return(0,R.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,R.jsxs)(k,{children:[(0,R.jsxs)(O,{children:[(0,R.jsxs)(M,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,R.jsxs)(j,{children:[`This only unregisters the project — `,(0,R.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.`,(0,R.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,R.jsxs)(T,{children:[(0,R.jsx)(D,{children:`Keep it`}),(0,R.jsx)(A,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var V=e({MaxParallelSelect:()=>Z,ProjectTagsEditor:()=>X,ProjectsSection:()=>G,STATUS_LABEL:()=>U}),H=1,U={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function W(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function G(){let e=s(),t=u();return e.isPending||t.isPending?(0,R.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,R.jsx)(C,{icon:(0,R.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,R.jsx)(K,{config:e.data,registry:t.data})}function K({config:e,registry:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,R.jsx)(q,{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`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,R.jsx)(q,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,R.jsx)(J,{registry:t,workspaceMax:e.resources.maxParallel}),(0,R.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,R.jsx)(E,{open:!0,onOpenChange:r}):null]})}function q({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,savedLabel:s,footer:c,refreshProjects:l=!1}){let u=p(),f=d({mutationFn:t=>h(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(o.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:o.fsBrowseRoot}):l&&u.invalidateQueries({queryKey:o.projects})}}),[g,_]=(0,L.useState)(t),v=g.trim(),b=v===t,x=f.isError?f.error.message:null;return(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${a}-root`,value:g,disabled:f.isPending,placeholder:i,onChange:e=>{_(e.target.value),f.isError&&f.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`}),(0,R.jsx)(P,{show:b&&v!==``&&!f.isPending,children:(0,R.jsx)(y,{type:`button`,variant:`primary`,size:`sm`,"data-action":`projects-save-${a}-root`,disabled:b||v===``||f.isPending,onClick:()=>f.mutate(v,{onSuccess:()=>m(`${s} set to ${v}`)}),children:`Save`})})]}),x===null?(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:c}):(0,R.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[x,` — setting unchanged`]})]})}function J({registry:e,workspaceMax:t}){let[n,r]=(0,L.useState)(null),i=z(),a=(0,L.useMemo)(()=>f(e.projects),[e.projects]);return(0,R.jsxs)(F,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,R.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,R.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,R.jsxs)(`colgroup`,{children:[(0,R.jsx)(`col`,{}),(0,R.jsx)(`col`,{style:{width:`104px`}}),(0,R.jsx)(`col`,{style:{width:`260px`}}),(0,R.jsx)(`col`,{style:{width:`150px`}}),(0,R.jsx)(`col`,{style:{width:`72px`}}),(0,R.jsx)(`col`,{style:{width:`92px`}})]}),(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,R.jsx)(`tbody`,{children:e.projects.map(n=>(0,R.jsx)(Y,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,R.jsx)(B,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function Y({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,R.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,R.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,R.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`block truncate font-mono text-xs text-soft-foreground`,title:e.root,children:e.root})]}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,R.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:U[e.status]}),e.status===`missing`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsx)(X,{project:e,vocabulary:r})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:I,children:`Max parallel tasks`}),(0,R.jsx)(Z,{project:e,workspaceMax:n})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:W(e.addedAt)}),(0,R.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,R.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,R.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,R.jsx)(y,{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 X({project:e,vocabulary:t}){let n=l(),[r,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[u,d]=(0,L.useState)(-1),f=(0,L.useRef)(null),p=e.tags??[],h=a(t,p,r),g=s&&h.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>m(r),onError:e=>m(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(p.some(e=>e.toLowerCase()===n.toLowerCase())){o(``);return}if(p.length>=20){m(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}o(``),_([...p,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(p.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,R.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[p.map(t=>(0,R.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-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,R.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,R.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,R.jsxs)(S,{open:g,onOpenChange:c,children:[(0,R.jsx)(b,{asChild:!0,children:(0,R.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":g,"aria-controls":g?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":g&&u>=0?`${w}-${u}`:void 0,placeholder:p.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!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(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=u+t;d(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&g){e.preventDefault(),c(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(u>=0?h[u]??r:r);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&r===``&&p.length>0){e.preventDefault();let t=p[p.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,R.jsxs)(x,{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,R.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===u,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.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 Z({project:e,workspaceMax:t}){let n=l(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,R.jsxs)(N,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>m(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>m(e.message,{tone:`danger`})})},className:`block w-full rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,R.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+H).map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})}export{z as a,B as i,U as n,V as r,Z as t};
@@ -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{t as r}from"./utils-DSMR_WLb.js";import{Jt as i,Wt as a,dn as o,k as s}from"./queries-ClkIgWFx.js";import{I as c,hi as l,n as u}from"./toaster-C-xqAWVX.js";import{J as d,W as f,at as p,c as m,ft as h,l as g,tt as _}from"./design-icons-CzEoMH9c.js";import{t as v}from"./button-B7MKxYjT.js";import{i as y,r as b,t as x}from"./popover-BPgUYFyu.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-KdW7aO0N.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-V15AR_qo.js";import{$ as N,Vn as P,X as F,et as I,pn as L,rt as R}from"./index-7M_Uae0m.js";import{t as z}from"./textarea-vJt9undk.js";import{n as B,t as V}from"./saved-draft-BwzBc-_Y.js";import{t as H}from"./save-cue-Cd3ZAPBS.js";import{t as U}from"./settings-field-DP9sYv5a.js";var W=e(t(),1),G=n();function K(){let e=s();return e.isPending?(0,G.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,G.jsx)(M,{icon:(0,G.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,G.jsx)(q,{initial:I(e.data.promptTemplates)})}function q({initial:e}){let t=l(),n=i(),r=s(),[f,m]=B(e,V),[g,_]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),x=o({mutationFn:e=>c({promptTemplates:e}),onSuccess:(e,n)=>{t.setQueryData(a.uiState,e),m(t=>V(t,n)?I(e.promptTemplates):t),u(`Prompt templates saved`)},onError:e=>u(e.message,{tone:`danger`})}),S=JSON.stringify(f)!==JSON.stringify(e),C=g.trim()!==``||y.trim()!==``;L(S||C);let w=f.some(e=>e.label.trim()===``||e.text.trim()===``),T=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),E=(e,t)=>m(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})),D=e=>m(t=>t.filter(t=>t.id!==e));return(0,G.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,G.jsxs)(Y,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,G.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,G.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:U,children:`Template label`}),(0,G.jsx)(P,{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=>T(e.id,{label:t.target.value}),className:`flex-1 border-border bg-background`})]}),(0,G.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:U,children:`Instructions`}),(0,G.jsx)(z,{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=>T(e.id,{text:t.target.value}),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,G.jsx)(`p`,{className:U,children:`Apply automatically with skills`}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(J,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>E(e.id,t)}),(e.skills??[]).map(t=>(0,G.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>E(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,G.jsx)(h,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,G.jsxs)(v,{type:`button`,className:`self-start`,variant:`danger-ghost`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>D(e.id),children:[(0,G.jsx)(p,{"aria-hidden":`true`,className:`size-3`}),`Delete template`]})]},e.id))}),(0,G.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,G.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,G.jsx)(`label`,{htmlFor:`new-template-label`,className:U,children:`Label`}),(0,G.jsx)(P,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:g,maxLength:80,onChange:e=>_(e.target.value),className:`border-border bg-background`}),(0,G.jsx)(`label`,{htmlFor:`new-template-text`,className:U,children:`Instructions to insert`}),(0,G.jsx)(z,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:y,maxLength:2e3,onChange:e=>b(e.target.value),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,G.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!g.trim()||!y.trim(),onClick:()=>{let e=g.trim(),t=y.trim();!e||!t||(m(n=>[...n,{id:N(),label:e,text:t}]),_(``),b(``))},className:`self-start`,children:[(0,G.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(H,{show:!S&&!w&&!x.isPending,children:(0,G.jsx)(v,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!S||w||x.isPending,onClick:()=>x.mutate(f),children:`Save`})}),(0,G.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:x.isPending,onClick:()=>m(F.map(e=>({...e}))),children:`Reset to defaults`}),w?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-xs text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function J({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=(0,W.useRef)(null),{mostUsed:d,project:f,global:p,ranked:h}=j(t,c,n),v=(e,t)=>{let n=i.includes(e.id);return(0,G.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,G.jsx)(R,{skill:e,emphasized:t}),n?(0,G.jsx)(m,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},O(e))};return(0,G.jsxs)(x,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,G.jsx)(y,{asChild:!0,children:(0,G.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,G.jsx)(_,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`Add skill`,(0,G.jsx)(g,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,G.jsx)(b,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,G.jsxs)(D,{shouldFilter:!1,children:[(0,G.jsx)(S,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,G.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,G.jsx)(C,{children:(0,G.jsxs)(w,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(h?h.length===0:d.length===0&&f.length===0&&p.length===0)?(0,G.jsx)(T,{children:`Nothing matches.`}):null,h?h.length>0?(0,G.jsx)(C,{children:h.map(e=>v(e,k(e)))}):null:(0,G.jsxs)(G.Fragment,{children:[d.length>0?(0,G.jsx)(C,{heading:`Most used`,children:d.map(e=>v(e,k(e)))}):null,f.length>0?(0,G.jsx)(C,{heading:`Project skills`,children:f.map(e=>v(e,!0))}):null,p.length>0?(0,G.jsx)(C,{heading:`Global`,children:p.map(e=>v(e,!1))}):null]})]})]})})]})}function Y({title:e,hint:t,children:n}){return(0,G.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}export{K 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{c as n,o as r}from"./utils-DSMR_WLb.js";import{$t as i,At as a,Bn as o,Br as s,C as c,Ct as l,D as u,Di as d,E as f,Et as p,F as m,Fi as h,Fn as g,G as _,Gt as v,In as y,J as ee,Jt as te,K as ne,Kr as re,Kt as ie,Ln as ae,Mi as oe,N as se,Nt as ce,O as le,Q as ue,Qt as de,Rn as fe,Rr as pe,Rt as me,S as he,Si as ge,Sr as _e,St as ve,T as ye,Tt as be,U as xe,Ut as Se,Vn as Ce,Vr as we,Vt as Te,W as Ee,Wt as De,X as Oe,Xt as ke,Yt as Ae,Z as je,Zt as Me,_n as Ne,_r as Pe,_t as Fe,a as Ie,ai as Le,an as Re,b as ze,bt as Be,ci as Ve,di as He,dn as Ue,dt as We,fi as Ge,fn as Ke,gi as qe,gn as Je,gt as Ye,h as Xe,hi as b,ht as Ze,ii as x,in as Qe,j as $e,ji as et,jt as tt,ki as nt,kt as rt,li as it,ln as at,m as ot,mn as st,mt as ct,n as lt,nn as ut,oi as dt,on as ft,ot as pt,pn as mt,q as ht,qr as gt,qt as _t,ri as vt,rn as yt,si as bt,ti as xt,tn as St,ui as Ct,un as wt,v as Tt,vi as Et,vn as Dt,vt as Ot,w as kt,wi as At,wt as jt,x as Mt,xt as Nt,y as Pt,yi as Ft,yn as It,yt as Lt,zn as Rt,zt}from"./toaster-C-xqAWVX.js";import{A as Bt,B as S,F as C,H as w,I as T,N as E,P as D,W as O,Z as k,a as Vt,j as A,z as j}from"./live-protocol-DMhTnCmf.js";function Ht(e,t){return e??t}function Ut(e,t){let n=Ht(e,t);return n===`1`||n===`true`}function Wt(e,t,n){return e?.trim()||Ht(t,n)||``}var Gt=class extends Et{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Kt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Ft({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),k.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Kt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var qt=class extends h{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),et(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ge(t.mutationKey)!==ge(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Kt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){k.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Jt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Yt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Xt=class extends h{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,k.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!et(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Jt(e,n).forEach(e=>{e.destroy()}),Jt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=nt(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new qe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Yt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=b(n),i=Ge(),a=He(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Le(e);let t=r.getQueryCache().get(e.queryHash);Ve(e,a,t)}),Ct(a);let[s]=M.useState(()=>new Xt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?s.subscribe(k.batchCalls(e)):d,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),M.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>bt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&bt(n,e)?dt(n,new qe(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&it({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function P(e,t){let n=b(t),[r]=M.useState(()=>new qt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(k.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(d)},[r]);if(i.error&&oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Zt(e,t=!0,n=!1,r){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>a(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:G.models(t),refetchType:n})}function Qt(e,t=!0,n){return x({...$t(e,n),enabled:t})}var $t=(e,t)=>({queryKey:G.models(e,t),queryFn:({signal:n})=>Ce(e,{signal:n},t),staleTime:300*1e3});function en(e,t=!0){let n=N({queries:e.map(e=>({...$t(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function tn(e,t){return JSON.stringify([e,t])}function nn(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function rn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var an=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(tn(e.projectId,e.id),t))}at(e,t){return this.positions.get(tn(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function on(e,t,n){let r=new an(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=fn(i,e.project,e.usage,r);else{let t=ln(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function sn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function cn(e,t,n){return ln(e,t,n,new an(e.runs))}function ln(e,t,n,r){let{project:i}=t,a=r.at(i,nn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:R(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!sn(e,i,n))return{index:e,reconcile:!0};let l=nt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||rn(t,i)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return dn(e,l,r);let u=r.insert(l);return{index:R(e,u),reconcile:l.archived&&rn(u,i)>e.perProjectLimit}}function un(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function dn(e,t,n){let r=un(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:R(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function fn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=nt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?R(e,r.runs):e}function pn(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function mn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function hn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function gn(e){e.stream=void 0}function _n(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,nn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function vn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function yn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function bn(e,t,n){if(!yn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=cn(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var z=[`workspace`,`runs-index`],xn=[`workspace`,`projects`],Sn=6e4,Cn=100,wn=new WeakMap;function Tn(e){let t=wn.get(e);return t||(t=An(e),wn.set(e,t)),t}function En(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Tn(t).merge(e)}function Dn(e){let t=e.getQueryData(xn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function On(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function kn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function An(e){let t=mn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=Dn(e),{index:s,reconcile:c}=on(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,Cn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){hn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){gn(t)},run(e,r,i=!1){if(l.has(e))return;let a=kn(e,r);if(!_n(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),vn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=pn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=bn(t,n,Dn(e));for(let e of l)i.index=pn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),On(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var jn=A([`own`,`provider-spanning`]),Mn=S({suggested:E(S({id:O(),label:O(),desc:O()})),retired:E(O())}),Nn=S({id:A([`settings`,`mcp`,`memory`]),label:O(),note:O().optional(),empty:O().optional(),showsUserMcp:T(!0).optional()}),Pn=S({label:O(),note:O().optional(),groups:E(Nn)}),Fn=S({runners:E(S({id:xt,displayName:O(),modelListName:O(),modelIdScope:jn,pickerLabel:O(),pickerDescription:O(),icon:O(),installHint:O(),loginCommand:O(),terminalLogin:D().optional(),browserLogin:D().optional(),managedInstall:T(!0).optional(),accountFolderExample:O().optional(),models:Mn,agentConfig:Pn}))}),In=[`workspace`,`runners`];async function Ln(e){return o(await y.api.v1.runners.$get({},ae(e)),`/runners`,Fn)}var Rn={queryKey:In,queryFn:({signal:e})=>Ln({signal:e}),staleTime:1/0};function zn(){return x(Rn)}function Bn(e){return e?.runners??[]}function Vn(e){return Bn(e).map(e=>e.id)}function Hn(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Un(e){let t=zn();return{runner:t.isSuccess?Hn(e,Vn(t.data))??e:e,ready:!t.isPending}}function B(e,t){return e?.runners.find(e=>e.id===t)}function Wn(e,t){return B(e,t)?.displayName??t}function Gn(e,t){return B(e,t)?.pickerLabel??t}function Kn(e,t){return B(e,t)?.modelListName}function qn(e,t,r=!0){let i=Ii(),a=Ur(),{runner:o,ready:s}=Un(e??i.data?.defaultRunner??`claude`),c=a.data?.capabilities?.localHandoff===!1?null:t,l=n(),u=x({queryKey:W.runnerSkills(o,c),queryFn:({signal:e})=>kt(o,c,{signal:e,projectId:l}),enabled:r&&s&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...u,runner:o,account:c,data:u.data?.skills,list:u.data,unchecked:u.isError||!u.data||u.data.source===`unavailable`}}var Jn={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},Yn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Xn(e){return typeof e==`string`&&Object.hasOwn(Jn,e)}function Zn(e){return e!==void 0&&Xn(e)?Jn[e]:void 0}var Qn=`cez.reference-statuses.v1`,$n=`cez.reference-conflicts.v1`,V=new Map(rr()),er=1e3;function tr(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>er;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}or()}}var H=new Set(ir());function nr(e,t){if(H.has(e)!==t){if(t)for(H.add(e);H.size>er;){let e=H.values().next().value;if(e===void 0)break;H.delete(e)}else H.delete(e);or()}}function rr(){try{let e=globalThis.sessionStorage?.getItem(Qn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&Xn(e[1])):[]}catch{return[]}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var ar;function or(){ar===void 0&&(ar=setTimeout(()=>{ar=void 0;try{globalThis.sessionStorage?.setItem(Qn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem($n,JSON.stringify([...H]))}catch{}},250))}var U=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function sr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function cr(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function lr(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;tr(t,o),s!==void 0&&nr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function ur(e,t,n){let r=U(t),i=V.get(r),a=H.has(r)?!0:void 0,o=n.data;if(o?.available){lr(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...sr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...sr(i,a)});return}e.set(r,{state:`loading`,...sr(i,a)})}function dr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of cr(i))ur(n,e,t)}),n}var W={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t)=>[n(),`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`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)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},G={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...G.fsBrowseRoot,e,t]};function fr(){return Ut(void 0,void 0)}function K(e){return!fr()&&e}function pr(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function mr(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function hr(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function gr(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function _r(e,t){return gt({kind:`topic`,topic:e},{value:t})}function vr(){let e=b();return x({queryKey:G.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(G.providerStatus),r=await Qe(!1,{signal:t});return _e(n,e.getQueryData(G.providerStatus),r)},staleTime:5*6e4,refetchInterval:K(!1),refetchOnWindowFocus:!0})}function yr(){let e=b();return P({mutationFn:()=>Qe(!0),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t)),L(e)}})}function br(){let e=b();return P({mutationFn:({provider:e,authFailureId:t})=>mt(e,t),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t,n.authFailureId)),L(e,n.provider)}})}function xr(e={}){return x({queryKey:G.projects,queryFn:({signal:e})=>yt({signal:e}),...e})}function Sr(e,t=!1){return x({queryKey:G.fsBrowse(e,t),queryFn:({signal:n})=>ie(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Cr(){let e=b();return P({mutationFn:e=>at(e),onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function wr(){let e=b();return P({mutationFn:e=>Ue(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:G.projects})}})}function Tr(){let e=b();return P({mutationFn:e=>{let{id:t,...n}=e;return Dt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:G.projects});let r=e.getQueryData(G.projects);return e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Er(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(G.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:G.projects})})}function Er(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:gr(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Dr(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(G.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:G.projects})})}function Or(){return Dr(e=>{let{projectId:t,...n}=e;return Me(t,n)})}function kr(){return Dr(e=>{let{projectId:t,webhookId:n,...r}=e;return It(t,n,r)})}function Ar(){return Dr(({projectId:e,webhookId:t})=>Ke(e,t))}function jr(){return P({mutationFn:({projectId:e,webhookId:t})=>Je(e,t),retry:!1})}function q(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:G.agentProfiles}),t.invalidateQueries({queryKey:G.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])},onError:()=>{t.invalidateQueries({queryKey:W.health}),t.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Mr(){return q(e=>Ae(e))}function Nr(){return q(e=>{let{id:t,...n}=e;return Ne(t,n)})}function Pr(){return q(e=>wt(e))}function Fr(){return q(e=>st(e))}function Ir(e,t){return x({queryKey:G.agentAccountStatus(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Lr(){let e=b();return P({mutationFn:({provider:e,profileId:t})=>te(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:G.agentProfiles}),e.invalidateQueries({queryKey:G.providerStatus}),L(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:W.health}),e.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Rr(){let e=b();return P({mutationFn:e=>de(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(G.agentAccountStatus(n),t),e.invalidateQueries({queryKey:G.agentProfiles}),L(e,t.status.provider)}})}function zr(){let e=b();return P({mutationFn:e=>_t(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Br(){let e=b();return P({mutationFn:e=>ke(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Vr({enabled:e}){return x({queryKey:G.githubOwners,queryFn:({signal:e})=>St({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Hr(){let e=b();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(W.health);n&&(s({bootProject:n.bootProject??`default`,apiBase:r()}),t??=_r(`health`,t=>{e.setQueryData(W.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),re()}},[e])}function Ur(){return x({queryKey:W.health,queryFn:({signal:e})=>ut({signal:e})})}function Wr(e,t){let n=Ur().data,r=xr(t).data?.projects,i=Ie(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?pr(n?.repo?.remote):void 0}function Gr(){return x({queryKey:G.uiState,queryFn:({signal:e})=>ft({signal:e})})}function Kr(){return x({queryKey:G.config,queryFn:({signal:e})=>Re({signal:e})})}function qr(){return x({queryKey:G.agentProfiles,queryFn:({signal:e})=>i({signal:e})})}var J=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>[e.cacheScope,`runs`,`detail`,e.runId],Z=e=>typeof e==`function`?e():e;function Jr(e){let{seenAt:t,...n}=e;return n}function Yr(e,t){let n=Jr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Xr(e,t,n){return t?{...e,seenAt:n}:Jr(e)}function Zr(e){let t=()=>{e.invalidateQueries({queryKey:J})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=we(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);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,n){await e.cancelQueries({queryKey:J});let i=e.getQueryData(J),a=n();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(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function Q(){let e=b();return(0,M.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Vt(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),gt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function $(e,t,n,r){let i=b(),a=JSON.stringify(t),o=(0,M.useMemo)(()=>JSON.parse(a),[a]);(0,M.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=Qr({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function $r(e,t=!1){return Rt(await y.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),fe(e,`/worker-destroy`))}function ei(){return x({queryKey:W.openTargets,queryFn:({signal:e})=>Lt({signal:e}),staleTime:5*6e4})}function ti(){return x({queryKey:W.runs.list(),queryFn:({signal:e})=>a(F(),{signal:e})})}function ni(e,t){return vt({queryKey:W.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ct({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function ri(e){let t=e.trim();return x({queryKey:G.runsSearch(t),queryFn:({signal:e})=>Se(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function ii(e=!0,t=Sn,n){let r=Tn(b());return $(`/api/v1/workspace/runs-index`,G.runsIndex,K(e?t:!1),En),x({queryKey:G.runsIndex,queryFn:({signal:e})=>tt({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return P({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:W.runs.relationships(e)})})}function oi(e,t={}){return x({queryKey:W.runs.relationships(e),queryFn:({signal:t})=>rt(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return x({queryKey:W.runs.detail(e??``),queryFn:({signal:t})=>Be(I(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return x({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Be(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function li(e,t){return x({queryKey:t?[t,`runs`,`diff`,e??``]:W.runs.diff(e??``),queryFn:({signal:n})=>jt(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ui(e,t=!1){return $(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,W.runs.changes(e??``),K(t?4e3:!1)),x({queryKey:W.runs.changes(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return x({queryKey:W.runs.file(e??``,t??``),queryFn:({signal:n})=>be(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return x({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Ot(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return x({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ze(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return x({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Ye(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return x({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Fe(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function gi(e,t=!1){return $(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,W.runs.commits(e??``),K(t?5e3:!1)),x({queryKey:W.runs.commits(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return x({queryKey:W.runs.commit(e??``,t??``),queryFn:({signal:n})=>ve(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return x({queryKey:W.runs.handoff(e??``),queryFn:({signal:t})=>p(I(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return x({queryKey:e===void 0?W.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>p(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>Tt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function xi(e){let t=b();return P({mutationFn:t=>ce(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Si(e){let t=b();return P({mutationFn:t=>me(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>v(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function wi(){let e=Q();return P({mutationFn:e=>v(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return P({mutationFn:({id:t,pinned:n})=>zt(I(t,e),n),onError:e=>lt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return P({mutationFn:n=>De(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof g&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return P({mutationFn:(n={})=>pt(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return P({mutationFn:({msgId:t,message:n})=>We(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function ki(e){let t=b();return P({mutationFn:t=>Te(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ai(){return x({queryKey:W.workflows,queryFn:({signal:e})=>u({signal:e})})}function ji(e){return x({queryKey:e?[e,`repo`]:W.repo,queryFn:({signal:t})=>ze({signal:t},e)})}function Mi(e){return x({queryKey:[e,`repo`],queryFn:({signal:t})=>ze({signal:t},e)})}function Ni(){return x({queryKey:W.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return x({queryKey:W.repoChanges,queryFn:({signal:e})=>he({signal:e}),retry:!1})}function Fi(e){return x({queryKey:W.repoCommit(e??``),queryFn:({signal:t})=>c(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e){return x({queryKey:e?[e,`config`]:W.config,queryFn:({signal:t})=>Pt({signal:t,...e?{projectId:e}:{}})})}function Li(){return x({queryKey:W.worktrees,queryFn:({signal:e})=>le({signal:e})})}function Ri(e){return x({queryKey:[e,`worktrees`],queryFn:({signal:t})=>le({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>f({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:pe(e.sidebarLimits)},enabled:t})}function Bi(){return zi(n())}function Vi(){return x({queryKey:W.agentConfig,queryFn:({signal:e})=>ot({signal:e})})}function Hi(e){return x({queryKey:W.agentConfigFile(e??``),queryFn:({signal:t})=>Xe(e,{signal:t}),enabled:e!==null})}function Ui(){return x({queryKey:W.sessionContext,queryFn:({signal:e})=>ye({signal:e})})}function Wi(e,t,n=``){return x({queryKey:W.sessionContextPreview(e,t,n),queryFn:({signal:n})=>$e({content:e,role:t},{signal:n}),placeholderData:At,staleTime:0,retry:!1})}function Gi(){let e=b();return P({onMutate:()=>({fileKey:W.sessionContext}),mutationFn:e=>m(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=W.agentConfig,r=W.agentConfigFile(e);return P({mutationFn:t=>se(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=A([`passing`,`failing`,`pending`]).nullable(),Ji=S({kind:A([`issue`,`pr`]),number:j(),title:O(),author:O(),createdAt:O(),labels:E(O()),body:O().optional(),url:O(),comments:j(),assignees:E(O()).optional(),projectIds:E(O()).optional(),isDraft:D().optional(),additions:j().optional(),deletions:j().optional(),checks:qi.optional()});C(`available`,[S({available:T(!0),item:Ji.nullable(),labelColors:w(O(),O()).optional()}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),number:Bt().int().positive().safe()});var Yi=S({id:O(),title:O(),url:O()});S({available:D(),reason:O().optional(),repo:O().optional(),syncedAt:O().optional(),issues:E(Ji),prs:E(Ji),labelColors:w(O(),O()).optional(),viewerLogin:O().optional(),projects:E(Yi).optional(),projectsReason:O().optional(),projectsState:A([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:O().optional(),issuesTotal:j().int().nonnegative().optional(),prsTotal:j().int().nonnegative().optional(),issuesNextCursor:O().nullable().optional(),prsNextCursor:O().nullable().optional(),commentsDeferred:T(!0).optional()});var Xi=O().min(1).max(2e3).optional();S({limit:O().optional(),refresh:O().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),S({kind:A([`issue`,`pr`]),numbers:O().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),C(`available`,[S({available:T(!0),counts:w(j(),j().int().nonnegative())}),S({available:T(!1),reason:O()})]),C(`available`,[S({available:T(!0),checks:w(j(),qi)}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),q:O().trim().min(1).max(256),limit:Bt().int().positive().max(50).optional()}),S({available:D(),projectsReason:O().optional(),reason:O().optional(),items:E(Ji),truncated:D().optional(),labelColors:w(O(),O()).optional()});var Zi=j().nullable();C(`available`,[S({available:T(!0),prs:w(j(),Pe),issues:w(j(),Pe),conflicts:E(j()).optional(),recheckAfterMs:Zi}),S({available:T(!1),reason:O(),recheckAfterMs:Zi})]);var Qi=S({id:j(),author:O(),avatarUrl:O().optional(),createdAt:O(),body:O(),kind:A([`comment`,`review`]),reviewState:A([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:O()}),$i=A([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=S({id:O(),kind:$i,actor:O(),avatarUrl:O().optional(),createdAt:O(),url:O().optional(),sha:O().optional(),message:O().optional(),checks:qi.optional(),label:S({name:O(),color:O().optional()}).optional(),subject:O().optional(),refNumber:j().optional(),refTitle:O().optional(),refIsPr:D().optional()});S({available:D(),reason:O().optional(),comments:E(Qi),truncated:D().optional(),events:E(ea).optional(),detail:S({body:O(),additions:j().int().nonnegative().optional(),deletions:j().int().nonnegative().optional()}).optional()});var ta=A([`merge`,`squash`,`rebase`]),na=S({name:O(),state:A([`passing`,`failing`,`pending`,`unknown`]),required:D().nullable(),url:O().optional()}),ra=S({number:j(),title:O(),url:O(),state:A([`open`,`closed`,`merged`]),isDraft:D(),headRef:O(),baseRef:O(),headSha:O(),mergeable:A([`mergeable`,`conflicting`,`unknown`]),reviewDecision:A([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:E(na),methods:E(ta),defaultMethod:ta.nullable(),eligibility:A([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:E(S({code:O(),message:O()})),canMerge:D(),canOverride:D()});C(`available`,[S({available:T(!0),mergeState:ra}),S({available:T(!1),reason:O()})]),S({merged:T(!0),number:j(),url:O(),method:ta,mergeCommitSha:O().optional()});var ia=S({path:O(),previousPath:O().optional(),status:A([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:j(),deletions:j(),patch:O().optional(),patchUnavailableReason:A([`binary`,`too-large`,`not-provided`]).optional(),truncated:D().optional()});C(`available`,[S({available:T(!0),number:j(),headSha:O(),files:E(ia),additions:j(),deletions:j(),truncated:D(),reason:O().optional()}),S({available:T(!1),reason:O()})]),S({generation:O().uuid()}),C(`state`,[S({generation:O().uuid(),state:T(`ready`),projects:E(Yi),membership:w(O(),E(O()))}),S({generation:O().uuid(),state:T(`unavailable`),reason:O()})]);function aa(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function oa(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function sa(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function ca(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){sa(t.issues,a,r),sa(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var la=e=>e.map(e=>e.number).join(`,`);function ua(e,t){let n=e[0];if(e.length>1&&n&&(la(n.issues)!==la(t.issues)||la(n.prs)!==la(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function da(e={},t=!0){let r=b(),i=W.github(e);$(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,K(t?6e4:!1));let a=x({queryKey:W.github(e),queryFn:({signal:t})=>xe({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),o=a.data?.projectsGeneration,s=x({queryKey:[...i,`projects`,o],queryFn:({signal:e})=>Oe(o,{signal:e}),enabled:t&&a.data?.projectsState===`refreshing`&&!!o,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!o||!s.data&&!s.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==o||e.projectsState!==`refreshing`)return e;let t=s.data;return t?.generation&&t.generation!==o?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[r,o,s.data,s.error,i]),a}var fa=class extends Error{};function pa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await xe({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new fa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof fa)&&!(t instanceof g&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ma(e=50,t=!0){let r=b(),i=W.githubPages(e),a=W.githubPagesHead(e);$(`/api/v1/p/${n()}/github?limit=${e}`,a,K(t?6e4:!1));let o=vt({...pa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=x({queryKey:a,queryFn:({signal:t})=>xe({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,M.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=ua(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=N({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Oe(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!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 r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,M.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ha(e,t=50,n=!0){let r=vt({...pa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ga(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:W.githubCommentCounts(e,t),queryFn:({signal:n})=>_(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function _a(e,t,n,r=!0){return x({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ue(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function va(e,t=!0){return x({queryKey:W.githubChecks(e),queryFn:({signal:t})=>Ee(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function ya(e,t,n=!0){return x({queryKey:W.githubSearch(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ba=100;function xa(e){return[...e].sort((e,t)=>t-e).slice(0,ba).sort((e,t)=>e-t)}function Sa(){let e=Ie(),t=Ur();return e.projectId??t.data?.bootProject}function Ca(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))tr(U({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))tr(U({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var wa=5*6e4;function Ta(e){return e?e.recheckAfterMs:wa}function Ea(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:xa(t.prs),issues:xa(t.issues)}))},[e.map(U).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:W.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>je(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ta(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),i=b(),a=JSON.stringify(n.map((e,t)=>({...e,interval:Ta(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||fr())return;let e=!0,n=JSON.parse(a).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=W.githubRefStatus(t.projectId,t.prs,t.issues);return Qr({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,a,i]);let o=(0,M.useMemo)(()=>dr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=U(e),n=o.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...H.has(t)?{conflicting:!0}:{}}},[o])}function Da(e,t,n=!0){return x({queryKey:W.githubComments(e,t),queryFn:({signal:n})=>ne(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e,t,n=!0){return x({queryKey:W.githubItem(e,t),queryFn:({signal:n})=>ht(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ka(e){return x({queryKey:W.githubPrChanges(e??0),queryFn:({signal:t})=>ee(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{li as $,Vn as $t,Ai as A,br as At,fi as B,hr as Bt,ji as C,vr as Ct,Ui as D,Pr as Dt,Fi as E,Cr as Et,hi as F,kr as Ft,Si as G,G as Gt,wi as H,K as Ht,bi as I,Kr as It,ki as J,qn as Jt,Ti as K,Yn as Kt,Di as L,Gr as Lt,ni as M,jr as Mt,pi as N,Nr as Nt,Wi as O,wr as Ot,mi as P,Tr as Pt,gi as Q,B as Qt,ai as R,_r as Rt,Gi as S,xr as St,Pi as T,yr as Tt,xi as U,fr as Ut,Ci as V,pr as Vt,ei as W,W as Wt,ui as X,Wn as Xt,si as Y,Hn as Yt,_i as Z,Bn as Zt,Ii as _,Sr as _t,Da as a,L as an,ri as at,Ri as b,Hr as bt,ka as c,Zt as cn,Qr as ct,_a as d,P as dn,qr as dt,Kn as en,di as et,Sa as f,N as fn,zr as ft,Hi as g,Or as gt,Vi as h,Br as ht,ga as i,Tn as in,ii as it,Li as j,Fr as jt,Bi as k,Ar as kt,ya as l,F as ln,Q as lt,oa as m,Wt as mn,Mr as mt,da as n,Un as nn,oi as nt,Oa as o,en as on,Ei as ot,Ea as p,Gt as pn,Lr as pt,ci as q,Zn as qt,va as r,zn as rn,ti as rt,ma as s,Qt as sn,yi as st,Ca as t,Gn as tn,vi as tt,ha as u,I as un,Ir as ut,Mi as v,Vr as vt,Ni as w,Rr as wt,Ki as x,Wr as xt,zi as y,Ur as yt,Oi as z,mr as zt};
@@ -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{n as r,t as i}from"./utils-DSMR_WLb.js";import{Kt as a,p as o,qt as s}from"./queries-ClkIgWFx.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-BkjZYg2J.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-BPgUYFyu.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E=e(t(),1),D=n(),O=(0,E.createContext)(null);function k({children:e}){let[t,n]=(0,E.useState)(()=>new Map),r=(0,E.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,E.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,E.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,E.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,D.jsx)(O.Provider,{value:s,children:e})}var A=(0,E.createContext)(null);function j({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,E.useContext)(O),a=(0,E.useContext)(A),s=(0,E.useId)();(0,E.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?M:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,E.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,D.jsx)(A.Provider,{value:d,children:r})}var M=[];function N(e,t,n){let r=(0,E.useContext)(A),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function ee(e,t){let n=(0,E.useContext)(A),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function P(){let e=(0,E.useContext)(A);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),F={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},I={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},ne={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},re={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function L(e){return e===`PR`?`pr-chip`:`issue-chip`}function R(e){return e?{"data-conflicting":`true`}:{}}function z(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function B(e,t,n){return e===`PR`&&(t??n)===!0}function V({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,F[a],r)}function H(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function U(e){return e===`PR`?`pull request`:`issue`}function W(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function G(e,t){return e&&t?I[t.tone]:void 0}function K(e,t){return!e&&(!t||!r(t))}function q({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,D.jsxs)(D.Fragment,{children:[e?(0,D.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,D.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,D.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,D.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function J({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,D.jsx)(`span`,{"data-slot":L(e),"data-status":t,"data-inert":`true`,...R(n),className:r,children:i})}function Y({kind:e,number:t,tooltip:n,url:i}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,D.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,D.jsx)(`span`,{className:`block opacity-70`,children:n.also}):null,i&&r(i)?(0,D.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function ie({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=P(),y=N(h,z(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=s(b),S=B(h,r,y.conflicting),C=S?a:x,w=C?.tone??`accent`,T=V({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=le(y,C,S?x:void 0),O=H(h,g,p,f),k=U(h),A=W(k,g,t,C),j=(0,D.jsx)(q,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:O,glyphClass:G(p,C)});if(m)return(0,D.jsx)(J,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=K(u,_)?(0,D.jsx)(`span`,{"data-slot":L(h),"data-status":b,...R(S),"aria-label":C?`${k} ${O} — ${C.label}`:void 0,className:T,children:j}):(0,D.jsx)(ae,{to:u,url:_,"data-slot":L(h),"data-status":b,...R(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,ne[w]),children:j});return E?(0,D.jsx)(ce,{chip:M,action:S?o:void 0,state:y.state,children:(0,D.jsx)(Y,{kind:h,number:g,tooltip:E,url:_})}):M}function ae({to:e,url:t,children:n,...r}){return e?(0,D.jsx)(c,{to:e,...r,children:n}):(0,D.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,E.createContext)(()=>{});function oe(){return(0,E.useContext)(X)}var se=150,Z=120;function ce({chip:e,action:t,state:n,children:r}){let[i,a]=(0,E.useState)(!1),o=(0,E.useRef)(null),s=(0,E.useRef)(null),c=(0,E.useRef)(void 0),l=(0,E.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,E.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,E.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,D.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,D.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,se)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,D.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},children:[(0,D.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,D.jsx)(X.Provider,{value:u,children:t}):null]})]})}function le(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${ue(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function ue(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Q({kind:e,number:t,className:n}){let r=N(e,t),o=s(r.status),c=e===`PR`&&r.conflicting===!0,l=c?a:o;if(!l)return null;let u=i(`size-2.5`,I[l.tone]);return(0,D.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,D.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,D.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,D.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=re[e];return n?(0,D.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{k as a,N as c,j as i,T as l,Q as n,ee as o,oe as r,P as s,ie as t};
@@ -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{Gt as r,Wt as i,yt as a}from"./queries-ClkIgWFx.js";import{hi as o}from"./toaster-C-xqAWVX.js";import{mn as s}from"./index-7M_Uae0m.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:i.health}),e.invalidateQueries({queryKey:i.agentConfig,exact:!0}),e.invalidateQueries({queryKey:r.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return a().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};