@hearsay-tools/squawk 0.19.0-dev.9155 → 0.19.0-dev.9162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-wait/controller.d.ts +7 -7
- package/dist/features/reports/routes.d.ts +2 -2
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/project-settings-routes.d.ts +107 -107
- package/dist/server/projects-routes.d.ts +41 -41
- package/dist/server/provider-sign-in-routes.d.ts +2 -2
- package/dist/server/runner-install-routes.d.ts +10 -10
- package/dist/server/runs-routes.d.ts +311 -311
- package/dist/server/server.d.ts +1170 -1170
- package/dist/server/workspace-identity-routes.d.ts +5 -5
- package/package.json +4 -4
- package/web/dist/assets/accounts-section-m_1ntZJh.js +1 -0
- package/web/dist/assets/activity-motion-DDqgr8eF.js +1 -0
- package/web/dist/assets/activity-route-BlEZZxyI.js +1 -0
- package/web/dist/assets/agent-accounts-D_ZKAmaW.js +1 -0
- package/web/dist/assets/{agent-config-section-D8pxNy2V.js → agent-config-section-wICtFVks.js} +2 -2
- package/web/dist/assets/agent-defaults-section-BC9Ypg0g.js +1 -0
- package/web/dist/assets/{appearance-D_t3wCjY.js → appearance-fkDdWPlG.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-C63xRNFZ.js → archive-on-merge-field-B6kX09p-.js} +1 -1
- package/web/dist/assets/{ask-card-kqWOqKIc.js → ask-card-Cue5EajQ.js} +5 -5
- package/web/dist/assets/attention-BI6592lk.js +1 -0
- package/web/dist/assets/{automation-format-DB34jUyF.js → automation-format-jKMOXcHS.js} +1 -1
- package/web/dist/assets/automations-route-BfOpJjLK.js +2 -0
- package/web/dist/assets/{badge-DVxxThpb.js → badge-DAnkqD7i.js} +1 -1
- package/web/dist/assets/{button-B22ANdCY.js → button-BV_AiLj2.js} +1 -1
- package/web/dist/assets/{centered-state-BgSV4e79.js → centered-state-N8vWM_Hw.js} +1 -1
- package/web/dist/assets/{cez-idle-CdswdDRd.js → cez-idle-C0drOeLs.js} +1 -1
- package/web/dist/assets/{change-counts-wqSYI3W8.js → change-counts-BLLRvt46.js} +1 -1
- package/web/dist/assets/chunk-KS7C4IRE-BdLLx37K.js +3 -0
- package/web/dist/assets/{code-editor-GfQChdgl.js → code-editor-DZMD1guX.js} +1 -1
- package/web/dist/assets/{code-workbench-CUkiQ1pF.js → code-workbench-B0GIezrD.js} +1 -1
- package/web/dist/assets/{collapsible-Bx2vViFx.js → collapsible-D5i3hm2L.js} +1 -1
- package/web/dist/assets/{command-B2Y0By1v.js → command-4D8sPZJy.js} +1 -1
- package/web/dist/assets/{commit-list-Bjc-pQxv.js → commit-list-StLehTiQ.js} +1 -1
- package/web/dist/assets/{dialog-rpNyAWGb.js → dialog-DKr-j9S6.js} +1 -1
- package/web/dist/assets/diff-DEw-tkVq.js +3 -0
- package/web/dist/assets/{diff-controls-CaCUSyxs.js → diff-controls-CSO8HgZ0.js} +1 -1
- package/web/dist/assets/{diff-stat-Dy4uLuyP.js → diff-stat-DCO_BkZB.js} +1 -1
- package/web/dist/assets/{diff-view-4wxDvYXE.js → diff-view-BcU4Rnuo.js} +3 -3
- package/web/dist/assets/discard-changes-dialog-BEsdWdyJ.js +1 -0
- package/web/dist/assets/{dist-BSUJIXeE.js → dist-B2_vvox1.js} +1 -1
- package/web/dist/assets/dist-CCX8mhHc.js +1 -0
- package/web/dist/assets/{dist-BuF3mvCA.js → dist-ClMNSUvT.js} +1 -1
- package/web/dist/assets/{dist--f2yFdPY.js → dist-CyFJ-9Ex.js} +1 -1
- package/web/dist/assets/{dist-DudPJH39.js → dist-Du6flkGD.js} +1 -1
- package/web/dist/assets/{dropdown-menu-DjtKUK8F.js → dropdown-menu-NJZfnQCU.js} +1 -1
- package/web/dist/assets/{es2015-CUEfzDjB.js → es2015-BHonSvOU.js} +1 -1
- package/web/dist/assets/file-preview-_4nAs_Ai.js +2 -0
- package/web/dist/assets/{folder-browser-Civftk0W.js → folder-browser-CFd1U5hn.js} +1 -1
- package/web/dist/assets/{git-toolbar-CepvG0Ng.js → git-toolbar-DXnIUFi1.js} +1 -1
- package/web/dist/assets/github-g-Ykk4uE.js +1 -0
- package/web/dist/assets/{global-activity-route-DhmrWj31.js → global-activity-route-OsAvUny-.js} +2 -2
- package/web/dist/assets/highlighter-Crq-WTmN.js +3 -0
- package/web/dist/assets/host-context-DDbYAKpm.js +1 -0
- package/web/dist/assets/host-storage-B72yoDU1.js +1 -0
- package/web/dist/assets/hosts-CpDMDiQW.js +1 -0
- package/web/dist/assets/{html-report-frame-Ck76gKfA.js → html-report-frame-Bk6UkqKa.js} +1 -1
- package/web/dist/assets/{image-preview-CeEKI2T5.js → image-preview-CdL9a1Zj.js} +1 -1
- package/web/dist/assets/index-D_WkVdwL.css +1 -0
- package/web/dist/assets/index-Dp7K74Jw.js +21 -0
- package/web/dist/assets/label-CgU9vxuM.js +1 -0
- package/web/dist/assets/{live-protocol-DMhTnCmf.js → live-protocol-CNUmr-VT.js} +1 -1
- package/web/dist/assets/markdown-BB-PN03o.js +2 -0
- package/web/dist/assets/{middle-truncated-name-D41ibfXD.js → middle-truncated-name-jUQS2QzL.js} +1 -1
- package/web/dist/assets/{nav-row-styles-CgP5uNp4.js → nav-row-styles-CIedRn3A.js} +1 -1
- package/web/dist/assets/{open-in-menu-CbQWVBD0.js → open-in-menu-BI7mnPPf.js} +1 -1
- package/web/dist/assets/{option-select-BwSkbCrQ.js → option-select-Bmm4ktgQ.js} +1 -1
- package/web/dist/assets/{page-shell-BgabWJ3w.js → page-shell-BdjH5hyc.js} +1 -1
- package/web/dist/assets/{popover-CvL6hQ5c.js → popover-BQolmvDR.js} +1 -1
- package/web/dist/assets/{preferences-section-Cvh644K0.js → preferences-section-dKDCZSWD.js} +1 -1
- package/web/dist/assets/preview-EtD19mg1.js +1 -0
- package/web/dist/assets/preview-pane-connected-DBbCXW1b.js +3 -0
- package/web/dist/assets/{project-location-DR8go8oL.js → project-location-DJjcFmsE.js} +1 -1
- package/web/dist/assets/project-router-Dc6KBQsv.js +1 -0
- package/web/dist/assets/projects-section-CVFyzORg.js +1 -0
- package/web/dist/assets/{prompt-templates-section-DcxD28iA.js → prompt-templates-section-Jj1YbCwG.js} +2 -2
- package/web/dist/assets/queries-IlC9MZgh.js +1 -0
- package/web/dist/assets/{read-state-c_RNJaXO.js → read-state-BeVNfGkB.js} +1 -1
- package/web/dist/assets/{reference-chip-z7dZJVH-.js → reference-chip-BjerVjzM.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-Dtaa3ovl.js → remote-settings-notice-Czl9yS5W.js} +1 -1
- package/web/dist/assets/repo-git-C9N9wa5l.js +1 -0
- package/web/dist/assets/{report-reader-mbkd2DKt.js → report-reader-Ci4sWoe1.js} +1 -1
- package/web/dist/assets/report-selection-CZ8eb9QP.js +1 -0
- package/web/dist/assets/reports-CQPRtR5G.js +1 -0
- package/web/dist/assets/{resources-section-g5XRlefz.js → resources-section-lLpdP6MD.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-BdBvLP6E.js → review-notes-drafts-BjXqp0gY.js} +1 -1
- package/web/dist/assets/{review-panel-Ba8yb8Fu.js → review-panel-B4dp-Rol.js} +1 -1
- package/web/dist/assets/{review-strip-CdlMeV2i.js → review-strip-BE71YjB6.js} +1 -1
- package/web/dist/assets/{run-detail-refresh-C5qmRdgD.js → run-detail-refresh-CE0vyYYA.js} +1 -1
- package/web/dist/assets/{run-diff-BDMdnSv7.js → run-diff-ClfLRsHF.js} +3 -3
- package/web/dist/assets/run-header-DvbVw3uo.js +2 -0
- package/web/dist/assets/{select-DdH25sWT.js → select-CYo1lo6a.js} +1 -1
- package/web/dist/assets/{session-context-section-BqEdLdTv.js → session-context-section-B_NEOGby.js} +2 -2
- package/web/dist/assets/{settings-agent-picker-b4M6fQ8m.js → settings-agent-picker-DeAST7qR.js} +1 -1
- package/web/dist/assets/{settings-field-Bhh8I9fJ.js → settings-field-AyinSFR_.js} +1 -1
- package/web/dist/assets/{settings-list-detail-D3ibaYUj.js → settings-list-detail-BlEEuyae.js} +1 -1
- package/web/dist/assets/settings-save-bar-Dd3bTznK.js +1 -0
- package/web/dist/assets/{settings-shell-BUwdvhI9.js → settings-shell-Bt7NYun7.js} +1 -1
- package/web/dist/assets/sidebar-section-DdrFJBTL.js +1 -0
- package/web/dist/assets/{skills-BLkPhZO8.js → skills-DNCuhhKf.js} +1 -1
- package/web/dist/assets/status-dot-Bmn4xhch.js +1 -0
- package/web/dist/assets/{switch-CAKeV99j.js → switch-B9OfOEzC.js} +1 -1
- package/web/dist/assets/{tab-link-BKlpD9sn.js → tab-link-6TltE1jl.js} +1 -1
- package/web/dist/assets/{task-changes-Drvnew5P.js → task-changes-CdAzeh9M.js} +2 -2
- package/web/dist/assets/{task-commits-1MJHuX1i.js → task-commits-CzZJZj2x.js} +1 -1
- package/web/dist/assets/{task-file-scope-CB3L3KQl.js → task-file-scope-BuFeMG6a.js} +1 -1
- package/web/dist/assets/task-files-BFdMVAb3.js +1 -0
- package/web/dist/assets/{task-github-item-CMNk7FxR.js → task-github-item-Dv0Uflz7.js} +1 -1
- package/web/dist/assets/{task-groups-CGCnVqHE.js → task-groups-DCg4iOB9.js} +1 -1
- package/web/dist/assets/task-thread-C98mqSie.js +2 -0
- package/web/dist/assets/{textarea-vEsJAUAV.js → textarea-BGp28xFr.js} +1 -1
- package/web/dist/assets/thread-state-DqBwIoCM.js +4 -0
- package/web/dist/assets/toaster-DNnL8v10.js +4 -0
- package/web/dist/assets/{tool-display-B9NN44oU.js → tool-display-CTbToGmi.js} +1 -1
- package/web/dist/assets/use-finish-run-CFEVvqeg.js +1 -0
- package/web/dist/assets/use-hand-to-agent-state-BYN578_s.js +1 -0
- package/web/dist/assets/use-path-bases-B238cLk1.js +1 -0
- package/web/dist/assets/{use-search-params-writer-ClMScnNe.js → use-search-params-writer-DD5PEEZw.js} +1 -1
- package/web/dist/assets/use-workspace-config-save-DScW6_8J.js +1 -0
- package/web/dist/assets/{workflows-BUcx-n8J.js → workflows-IT5WTfLr.js} +3 -3
- package/web/dist/assets/{workspace-tools-dbiR1fzO.js → workspace-tools-D_opTe6D.js} +1 -1
- package/web/dist/assets/{worktrees-section-Dyb_QkSd.js → worktrees-section-B8ycJMoK.js} +4 -4
- package/web/dist/assets/zoomable-image-CULOtYYp.js +1 -0
- package/web/dist/index.html +41 -37
- package/web/dist/live-worker.js +2 -2
- package/web/dist/assets/accounts-section-BsgnDmow.js +0 -1
- package/web/dist/assets/activity-motion-Ckq9kC3I.js +0 -1
- package/web/dist/assets/activity-route-5S9WhN9U.js +0 -1
- package/web/dist/assets/agent-accounts-D_7QcFSx.js +0 -1
- package/web/dist/assets/agent-defaults-section-et5LHv9W.js +0 -1
- package/web/dist/assets/attention-DnxGjw_R.js +0 -1
- package/web/dist/assets/automations-route-B5YBpGMc.js +0 -2
- package/web/dist/assets/chunk-KS7C4IRE-Cg8l-LDN.js +0 -3
- package/web/dist/assets/diff-lwWO-At7.js +0 -3
- package/web/dist/assets/discard-changes-dialog-B3gvm7lX.js +0 -1
- package/web/dist/assets/dist-C_rn70hE.js +0 -1
- package/web/dist/assets/file-preview-98pJhZJj.js +0 -2
- package/web/dist/assets/github-4Jhl7lLG.js +0 -1
- package/web/dist/assets/highlighter-Cfo7mLVB.js +0 -3
- package/web/dist/assets/index-BK1FcZrA.css +0 -1
- package/web/dist/assets/index-DJB0lid-.js +0 -21
- package/web/dist/assets/label-feCJ3WOT.js +0 -1
- package/web/dist/assets/markdown-BAPhDASs.js +0 -2
- package/web/dist/assets/preview-pane-connected-B08ZdGux.js +0 -3
- package/web/dist/assets/project-router-j0uBi7Ep.js +0 -1
- package/web/dist/assets/projects-section-XDboHBFP.js +0 -1
- package/web/dist/assets/queries-CchoEEzj.js +0 -1
- package/web/dist/assets/repo-git-Dp9R2TuI.js +0 -1
- package/web/dist/assets/report-selection-BdGxjISG.js +0 -1
- package/web/dist/assets/reports-ya2OW-iR.js +0 -1
- package/web/dist/assets/run-header-BTRXYB4W.js +0 -2
- package/web/dist/assets/settings-save-bar-DFY_Km4X.js +0 -1
- package/web/dist/assets/sidebar-section-CcucfASN.js +0 -1
- package/web/dist/assets/status-dot-Drd4-nfa.js +0 -1
- package/web/dist/assets/task-files-B9okW1TC.js +0 -1
- package/web/dist/assets/task-thread-_2ch8BRt.js +0 -2
- package/web/dist/assets/thread-state-qNczqxZQ.js +0 -4
- package/web/dist/assets/toaster-zMN8cNZQ.js +0 -4
- package/web/dist/assets/use-finish-run-Dvm4JnAH.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-CBJvP-US.js +0 -1
- package/web/dist/assets/use-path-bases-C9yvZF5B.js +0 -1
- package/web/dist/assets/use-workspace-config-save-9jm9qV6u.js +0 -1
- package/web/dist/assets/zoomable-image-BUTgYpld.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{f as r,o as i,p as a,u as o}from"./dist-C_rn70hE.js";import{Ut as s,Wt as c,cn as l,rn as u,yt as d}from"./queries-CchoEEzj.js";import{Er as f,Jn as p,Jr as m,Kn as h,Kr as ee,Xr as g,Yn as _,Zr as v,qn as y,ti as te,vi as b,wr as ne}from"./toaster-zMN8cNZQ.js";import{B as x,H as S,I as C,N as w,W as T,z as E}from"./live-protocol-DMhTnCmf.js";import{i as D,r as O}from"./cez-idle-CdswdDRd.js";import{n as re,r as k,t as ie}from"./run-detail-refresh-C5qmRdgD.js";import{h as ae}from"./es2015-CUEfzDjB.js";var A=class extends EventTarget{readyState=0;release;constructor(e,t){super(),this.release=this.subscribe()}subscribe(){let e=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});return g({kind:`workspace`},{ready:e,reset:()=>{this.readyState!==2&&(this.readyState=0,e())},frame:t=>{if(`data`in t&&t.event===`reconnect`){this.readyState=0,e();return}if(`data`in t&&t.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in t&&t.event===`ready`&&v(),`data`in t&&this.dispatchEvent(new MessageEvent(t.event,{data:t.data}))}})}requestReady(){return this.readyState!==2&&m()}close(){this.readyState=2,this.release()}},j=e(t(),1);x({runs:C(`summary`).optional()});var M=T().min(1),N=E().int().positive(),oe=x({project:M,seq:N,run:_,relationships:T().min(1)}),se=x({project:M,seq:N,id:T().min(1)}),ce=x({generation:T().min(1),seq:E().int().nonnegative()}),le=x({project:M,usage:S(T(),h)});x({runs:w(p),referenceStatuses:y,perProjectLimit:E(),truncated:w(T()),generation:T().min(1),eventSeq:E().int().nonnegative()});function ue(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=oe.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=se.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=le.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=ce.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}function de(){let e;return{ready(t){let n=e!==void 0&&t>e;return e=t,n},frame(t){let n=e!==void 0&&t!==e+1;return e=t,n},reset(){e=void 0}}}function P(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function fe(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var F=Object.freeze({});function pe(){let e=F,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}var I=n(),L=o(`/workspace/events?runs=summary`),R=2,z=3e3,B=[`run-summary`,`run-deleted`,`usage`,`ping`,`ready`],me=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],V=new Set;function he(e){return V.add(e),()=>{V.delete(e)}}function H(e){return e[1]===`runs`&&e[2]===`list`}function U(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function W(e){return e.invalidateQueries({predicate:e=>H(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>H(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>U(e,t.queryKey))}var ge=1e3,G=new WeakMap;function K(e){let t=s.repoBranches,n=G.get(e);if(n){n.set(JSON.stringify(t),t);return}G.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=G.get(e);G.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},ge)}function q(e,t,n=!1){if(t?.aborted)return Promise.resolve();let r=[s.runs.all,c.runsIndex,c.projects,s.health,s.worktrees,s.repoBranches,c.providerStatus],i=()=>{for(let t of r)e.cancelQueries({queryKey:t})};return t?.addEventListener(`abort`,i,{once:!0}),D(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>H(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:s.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>H(e.queryKey)}),u(e).reconcile(),e.invalidateQueries({queryKey:c.projects}),U(e,s.health),e.invalidateQueries({queryKey:s.worktrees}),e.invalidateQueries({queryKey:s.repoBranches}),e.invalidateQueries({queryKey:c.providerStatus}),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,i))}function J(e){return r()??Y(e)}function Y(e){let t=e.getQueryData(c.projects);if(t?.bootProject!==null)return typeof t?.bootProject==`string`&&t.bootProject!==``?t.bootProject:e.getQueryData(s.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject??void 0}function _e(e,t){return[l({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function ve(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},i=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),a=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},o,c,l=(i=!1)=>{c!==void 0&&clearTimeout(c),c=void 0,o!==void 0&&cancelAnimationFrame(o),o=void 0;let s=[];for(let{key:r,baseList:i,baseQuery:o,baseUpdateCount:c,runs:l}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==o||t?.state.dataUpdateCount!==c||t?.state.data!==i){s.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}a(r,s),e.setQueryData(r,e=>{let t=e;for(let e of l.values())t=P(t,e);return t})}if(t.clear(),!i)for(let e of s)r(e);return s},u=t=>{let n=[_e(t,Y(e))],r=[t,`runs`,`list`];return(t===J(e)||e.getQueryState(r))&&n.push(r),t===J(e)&&n.push(s.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,s){let d=u(i);if(s.type===`run-summary`&&s.summary.archived&&d.every(t=>!e.getQueryData(t)?.find(e=>e.id===s.summary.id)?.archived)&&s.type===`run-summary`){for(let r of d){let i=JSON.stringify(r),a=n.get(i);a?.phase===`fetching`&&(a.dirty=!0);let o=t.get(i);if(!o){let n=e.getQueryCache().find({queryKey:r,exact:!0});o={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,o)}o.runs.set(s.summary.id,s.summary)}c===void 0&&(c=setTimeout(()=>{l()},50),typeof requestAnimationFrame==`function`&&(o=requestAnimationFrame(()=>{l()})));return}let f=l(!0);for(let t of d)a(t,f),s.type===`run-summary`?e.setQueryData(t,e=>P(e,s.summary)):e.setQueryData(t,e=>fe(e,s.id));for(let e of f)r(e)},flush:l,cancel(){i(),n.clear()}}}var ye=400;function be(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},ye))};return{onSummary(e,n){let i=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,a=e.delegation?.role===`worker`?e.delegation.supervisorRunId:void 0,o=t.get(e.id);if(t.set(e.id,{shape:n,...i===void 0?{}:{parentRunId:i},...a===void 0?{}:{supervisorRunId:a}}),o?.shape!==n){r(s.runs.relationships(e.id),!0);for(let e of[i,a])e!==void 0&&r(s.runs.relationships(e),!0)}},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:s.runs.relationships(n)}),i?.supervisorRunId!==void 0&&r(s.runs.relationships(i.supervisorRunId),!0),i?.parentRunId===void 0?r([...s.runs.all,`relationships`],!1):r(s.runs.relationships(i.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var X={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function xe(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(X)){let i=r.state.data;i&&(i.pages.some(e=>e.runs.some(e=>e.id===t.id))?(e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?t:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)):t.archived&&(n=!0))}n&&e.invalidateQueries(X)}function Se(e,t,n,r,i){switch(n.type){case`run-summary`:{let t=n.summary;if(xe(e,t),i.onSummary(t,n.relationships),r.fetcher.onEvent(t.id),t.delegation?.role===`worker`){let n=t.delegation.parentRunId;k(e,s.runs.detail(n)),r.refreshParent(n)}let a=s.runs.changes(t.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:s.worktrees}),K(e);return}case`run-deleted`:i.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:s.runs.detail(n.id)}),e.removeQueries({queryKey:s.runs.diff(n.id)}),e.setQueriesData(X,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(X),e.invalidateQueries({queryKey:s.worktrees}),K(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function Z(e,t,n,r){if(n!==a()){if(r.type===`run-summary`){let i=r.summary;if(t.fetcher.onEvent(i.id,n),i.delegation?.role===`worker`){let r=i.delegation.parentRunId;k(e,[n,`runs`,`detail`,r]),t.refreshParent(r,n)}return}t.fetcher.forget(r.id,n),e.removeQueries({queryKey:[n,`runs`,`detail`,r.id]}),e.removeQueries({queryKey:[n,`runs`,`diff`,r.id]})}}function Ce(e,t=L){let n=b();(0,j.useEffect)(()=>{let r=A;if(typeof r!=`function`)return;let i=null,a=u(n);a.setUnknownGenerationHandler(()=>{let e=i?.requestReady;return typeof e==`function`&&e.call(i)});let o=re(n),l=ie(n),d={fetcher:l,refreshParent:o.refresh},p=de(),m=ve(n),h=be(n),g=!1,_,v=!1,y=!1,b=!1,x=!1,S=()=>{b=!0,x=!1;let e=c.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(y||!x){b=!1;return}S()})},C=()=>{y||_!==void 0||(_=setTimeout(()=>{_=void 0,y||w()},z))},w=()=>{i?.close(),i=new r(t,{withCredentials:!0}),i.addEventListener(`open`,()=>{g=!0,p.reset(),a.detach(),O(!1),v&&(m.flush(),q(n)),v||(D(()=>W(n)),n.cancelQueries({queryKey:s.health}).then(()=>{y||n.invalidateQueries({queryKey:s.health})}),a.reconcile()),v=!0});for(let t of B)i.addEventListener(t,r=>{let i=ue(t,r.data);if(!i)return;if(i.event.type===`ready`){let e=p.ready(i.event.seq);a.ready(i.event.generation,i.event.seq),e&&(m.flush(),q(n));return}let o=(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&p.frame(i.event.seq);i.event.type===`ping`&&g&&(g=!1,D(()=>W(n)),O(!0)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`?a.run(i.project,i.event,o):i.event.type===`usage`&&a.usage(i.project,i.event.usage)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&(m.onEvent(i.project,i.event),Z(n,d,i.project,i.event)),(i.project===null||i.project===J(n))&&Se(n,e,i.event,d,h),o&&(m.flush(),q(n))});for(let e of me)i.addEventListener(e,t=>{let r;try{r=JSON.parse(t.data)}catch{return}if(e===`project-ready`?a.reconcile({hold:!0}):e!==`checkout-progress`&&e!==`automation-change`&&n.invalidateQueries({queryKey:c.projects}),e===`project-added`){let e=r?.project?.id;typeof e==`string`&&e!==``&&a.restoreProject(e),a.reconcile({hold:!0})}if(e===`project-removed`){let e=r?.id;typeof e==`string`&&e!==``&&a.dropProject(e)}for(let t of[...V])t(e,r)});i.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=te.safeParse(t);r.success&&(n.cancelQueries({queryKey:s.health}),n.setQueryData(s.health,r.data))}),i.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=f(t);if(!r)return;let i=c.providerStatus,a=ne(n.getQueryData(i),r);if(a!==void 0){n.setQueryData(i,a);return}if(b){x=!0;return}S()}),i.addEventListener(`error`,()=>{O(!1),a.detach(),i?.readyState===R&&C()})},T=()=>{document.visibilityState===`visible`&&(m.flush(),a.flush(),(!i||i.readyState===R)&&(clearTimeout(_),_=void 0,w()))},E=()=>{clearTimeout(_),_=void 0,m.flush()};document.addEventListener(`visibilitychange`,T),window.addEventListener(`pagehide`,E);let k=ee((e,t)=>(m.flush(),q(n,e,t)));return w(),()=>{k(),y=!0,O(!1),clearTimeout(_),m.flush(),m.cancel(),a.stop(),o.cancel(),l.cancel(),a.setUnknownGenerationHandler(void 0),h.cancel(),document.removeEventListener(`visibilitychange`,T),window.removeEventListener(`pagehide`,E),i?.close(),i=null}},[n,e,t])}var Q=(0,j.createContext)(null);function we({children:e}){let[t]=(0,j.useState)(pe);return Ce(t),d(),(0,I.jsx)(Q.Provider,{value:t,children:e})}function Te(e){let t=(0,j.useContext)(Q),n=t?t.get:De;return(0,j.useSyncExternalStore)(t?t.subscribe:Ee,()=>e?n()[e]:void 0,()=>void 0)}var Ee=()=>()=>void 0,De=()=>F,Oe=`Label`,$=j.forwardRef((e,t)=>(0,I.jsx)(ae.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));$.displayName=Oe;var ke=$;function Ae({className:e,...t}){return(0,I.jsx)(ke,{"data-slot":`label`,className:i(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}export{Te as i,we as n,he as r,Ae as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r}from"./dist-C_rn70hE.js";import{d as i,f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{T as s,_ as c,an as l,cn as u,in as d,ln as f,nn as p,on as m,rn as h,sn as g,w as _}from"./index-DJB0lid-.js";import{i as v,n as y,s as b}from"./chunk-BO2N2NFS-DQrpGzb-.js";import{i as x,o as S,r as C,t as w}from"./highlighter-Cfo7mLVB.js";var T=e(t(),1),E=n();function D({isOpen:e,onClose:t,onConfirm:n,url:r}){return(0,E.jsx)(p,{open:e,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(l,{"data-slot":`link-safety-dialog`,children:[(0,E.jsxs)(u,{children:[(0,E.jsx)(f,{children:`Open this link?`}),(0,E.jsxs)(m,{children:[`It leaves Squawk in a new tab. The words of a link in a transcript are the agent's — the address below is where it actually goes.`,(0,E.jsx)(`span`,{"data-slot":`link-safety-url`,className:`mt-3 block wrap-anywhere rounded-md border border-border bg-muted px-3 py-2 font-mono text-xs text-foreground`,children:r})]})]}),(0,E.jsxs)(g,{children:[(0,E.jsx)(d,{children:`Cancel`}),(0,E.jsx)(h,{onClick:n,children:`Open link`})]})]})})}var O=`text-accent-text underline underline-offset-2`;function k({href:e,children:t,internal:n,...r}){let[a,o]=(0,T.useState)(!1),s=i();return e?n?s?(0,E.jsx)(A,{...r,href:e,children:t}):(0,E.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:O,children:t}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`a`,{...r,href:e,"data-streamdown":`link`,className:`cursor-pointer ${O}`,onClick:e=>{e.preventDefault(),o(!0)},children:t}),(0,E.jsx)(D,{isOpen:a,url:e,onClose:()=>o(!1),onConfirm:()=>{window.open(e,`_blank`,`noreferrer`),o(!1)}})]}):(0,E.jsx)(`span`,{children:t})}function A({href:e,children:t,...n}){let r=o(),i=a(),s=c();return(0,E.jsx)(`a`,{...n,href:e,"data-streamdown":`link`,className:O,onClick:t=>{j(t,s,e)||N(t,r,e,i)},children:t})}function j(e,t,n){if(!t?.showing||!M(e))return!1;let r=new URL(n,window.location.origin),i=/\/files\/?$/.test(r.pathname)?r.searchParams.get(`path`):null;return!i||!t.revealChange(i)?!1:(e.preventDefault(),!0)}var M=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function N(e,t,n,r){M(e)&&(e.preventDefault(),t(n,{state:{readerFrom:r.pathname+r.search,filesRestoreKey:r.key}}))}var P={code:{name:`shiki`,type:`code-highlighter`,getThemes:()=>[w,w],getSupportedLanguages:()=>S(),supportsLanguage:e=>S().includes(String(e).toLowerCase()),highlight:({code:e,language:t},n)=>x(e,String(t))||(C(e,String(t)).then(e=>n?.(e)),null)}},F=[w,w],I={code:{copy:!0,download:!1},table:!1,mermaid:!1},L=[...Object.values(b),q];function R(){let e=t=>{if(!t.children)return;let n=[];for(let r of t.children)if(r.type===`text`&&r.value?.includes(`
|
|
2
|
-
`)){let e=r.value.split(/\r?\n/);e.forEach((t,r)=>{r>0&&!(t===``&&r===e.length-1)&&n.push({type:`break`}),t&&n.push({type:`text`,value:t})})}else e(r),n.push(r);t.children=n};return e}var z=[...Object.values(y),R],B=[`p`,`strong`,`em`,`del`,`code`,`a`],V={p:`span`,a:`span`},H={enabled:!0,renderModal:e=>(0,E.jsx)(D,{...e})},U=`https://refused.invalid/`,W=new WeakSet;function G(e){let t=e.position?.start.offset,n=e.position?.end.offset;return t===void 0||n===void 0?null:`${t}:${n}`}function K(e){return(t,n)=>{let r=new Set,i=new Map,a=t=>{if((t.type===`link`||t.type===`definition`)&&t.url){let n=s(t.url,e);if(t.type===`definition`&&t.identifier&&!i.has(t.identifier)&&i.set(t.identifier,n!==null),n){t.url=n;let e=G(t);t.type===`link`&&e!==null&&r.add(e)}}t.children?.forEach(a)};a(t);let o=e=>{let t=G(e);e.type===`linkReference`&&e.identifier&&i.get(e.identifier)&&t!==null&&r.add(t),e.children?.forEach(o)};o(t),n.data.taskLinks=r}}function q(){return(e,t)=>{let n=e=>{let r=G(e);e.tagName===`a`&&r!==null&&t.data.taskLinks instanceof Set&&t.data.taskLinks.has(r)&&W.add(e),e.children?.forEach(n)};n(e)}}var J=0,Y=(0,T.memo)(function({children:e,breaks:t=!1,inline:n=!1,document:i=!1,imageSrc:a}){let o=(0,T.useContext)(_),s=(0,T.useMemo)(()=>{let e={instance:++J},n=new Set;function r(){let e=t=>{if(t.type===`image`&&t.url&&a){let e=a(t.url);t.url=e?new URL(e,window.location.href).href:U,e&&n.add(t.url)}t.children?.forEach(e)};return e}let s=o?[[K,o]]:[],c=i&&a?[[r,e]]:[];return{key:e.instance,remark:[...t?z:Object.values(y),...s,...c],components:{...o||i?{a:({href:e,children:t,node:n})=>i&&!o&&!/^(?:https?:|mailto:|#)/i.test(e??``)?(0,E.jsx)(`span`,{children:t}):(0,E.jsx)(k,{href:e,internal:n!==void 0&&W.has(n),children:t})}:{},...i?{img:({src:e,alt:t})=>typeof e==`string`&&n.has(e)?(0,E.jsx)(`img`,{src:e,alt:t??``,loading:`lazy`}):(0,E.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[Image: `,t||`embedded image`,`]`]})}:{}}}},[o,t,i,a]);return(0,E.jsx)(v,{className:n?`thread-markdown thread-markdown-inline`:`thread-markdown`,plugins:P,shikiTheme:F,...r({rehypePlugins:o?L:void 0,remarkPlugins:o||i&&a?s.remark:t?z:void 0,allowedElements:n?B:void 0,unwrapDisallowed:n||void 0,components:n?V:o||i?s.components:void 0}),linkSafety:H,controls:I,lineNumbers:!1,children:e},s.key)});export{N as n,Y as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{$r as i,Qr as a,_r as o,ei as s,n as c}from"./toaster-zMN8cNZQ.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{t as u}from"./arrow-right-Dh_Lx3um.js";import{t as d}from"./check-OP-CVgZG.js";import{t as f}from"./chevron-down-CHGyCDBH.js";import{n as p,t as m}from"./circle-x-7nTlobAF.js";import{n as h,t as g}from"./smartphone-Lr8Ug2z_.js";import{t as _}from"./info-DA1x_4bz.js";import{t as v}from"./loader-circle-CPBhhDbB.js";import{n as y,t as ee}from"./moon-CRE9nU5R.js";import{t as b}from"./play-CmVAj_fu.js";import{o as x}from"./tool-display-B9NN44oU.js";import{n as te,o as S,s as C}from"./thread-state-qNczqxZQ.js";import{t as ne}from"./square-terminal-B6RYYieR.js";import{t as w}from"./button-B22ANdCY.js";import{a as T,c as re,i as E,l as D,p as O,r as k,s as ie,t as A}from"./dropdown-menu-DjtKUK8F.js";import{s as ae}from"./project-router-j0uBi7Ep.js";import{t as j}from"./status-dot-Drd4-nfa.js";import{$n as oe,Cr as M,Qn as se,Sr as ce,Tr as le,b as ue,c as de,er as fe,f as pe,gr as me,h as he,l as ge,m as N,p as _e,pr as ve,tr as ye,x as be,y as xe}from"./index-DJB0lid-.js";var Se=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),P=l(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Ce=l(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),F=l(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),I=l(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),L=l(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),we=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),R=l(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),z=l(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Te=l(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Ee=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),B=l(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),V=l(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),H=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),U=l(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),W=l(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),G=l(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),K=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),q=l(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),De=l(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(t(),1),Oe=1e3,ke=[500,1e3,2e3,4e3,8e3],Ae=1;function je(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,s=null,c,l=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||a(),m=()=>{if(l||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,s=n,n.addEventListener(`open`,()=>{n===s&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==s)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=o.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==s||l)return;if(s=null,!u){if(d+=1,d>=2){l=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),c=setTimeout(m,Oe);return}if(f>=5){l=!0,t.onTransport(`closed`);return}let e=ke[Math.min(f,ke.length-1)];f+=1,t.onTransport(`reconnecting`,f),c=setTimeout(m,e)})},h=i(e=>{if(!l)if(e)s||m();else{clearTimeout(c),c=void 0;let e=s;s=null,e?.close(),t.onTransport(`connecting`)}});return t.onTransport(`connecting`),m(),{send(e){s?.readyState===Ae&&s.send(JSON.stringify(e))},close(){l=!0,h(),clearTimeout(c),c=void 0;let e=s;s=null,e?.close()}}}var Y=n();function Me({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(fe,{children:(0,Y.jsxs)(se,{children:[(0,Y.jsx)(ye,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[860px]:gap-1.5 @min-[860px]:px-2.5`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[860px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(oe,{children:`Experimental`})]})}):e?(0,Y.jsx)(fe,{children:(0,Y.jsxs)(se,{children:[(0,Y.jsx)(ye,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(oe,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(I,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function X({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
|
|
2
|
-
`);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(M,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Ne=/^([a-z][a-z0-9+.-]*):/i;function Pe(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Ne.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Fe(n):Fe(`http://${n}`)}function Fe(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Ie(e){return e.replace(/^https?:\/\//i,``)}var Le=`https://github.com/hearsay-tools/squawk#environment-variables`;function Re({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(He,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(We,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(Ge,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(qe,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Xe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)(Ze,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(tt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(rt,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(it,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(at,{actions:t});case`taken-over`:return(0,Y.jsx)(st,{state:e,actions:t})}}function Z({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Q=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),$=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function ze({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(ne,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${N(e.command)} in this task's worktree, on the host.`})]})}function Be({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ve({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(ze,{server:e})})]})}function He({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Q,{children:e.canDownload?`Preview runs Chromium on the machine Squawk runs on. Squawk can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine Squawk runs on. Squawk has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ue(e){return Math.round(e/1e6)}function We({state:e,actions:t}){let n=(0,J.useRef)(null);n.current??={at:Date.now(),received:e.received};let r=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,i=(Date.now()-n.current.at)/1e3,a=i>=1?(e.received-n.current.received)/i:0,o=a>0?Math.ceil((e.total-e.received)/a):void 0;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(F,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Q,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ue(e.received)} of ${Ue(e.total)} MB · ${r}%`}),o===void 0?null:(0,Y.jsx)(`span`,{children:`about ${o} s left`})]})]}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function Ge({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Q,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(Be,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Ke({state:e,actions:t}){return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(W,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsx)(Q,{children:`The host blocks the sandbox Chromium needs. This usually means Squawk runs as root, or inside a container without user namespaces.`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function qe({state:e,actions:t}){let n=e.reason===`timeout`,r=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,i=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,a=n?`Chromium did not start in time`:`Chromium exited${r}`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:n?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Q,{children:n?`Chromium did not open its DevTools port in time. ${i}`:`Chromium exited unexpectedly${r}. ${i}`}),(0,Y.jsx)(X,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(w,{variant:`outline`,onClick:()=>t.copy(`${a}\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Je=2;function Ye(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Xe({state:e,actions:t}){let{server:n,wasRunning:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:r?(0,Y.jsx)(q,{className:`text-pending-strong`}):(0,Y.jsx)(b,{}),title:r?`Nothing answers on :${n.port} anymore`:`${n.label} isn't running yet`,children:[(0,Y.jsx)(Q,{children:r?`${n.label} was running when the agent registered it, likely inside the agent's own session, which has ended. Squawk can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ve,{server:n,status:r?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(b,{"aria-hidden":`true`}),`Run and open`]})})]})}function Ze({state:e,actions:t}){let{server:n,ownerTitle:r}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(K,{className:`text-pending-strong`}),title:`${n.label} :${n.port} is in use by another task`,children:[(0,Y.jsx)(Q,{children:`Task "${r}" is running its own server on :${n.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function Qe({state:e,actions:t}){let{server:n}=e,r=Ye(1e3),i=Math.max(0,Math.floor((r-Date.parse(e.startedAt))/1e3)),[a,o]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>o(Date.now()),[e.attempt]);let s=Math.max(0,Math.ceil(Je-(r-a)/1e3));return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(b,{}),title:`Starting ${n.label}`,children:[(0,Y.jsx)(Q,{children:`Squawk ran ${N(n.command)} in the worktree. The page opens as soon as :${n.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(v,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),s>0?`Attempt ${e.attempt} · next try in ${s} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${i} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(X,{text:e.logTail.join(`
|
|
3
|
-
`),source:N(n.command),onCopy:t.copy}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})})]})}function $e({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(R,{className:`text-pending-strong`}),title:`${n.label} is running, but :${n.port} is silent`,children:[(0,Y.jsx)(Q,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(X,{text:e.logTail,source:N(n.command),onCopy:t.copy}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`contrast`,onClick:()=>t.keepWaiting(n.port),children:`Keep waiting`}),(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t.stop(n.port),children:`Stop server`})]})]})}function et({state:e,actions:t}){let{server:n}=e;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(m,{className:`text-danger`}),title:e.exitCode===null?`${n.label} was stopped by a signal`:`${n.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Q,{children:`${N(n.command)} stopped.`}),(0,Y.jsx)(X,{text:e.logTail,source:N(n.command),onCopy:t.copy}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}function tt({state:e,actions:t}){let{server:n}=e,r=e.reason===`idle`;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(ee,{}),title:r?`Stopped after 15 min idle`:`${n.label} stopped`,children:[(0,Y.jsx)(Q,{children:r?`Nobody had this pane open for 15 min, so Squawk stopped ${n.label} :${n.port} and the browser to free memory. Start again reopens ${Ie(e.lastUrl)}.`:`You stopped ${n.label} :${n.port}. Start again reopens ${Ie(e.lastUrl)}.`}),(0,Y.jsx)($,{children:(0,Y.jsxs)(w,{variant:`contrast`,onClick:()=>t.run(n.port),children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(ze,{server:n})]})}var nt=[`browser`,`page`,`frame`];function rt({step:e,url:t}){let n=nt.indexOf(e),i=t?Ie(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(p,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(v,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(Ce,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function it({state:e,actions:t,worktree:n}){let r=n?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(n)?.[0]:void 0,i=e.server?.label;return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(L,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Q,{children:`${i??`The server`} ran in ${r??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(S,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)($,{children:(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function at({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Me,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(V,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsx)(Q,{children:`The proxy in front of Squawk didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in Squawk keeps working.`}),(0,Y.jsxs)($,{children:[(0,Y.jsx)(w,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:Le,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ot(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function st({state:e,actions:t}){let n=ot(e.by);return(0,Y.jsxs)(Z,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Q,{children:`Another tab took this browser${n?` (${n})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)($,{children:[(0,Y.jsxs)(w,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(w,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ct({attempt:e,exhausted:t,onReconnect:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(De,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(w,{variant:`outline`,onClick:n,children:t?`Reconnect`:`Reconnect now`})]})}function lt({servers:e,states:t,onOpen:n,agentLive:r=!1,agentIdle:i=!1,onOpenAgent:a}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":i?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Q,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),i?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(q,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,r&&a!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,"aria-label":`Open the agent's page`,onClick:a,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let r=pe(e,t),i=he(r);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:i.tone,shape:i.ring?`ring`:`filled`,pulse:i.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:i.text})]}),(0,Y.jsx)(w,{variant:`outline`,size:`sm`,onClick:()=>n(e.port),children:_e(r)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(_,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ut({dialog:e,onResult:t}){let[n,r]=(0,J.useState)(e.defaultPrompt??``),i=e.type===`beforeunload`,a=(0,J.useRef)(null),o=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?o.current:a.current)?.focus()},[e.type]);let s=(0,J.useRef)(t);s.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),s.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let c=()=>t(e.type===`prompt`?{accept:!0,text:n}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-card-edge bg-card p-4 shadow-modal`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(i?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(w,{variant:`outline`,onClick:()=>t({accept:!1}),children:i?`Stay`:`Cancel`}),(0,Y.jsx)(w,{ref:a,variant:`contrast`,onClick:c,children:i?`Leave`:`OK`})]})]})})}var dt=10,ft=500,pt=500,mt=4,ht=16,gt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function _t(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function vt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var yt=[`left`,`middle`,`right`];function bt(e,t,n,r){let i=_t(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:yt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:gt(n),...r}}var xt=e=>e===0?0:-e;function St(e,t,n,r,i){let a=_t(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:xt(r/e.scale),deltaY:xt(i/e.scale),modifiers:0}}function Ct(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=dt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[St(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=ft;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[bt(`mouseMoved`,t,a,{button:`none`,buttons:0}),bt(`mousePressed`,t,a,{button:`left`,buttons:1}),bt(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function wt(e,t){if(e.pointerType===`touch`)return Ct(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=pt&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=mt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[bt(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[bt(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[bt(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Tt(e,t,n){let r=_t(e.clientX,e.clientY,t,n),i=e.deltaMode===1?ht:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:gt(e)}}var Et={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Dt(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:gt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Et[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:gt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function Ot(e){return e?{t:`insertText`,text:e}:void 0}var kt=e=>e,At=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function jt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(vt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of wt(kt(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Tt(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=Ot(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(At(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Dt(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Mt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Nt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:o,renderInput:s,children:c}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(o);m.current=o,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!a()))try{let i=await Mt(e);try{if(t!==l.current||!a()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),s?.({canvas:d.current,scale:g,viewport:h})]}):null,c]})}var Pt=`cez-preview-quality`,Ft=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function It(e){return Ft.find(t=>t.value===e)?.value??`normal`}var Lt=e=>Ft.find(t=>t.value===e)?.label??`Normal`;function Rt(){try{return It(localStorage.getItem(Pt))}catch{return`normal`}}function zt(e){try{localStorage.setItem(Pt,e)}catch{}}var Bt=[{w:390,h:844,icon:g},{w:820,h:1180,icon:G},{w:1440,h:900,icon:y}],Vt=`shrink-0`,Ht=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Ut(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Wt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Gt({stats:e,shrunk:t}){let n=Ut(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Wt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[960px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Wt(e)})]})}function Kt({current:e,agentShown:t,...n}){let r=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`max-w-[9rem] min-w-0 gap-1.5 @min-[760px]:max-w-[11rem]`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${r}`:`Server`,...n,children:[e||t?(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(C,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:r}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function qt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]})}function Jt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Yt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Xt(e){let{compact:t=!1,navEnabled:n,loading:r=!1}=e,i=(0,J.useRef)(null),a=e.urlInputRef??i,o=(0,J.useRef)(!1),[s,c]=(0,J.useState)(null),[l,d]=(0,J.useState)(!1),f=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Back`,disabled:!n,onClick:e.onBack,children:(0,Y.jsx)(Se,{"aria-hidden":`true`})}),p=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Forward`,disabled:!n,onClick:e.onForward,children:(0,Y.jsx)(u,{"aria-hidden":`true`})}),m=(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Reload`,"aria-busy":r||void 0,disabled:!n||r,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(U,{"aria-hidden":`true`})}),h=e.onSession?(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1`,onClick:e.onSession,children:[(0,Y.jsx)(le,{"aria-hidden":`true`}),`Session`]}):null,g=r?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,_=(0,Y.jsx)(Qt,{props:e,input:a,draft:s,setDraft:c,focused:l,setFocused:d}),{agentListed:v}=Yt(e),y=e.servers.length+ +!!v>=2,ee=y||e.adopted,b={back:f,forward:p,reload:m,address:_,more:(0,Y.jsx)(rn,{props:e,compact:t}),session:h,progress:g};return t?(0,Y.jsx)(an,{props:e,elements:b}):(0,Y.jsx)(on,{props:e,elements:b,switcher:y,crowded:ee,input:a,focusUrlAfterMenu:o})}function Zt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Yt(e);return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(Kt,{current:i,agentShown:o})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(qt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=he(pe(t,e.serverStates));return(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(h,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function Qt({props:e,input:t,draft:n,setDraft:i,focused:a,setFocused:o}){let{url:s,adopted:c}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-20 flex-1 items-center`,children:[(0,Y.jsx)(h,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:t,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:n??(a?s:Ie(s)),title:s||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,c?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;o(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{o(!1),i(null)},onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(n??s),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),c&&!a?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(z,{className:`size-3`,"aria-hidden":`true`}),`Not started by Squawk`]}):null]})}function $t({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ht(t)}`,children:[t===`fit`?(0,Y.jsx)(Ee,{"aria-hidden":`true`}):(0,Y.jsx)(y,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[620px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ht(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(E,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(Ee,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(d,{className:`size-4`,"aria-hidden":`true`}):null]}),Bt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(E,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(d,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function en({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(ie,{value:e,onValueChange:e=>t(It(e)),children:Ft.map(e=>(0,Y.jsx)(re,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function tn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsxs)(w,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Lt(t)}`,children:[(0,Y.jsx)(we,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[680px]:inline`,children:Lt(t)}),(0,Y.jsx)(f,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(k,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function nn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Gt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,role:`img`,"aria-label":t.label,title:t.label,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:t.tone,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[760px]:inline`,children:t.label})]}):null}function rn({props:e,compact:t}){let{stats:n,navEnabled:r,url:i,current:a,adopted:o}=e;return(0,Y.jsxs)(A,{children:[(0,Y.jsx)(O,{asChild:!0,children:(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`More`,children:(0,Y.jsx)(ce,{"aria-hidden":`true`})})}),(0,Y.jsxs)(k,{align:`end`,className:`min-w-64`,children:[n&&!t?(0,Y.jsx)(T,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Wt(n)}):null,(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!r,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:i===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(me,{"aria-hidden":`true`}),`Copy page URL`]}),a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),o?(0,Y.jsxs)(E,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(Te,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${a.label} :${a.port}`}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:`Squawk didn't start this server, so it won't stop it. Stop it where it was started.`})]})]}):(0,Y.jsxs)(E,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(a.port),children:[(0,Y.jsx)(P,{"aria-hidden":`true`}),`Stop server · ${a.label} :${a.port}`]})]}):null,t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{}),(0,Y.jsx)(T,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(en,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(E,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(ve,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function an({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Yt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Jt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function on({props:e,elements:t,switcher:n,crowded:r,input:i,focusUrlAfterMenu:a}){let{badge:o=!0,stats:s,status:c}=e,{back:l,forward:u,reload:d,address:f,more:p,session:m,progress:h}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1 border-b border-border bg-background px-2 py-2 @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,children:[m,l,u,d,n?(0,Y.jsx)(Zt,{props:e,input:i,focusUrlAfterMenu:a}):null,f,(0,Y.jsx)($t,{props:e}),(0,Y.jsx)(tn,{props:e}),(0,Y.jsx)(nn,{stats:s,status:c,crowded:r}),o?(0,Y.jsx)(Me,{iconOnly:r,responsive:!r}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),p,(0,Y.jsx)(w,{variant:`ghost`,size:`icon-sm`,className:Vt,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(ve,{"aria-hidden":`true`})}),h]})}function sn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function cn(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(Re,{...n,actions:o})}case`empty`:return(0,Y.jsx)(lt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function ln(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function un(){let[e,t]=(0,J.useState)(ln);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(ln());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var dn=2e3,fn=500,pn=1e3;function mn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function hn(e){navigator.clipboard?.writeText(e).then(()=>c(`Copied`),()=>c(`Couldn't copy to the clipboard`,{tone:`danger`}))}var gn=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function _n(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function vn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function yn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:o}){let l=un(),u=(0,J.useRef)(l);u.current=l;let d=s(),f=(0,J.useRef)(crypto.randomUUID()),p=(0,J.useRef)(!1),m=ae(),h=ue(xe,!1),[g,_]=(0,J.useState)(0),[v,y]=(0,J.useState)({state:`connecting`,attempt:0}),[ee,b]=(0,J.useState)(!1),[x,te]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[ne,w]=(0,J.useState)(``),[T,re]=(0,J.useState)(void 0),[E,D]=(0,J.useState)(!1),[O,k]=(0,J.useState)(void 0),[ie,A]=(0,J.useState)(!1),[j,oe]=(0,J.useState)(!1),[M,se]=(0,J.useState)(void 0),[ce,le]=(0,J.useState)(void 0),[de,fe]=(0,J.useState)(void 0),[pe,me]=(0,J.useState)(`fit`),[he,ge]=(0,J.useState)(Rt),[N,_e]=(0,J.useState)(null),[ve,ye]=(0,J.useState)(void 0),[be,Se]=(0,J.useState)(0),P=(0,J.useRef)(void 0),Ce=(0,J.useRef)(null),F=(0,J.useRef)(null),I=(0,J.useRef)(void 0),L=(0,J.useRef)(void 0),we=(0,J.useRef)(he);we.current=he;let R=(0,J.useRef)({port:T,stage:S,agent:E});R.current={port:T,stage:S,agent:E};let z=(0,J.useRef)([]),Te=(0,J.useRef)(void 0),Ee=(0,J.useRef)(!1),B=(0,J.useRef)(!1),V=(0,J.useCallback)(e=>{B.current&&P.current?.send(e)},[]),H=(0,J.useRef)([]),U=(0,J.useCallback)(e=>{B.current?P.current?.send(e):H.current.push(e)},[]);(0,J.useEffect)(()=>{let t;return t=je({projectId:m??`default`,runId:e.id},{onFrame(e){if(!a())return;let n=Date.now();z.current.push({at:n,bytes:e.size}),Ee.current||(Ee.current=!0,oe(!0)),(Ce.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&Se(e=>e+1),L.current!==void 0&&mn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return w(e.url);case`cursor`:return se(e.cursor);case`dialog`:return le(e);case`pong`:Te.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:te(e.by),B.current=!1,H.current=[],t?.close();return}},onTransport(e,n){if(B.current=e===`open`,y({state:e,attempt:n??0}),(e===`blocked`||e===`closed`)&&(H.current=[]),e===`open`){b(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:f.current,resume:p.current,quality:we.current,dpr:u.current}),p.current=!0);for(let e of H.current.splice(0))t?.send(e)}}}),P.current=t,()=>{B.current=!1,H.current=[],t?.close(),P.current===t&&(P.current=void 0)}},[m,e.id,g]);let W=d&&v.state===`open`&&x===void 0,G=h||pe===`fit`?N:pe;(0,J.useEffect)(()=>{G&&W&&(S?.stage===`streaming`||S?.stage===`loading`)&&V({t:`resize`,w:G.w,h:G.h,...l===1?{}:{dpr:l}})},[G?.w,G?.h,l,W,S?.stage,be,V]),(0,J.useEffect)(()=>{if(!W)return;let e=setInterval(()=>V({t:`ping`,ts:Date.now()}),dn);return()=>clearInterval(e)},[W,V]);let K=W&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!K){fe(void 0);return}let e=setInterval(()=>{let e=Date.now();z.current=z.current.filter(t=>e-t.at<=pn);let t={fps:z.current.length,kbps:Math.round(z.current.reduce((e,t)=>e+t.bytes,0)/1024),...Te.current===void 0?{}:{rttMs:Te.current},...z.current.length>0?{lastFrameAt:z.current.at(-1).at}:{}};fe(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},fn);return()=>clearInterval(e)},[K]),(0,J.useEffect)(()=>(i?.(K),()=>i?.(!1)),[K,i]),(0,J.useEffect)(()=>{O&&r?.(O)},[O,r]);let q=(0,J.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,A(!0),C(void 0),te(void 0),ye(void 0),w(t),re(`port`in e?e.port:void 0),D(`agent`in e),k(vn(e)),V({t:`open`,target:e,viewerId:f.current,quality:we.current,dpr:u.current}),p.current=B.current},[V]),De=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);q({port:e},r?gn(r):`http://localhost:${e}`,n)},[t,q]),Oe=(0,J.useCallback)(()=>q({agent:!0},``),[q]);(0,J.useEffect)(()=>{if(n?.agent){if(R.current.agent&&R.current.stage?.stage===`streaming`)return;Oe();return}if(n?.url!==void 0){let e=Pe(n.url,t);e.kind===`server`?De(e.port):e.kind===`url`&&q({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||R.current.port===n.port&&R.current.stage?.stage===`streaming`&&n.run!==!0||De(n.port,n.run===!0))},[n]);let ke=!ie&&!x&&v.state!==`blocked`,Ae=_n(n,t);(0,J.useEffect)(()=>{ke&&!Ae&&F.current?.focus()},[ke,Ae]);let Y=e=>{let n=Pe(e,t);if(n.kind===`error`)return ye(n.message);if(n.kind===`server`)return De(n.port);if(R.current.stage?.stage===`streaming`&&!R.current.agent)return I.current={url:n.url},L.current=void 0,re(void 0),k({url:n.url}),ye(void 0),w(n.url),V({t:`nav`,url:n.url});q({url:n.url},n.url)},Me=(0,J.useCallback)(e=>{we.current=e,ge(e),zt(e),V({t:`quality`,quality:e})},[V]),X=()=>{p.current=!1,te(void 0),y({state:`connecting`,attempt:0}),Ee.current=!1,_(e=>e+1)};return{compact:h,transport:v,everOpened:ee,takenOver:x,stage:S,url:ne,port:T,agent:E,hasFrame:j,cursor:M,dialog:ce,setDialog:le,stats:de,viewport:pe,setViewport:me,quality:he,chooseQuality:Me,setStageSize:_e,addressError:ve,stageHandle:Ce,urlInput:F,send:V,connected:W,streaming:K,openServer:De,openAgent:Oe,empty:ke,navigate:Y,reconnect:X,actions:(0,J.useMemo)(()=>({download:()=>U({t:`download`}),cancelDownload:()=>U({t:`cancelDownload`}),retryBrowser:()=>U({t:`retryBrowser`}),run:e=>{B.current?V({t:`run`,port:e}):c(`The preview is reconnecting. Run the server again once it is back.`,{tone:`danger`})},stop:e=>U({t:`stop`,port:e}),keepWaiting:e=>U({t:`keepWaiting`,port:e}),close:o,useHere:X,copy:hn}),[V,U,o])}}function bn(e){return(0,Y.jsx)(be,{onClose:e.onClose,children:(0,Y.jsx)(Cn,{...e})})}function xn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Sn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Sn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function Cn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=yn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:b,addressError:x,urlInput:te,send:S,streaming:C,openServer:ne,openAgent:w,empty:T,navigate:re,actions:E}=s,D=n.find(e=>e.port===m),O=f?.stage===`streaming`&&f.adopted,k=u&&(l.state===`reconnecting`||l.state===`closed`),{content:ie,dim:A}=sn({transport:l.state,takenOver:d,empty:T,stage:f,hasFrame:g,lost:k,url:p,worktree:t.worktreePath}),ae=cn(ie,{servers:n,serverStates:r,agentLive:i,openServer:ne,openAgent:w,actions:E});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Xt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:D,agentLive:i===!0,agentShown:h,adopted:O,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:C,loading:f?.stage===`loading`,stats:C?_??{fps:0,kbps:0}:void 0,status:C?void 0:xn(l,u,d!==void 0,f),urlInputRef:te,onSession:a,onNavigate:re,onBack:()=>S({t:`back`}),onForward:()=>S({t:`forward`}),onReload:e=>S({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>ne(e),onPickAgent:w,onViewport:y,onQuality:b,onCopyUrl:()=>hn(p),onStop:E.stop,onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(wn,{transportState:s,overlay:ae,dim:A,lost:k})]})}function wn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Nt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(jt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ct,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(ut,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function Tn(e){let{visibleEvents:t}=ge(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of te(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function En(e){let t=Tn(e.run.id),n=de(e.run.id);return(0,Y.jsx)(bn,{...e,serverStates:t,agentLive:n})}export{En as ConnectedPreviewPane};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{a as r}from"./toaster-zMN8cNZQ.js";import{f as i,i as a,l as o,n as s,p as c,r as l}from"./chunk-KS7C4IRE-Cg8l-LDN.js";var u=e(t(),1),d=n(),f=/^\/p\/([^/]+)(?=\/|$)/;function p(e){let t=f.exec(e)?.[1];return t===void 0?null:decodeURIComponent(t)}function m(e){let t=f.exec(e);if(!t)return e;let n=e.slice(t[0].length);return n===``?`/`:n}function h(e,t){return!t.startsWith(`/`)||t===`/p`||t.startsWith(`/p/`)?t:`/p/${encodeURIComponent(e)}${t}`}function g(e,t){return e===null?t:typeof t==`string`?h(e,t):t.pathname===void 0?t:{...t,pathname:h(e,t.pathname)}}function _(){let{projectId:e}=r(),{pathname:t}=i();return e??p(t)}function v(){let e=_();return(0,u.useCallback)(t=>g(e,t),[e])}function y(e){let{pathname:t}=i();return(0,u.useMemo)(()=>o(e,m(t)),[e,t])}function b({to:e,...t}){let n=v();return(0,d.jsx)(s,{...t,to:n(e)})}function x({to:e,...t}){let n=v();return(0,d.jsx)(l,{...t,to:n(e)})}function S({to:e,...t}){let n=v();return(0,d.jsx)(a,{...t,to:n(e)})}function C(){let e=c(),t=v();return(0,u.useMemo)(()=>((n,r)=>typeof n==`number`?e(n):e(t(n),r)),[e,t])}export{g as a,C as c,p as i,y as l,x as n,m as o,S as r,_ as s,b as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{o as i}from"./dist-C_rn70hE.js";import{Dt as a,Ft as o,Nt as s,Rt as c,Wt as l,un as u,xt as d,zt as f}from"./queries-CchoEEzj.js";import{n as p,un as m,vi as h}from"./toaster-zMN8cNZQ.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{k as _,mt as ee}from"./design-icons-QbNMZniQ.js";import{t as v}from"./button-B22ANdCY.js";import{n as y,r as b,t as x}from"./popover-CvL6hQ5c.js";import{t as S}from"./centered-state-BgSV4e79.js";import{Vn as C,an as w,cn as T,dr as E,in as D,ln as O,nn as k,on as A,rn as j,sn as M}from"./index-DJB0lid-.js";import{t as te}from"./option-select-BwSkbCrQ.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-Bhh8I9fJ.js";import{t as L}from"./use-path-bases-C9yvZF5B.js";import{r as R}from"./settings-save-bar-DFY_Km4X.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-D3ibaYUj.js";var V=t(n(),1),H=r();function U(){let e=a();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{p(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>p(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:o().data?.homeDir??null,root:null};return(0,H.jsx)(k,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(w,{children:[(0,H.jsxs)(T,{children:[(0,H.jsxs)(O,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(A,{children:[`This only unregisters the project — `,(0,H.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,e?(0,H.jsx)(C,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(M,{children:[(0,H.jsx)(D,{children:`Keep it`}),(0,H.jsx)(j,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=o(),t=d();return e.isPending||t.isPending?(0,H.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,H.jsx)(S,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(v,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(E,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,footer:o,refreshProjects:s=!1}){let c=h(),d=u({mutationFn:t=>m(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{c.setQueryData(l.config,t),e===`browseRoot`?c.invalidateQueries({queryKey:l.fsBrowseRoot}):s&&c.invalidateQueries({queryKey:l.projects})}}),[f,p]=z(t),g=f.trim();R({dirty:g!==t,invalid:g===``,save:()=>d.mutateAsync(g),discard:()=>{p(t),d.reset()}});let _=d.isError?d.error.message:null;return(0,H.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${a}-root`,value:f,disabled:d.isPending,placeholder:i,onChange:e=>{p(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:o}):(0,H.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=U(),s=(0,V.useMemo)(()=>c(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:s,disabled:o.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),o.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(C,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(C,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(v,{asChild:!0,variant:`outline`,children:(0,H.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function Q({project:e,vocabulary:t,onSaved:n}){let r=s(),[a,o]=(0,V.useState)(``),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(-1),m=(0,V.useRef)(null),h=e.tags??[],g=f(t,h,a),_=c&&g.length>0,v=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},S=t=>{let n=t.trim().slice(0,32);if(d(-1),n){if(h.some(e=>e.toLowerCase()===n.toLowerCase())){o(``);return}if(h.length>=20){p(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}o(``),v([...h,n])}},C=e=>{v(h.filter(t=>t!==e))},w=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[h.map(t=>(0,H.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(ee,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(x,{open:_,onOpenChange:l,children:[(0,H.jsx)(y,{asChild:!0,children:(0,H.jsx)(`input`,{ref:m,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&u>=0?`${w}-${u}`:void 0,placeholder:h.length===0?`Add tag…`:`+`,value:a,maxLength:32,disabled:r.isPending,onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:e=>{if(l(!0),d(-1),e.target.value.includes(`,`)){o(e.target.value.replace(/,/g,``));return}o(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(g.length===0)return;e.preventDefault(),l(!0);let t=e.key===`ArrowDown`?1:-1,n=u+t;d(n>=g.length?-1:n<-1?g.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),l(!1),d(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),S(u>=0?g[u]??a:a);return}if(e.key===`Tab`){l(!1);return}if(e.key===`Backspace`&&a===``&&h.length>0){e.preventDefault();let t=h[h.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,H.jsxs)(b,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,H.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),g.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===u,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{S(e),m.current?.focus()},onMouseEnter:()=>d(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===u&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=s(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(te,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{d as n,p as r}from"./dist-C_rn70hE.js";import{$ as i,$t as a,A as o,Ai as s,Bn as c,C as l,Ct as u,D as d,Di as f,Dt as p,E as m,Et as h,F as g,Fi as _,G as v,Hn as ee,Ht as te,It as ne,J as re,Jt as ie,K as ae,Kt as oe,L as se,Mi as ce,Mt as le,N as ue,Nt as de,O as fe,Ot as pe,Pi as me,Pt as he,Q as ge,Qt as _e,Ri as ve,Rn as ye,S as be,Si as xe,Sn as Se,St as Ce,Ti as we,Tr as Te,Un as Ee,Ur as De,Vn as Oe,Vr as ke,Vt as Ae,Wn as je,Wr as Me,Wt as Ne,X as Pe,Xr as Fe,Xt as Ie,Y as Le,Yr as Re,Yt as ze,Zt as Be,_n as Ve,_t as He,a as Ue,an as We,b as Ge,bn as Ke,br as qe,bt as Je,ci as Ye,cn as Xe,ct as Ze,di as Qe,en as $e,et,fi as tt,fn as nt,gn as rt,gt as it,h as at,hi as ot,hn as st,ii as ct,in as lt,k as ut,kt as dt,li as ft,ln as pt,m as mt,mi as ht,mn as gt,n as _t,nn as vt,oi as yt,on as bt,pi as xt,pn as St,pt as Ct,q as wt,qt as Tt,si as y,sn as Et,tn as Dt,ui as Ot,v as kt,vi as b,vt as At,wt as jt,x as Mt,xi as Nt,xn as Pt,xt as Ft,y as It,yi as Lt,yn as Rt,yt as zt,zn as Bt}from"./toaster-zMN8cNZQ.js";import{A as Vt,B as x,F as S,H as C,I as w,N as T,P as E,W as D,Z as O,a as Ht,j as k,z as A}from"./live-protocol-DMhTnCmf.js";function Ut(e,t){return e??t}function Wt(e,t){let n=Ut(e,t);return n===`1`||n===`true`}function Gt(e,t,n){return e?.trim()||Ut(t,n)||``}var Kt=class extends Nt{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||qt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=xe({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),O.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function qt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Jt=class extends ve{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),me(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&we(t.mutationKey)!==we(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??qt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){O.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Yt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Xt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Zt=class extends ve{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,O.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!me(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Yt(e,n).forEach(e=>{e.destroy()}),Yt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=ce(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Lt(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Xt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&O.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},j=e(t(),1);function M({queries:e,...t},n){let r=b(n),i=ot(),a=ht(),o=j.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ye(e);let t=r.getQueryCache().get(e.queryHash);Qe(e,a,t)}),xt(a);let[c]=j.useState(()=>new Zt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(e=>f?c.subscribe(O.batchCalls(e)):s,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>Ot(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&Ot(n,e)?ft(n,new Lt(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&tt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function N(e,t){let n=b(t),[r]=j.useState(()=>new Jt(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);let i=j.useSyncExternalStore(j.useCallback(e=>r.subscribe(O.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((e,t)=>{r.mutate(e,t).catch(s)},[r]);if(i.error&&_(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function P(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function F(e,t={}){return{...P(t),runId:e}}function Qt(e,t=!0,n=!1,r){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>de(P({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function I(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:W.models(t),refetchType:n})}function $t(e,t=!0,n){return y({...en(e,n),enabled:t})}var en=(e,t)=>({queryKey:W.models(e,t),queryFn:({signal:n})=>je(e,{signal:n},t),staleTime:300*1e3});function tn(e,t=!0){let n=M({queries:e.map(e=>({...en(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function nn(e,t){return JSON.stringify([e,t])}function rn(e){return e.type===`run`?e.run.id:e.id}function L(e,t){return{...e,runs:t}}function an(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var on=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(nn(e.projectId,e.id),t))}at(e,t){return this.positions.get(nn(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function sn(e,t,n){let r=new on(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=pn(i,e.project,e.usage,r);else{let t=un(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function cn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function ln(e,t,n){return un(e,t,n,new on(e.runs))}function un(e,t,n,r){let{project:i}=t,a=r.at(i,rn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:L(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:L(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!cn(e,i,n))return{index:e,reconcile:!0};let l=ce(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||an(t,i)>e.perProjectLimit);return{index:L(e,t),reconcile:n}}if(s)return fn(e,l,r);let u=r.insert(l);return{index:L(e,u),reconcile:l.archived&&an(u,i)>e.perProjectLimit}}function dn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function fn(e,t,n){let r=dn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:L(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function pn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=ce(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?L(e,r.runs):e}function mn(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function hn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function gn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function _n(e){e.stream=void 0}function vn(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,rn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function yn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function bn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function xn(e,t,n){if(!bn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=ln(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var R=[`workspace`,`runs-index`],Sn=[`workspace`,`projects`],Cn=6e4,wn=100,Tn=new WeakMap;function En(e){let t=Tn.get(e);return t||(t=jn(e),Tn.set(e,t)),t}function Dn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:En(t).merge(e)}function On(e){let t=e.getQueryData(Sn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function kn(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function An(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function jn(e){let t=hn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(R,t)},h=()=>e.getQueryData(R),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:R,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:R,exact:!0}).then(()=>e.invalidateQueries({queryKey:R})):e.invalidateQueries({queryKey:R})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=On(e),{index:s,reconcile:c}=sn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,wn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){gn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){_n(t)},run(e,r,i=!1){if(l.has(e))return;let a=An(e,r);if(!vn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),ee()}},dropProject(e){l.add(e),yn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=mn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=xn(t,n,On(e));for(let e of l)i.index=mn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),kn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var Mn=k([`own`,`provider-spanning`]),Nn=x({suggested:T(x({id:D(),label:D(),desc:D()})),retired:T(D())}),Pn=x({id:k([`settings`,`mcp`,`memory`]),label:D(),note:D().optional(),empty:D().optional(),showsUserMcp:w(!0).optional()}),Fn=x({label:D(),note:D().optional(),groups:T(Pn)}),In=x({runners:T(x({id:ct,displayName:D(),modelListName:D(),modelIdScope:Mn,pickerLabel:D(),pickerDescription:D(),icon:D(),installHint:D(),loginCommand:D(),terminalLogin:E().optional(),browserLogin:E().optional(),managedInstall:w(!0).optional(),accountFolderExample:D().optional(),models:Nn,agentConfig:Fn}))}),Ln=[`workspace`,`runners`];async function Rn(e){return Ee(await Bt.api.v1.runners.$get({},c(e)),`/runners`,In)}var zn={queryKey:Ln,queryFn:({signal:e})=>Rn({signal:e}),staleTime:1/0};function Bn(){return y(zn)}function Vn(e){return e?.runners??[]}function Hn(e){return Vn(e).map(e=>e.id)}function Un(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Wn(e){let t=Bn();return{runner:t.isSuccess?Un(e,Hn(t.data))??e:e,ready:!t.isPending}}function z(e,t){return e?.runners.find(e=>e.id===t)}function Gn(e,t){return z(e,t)?.displayName??t}function Kn(e,t){return z(e,t)?.pickerLabel??t}function qn(e,t){return z(e,t)?.modelListName}function Jn(e,t,n=!0,i){let a=Ii(i,n),o=q(),{runner:s,ready:c}=Wn(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??r(),d=y({queryKey:U.runnerSkills(s,l,u),queryFn:({signal:e})=>m(s,l,{signal:e,projectId:u}),enabled:n&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...d,runner:s,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var Yn={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},Xn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Zn(e){return typeof e==`string`&&Object.hasOwn(Yn,e)}function Qn(e){return e!==void 0&&Zn(e)?Yn[e]:void 0}var $n=`cez.reference-statuses.v1`,er=`cez.reference-conflicts.v1`,B=new Map(ir()),tr=1e3;function nr(e,t){if(B.get(e)!==t){for(B.delete(e),B.set(e,t);B.size>tr;){let e=B.keys().next().value;if(e===void 0)break;B.delete(e)}sr()}}var V=new Set(ar());function rr(e,t){if(V.has(e)!==t){if(t)for(V.add(e);V.size>tr;){let e=V.values().next().value;if(e===void 0)break;V.delete(e)}else V.delete(e);sr()}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&Zn(e[1])):[]}catch{return[]}}function ar(){try{let e=globalThis.sessionStorage?.getItem(er);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var or;function sr(){or===void 0&&(or=setTimeout(()=>{or=void 0;try{globalThis.sessionStorage?.setItem($n,JSON.stringify([...B])),globalThis.sessionStorage?.setItem(er,JSON.stringify([...V]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function cr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function lr(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function ur(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;nr(t,o),s!==void 0&&rr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function dr(e,t,n){let r=H(t),i=B.get(r),a=V.has(r)?!0:void 0,o=n.data;if(o?.available){ur(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...cr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...cr(i,a)});return}e.set(r,{state:`loading`,...cr(i,a)})}function fr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of lr(i))dr(n,e,t)}),n}var U={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t,n=r())=>[n,`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},get uiState(){return[r(),`ui-state`]},get config(){return[r(),`config`]},get agentConfig(){return[r(),`agent-config`]},agentConfigFile:e=>[r(),`agent-config`,`file`,e],get sessionContext(){return[r(),`session-context`]},sessionContextPreview:(e,t,n=``)=>[r(),`session-context`,`preview`,t,e,n],get worktrees(){return[r(),`worktrees`]},github:(e={})=>[r(),`github`,e.limit??null],githubPages:e=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[r(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[r(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[r(),`github`,`comments`,e,t],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},W={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:R,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...W.fsBrowseRoot,e,t]};function pr(){return Wt(void 0,void 0)}function G(e){return!pr()&&e}function mr(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function hr(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function gr(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function _r(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function vr(e,t){return Fe({kind:`topic`,topic:e},{value:t})}function yr(){let e=b();return y({queryKey:W.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(W.providerStatus),r=await Et(!1,{signal:t});return Te(n,e.getQueryData(W.providerStatus),r)},staleTime:5*6e4,refetchInterval:G(!1),refetchOnWindowFocus:!0})}function br(){let e=b();return N({mutationFn:()=>Et(!0),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t)),I(e)}})}function xr(){let e=b();return N({mutationFn:({provider:e,authFailureId:t})=>rt(e,t),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t,n.authFailureId)),I(e,n.provider)}})}function Sr(e={}){return y({queryKey:W.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function Cr(e,t=!1){return y({queryKey:W.fsBrowse(e,t),queryFn:({signal:n})=>ze(e??void 0,{signal:n,showHidden:t}),retry:!1})}function wr(){let e=b();return N({mutationFn:e=>nt(e),onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Tr(){let e=b();return N({mutationFn:e=>gt(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:W.projects})}})}function Er(){let e=b();return N({mutationFn:e=>{let{id:t,...n}=e;return Pt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:W.projects});let r=e.getQueryData(W.projects);return e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Dr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(W.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:W.projects})})}function Dr(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:_r(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Or(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(W.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:W.projects})})}function kr(){return Or(e=>{let{projectId:t,...n}=e;return $e(t,n)})}function Ar(){return Or(e=>{let{projectId:t,webhookId:n,...r}=e;return Se(t,n,r)})}function jr(){return Or(({projectId:e,webhookId:t})=>st(e,t))}function Mr(){return N({mutationFn:({projectId:e,webhookId:t})=>Rt(e,t),retry:!1})}function K(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:W.agentProfiles}),t.invalidateQueries({queryKey:W.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),I(t)])},onError:()=>{t.invalidateQueries({queryKey:U.health}),t.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function Nr(){return K(e=>_e(e))}function Pr(){return K(e=>{let{id:t,...n}=e;return Ke(t,n)})}function Fr(){return K(e=>St(e))}function Ir(){return K(e=>Ve(e))}function Lr(e,t){return y({queryKey:W.agentAccountStatus(e),queryFn:({signal:t})=>Dt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Rr(){let e=b();return N({mutationFn:({provider:e,profileId:t})=>Be(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:W.agentProfiles}),e.invalidateQueries({queryKey:W.providerStatus}),I(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:U.health}),e.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function zr(){let e=b();return N({mutationFn:e=>Dt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.agentAccountStatus(n),t),e.invalidateQueries({queryKey:W.agentProfiles}),I(e,t.status.provider)}})}function Br(){let e=b();return N({mutationFn:e=>Ie(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Vr(){let e=b();return N({mutationFn:e=>a(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Hr({enabled:e}){return y({queryKey:W.githubOwners,queryFn:({signal:e})=>lt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Ur(){let e=b();(0,j.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(U.health);r&&(De({bootProject:r.bootProject===void 0?`default`:r.bootProject,apiBase:n()}),t??=vr(`health`,t=>{e.setQueryData(U.health,t)}))};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),Re()}},[e])}function q(){return y({queryKey:U.health,queryFn:({signal:e})=>We({signal:e})})}function Wr(e,t){let n=q().data,r=Sr(t).data?.projects,i=Ue(),a=e??i.projectId,o=a??n?.bootProject??void 0,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:n?.bootProject!==null&&(a===null||a===n?.bootProject)?mr(n?.repo?.remote):void 0}function Gr(){return y({queryKey:W.uiState,queryFn:({signal:e})=>pt({signal:e})})}function Kr(){return y({queryKey:W.config,queryFn:({signal:e})=>Xe({signal:e})})}function qr(){return y({queryKey:W.agentProfiles,queryFn:({signal:e})=>vt({signal:e})})}var J=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>[e.cacheScope,`runs`,`detail`,e.runId],Z=e=>typeof e==`function`?e():e;function Jr(e){let{seenAt:t,...n}=e;return n}function Yr(e,t){let n=Jr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Xr(e,t,n){return t?{...e,seenAt:n}:Jr(e)}function Zr(e){let t=()=>{e.invalidateQueries({queryKey:J})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Me(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:Y(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let i=e.getQueryData(Y(Z(n))),a=e.getQueryData(X(Z(n))),o=Z(n).runId,s=new Date().toISOString();return e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Xr(e,r,s):e)),e.setQueryData(X(Z(n)),e=>e&&Xr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(Y(Z(n)),i),a&&e.setQueryData(X(Z(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Yr(e,t):e)),a&&e.setQueryData(X(Z(n)),e=>e&&Yr(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Xr(e,r,i.seenAt):e;e.setQueryData(Y(Z(n)),e=>e?.map(a));let s={...Z(n),runId:r?o:i.id};e.setQueryData(X(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:J});let i=e.getQueryData(J),a=r();return e.setQueryData(J,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(J,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function Q(){let e=b();return(0,j.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Ht(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),Fe({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function $(e,t,n,r){let i=b(),a=JSON.stringify(t),o=(0,j.useMemo)(()=>JSON.parse(a),[a]);(0,j.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=Qr({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function $r(e,t=!1){return ee(await Bt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),Oe(e,`/worker-destroy`))}function ei(){return y({queryKey:U.openTargets,queryFn:({signal:e})=>Ft({signal:e}),staleTime:5*6e4})}function ti(e=!0,t){return y({queryKey:t?U.runs.list(t):U.runs.list(),queryFn:({signal:e})=>de(P(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function ni(e,t){return yt({queryKey:U.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>it({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function ri(e){let t=e.trim();return y({queryKey:W.runsSearch(t),queryFn:({signal:e})=>oe(t,{signal:e}),enabled:t.length>=2,placeholderData:f,staleTime:1e4})}function ii(e=!0,t=Cn,n){let r=En(b());return $(`/api/v1/workspace/runs-index`,W.runsIndex,G(e?t:!1),Dn),y({queryKey:W.runsIndex,queryFn:({signal:e})=>he({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return N({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:U.runs.relationships(e)})})}function oi(e,t={}){return y({queryKey:U.runs.relationships(e),queryFn:({signal:t})=>le(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return y({queryKey:U.runs.detail(e??``),queryFn:({signal:t})=>Ce(F(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return y({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Ce(F(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function li(e,t){return y({queryKey:t?[t,`runs`,`diff`,e??``]:U.runs.diff(e??``),queryFn:({signal:n})=>p(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ui(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,U.runs.changes(e??``),G(t?4e3:!1)),y({queryKey:U.runs.changes(e??``),queryFn:({signal:t})=>u(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return y({queryKey:U.runs.file(e??``,t??``),queryFn:({signal:n})=>pe(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return y({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Je(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return y({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>He(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return y({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>At(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return y({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>zt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function gi(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,U.runs.commits(e??``),G(t?5e3:!1)),y({queryKey:U.runs.commits(e??``),queryFn:({signal:t})=>h(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return y({queryKey:U.runs.commit(e??``,t??``),queryFn:({signal:n})=>jt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return y({queryKey:U.runs.handoff(e??``),queryFn:({signal:t})=>dt(F(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return y({queryKey:e===void 0?U.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>dt(F(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let n=[...new Set(e)],i=M({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>kt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,j.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function xi(e){let t=b();return N({mutationFn:t=>ne(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Si(e){let t=b();return N({mutationFn:t=>Ae(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=N({mutationFn:e=>ie(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,j.useCallback)(e=>({...F(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,j.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,j.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,j.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function wi(){let e=Q();return N({mutationFn:e=>ie(F(e),!1),onMutate:t=>e.patchRead(()=>F(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return N({mutationFn:({id:t,pinned:n})=>te(F(t,e),n),onError:e=>_t(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??P(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return N({mutationFn:n=>Tt(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof ye&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return N({mutationFn:(n={})=>Ze(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return N({mutationFn:({msgId:t,message:n})=>Ct(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ki(e){let t=b();return N({mutationFn:t=>Ne(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ai(){return y({queryKey:U.workflows,queryFn:({signal:e})=>ut({signal:e})})}function ji(e){return y({queryKey:e?[e,`repo`]:U.repo,queryFn:({signal:t})=>Ge({signal:t},e)})}function Mi(e){return y({queryKey:[e,`repo`],queryFn:({signal:t})=>Ge({signal:t},e)})}function Ni(){return y({queryKey:U.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return y({queryKey:U.repoChanges,queryFn:({signal:e})=>be({signal:e}),retry:!1})}function Fi(e){return y({queryKey:U.repoCommit(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e,t=!0){return y({queryKey:e?[e,`config`]:U.config,queryFn:({signal:t})=>It({signal:t,...e?{projectId:e}:{}}),enabled:t})}function Li(){return y({queryKey:U.worktrees,queryFn:({signal:e})=>o({signal:e})})}function Ri(e){return y({queryKey:[e,`worktrees`],queryFn:({signal:t})=>o({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>fe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ke(e.sidebarLimits)},enabled:t})}function Bi(e=!0,t){return zi(t??r(),e)}function Vi(){return y({queryKey:U.agentConfig,queryFn:({signal:e})=>mt({signal:e})})}function Hi(e){return y({queryKey:U.agentConfigFile(e??``),queryFn:({signal:t})=>at(e,{signal:t}),enabled:e!==null})}function Ui(){return y({queryKey:U.sessionContext,queryFn:({signal:e})=>d({signal:e})})}function Wi(e,t,n=``){return y({queryKey:U.sessionContextPreview(e,t,n),queryFn:({signal:n})=>ue({content:e,role:t},{signal:n}),placeholderData:f,staleTime:0,retry:!1})}function Gi(){let e=b();return N({onMutate:()=>({fileKey:U.sessionContext}),mutationFn:e=>se(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=U.agentConfig,r=U.agentConfigFile(e);return N({mutationFn:t=>g(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=k([`passing`,`failing`,`pending`]).nullable(),Ji=x({kind:k([`issue`,`pr`]),number:A(),title:D(),author:D(),createdAt:D(),labels:T(D()),body:D().optional(),url:D(),comments:A(),assignees:T(D()).optional(),projectIds:T(D()).optional(),isDraft:E().optional(),additions:A().optional(),deletions:A().optional(),checks:qi.optional()});S(`available`,[x({available:w(!0),item:Ji.nullable(),labelColors:C(D(),D()).optional()}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),number:Vt().int().positive().safe()});var Yi=x({id:D(),title:D(),url:D()});x({available:E(),reason:D().optional(),repo:D().optional(),syncedAt:D().optional(),issues:T(Ji),prs:T(Ji),labelColors:C(D(),D()).optional(),viewerLogin:D().optional(),projects:T(Yi).optional(),projectsReason:D().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:D().optional(),issuesTotal:A().int().nonnegative().optional(),prsTotal:A().int().nonnegative().optional(),issuesNextCursor:D().nullable().optional(),prsNextCursor:D().nullable().optional(),commentsDeferred:w(!0).optional()});var Xi=D().min(1).max(2e3).optional();x({limit:D().optional(),refresh:D().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:w(`1`).optional(),prsDone:w(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),x({kind:k([`issue`,`pr`]),numbers:D().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:w(`1`).optional()}),S(`available`,[x({available:w(!0),counts:C(A(),A().int().nonnegative())}),x({available:w(!1),reason:D()})]),S(`available`,[x({available:w(!0),checks:C(A(),qi)}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),q:D().trim().min(1).max(256),limit:Vt().int().positive().max(50).optional()}),x({available:E(),projectsReason:D().optional(),reason:D().optional(),items:T(Ji),truncated:E().optional(),labelColors:C(D(),D()).optional()});var Zi=A().nullable();S(`available`,[x({available:w(!0),prs:C(A(),qe),issues:C(A(),qe),conflicts:T(A()).optional(),recheckAfterMs:Zi}),x({available:w(!1),reason:D(),recheckAfterMs:Zi})]);var Qi=x({id:A(),author:D(),avatarUrl:D().optional(),createdAt:D(),body:D(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:D()}),$i=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=x({id:D(),kind:$i,actor:D(),avatarUrl:D().optional(),createdAt:D(),url:D().optional(),sha:D().optional(),message:D().optional(),checks:qi.optional(),label:x({name:D(),color:D().optional()}).optional(),subject:D().optional(),refNumber:A().optional(),refTitle:D().optional(),refIsPr:E().optional()});x({available:E(),reason:D().optional(),comments:T(Qi),truncated:E().optional(),events:T(ea).optional(),detail:x({body:D(),additions:A().int().nonnegative().optional(),deletions:A().int().nonnegative().optional()}).optional()});var ta=k([`merge`,`squash`,`rebase`]),na=x({name:D(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:E().nullable(),url:D().optional()}),ra=x({number:A(),title:D(),url:D(),state:k([`open`,`closed`,`merged`]),isDraft:E(),headRef:D(),baseRef:D(),headSha:D(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:T(na),methods:T(ta),defaultMethod:ta.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:T(x({code:D(),message:D()})),canMerge:E(),canOverride:E()});S(`available`,[x({available:w(!0),mergeState:ra}),x({available:w(!1),reason:D()})]),x({merged:w(!0),number:A(),url:D(),method:ta,mergeCommitSha:D().optional()});var ia=x({path:D(),previousPath:D().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:A(),deletions:A(),patch:D().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:E().optional()});S(`available`,[x({available:w(!0),number:A(),headSha:D(),files:T(ia),additions:A(),deletions:A(),truncated:E(),reason:D().optional()}),x({available:w(!1),reason:D()})]),x({generation:D().uuid()}),S(`state`,[x({generation:D().uuid(),state:w(`ready`),projects:T(Yi),membership:C(D(),T(D()))}),x({generation:D().uuid(),state:w(`unavailable`),reason:D()})]);function aa(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function oa(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function sa(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function ca(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){sa(t.issues,a,r),sa(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var la=e=>e.map(e=>e.number).join(`,`);function ua(e,t){let n=e[0];if(e.length>1&&n&&(la(n.issues)!==la(t.issues)||la(n.prs)!==la(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}var da=class extends Error{};function fa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await v({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new da(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof da)&&!(t instanceof ye&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function pa(e=50,t=!0){let n=b(),i=U.githubPages(e),a=U.githubPagesHead(e);$(`/api/v1/p/${r()}/github?limit=${e}`,a,G(t?6e4:!1));let o=yt({...fa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=y({queryKey:a,queryFn:({signal:t})=>v({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,j.useEffect)(()=>{if(!s.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=ua(e.pages,s.data);t===`refetch`?c():n.setQueryData(i,{...e,pages:t})},[n,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=M({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,j.useEffect)(()=>{u.forEach((e,t)=>{let r=l[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return n?{...t,pages:i}:t})})},[n,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,j.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ma(e,t=50,n=!0){let r=yt({...fa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,j.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ha(e,t,n=!0){let r=M({queries:t.filter(e=>e.length>0).map(t=>({queryKey:U.githubCommentCounts(e,t),queryFn:({signal:n})=>wt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,j.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function ga(e,t,n,r=!0){return y({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>et(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function _a(e,t=!0){return y({queryKey:U.githubChecks(e),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function va(e,t,n=!0){return y({queryKey:U.githubSearch(e,t),queryFn:({signal:n})=>et(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ya=100;function ba(e){return[...e].sort((e,t)=>t-e).slice(0,ya).sort((e,t)=>e-t)}function xa(){let e=Ue(),t=q();return e.projectId??t.data?.bootProject??void 0}function Sa(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))nr(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))nr(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Ca=5*6e4;function wa(e){return e?e.recheckAfterMs:Ca}function Ta(e,t=!0){let n=(0,j.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:ba(t.prs),issues:ba(t.issues)}))},[e.map(H).sort().join(`|`)]),r=M({queries:n.map(e=>({queryKey:U.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>i(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>wa(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:wa(r[t]?.data)??!1})));(0,j.useEffect)(()=>{if(!t||pr())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=U.githubRefStatus(t.projectId,t.prs,t.issues);return Qr({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,j.useMemo)(()=>fr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,j.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=B.get(t);return{state:`idle`,...r?{status:r}:{},...V.has(t)?{conflicting:!0}:{}}},[s])}function Ea(e,t,n=!0){return y({queryKey:U.githubComments(e,t),queryFn:({signal:n})=>re(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Da(e,t,n=!0){return y({queryKey:U.githubItem(e,t),queryFn:({signal:n})=>Le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e){return y({queryKey:U.githubPrChanges(e??0),queryFn:({signal:t})=>Pe(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{di as $,qn as $t,Li as A,Ir as At,Ci as B,mr as Bt,Ni as C,zr as Ct,Wi as D,Tr as Dt,Ui as E,Fr as Et,bi as F,Kr as Ft,Ti as G,Xn as Gt,xi as H,pr as Ht,Di as I,Gr as It,si as J,Un as Jt,ci as K,Qn as Kt,ai as L,vr as Lt,pi as M,Pr as Mt,mi as N,Er as Nt,Bi as O,jr as Ot,hi as P,Ar as Pt,li as Q,Hn as Qt,Oi as R,hr as Rt,ji as S,yr as St,Fi as T,wr as Tt,ei as U,U as Ut,wi as V,G as Vt,Si as W,W as Wt,_i as X,Vn as Xt,ui as Y,Gn as Yt,gi as Z,z as Zt,Mi as _,Hr as _t,Da as a,tn as an,Ei as at,Ki as b,Wr as bt,va as c,P as cn,Q as ct,xa as d,M as dn,Br as dt,Kn as en,vi as et,Ta as f,Kt as fn,Rr as ft,Ii as g,Cr as gt,Hi as h,kr as ht,Ea as i,I as in,ri as it,ni as j,Mr as jt,Ai as k,xr as kt,ma as l,F as ln,Lr as lt,Vi as m,Vr as mt,_a as n,Bn as nn,ti as nt,pa as o,$t as on,yi as ot,oa as p,Gt as pn,Nr as pt,ki as q,Jn as qt,ha as r,En as rn,ii as rt,Oa as s,Qt as sn,Qr as st,Sa as t,Wn as tn,oi as tt,ga as u,N as un,qr as ut,zi as v,q as vt,Pi as w,br as wt,Gi as x,Sr as xt,Ri as y,Ur as yt,fi as z,gr as zt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,p as i,s as a}from"./dist-C_rn70hE.js";import{A as o,C as s,Kt as c,S as l,T as u,U as d,Ut as f,bt as p,nt as m,un as h,w as g}from"./queries-CchoEEzj.js";import{B as ee,Rn as _,T as v,f as y,n as b,ut as x,vi as S,w as C,z as te,zt as ne}from"./toaster-zMN8cNZQ.js";import{Z as w}from"./live-protocol-DMhTnCmf.js";import{g as T,h as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{c as D,f as O,i as re,t as k}from"./reference-chip-z7dZJVH-.js";import{D as ie,F as ae,I as oe,M as se,N as ce,P as le,Q as ue,S as de,X as fe,Z as pe,c as me,ct as he,d as ge,j as _e,l as ve,n as ye,st as be,w as xe,y as Se}from"./design-icons-QbNMZniQ.js";import{t as Ce}from"./createLucideIcon-BHp8sXmF.js";import{n as we,t as Te}from"./circle-x-7nTlobAF.js";import{_ as Ee}from"./nav-row-styles-CgP5uNp4.js";import{i as De,r as Oe,t as ke}from"./git-toolbar-CepvG0Ng.js";import{t as A}from"./info-DA1x_4bz.js";import{t as Ae}from"./loader-circle-CPBhhDbB.js";import{a as je,i as Me,n as Ne,r as Pe}from"./diff-controls-CaCUSyxs.js";import{t as j}from"./button-B22ANdCY.js";import{i as M,l as Fe,p as Ie,r as Le,t as Re}from"./dropdown-menu-DjtKUK8F.js";import{a as ze,i as Be,n as Ve,o as He,r as Ue,s as We,t as Ge}from"./dialog-rpNyAWGb.js";import{t as N}from"./project-router-j0uBi7Ep.js";import{t as Ke}from"./status-dot-Drd4-nfa.js";import{c as qe,d as Je,f as Ye,m as P,n as Xe,s as F,t as Ze}from"./page-shell-BgabWJ3w.js";import{a as Qe,o as $e}from"./format-BU7D3IfE.js";import{t as et}from"./control-locations-kCPVEtOM.js";import{t as I}from"./centered-state-BgSV4e79.js";import{$t as tt,Er as L,Gt as nt,Hn as rt,Ht as it,Jt as R,Kt as at,Ln as ot,M as st,N as z,Qt as ct,Un as lt,Ut as ut,Vn as dt,Vt as ft,Wt as pt,Xt as B,Yt as mt,Zt as ht,_r as gt,an as V,cn as H,en as _t,in as U,ln as W,nn as G,on as K,qt as vt,rn as q,sn as J,tn as yt,ur as bt,wr as xt}from"./index-DJB0lid-.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-lwWO-At7.js";import{t as wt}from"./change-counts-wqSYI3W8.js";import{t as Tt}from"./code-workbench-CUkiQ1pF.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-Bjc-pQxv.js";var Y=e(t(),1);function At(e,t){let n=S(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(w.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=Ce(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mt=Ce(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function Nt(){let e=i(),t=l(),n=S(),a=At({queryKey:f.repo})>0,o=t.data?.info?t.data:null,s=ft(e,o,`screen`);return(0,X.jsx)(Je,{route:`repo-git`,density:o?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(qe,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:a,onClick:()=>{n.invalidateQueries({queryKey:f.repo}),n.invalidateQueries({queryKey:f.worktrees})},children:(0,X.jsx)(pe,{size:17,"aria-hidden":`true`,className:r(`size-[17px]`,a&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(pt,{scope:e,repo:o,info:o.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(it,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(qe,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:R(i())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(fe,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=vt(i()),a=R(i()),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),u=o.trim(),d=Pt(u),f=d??c;return(0,X.jsx)(Ge,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(Ue,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!u||d||a)&&(l(null),r.mutate(u,{onSuccess:n,onError:e=>l(e.message)}))},children:[(0,X.jsxs)(He,{children:[(0,X.jsx)(We,{children:`New branch`}),(0,X.jsxs)(Be,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(Ve,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(bt,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:o,"aria-invalid":f?!0:void 0,"aria-describedby":f?`new-branch-name-hint`:void 0,onChange:e=>{s(e.target.value),l(null)}}),f?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":d?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:f}):null]}),(0,X.jsxs)(ze,{children:[(0,X.jsx)(j,{type:`button`,variant:`outline`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(j,{type:`submit`,variant:`primary`,"data-action":`create-branch`,disabled:!u||d!==null||a,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=s(),a=new Map((n.data?.branches??[]).map(e=>[e.name,e])),o=n.data?.base??e.baseBranch??t.branch,c=vt(i(),e=>b(e.message,{tone:`danger`})),l=R(i()),[u,d]=(0,Y.useState)(``),f=u.trim().toLowerCase(),p=Gt(e,n.data?.branches),m=f?p.filter(e=>e.toLowerCase().includes(f)):p;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(bt,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:u,onChange:e=>d(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[m.map(e=>{let n=e===t.branch,i=a.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(N,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:r(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:o}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(j,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto`,disabled:l,onClick:()=>c.mutate(e),children:[(0,X.jsx)(_e,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),m.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,u.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:oe,className:`border-success/40 text-semantic-green`},draft:{icon:ae,className:`border-border text-muted-foreground`},merged:{icon:ce,className:`border-merged-strong/35 text-merged-text`},closed:{icon:le,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],i=(0,X.jsxs)(`span`,{className:r(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),o=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:r(o,`group focus-visible:outline-2 focus-visible:outline-ring`),children:i}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:o,children:i})}function Ht({checks:e}){let t=e===`passing`?we:e===`failing`?Te:xt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:r(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:r(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ut[e.class]})}function Gt(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Kt(){let e=g(),t=P(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof _&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Oe(f),[f]),m=(0,Y.useMemo)(()=>f.some(St),[f]),h=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:d?(0,X.jsx)(xe,{size:16}):(0,X.jsx)(he,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(xe,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button:not([data-button-size])]:min-h-11`,children:[e.data?(0,X.jsx)(ke,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[m&&o?(0,X.jsx)(Me,{}):null,m?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(je,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Pe,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:m&&o}),(0,X.jsx)(Ne,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:m?s:void 0,disabled:m&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(De,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:h,wrap:i,preview:o,loadFileText:e=>Et(()=>v(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=E(),r=P(),i=e.log,a=(0,Y.useMemo)(()=>yt(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=ht(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(se,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:r(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(N,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:_t(e.when,e.at),children:tt(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=r(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(N,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:r(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(me,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=at(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ae,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ye,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(nt,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:u(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>C(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:u(e),sha:e,backTo:mt,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>C(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=s(),t=m(),n=i(),r=p(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(he,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let c=en(e.data.branches),l=c.reduce((e,t)=>e+t.rows.length,0),u=tn(e.data.branches),d=u>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(A,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[u,` finished task`,u===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,u===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(N,{to:B.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,f=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(re,{projectId:n,repoBase:r,requests:c.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),d,c.length===0?(0,X.jsx)(Ze,{icon:(0,X.jsx)(gt,{size:16}),title:u>0?`Nothing else waiting to land`:`Everything landed`,description:u>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(N,{to:B.cleanup,children:`Check cleanup`})}),(0,X.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(N,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:c.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?f.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(A,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),l<=3?(0,X.jsx)(Xe,{summary:`${l} ${l===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(N,{to:B.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:a,onClose:()=>o(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:r(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(A,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(k,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=S(),i=e.class===`orphan`,a=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!i&&e.runId!==null&&!a,s=h({mutationFn:()=>x(e.runId),onSuccess:e=>{b(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:f.repoBranches}),n.invalidateQueries({queryKey:f.runs.all})},onError:e=>b(e instanceof _&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);let d=()=>void navigator.clipboard.writeText(e.name).then(()=>{b(`Copied ${e.name}`),u.current!==null&&clearTimeout(u.current),l(!0),u.current=setTimeout(()=>l(!1),2e3)},()=>b(`Could not copy the branch name`,{tone:`danger`})),p=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(N,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,i?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:d,className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,X.jsx)(ve,{"aria-hidden":`true`}):(0,X.jsx)(Se,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Re,{children:[(0,X.jsx)(Ie,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(de,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Le,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(M,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(N,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(M,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(M,{className:r(!i&&`md:hidden`),onSelect:d,children:`Copy branch`}),(0,X.jsx)(Fe,{className:`md:hidden`}),(0,X.jsx)(M,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Qe(i),o=e.runStatus?ot(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Ee,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ke,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(N,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(N,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=c(D(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=S(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=h({mutationFn:e=>y({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;b(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:f.repo}),s()},onError:e=>b(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(G,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(V,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(W,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(K,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(lt,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(bt,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(J,{children:[(0,X.jsx)(U,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(q,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=s(),n=S(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),u=[...c,...l],d=h({mutationFn:e=>y({names:e}),onSuccess:e=>{let t=e.refused.length;b(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:f.repo})},onError:e=>{n.invalidateQueries({queryKey:f.repo}),b(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=u.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||d.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(be,{"aria-hidden":`true`,className:`size-[12px]`}),d.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(G,{open:a,onOpenChange:o,children:(0,X.jsxs)(V,{children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(W,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(K,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(J,{children:[(0,X.jsx)(U,{children:`Keep them`}),(0,X.jsxs)(q,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{d.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:i,open:a,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":s,disabled:i.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,i.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),i.length>0?(0,X.jsx)(ge,{"aria-hidden":`true`,className:r(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,a&&`rotate-90`)}):null]}),a?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:i.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(dt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(N,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(rt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${O(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?O(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${O(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(L,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(V,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(W,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(K,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${O(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(J,{children:[(0,X.jsx)(U,{children:`Keep them`}),(0,X.jsx)(q,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(G,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(V,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(W,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(K,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${O(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(J,{children:[(0,X.jsx)(U,{children:`Keep them`}),(0,X.jsx)(q,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(G,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(V,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(W,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(K,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(J,{children:[(0,X.jsx)(U,{children:`Keep it`}),(0,X.jsx)(q,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=o(),t=d().data?.targets.find(e=>e.id===`finder`),n=h({mutationFn:e=>ne(e,t.id),onError:e=>b(e.message,{tone:`danger`})}),r=S(),[i,a]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),p=()=>Promise.all([r.invalidateQueries({queryKey:f.worktrees}),r.invalidateQueries({queryKey:f.repoBranches})]),m=h({mutationFn:({runIds:e})=>ee(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{p(),b(gn(e.reclaimed.length,t,!!n))},onError:e=>b(e.message,{tone:`danger`})}),g=h({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{p(),b(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{p(),b(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:_,totalBytes:v,keep:y}=e.data,x=m.isPending||g.isPending,C=_.filter(e=>e.pastKeep),w=C.filter(e=>!e.reclaimBlocker),T=C.filter(e=>e.reclaimBlocker!==null),E=w.length>0,D=$(w),re=$(C),k=_n(w.length,D),ie=vn(C.length,re,E),ae=v?O(v):null,oe=bn(y);return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,ae?` · ${ae}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[oe.prefix,(0,X.jsx)(N,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:et(`worktrees`,` › `)}),oe.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:x||!E,title:yn(E,T.length),onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(L,{"aria-hidden":`true`,className:`size-[12px]`}),k]})]}),T.length>0?(0,X.jsx)(xn,{blocked:T,discardLabel:ie,disabled:x,onDiscard:()=>c(C)}):null,_.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:_.map(e=>(0,X.jsx)(En,{worktree:e,keep:y,disabled:x,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?u(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:w.length,cleanBytes:D,reclaimLabel:k,onConfirmClean:()=>{m.mutate({expected:w.length}),a(!1)},discardBatch:s,onCloseDiscardBatch:()=>c(null),onConfirmDiscardBatch:e=>{m.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:l,onCloseRow:()=>u(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:i,opening:a,onReclaim:o}){let s=Tn(e,t),c=Qe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${$e(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,f=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:r(`text-xs`,u),children:s.label}),p=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:O(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),i?(0,X.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:a,onClick:i,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:r(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(L,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=l(),r=P(),[i]=T(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(st,{});if(n.isError)return(0,X.jsx)(F,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(he,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(F,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(_e,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function kn({repo:e,info:t,section:n}){let r=Dn(n),i=s(),a=An(n),o=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(F,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Ye(o),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(z,{}),header:{title:a?.title??ut(n,t.branch),headerSlot:`repo-header`,subtitle:a?(0,X.jsxs)(X.Fragment,{children:[`Commit `,a.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=E(),n=P(),r=e===`main`&&!n?t:void 0,i=u(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${ct(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Mn,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Mn({repo:e,info:t}){let n=Gt(e,s().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On as RepoGitRoute};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{Ht as i}from"./queries-CchoEEzj.js";import{f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{mt as s}from"./design-icons-QbNMZniQ.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist--f2yFdPY.js";import{t as g}from"./use-search-params-writer-ClMScnNe.js";var _=e(t(),1),v=n();function y({...e}){return(0,v.jsx)(h,{"data-slot":`sheet`,...e})}function b({...e}){return(0,v.jsx)(l,{"data-slot":`sheet-trigger`,...e})}function x({...e}){return(0,v.jsx)(d,{"data-slot":`sheet-close`,...e})}function S({...e}){return(0,v.jsx)(f,{"data-slot":`sheet-portal`,...e})}function C({className:e,...t}){return(0,v.jsx)(c,{"data-slot":`sheet-overlay`,className:r(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function w({className:e,children:t,side:n=`right`,showCloseButton:i=!0,overlayClassName:a,...o}){return(0,v.jsxs)(S,{children:[(0,v.jsx)(C,{className:a}),(0,v.jsxs)(p,{"data-slot":`sheet-content`,className:r(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition-colors ease-in-out motion-safe:data-[state=closed]:animate-out data-[state=closed]:duration-300 motion-safe:data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 end-0 h-full w-3/4 border-s motion-safe:data-[state=closed]:slide-out-to-right motion-safe:data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 start-0 h-full w-3/4 border-e motion-safe:data-[state=closed]:slide-out-to-left motion-safe:data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 inset-bs-0 h-auto border-be motion-safe:data-[state=closed]:slide-out-to-top motion-safe:data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 inset-be-0 h-auto border-bs motion-safe:data-[state=closed]:slide-out-to-bottom motion-safe:data-[state=open]:slide-in-from-bottom`,e),...o,children:[t,i&&(0,v.jsxs)(d,{className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,v.jsx)(s,{className:`size-4`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function T({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`sheet-header`,className:r(`flex flex-col gap-1.5 p-4`,e),...t})}function E({className:e,...t}){return(0,v.jsx)(m,{"data-slot":`sheet-title`,className:r(`font-semibold text-foreground`,e),...t})}function D({className:e,...t}){return(0,v.jsx)(u,{"data-slot":`sheet-description`,className:r(`text-sm text-muted-foreground`,e),...t})}function O(e){let[t,n]=_.useState(()=>Date.now());return _.useEffect(()=>{if(i())return;let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function A(e){let t=e.get(`report`);return!t||!k.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var j=(0,_.createContext)(null);function M(e){let t=a(),n=o(),[r,i]=g(),s=A(r),[c,l]=(0,_.useState)(()=>({runId:e,entries:new Map}));c.runId!==e&&l({runId:e,entries:new Map});let u=(0,_.useCallback)((t,n)=>(l(r=>{if(r.runId===e&&r.entries.get(t)===n)return r;let i=new Map(r.runId===e?r.entries:[]);return i.set(t,n),{runId:e,entries:i}}),()=>void 0),[e]),d=(0,_.useRef)({runId:e,callbacks:new Map});d.current.runId!==e&&(d.current={runId:e,callbacks:new Map});let f=(0,_.useCallback)((e,t)=>(d.current.callbacks.set(e,t),()=>{d.current.callbacks.get(e)===t&&d.current.callbacks.delete(e)}),[]),p=(0,_.useMemo)(()=>({register:u,registerOpener:f}),[u,f]),m=(0,_.useRef)(null);return(0,_.useEffect)(()=>{r.has(`report`)&&!s&&i(e=>(e.delete(`report`),e.delete(`card`),e))},[r,s,i]),(0,_.useEffect)(()=>{let n=m.current;!s&&n&&n.runId===e&&n.card&&d.current.callbacks.get(n.card)?.(n.artifactId,n.scrollTop),m.current=s?{...s,runId:e,scrollTop:t.state?.reportScrollTop}:null},[e,s,t.state]),{selection:s,sourceRunId:c.runId===e&&s?c.entries.get(s.artifactId)??(s.card?void 0:e):void 0,registry:p,close:()=>{let e=t.state,r=window.navigation;if(e?.reportReturnKey&&r){r.traverseTo(e.reportReturnKey);return}if(e?.reportReturnTo){n(e.reportReturnTo,{replace:!0});return}i(e=>(e.delete(`report`),e.delete(`card`),e))}}}export{x as a,T as c,y as i,E as l,M as n,w as o,O as r,D as s,j as t,b as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,p as i}from"./dist-C_rn70hE.js";import{Lt as a,M as o,st as s,vt as c}from"./queries-CchoEEzj.js";import{Bn as l,Cr as u,Gr as d,Hn as f,gi as p,oi as m,qr as h,vi as g,zn as _}from"./toaster-zMN8cNZQ.js";import{B as v,F as ee,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{Q as te}from"./design-icons-QbNMZniQ.js";import{t as ne}from"./arrow-up-right-DKGzsMqY.js";import{t as D}from"./chevron-right-BENZ-1ZN.js";import{t as O}from"./eye-B8okNWXU.js";import{t as k}from"./button-B22ANdCY.js";import{t as A}from"./project-router-j0uBi7Ep.js";import{f as j,i as M,n as N,r as P,t as re,u as F}from"./page-shell-BgabWJ3w.js";import{t as I}from"./use-search-params-writer-ClMScnNe.js";import{Hn as L,On as R,P as z,Yn as B,ur as V,yr as H}from"./index-DJB0lid-.js";import{t as U}from"./report-title-D4Mbu2Er.js";import{t as W}from"./html-report-frame-Ck76gKfA.js";var G=e(t(),1),K=1e3,q=S().min(1).max(1024);v({q:S().max(K).optional(),before:q.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var J=v({reports:x(v({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:u}).strict()),nextCursor:q.nullable(),total:w().int().nonnegative()}).strict(),Y=v({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),ie=v({runId:b(),taskTitle:S(),taskStatus:u}).strict(),ae=ee(`type`,[Y.extend({type:y(`snapshot`)}),Y.extend({type:y(`content`)}),Y.extend({type:y(`metadata`),runs:x(ie)})]),X=new WeakMap;function oe(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var se=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=oe(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function ce(e,t){let n=X.get(e);n||(n=new Map,X.set(e,n));let r=n.get(t);return r||(r=new se(e,t),n.set(t,r)),r}async function le(e,t){let n=await _.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},l({signal:t}));return Y.parse(await f(n,`/reports/state`))}function ue(e){let t=ce(g(),e);return(0,G.useEffect)(()=>{let n=a(`reports:project:${e}`,e=>{let n=ae.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,o=()=>{if(d()===`finite`&&!r){i=new AbortController;let n=i.signal;le(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=s({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=Y.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else d()!==`finite`&&(i?.abort(),r?.(),r=void 0)};o();let c=h(o);return()=>{c(),i?.abort(),r?.(),n()}},[t,e]),t}async function de(e,t,n,r){let i=await _.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,K),...n?{before:n}:{}}},l(r?{signal:r}:void 0));return J.parse(await f(i,`/reports`))}function fe(e){let t=i(),n=ue(t);return m({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>de(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Z=n(),Q=new Map,$={title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`};function pe(){let e=B(),t=c();return e===`unknown`?(0,Z.jsx)(F,{route:`reports`,density:`full`,fillHeight:!0,bodyClassName:`gap-4`,header:$,children:(0,Z.jsx)(`div`,{"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:t.isError&&!t.isFetching?(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.error instanceof Error?t.error.message:`Could not reach the server`}),(0,Z.jsx)(k,{variant:`outline`,onClick:()=>void t.refetch(),children:`Retry`})]}):(0,Z.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})})}):e===`absent`?(0,Z.jsx)(z,{}):(0,Z.jsx)(me,{})}function me(){let e=T(),t=E(),[n,i]=I(),a=(n.get(`q`)??``).slice(0,K),o=fe(a),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{Q.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,G.useState)(null),h=M(s);(0,G.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=Q.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>i(n=>(t?n.set(`q`,t.slice(0,K)):n.delete(`q`),Q.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:j(d.length);return(0,Z.jsx)(F,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:$,children:(0,Z.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Z.jsx)(te,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(V,{maxLength:K,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Z.jsx)(k,{variant:`outline`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(re,{icon:(0,Z.jsx)(H,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Z.jsxs)(Z.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Z.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[R(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Z.jsx)(k,{"data-slot":`reports-clear-search`,variant:`outline`,onClick:()=>g(``),children:`Clear search`}):(0,Z.jsx)(k,{variant:`outline`,asChild:!0,children:(0,Z.jsx)(A,{to:`/new`,children:`Start a task`})})})}):(0,Z.jsx)(P,{list:(0,Z.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Z.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:r(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Z.jsx)(H,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Z.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:U(e),children:(0,Z.jsx)(A,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:U(e)})})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Z.jsx)(A,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsx)(L,{className:`shrink-0`,iso:e.createdAt,prefix:`Published · `})]})]}),h?(0,Z.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${U(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Z.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Z.jsx)(D,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(k,{variant:`outline`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Z.jsx)(N,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Z.jsx)(he,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function he({report:e,restoreKey:t,onOpenReader:n}){let r=(0,G.useContext)(p)!==void 0;return(0,Z.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${U(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:U(e)}),(0,Z.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,(0,Z.jsx)(L,{iso:e.createdAt,prefix:`Published · `})]})]}),(0,Z.jsx)(k,{variant:`outline`,size:`sm`,asChild:!0,className:`shrink-0 py-1.5`,children:(0,Z.jsxs)(A,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Z.jsx)(ne,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Z.jsx)(ge,{report:e}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function ge({report:e}){let t=o(e.runId,e.id);if(t.isPending)return(0,Z.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Z.jsx)(`p`,{children:t.error.message}),(0,Z.jsx)(k,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Z.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Z.jsx)(W,{html:n.content,title:U(e),className:`min-h-0 flex-1`})}export{pe as ReportsRoute};
|