@staff0rd/assist 0.834.0 → 0.836.0
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/README.md +17 -9
- package/allowed.cli-reads +1 -1
- package/claude/commands/extension.md +1 -1
- package/dist/allowed.cli-reads +1 -1
- package/dist/commands/extension/extension/background.js +1 -0
- package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/manifest.json +9 -5
- package/dist/commands/extension/extension/options.html +33 -0
- package/dist/commands/extension/extension/options.js +1 -0
- package/dist/commands/extension/extension/updates.json +7 -0
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +50 -57
- package/package.json +1 -1
- package/dist/commands/criteriaExtension/criteria-extension/background.js +0 -1
- package/dist/commands/criteriaExtension/criteria-extension/updates.json +0 -12
- /package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/content.js +0 -0
- /package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/icons/assist-128.png +0 -0
- /package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/icons/assist-16.png +0 -0
- /package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/icons/assist-32.png +0 -0
- /package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/icons/assist-master.png +0 -0
package/README.md
CHANGED
|
@@ -332,7 +332,7 @@ Rules are `- **<code>** — **<title>** — <text>` bullets, the title optional,
|
|
|
332
332
|
|
|
333
333
|
- `assist netcap [-p, --port <port>] [-o, --out <dir>] [-f, --filter <pattern>]` - Capture browser network traffic under `--out` (default `~/.assist/netcap`), paired with the [netcap browser extension](#netcap-browser-extension)
|
|
334
334
|
- `assist netcap extract-linkedin-posts [file]` - Parse a netcap capture into structured LinkedIn posts
|
|
335
|
-
- `assist
|
|
335
|
+
- `assist extension [--sign] [--url]` - Locate the [acceptance criteria outliner extension](#acceptance-criteria-outliner-extension) to load unpacked; `--sign` signs it for a permanent Firefox install; `--url` prints the latest signed build's download URL
|
|
336
336
|
- `assist screenshot <process>` - Capture a screenshot of a running application window (`screenshot.outputDir`, default `./screenshots`)
|
|
337
337
|
- `assist mermaid export [file.md]` - Render each fenced mermaid block to SVG via [Kroki](https://kroki.io) (`--out`, `--index`, `mermaid.krokiUrl`)
|
|
338
338
|
- `assist prompts` - Show the most frequently denied tool calls
|
|
@@ -560,31 +560,39 @@ A restart kills every managed session's pty, which also kills any background tas
|
|
|
560
560
|
|
|
561
561
|
## Acceptance criteria outliner extension
|
|
562
562
|
|
|
563
|
-
`assist
|
|
563
|
+
`assist extension` prints the directory to load unpacked. The extension is a Manifest V3 content script scoped to `https://github.com/*`, plus a background script and an options page, built by `npm run build` from `src/commands/extension/` into `extension/content.js`, `background.js` and `options.js` (gitignored). It adds an **Outline criteria** toggle to the markdown toolbar of an issue's body editor and the new-issue form, re-attaching after client-side navigation; pressing it hides the textarea and mounts the same `AcceptanceCriteriaOutline` control the web preview panel uses, in a shadow root with its own emotion cache and MUI theme. A body whose acceptance criteria are bullets, checkboxes or prose gets a **Convert to outline** button instead, and a body with no acceptance criteria heading gets **Add acceptance criteria**. Each edit is written back through `writeAcceptanceCriteria` into the textarea and dispatched as an `input` event, so GitHub's own Save pushes it.
|
|
564
564
|
|
|
565
|
-
1. Run `assist
|
|
565
|
+
1. Run `assist extension` — it prints the extension directory. Under WSL it copies the extension to `C:\tools\extension` and prints that Windows path instead; re-run and reload the extension after a rebuild.
|
|
566
566
|
2. Load the unpacked extension:
|
|
567
567
|
- **Chrome**: open `chrome://extensions`, enable **Developer mode**, click **Load unpacked**, and select the extension directory.
|
|
568
568
|
- **Firefox**: open `about:debugging#/runtime/this-firefox` → **Load Temporary Add-on…** → pick `manifest.json` inside the printed extension directory. Firefox drops a temporary add-on on every restart; see [permanent Firefox install](#permanent-firefox-install) to avoid that.
|
|
569
569
|
3. Open an issue, press **Edit** on the body, and press **Outline criteria**. The new-issue form works the same way.
|
|
570
570
|
|
|
571
|
+
### Send to assist
|
|
572
|
+
|
|
573
|
+
The extension also adds an **assist** button beside each PR review comment, review and issue comment timestamp, and to the PR/issue header. Pressing it opens a popover with an optional instructions field; **Enter** sends (even when empty), **Shift+Enter** adds a newline and **Escape** closes. The background script POSTs the link and instructions to the assist web server's `POST /api/sessions/from-github` (`{ url, instructions? }`), which parses `owner/repo` from the GitHub URL, finds its clone under `clone.baseDir` and starts a Claude session there whose prompt is the link followed by the instructions, answering `{ sessionId, cwd }`. A toast reports the result: a URL that isn't a GitHub repo link gets a 400, a repo that isn't cloned gets a 404 saying so (nothing is cloned), and an unreachable server names the URL the extension tried. The endpoint has no auth and answers CORS only for `moz-extension://` and `chrome-extension://` origins.
|
|
574
|
+
|
|
575
|
+
Sending is Firefox-only (it relies on the `browser.*` promise APIs). The web server URL is set on the extension's options page (**about:addons** → the extension → **Options**) and defaults to `http://localhost:3100`. `host_permissions` covers any port on `localhost` and `127.0.0.1`; another host relies on the endpoint's CORS.
|
|
576
|
+
|
|
571
577
|
### Permanent Firefox install
|
|
572
578
|
|
|
573
579
|
Firefox release and beta only install signed add-ons, so a permanent install means having Mozilla sign the package. Signing uses AMO's **unlisted** (self-distribution) channel: Mozilla signs the `.xpi` and hands it back, with no public store listing and no human review queue.
|
|
574
580
|
|
|
575
|
-
Signing runs in CI, so the AMO key lives only as repo secrets and never on a developer machine. One-time setup: create an AMO API key at [addons.mozilla.org/developers/addon/api/key](https://addons.mozilla.org/en-US/developers/addon/api/key/) and add its two halves as the repo secrets `AMO_JWT_ISSUER` (the `user:12345678:123` issuer) and `AMO_JWT_SECRET`. The **
|
|
581
|
+
Signing runs in CI, so the AMO key lives only as repo secrets and never on a developer machine. One-time setup: create an AMO API key at [addons.mozilla.org/developers/addon/api/key](https://addons.mozilla.org/en-US/developers/addon/api/key/) and add its two halves as the repo secrets `AMO_JWT_ISSUER` (the `user:12345678:123` issuer) and `AMO_JWT_SECRET`. The **Extension** workflow maps them onto the `WEB_EXT_API_KEY` / `WEB_EXT_API_SECRET` that `web-ext` reads.
|
|
576
582
|
|
|
577
|
-
1. Each release signs a new add-on version on its own when it changed the extension (see below). To sign by hand, run the **
|
|
578
|
-
2. Download `
|
|
583
|
+
1. Each release signs a new add-on version on its own when it changed the extension (see below). To sign by hand, run the **Extension** workflow from the Actions tab (`gh workflow run extension.yml`). It checks out `main`, builds, signs the extension at assist's current version, and uploads the signed add-on to that version's GitHub release as `assist-extension.xpi`. A failed AMO submission fails the job and attaches nothing.
|
|
584
|
+
2. Download `assist-extension.xpi` from the release — the URL follows from the version, `https://github.com/staff0rd/assist/releases/download/v<version>/assist-extension.xpi`. `assist extension --url` (or `/extension`) prints the latest signed build's URL, read from the update manifest on `main`.
|
|
579
585
|
3. Open the `.xpi` in Firefox (drag it onto a window, or `about:addons` → gear → **Install Add-on From File…**). It survives restarts.
|
|
580
586
|
|
|
581
587
|
AMO refuses a version it has already signed, which is why the staged manifest carries assist's version instead of the manifest's `1.0.0` placeholder — sign once per release, not twice at the same version.
|
|
582
588
|
|
|
583
|
-
After each release, the **Release** workflow dispatches **
|
|
589
|
+
After each release, the **Release** workflow dispatches **Extension** for the new tag with `only-if-changed`, which runs `extensionChanged.ts`. A release signs a new add-on version only when, since the last signed version (read from `updates.json` on `main`), it changed `extension/`, `src/commands/extension/`, or any file under `src/commands/sessions/web/ui` that `content.js` bundles, so a change to a criterion row ships. Every other release skips signing and publishes nothing. Dependency bumps alone do not sign; dispatch by hand to ship one. The release workflow dispatches rather than the signing workflow listening for `release: published`, because a release published with `GITHUB_TOKEN` starts no other workflows.
|
|
590
|
+
|
|
591
|
+
Unlisted add-ons get no updates from AMO, so the manifest's `gecko.update_url` points at `extension/updates.json` on `main` instead. `--sign` writes that update manifest next to the `.xpi`, pointing at the signed version's release asset, and the workflow commits it back to `main` with `[skip ci]`, then dispatches **Release** so commits that a release run in flight skipped (seeing `main` move under it) still get released; an installed add-on then upgrades itself on Firefox's next update check (or **Check for Updates** in `about:addons`).
|
|
584
592
|
|
|
585
|
-
|
|
593
|
+
`assist extension --sign` still signs locally for someone who holds an AMO key: export `WEB_EXT_API_KEY` and `WEB_EXT_API_SECRET`, run `npm run build` (to refresh `content.js`), then the command. It stages a copy of the extension with assist's version stamped into `manifest.json`, shells out to `npx web-ext sign`, and writes the signed add-on to `~/.assist/extension/assist-extension.xpi`. Under WSL it copies that to `C:\tools\assist-extension.xpi` and prints the Windows path.
|
|
586
594
|
|
|
587
|
-
|
|
595
|
+
The add-on was previously called `assist criteria outliner` with the id `criteria-outliner@staff0rd.github.io`. It is now `assist` with the id `assist@staff0rd.github.io`, which Firefox treats as a different add-on, so an existing `assist criteria outliner` install no longer updates: remove it in `about:addons` and reinstall via `/extension`.
|
|
588
596
|
|
|
589
597
|
Two alternatives need no signing: **Firefox Developer Edition** or **Nightly** honour `xpinstall.signatures.required = false` in `about:config` and will then install an unsigned local `.xpi` permanently, and Chrome's **Load unpacked** already survives restarts, so the unpacked directory is one-time setup there.
|
|
590
598
|
|
package/allowed.cli-reads
CHANGED
package/dist/allowed.cli-reads
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(()=>{function o(){return globalThis.browser?.storage?.local}function i(s){let e;try{e=new URL(s.trim())}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return e.origin}var p="http://localhost:3100",a="serverUrl";async function u(){let e=(await o()?.get(a).catch(()=>{}))?.[a];return typeof e=="string"&&i(e)||p}function g(s){let{type:e,url:n}=s??{};return e==="assist-send"&&typeof n=="string"}function d(){return globalThis.browser?.runtime}async function l(s,{url:e,instructions:n}){let t;try{t=await fetch(`${s}/api/sessions/from-github`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e,instructions:n})})}catch{return{ok:!1,message:`assist web server unreachable at ${s}`}}let r=await t.json().catch(()=>({}));return t.ok?{ok:!0,message:`assist session started in ${r.cwd}`}:{ok:!1,message:r.error??`assist web server returned ${t.status}`}}function c(){d()?.onMessage.addListener(s=>{if(g(s))return u().then(e=>l(e,s))})}c();})();
|
package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/manifest.json
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
|
-
"name": "assist
|
|
3
|
+
"name": "assist",
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Brings assist to GitHub: an Outline criteria toggle that edits an issue's acceptance criteria as an outline, and an assist button that sends a comment, PR or issue to assist to start a session.",
|
|
6
6
|
"browser_specific_settings": {
|
|
7
7
|
"gecko": {
|
|
8
|
-
"id": "
|
|
8
|
+
"id": "assist@staff0rd.github.io",
|
|
9
9
|
"strict_min_version": "109.0",
|
|
10
|
-
"update_url": "https://raw.githubusercontent.com/staff0rd/assist/main/
|
|
10
|
+
"update_url": "https://raw.githubusercontent.com/staff0rd/assist/main/extension/updates.json"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"icons": {
|
|
@@ -21,7 +21,11 @@
|
|
|
21
21
|
"matches": ["https://github.com/*"]
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"
|
|
24
|
+
"permissions": ["storage"],
|
|
25
|
+
"host_permissions": ["http://localhost/*", "http://127.0.0.1/*"],
|
|
26
|
+
"options_ui": {
|
|
27
|
+
"page": "options.html"
|
|
28
|
+
},
|
|
25
29
|
"background": {
|
|
26
30
|
"scripts": ["background.js"]
|
|
27
31
|
},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
font:
|
|
8
|
+
14px/20px -apple-system,
|
|
9
|
+
BlinkMacSystemFont,
|
|
10
|
+
sans-serif;
|
|
11
|
+
margin: 16px;
|
|
12
|
+
}
|
|
13
|
+
label {
|
|
14
|
+
display: block;
|
|
15
|
+
margin-bottom: 4px;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
}
|
|
18
|
+
input {
|
|
19
|
+
width: 320px;
|
|
20
|
+
padding: 4px 6px;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
<form>
|
|
26
|
+
<label for="serverUrl">assist web server URL</label>
|
|
27
|
+
<input id="serverUrl" name="serverUrl" type="url" required />
|
|
28
|
+
<button type="submit">Save</button>
|
|
29
|
+
<span data-status role="status"></span>
|
|
30
|
+
</form>
|
|
31
|
+
<script src="options.js"></script>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(()=>{function n(){return globalThis.browser?.storage?.local}function o(t){let e;try{e=new URL(t.trim())}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return e.origin}var c="http://localhost:3100",s="serverUrl";async function u(){let e=(await n()?.get(s).catch(()=>{}))?.[s];return typeof e=="string"&&o(e)||c}function a(t,e){let r=t.querySelector(e);if(!r)throw new Error(`options page is missing ${e}`);return r}async function d(t=document){let e=a(t,"form"),r=a(t,"input[name=serverUrl]"),l=a(t,"[data-status]");r.value=await u(),e.addEventListener("submit",async m=>{m.preventDefault();let i=o(r.value);if(!i){l.textContent="Enter an http:// or https:// URL";return}await n()?.set({[s]:i}),r.value=i,l.textContent="Saved"})}typeof document<"u"&&document.querySelector("form")&&d();})();
|
|
@@ -4009,7 +4009,7 @@ ${f.join(`
|
|
|
4009
4009
|
`)})}var XB=R(z(),1);function D0r({entry:e,state:t,actions:r}){return(0,XB.jsxs)(ie,{sx:{px:2,pb:2,pl:{xs:2,sm:7.5},display:"grid",gap:1.5},children:[(0,XB.jsx)(M0r,{entry:e,state:t,actions:r}),(0,XB.jsx)(Ie,{variant:"caption",color:"text.secondary",children:"History \xB7 ~/.assist/watchers/"}),(0,XB.jsx)(I0r,{lines:e.status?.history??[]})]})}function ZB(e){let t=e.status?.loop;return t!==void 0&&(t.phase!=="off"||t.paused===!0)}var QB=R(z(),1),Qjn={display:"flex",gap:.5,flexWrap:"wrap",justifyContent:{xs:"flex-start",sm:"flex-end"},gridColumn:{xs:"1 / -1",sm:"auto"}};function N0r({entry:e,state:t,actions:r}){let n=r.notices.busy[e.name],i=e.status?.loop.paused===!0;return(0,QB.jsxs)(ie,{sx:Qjn,children:[t.kind==="ready"&&(0,QB.jsx)(z0e,{entry:e,actions:r}),t.kind==="diverged"&&(0,QB.jsx)(B0e,{entry:e,actions:r}),ZB(e)&&(0,QB.jsx)(Ut,{size:"small",disabled:n!==void 0,onClick:()=>{r.control(e,i?"resume":"pause")},children:i?"Resume":"Pause"})]})}var Jjn={ready:"warning",diverged:"error"},O0r=e=>t=>{let r=Jjn[e];return{display:"grid",gridTemplateColumns:{xs:"28px minmax(0,1fr)",sm:"28px minmax(0,1.3fr) minmax(0,1fr) minmax(0,1.6fr) auto"},alignItems:"center",columnGap:1.5,rowGap:1,px:2,py:1.5,boxShadow:r?`inset 3px 0 0 ${t.palette[r].main}`:"none"}};var B0r=R(z(),1),F0r=st((0,B0r.jsx)("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8z"}),"ArrowUpward");var $0r=R(z(),1),z0r=st((0,$0r.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.48 0-2.85.43-4.01 1.17l1.46 1.46C10.21 6.23 11.08 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 1.13-.64 2.11-1.56 2.62l1.45 1.45C23.16 18.16 24 16.68 24 15c0-2.64-2.05-4.78-4.65-4.96M3 5.27l2.75 2.74C2.56 8.15 0 10.77 0 14c0 3.31 2.69 6 6 6h11.73l2 2L21 20.73 4.27 4zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4z"}),"CloudOff");var H0r=R(z(),1),U0r=st((0,H0r.jsx)("path",{d:"M6 19h4V5H6zm8-14v14h4V5z"}),"Pause");var W0r=R(z(),1),V0r=st((0,W0r.jsx)("path",{d:"M13 3h-2v10h2zm4.83 2.17-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83"}),"PowerSettingsNew");var G0r=R(z(),1),q0r=st((0,G0r.jsx)("path",{d:"M1 21h22L12 2zm12-3h-2v-2h2zm0-4h-2v-4h2z"}),"Warning");var dv=R(z(),1),eYn={ok:{tone:"success",icon:(0,dv.jsx)(gy,{})},ready:{tone:"warning",icon:(0,dv.jsx)(F0r,{})},diverged:{tone:"error",icon:(0,dv.jsx)(q0r,{})},retrying:{tone:"warning",icon:(0,dv.jsx)(Ute,{})},paused:{tone:"neutral",icon:(0,dv.jsx)(U0r,{})},off:{tone:"neutral",icon:(0,dv.jsx)(V0r,{})},unavailable:{tone:"neutral",icon:(0,dv.jsx)(z0r,{})}};function tYn(e,t){return t==="neutral"?e.palette.text.secondary:e.palette[t].main}function j0r({state:e}){let{tone:t,icon:r}=eYn[e.kind];return(0,dv.jsxs)(ie,{component:"span",sx:n=>({alignSelf:"flex-start",display:"inline-flex",alignItems:"center",gap:.75,height:24,px:1.25,borderRadius:3,fontSize:12,fontWeight:500,whiteSpace:"nowrap",color:tYn(n,t),bgcolor:t==="neutral"?n.palette.action.hover:zo(n.palette[t].main,.1),border:t==="neutral"?`1px solid ${n.palette.divider}`:0,"& svg":{fontSize:14}}),children:[r,e.label]})}var fK=R(z(),1);function Y0r({state:e}){return(0,fK.jsxs)(ie,{sx:{...O0e,gridColumn:{xs:"2",sm:"auto"},gap:.25},children:[(0,fK.jsx)(j0r,{state:e}),(0,fK.jsx)(Ie,{variant:"caption",color:"text.secondary",noWrap:!0,children:e.line})]})}var hv=R(z(),1),K0r={gridColumn:{xs:"2",sm:"auto"}},rYn={fontFamily:"'Roboto Mono', ui-monospace, Menlo, monospace",fontSize:12,fontVariantNumeric:"tabular-nums"};function X0r({entry:e}){let t=e.status;if(!t)return(0,hv.jsx)(Ie,{variant:"caption",color:"text.secondary",sx:K0r,children:"\u2014"});let r=t.running!==t.built;return(0,hv.jsxs)(ie,{sx:{...K0r,display:"flex",flexDirection:"column"},children:[(0,hv.jsxs)(ie,{component:"span",sx:rYn,children:["v",t.running,r&&(0,hv.jsxs)(hv.Fragment,{children:[" ",(0,hv.jsx)(ie,{component:"span",sx:{color:"warning.main"},children:"\u2192"})," ","v",t.built]})]}),(0,hv.jsx)(Ie,{variant:"caption",color:"text.secondary",children:r?"running \u2192 built":"running"})]})}function JB(e){return(e.status?.restart.length??0)>0}function Z0r(e,t){return e.paused?{kind:"paused",label:"Paused",line:"won't pull until resumed"}:e.phase==="off"?{kind:"off",label:"Off",line:e.reason??"not running"}:e.phase==="retrying"?{kind:"retrying",label:"Retrying",line:`${e.reason??"lap failed"} \xB7 ${t}`}:{kind:"ok",label:"Up to date",line:`watching origin since ${t}`}}function Kk(e){let{status:t}=e;if(!t)return{kind:"unavailable",label:"Unavailable",line:e.error??"no update state"};let{loop:r}=t,n=wo(r.since);return r.phase==="diverged"?{kind:"diverged",label:"Diverged \xB7 fixing",line:`diverged ${n}${r.escalationId?` \xB7 session ${r.escalationId}`:""}`}:JB(e)?{kind:"ready",label:"Restart to update",line:`restart ${t.restart.map(YB).join(" + ")}${r.paused?" \xB7 paused":""}`}:Z0r(r,n)}var pv=R(z(),1);function J0r({entry:e,actions:t}){let[r,n]=(0,Q0r.useState)(!1),i=Kk(e);return(0,pv.jsxs)(ie,{component:"article",sx:{"& + &":{borderTop:1,borderColor:"divider"}},children:[(0,pv.jsxs)(ie,{sx:O0r(i.kind),children:[(0,pv.jsx)(_0r,{open:r,label:`${r?"Hide":"Show"} history for ${e.name}`,onToggle:()=>n(o=>!o)}),(0,pv.jsx)(E0r,{entry:e}),(0,pv.jsx)(X0r,{entry:e}),(0,pv.jsx)(Y0r,{state:i}),(0,pv.jsx)(N0r,{entry:e,state:i,actions:t})]}),r&&(0,pv.jsx)(D0r,{entry:e,state:i,actions:t})]})}var eyr=R(z(),1),U0e=st((0,eyr.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");var zHe=R(he(),1);var eF=R(z(),1);function tyr({entries:e,actions:t}){let[r,n]=(0,zHe.useState)(!1),[i,o]=(0,zHe.useState)(!1),a=e.filter(l=>Kk(l).kind==="ready").length,s=e.some(l=>ZB(l)&&!l.status?.loop.paused);return(0,eF.jsxs)(ie,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:[(0,eF.jsx)(Ut,{variant:"outlined",size:"small",startIcon:(0,eF.jsx)(U0e,{}),disabled:!s||r,onClick:()=>{n(!0),t.checkAll(e).finally(()=>n(!1))},children:"Check now"}),(0,eF.jsx)(Ut,{variant:"contained",size:"small",disabled:a===0||i,onClick:()=>{o(!0),t.restartReady(e).finally(()=>o(!1))},children:a?`Restart ready nodes (${a})`:"Restart ready nodes"})]})}function ryr(e){let t=e.map(o=>Kk(o).kind),r=o=>t.filter(a=>a===o).length,n=r("ready"),i=[`${e.length} node${e.length===1?"":"s"}`];return i.push(n?`${n} ready to restart`:"all running their latest build"),r("diverged")&&i.push(`${r("diverged")} diverged`),r("unavailable")&&i.push(`${r("unavailable")} unavailable`),i.join(" \xB7 ")}var myr=R(he(),1);function nyr(e,t){return`${e}:${t}`}var HHe=R(he(),1);async function tF(e){if(!e)return"web server unreachable";try{return(await e.json()).error??`HTTP ${e.status}`}catch{return`HTTP ${e.status}`}}async function iyr(e,t){let r;try{r=await fetch(Xr(`/api/updates/control?action=${t}`,e.local?void 0:e.name),{method:"POST"})}catch{}return r?.ok?void 0:tF(r)}var nYn=5e3,oyr={pause:"Pausing",resume:"Resuming",check:"Checking"};function ayr(e,t){let{mark:r,setError:n,setBack:i}=e,o=(0,HHe.useCallback)(async(s,l)=>{r(s.name,oyr[l]);let u=await iyr(s,l);return u&&n(`${oyr[l]} ${s.name} failed: ${u}`),r(s.name),t(),!u&&l==="check"&&setTimeout(t,nYn),!u},[r,n,t]),a=(0,HHe.useCallback)(async s=>{let l=s.filter(d=>ZB(d)&&!d.status?.loop.paused),f=(await Promise.all(l.map(d=>o(d,"check")))).filter(Boolean).length;f&&i(`Checking ${f} node${f===1?"":"s"} against origin`)},[o,i]);return{control:o,checkAll:a}}var UHe=R(he(),1);var mv=R(he(),1);var rF={target:"both",label:"Restart daemon",message:"This restarts the sessions daemon and the web server, then reloads the page once the server is back."};function Xk(e,t){let r=t?`&node=${encodeURIComponent(t)}`:"";return fetch(`/api/restart?target=${e}${r}`,{method:"POST"})}var K2=R(he(),1);var iYn="/api/session-layout";async function oYn(){try{return(await fetch(iYn,{cache:"no-store"})).ok}catch{return!1}}async function syr(e){let t=0;for(;!e();){if(t=await oYn()?t+1:0,t>=2)return!e();await new Promise(r=>setTimeout(r,300))}return!1}function aYn(){return{sawDisconnect:!1,waiting:!1,abandoned:!0}}function lyr(e,t,r){let n=(0,K2.useRef)(aYn()),i=(0,K2.useRef)(r);i.current=r,(0,K2.useEffect)(()=>{let s=n.current;if(!(!e||s.abandoned)){if(t){s.sawDisconnect=!0;return}!s.sawDisconnect||s.waiting||(s.waiting=!0,syr(()=>s.abandoned).then(l=>{l&&i.current()}))}},[e,t]);let o=(0,K2.useCallback)(()=>{n.current.abandoned=!0},[]),a=(0,K2.useCallback)(()=>{n.current.abandoned=!0,n.current={sawDisconnect:!1,waiting:!1,abandoned:!1}},[]);return(0,K2.useEffect)(()=>o,[o]),{arm:a,abandon:o}}var sYn=15e3;function Zk(e,t,r){let[n,i]=(0,mv.useState)(!1),[o,a]=(0,mv.useState)(null),s=(0,mv.useRef)(void 0),{arm:l,abandon:u}=lyr(n,t,()=>{clearTimeout(s.current),r?.(),globalThis.location.reload()});(0,mv.useEffect)(()=>()=>clearTimeout(s.current),[]);let f=(0,mv.useCallback)(async h=>{i(!0),l(),s.current=setTimeout(()=>{u(),i(!1),a("Web server did not come back")},sYn);try{if(!(await Xk(h)).ok)throw new Error("restart failed")}catch{u(),clearTimeout(s.current),i(!1),a("Failed to restart web server")}},[l,u]),d=(0,mv.useCallback)(()=>f(e),[f,e]);return{pending:n,error:o,clearError:()=>a(null),restart:d,restartTo:f}}function W0e(e){return e.local&&JB(e)}async function V0e(e,t){try{let r=await fetch(Xr("/api/updates",t?void 0:e)),n=await r.json();if(!r.ok)throw new Error(n?.error??`HTTP ${r.status}`);return{name:e,local:t,status:n}}catch(r){return{name:e,local:t,error:r instanceof Error?r.message:"Failed to load update state"}}}var lYn=2e3,cYn=9e4,uYn=e=>new Promise(t=>setTimeout(t,e));async function cyr(e,t){let r=Date.now()+cYn;for(;Date.now()<r;){await uYn(lYn);let n=await V0e(e.name,e.local),i=n.status;if(i?.daemonReachable&&!t.some(o=>i.restart.includes(o)))return n}}async function uyr(e,t,r){let n;try{n=await Xk(t,e.local?void 0:e.name)}catch{}if(!n?.ok)throw new Error(await tF(n));let i=await cyr(e,r);if(!i?.status)throw new Error(`${e.name} did not come back`);return i.status.running}async function fyr(e,t,r){try{let n=await uyr(e,t,e.status?.restart??[]);r.setBack(`${e.name} is running v${n}`)}catch(n){r.setError(`Restart ${e.name} failed: ${n instanceof Error?n.message:String(n)}`)}}function dyr(e){return e.length>1?"both":e[0]}function hyr(e,t,r){let n=Zk("webserver",e),i=(0,UHe.useCallback)(async a=>{let s=dyr(a.status?.restart??[]);if(s){if(t.mark(a.name,"Restarting"),W0e(a))return n.restartTo(s==="daemon"?"both":s);await fyr(a,s,t),t.mark(a.name),r()}},[n,t,r]),o=(0,UHe.useCallback)(async a=>{let s=a.filter(l=>Kk(l).kind==="ready");await Promise.all(s.filter(l=>!W0e(l)).map(l=>i(l)));for(let l of s.filter(W0e))await i(l)},[i]);return{restart:i,restartReady:o,localError:n.error,clearLocalError:n.clearError}}var nF=R(he(),1);function pyr(){let[e,t]=(0,nF.useState)(null),[r,n]=(0,nF.useState)(null),[i,o]=(0,nF.useState)({}),a=(0,nF.useCallback)((s,l)=>{o(u=>{let f={...u};return l?f[s]=l:delete f[s],f})},[]);return{busy:i,mark:a,back:e,setBack:t,clearBack:()=>t(null),error:r,setError:n,clearError:()=>n(null)}}function gyr(e,t){let{refresh:r}=qB(),n=pyr(),i=hyr(e,n,r),o=ayr(n,r),a=wS(t),s=(0,myr.useCallback)(l=>{let u=l.status?.loop.escalationId;u&&a(l.local?u:nyr(l.name,u))},[a]);return{...i,...o,openFix:s,notices:n}}var k0=R(z(),1);function yyr({reconnecting:e,selectSession:t}){let{entries:r,loading:n}=qB(),i=gyr(e,t),{notices:o}=i;return(0,k0.jsxs)(ql,{loading:n,header:(0,k0.jsxs)(ie,{sx:{display:"flex",alignItems:"flex-end",gap:2,flexWrap:"wrap",mb:3},children:[(0,k0.jsxs)(ie,{sx:{flex:"1 1 auto"},children:[(0,k0.jsx)(Ie,{variant:"h5",component:"h1",children:"Updates"}),(0,k0.jsx)(Ie,{variant:"body2",color:"text.secondary",children:ryr(r)})]}),(0,k0.jsx)(tyr,{entries:r,actions:i})]}),children:[(0,k0.jsx)(cn,{variant:"outlined",component:"section","aria-label":"Nodes",children:r.map(a=>(0,k0.jsx)(J0r,{entry:a,actions:i},a.name))}),(0,k0.jsx)(cK,{notices:{...o,error:o.error??i.localError,clearError:()=>{o.clearError(),i.clearLocalError()}}})]})}var o1r=R(he(),1);var iF=R(he(),1);function G0e(e,t){let r=(0,iF.useRef)(null),[n,i]=(0,iF.useState)();return(0,iF.useLayoutEffect)(()=>{e===t&&r.current&&i(r.current.offsetHeight)},[e,t]),{ref:r,height:n}}var byr=R(he(),1);function q0e(e){if(e.startsWith("local:")){let n=e.slice(6).replace(/\/+$/,"").split("/").filter(Boolean);return n[n.length-1]??e}let t=e.indexOf("/");return t===-1?e:e.slice(t+1)}function j0e(e){let t=o=>o.startsWith("local:"),r=o=>{let a=q0e(o),s=a.split("/");return s[s.length-1]??a},n=new Map;for(let o of new Set(e)){if(t(o))continue;let a=r(o);n.set(a,(n.get(a)??0)+1)}let i=new Map;for(let o of e){if(t(o)){i.set(o,q0e(o));continue}let a=r(o),s=(n.get(a)??0)>1;i.set(o,s?q0e(o):a)}return i}var dK={field:"lastPhase",direction:"desc"};var hK="all",pK="all";async function vyr(e,t,r){let n=new URLSearchParams({page:String(e),pageSize:String(t)});r.origin!==hK&&n.set("origin",r.origin),r.status!==pK&&n.set("status",r.status),r.sort.field!==dK.field&&n.set("sort",r.sort.field),r.sort.direction!==dK.direction&&n.set("direction",r.sort.direction);let i=await fetch(`/api/usage/items?${n}`);if(!i.ok)throw new Error(`Failed to load item usage (HTTP ${i.status}).`);return i.json()}var mK=R(z(),1);function xyr({origins:e,origin:t,onChange:r}){let n=(0,byr.useMemo)(()=>j0e(e.map(o=>o.origin)),[e]),i=e.reduce((o,a)=>o+a.count,0);return(0,mK.jsxs)(qn,{select:!0,size:"small",label:"Repo",value:t,onChange:o=>r(o.target.value),sx:{minWidth:220},children:[(0,mK.jsx)(hn,{value:hK,children:`All repos (${i})`}),e.map(o=>(0,mK.jsx)(hn,{value:o.origin,children:`${n.get(o.origin)??o.origin} (${o.count})`},o.origin))]})}var WHe=R(z(),1),fYn=[{value:pK,label:"All"},{value:"done",label:"Done"},{value:"running",label:"Running"}];function Tyr({status:e,onChange:t}){return(0,WHe.jsx)(Cu,{size:"small",exclusive:!0,value:e,onChange:(r,n)=>n&&t(n),"aria-label":"Filter items by status",children:fYn.map(r=>(0,WHe.jsx)(bs,{value:r.value,children:r.label},r.value))})}var oF=R(z(),1),dYn={display:"flex",alignItems:"center",gap:2,flexWrap:"wrap",mb:2},hYn="Repos show their bare name, or org/repo when two share one. Totals sum every phase's recorded usage.";function Syr({origins:e,origin:t,onOriginChange:r,status:n,onStatusChange:i}){return(0,oF.jsxs)(ie,{sx:dYn,children:[(0,oF.jsx)(Tyr,{status:n,onChange:i}),(0,oF.jsx)(xyr,{origins:e,origin:t,onChange:r}),(0,oF.jsx)(Ie,{variant:"caption",color:"text.disabled",children:hYn})]})}var Dyr=R(he(),1);function nh(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function _0(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let r=Math.floor(t/60);if(r<60){let o=t%60;return o>0?`${r}m ${o}s`:`${r}m`}let n=Math.floor(r/60),i=r%60;return i>0?`${n}h ${i}m`:`${n}h`}var K0e=R(z(),1),pYn={whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},Cyr={display:"block",fontSize:"0.75rem",color:"text.disabled",whiteSpace:"nowrap"},mYn={...Cyr,fontStyle:"italic"};function Y0e({total:e,perPhase:t,partial:r}){return(0,K0e.jsxs)(_n,{align:"right",sx:pYn,children:[e,t?(0,K0e.jsx)(Ie,{component:"span",sx:r?mYn:Cyr,children:t}):null]})}var gK=R(z(),1),gYn={width:"100%",maxWidth:0},yYn={display:"block",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},vYn={display:"block",mt:"2px",fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function wyr({id:e,name:t,type:r,repoLabel:n}){return(0,gK.jsxs)(_n,{sx:gYn,children:[(0,gK.jsx)(jr,{component:Cs,to:cS(e),underline:"hover",color:"text.primary",title:t,sx:yYn,children:t}),(0,gK.jsxs)(Ie,{component:"span",sx:vYn,children:[ho(e)," \xB7 ",r," \xB7 ",n]})]})}function kyr(e){let t=Math.max(1,e.recordedPhases);return{active:`${_0(e.activeMs/t)} / phase`,tokens:`${nh(Math.round((e.tokensUp+e.tokensDown)/t))} / phase`}}function _yr(e){if(!(e.status==="done"||e.recordedPhases>e.phaseCount))return`${e.recordedPhases} of ${e.phaseCount} phases`}var X0e={story:"info",bug:"error"},Z0e={todo:"default","in-progress":"warning",done:"success",wontdo:"error"};var bYn=new Set(["done","wontdo"]);function Eyr(e){return bYn.has(e)?{label:e,color:Z0e[e]}:{label:"running",color:"warning"}}var VHe=R(z(),1),xYn={height:20,fontSize:"0.6875rem"};function Ryr({status:e}){let t=Eyr(e);return(0,VHe.jsx)(_n,{children:(0,VHe.jsx)(en,{label:t.label,size:"small",variant:"outlined",color:t.color,sx:xYn})})}var E0=R(z(),1),Ayr={whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"};function Pyr({row:e,repoLabel:t}){let r=kyr(e);return(0,E0.jsxs)(cf,{hover:!0,children:[(0,E0.jsx)(wyr,{id:e.id,name:e.name,type:e.type,repoLabel:t}),(0,E0.jsx)(Ryr,{status:e.status}),(0,E0.jsx)(Y0e,{total:String(e.phaseCount||e.recordedPhases),perPhase:_yr(e),partial:!0}),(0,E0.jsx)(Y0e,{total:_0(e.activeMs),perPhase:r.active}),(0,E0.jsx)(Y0e,{total:`\u2191 ${nh(e.tokensUp)} \u2193 ${nh(e.tokensDown)}`,perPhase:r.tokens}),(0,E0.jsx)(_n,{align:"right",sx:Ayr,children:(0,E0.jsxs)(ie,{component:"span",sx:{color:cte(e.peakContextPct)},children:[Math.round(e.peakContextPct),"%"]})}),(0,E0.jsx)(_n,{align:"right",sx:Ayr,children:e.lastPhaseAt?wo(e.lastPhaseAt):"\u2014"})]})}var Lyr=[{label:"Item"},{label:"Status"},{label:"Phases",sort:"phases",numeric:!0},{label:"Active",sort:"active",numeric:!0,tooltip:"Accumulated active time across the item's phases \u2014 not wall clock."},{label:"Tokens",sort:"tokens",numeric:!0},{label:"Peak ctx",sort:"peakContext",numeric:!0,tooltip:"The highest context-window usage any one phase reached."},{label:"Last phase",sort:"lastPhase",numeric:!0,tooltip:"When the item's most recent phase session started."}];var og=R(z(),1),TYn={"& th":{whiteSpace:"nowrap"}};function Myr({column:e}){return e.tooltip?(0,og.jsx)(sr,{title:e.tooltip,describeChild:!0,children:(0,og.jsx)("span",{children:e.label})}):(0,og.jsx)(og.Fragment,{children:e.label})}function Iyr({sort:e,onSort:t}){return(0,og.jsx)(g5,{sx:TYn,children:(0,og.jsx)(cf,{children:Lyr.map(r=>{let n=r.sort,i=n!==void 0&&e.field===n;return(0,og.jsx)(_n,{align:r.numeric?"right":"left",sortDirection:i?e.direction:!1,children:n===void 0?(0,og.jsx)(Myr,{column:r}):(0,og.jsx)(oxe,{active:i,direction:i?e.direction:"desc",onClick:()=>t(n),children:(0,og.jsx)(Myr,{column:r})})},r.label)})})})}var iA=R(z(),1),SYn={"& td, & th":{px:1.5}};function Nyr({rows:e,origins:t,sort:r,onSort:n}){let i=(0,Dyr.useMemo)(()=>j0e([...t,...e.map(o=>o.origin)]),[t,e]);return(0,iA.jsx)(m5,{component:cn,children:(0,iA.jsxs)(Yv,{size:"small",sx:SYn,children:[(0,iA.jsx)(Iyr,{sort:r,onSort:n}),(0,iA.jsx)(Kv,{children:e.map(o=>(0,iA.jsx)(Pyr,{row:o,repoLabel:i.get(o.origin)??o.origin},o.id))})]})})}function Oyr(e){let t=Math.max(1,e.medianPhases),r=e.repoCount===1?"repo":"repos";return{items:String(e.itemCount),itemsFoot:`across ${e.repoCount} ${r} \xB7 ${e.doneCount} done`,phases:String(Math.round(e.medianPhases*10)/10),active:_0(e.medianActiveMs),activeFoot:`${_0(e.medianActiveMs/t)} per phase`,tokens:nh(Math.round(e.medianTokens)),tokensFoot:`${nh(Math.round(e.medianTokens/t))} per phase`}}var aF=R(z(),1),Byr={display:"block"},CYn={fontWeight:400,fontVariantNumeric:"tabular-nums"};function yK({label:e,value:t,foot:r}){return(0,aF.jsxs)(ie,{children:[(0,aF.jsx)(Ie,{variant:"caption",color:"text.secondary",sx:Byr,children:e}),(0,aF.jsx)(Ie,{variant:"h5",sx:CYn,children:t}),r?(0,aF.jsx)(Ie,{variant:"caption",color:"text.disabled",sx:Byr,children:r}):null]})}var oA=R(z(),1),wYn={display:"flex",flexDirection:{xs:"column",sm:"row"},mb:3,"& > *":{flex:1,minWidth:0,p:2},"& > * + *":{borderColor:"divider",borderTop:{xs:1,sm:0},borderLeft:{xs:0,sm:1}}};function Fyr({summary:e}){let t=Oyr(e);return(0,oA.jsxs)(cn,{sx:wYn,children:[(0,oA.jsx)(yK,{label:"Items with recorded usage",value:t.items,foot:t.itemsFoot}),(0,oA.jsx)(yK,{label:"Median phases",value:t.phases}),(0,oA.jsx)(yK,{label:"Median active time",value:t.active,foot:t.activeFoot}),(0,oA.jsx)(yK,{label:"Median tokens",value:t.tokens,foot:t.tokensFoot})]})}var Tp=R(z(),1);function $yr({items:e,data:t}){let{rows:r,total:n,page:i,pageSize:o}=e,{ref:a,height:s}=G0e(r.length,o);return(0,Tp.jsxs)(Tp.Fragment,{children:[(0,Tp.jsx)(Fyr,{summary:t.summary}),(0,Tp.jsx)(Syr,{origins:t.origins,origin:e.origin,onOriginChange:e.selectOrigin,status:e.status,onStatusChange:e.selectStatus}),n===0?(0,Tp.jsx)(Ie,{color:"text.secondary",align:"center",sx:{py:6},children:"No items match this filter."}):(0,Tp.jsxs)(Tp.Fragment,{children:[(0,Tp.jsx)(ie,{ref:a,sx:{minHeight:s},children:(0,Tp.jsx)(Nyr,{rows:r,origins:t.origins.map(l=>l.origin),sort:e.sort,onSort:e.sortBy})}),(0,Tp.jsx)(dz,{component:"div",count:n,page:i,rowsPerPage:o,rowsPerPageOptions:[o],onPageChange:(l,u)=>e.setPage(u)})]})]})}var X2=R(z(),1);function zyr({items:e}){let{data:t}=e;return(0,X2.jsxs)(X2.Fragment,{children:[(0,X2.jsx)(ie,{sx:{height:4,mb:1},children:e.fetching&&(0,X2.jsx)(p5,{})}),t?t.origins.length===0?(0,X2.jsx)(Ie,{color:"text.secondary",align:"center",sx:{py:6},children:"No item usage recorded yet."}):(0,X2.jsx)($yr,{items:e,data:t}):null]})}function GHe(e,t,r){if(e==null)return;let n=Math.max(0,e-r),i=Math.max(0,t-n)/t;if(!(i<.05))return i}function Q0e(e,t){let r=Math.max(0,e-t),n=Math.floor(r/86400),i=Math.floor(r%86400/3600),o=Math.floor(r%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function kYn(e,t,r,n){let i=GHe(t,r,n);if(i!=null)return e/i}function Qk(e,t,r,n){let i=kYn(e,t,r,n);return i==null?"ok":i>100?"over":i>75?"warn":"ok"}var _Yn=["five_hour","seven_day"],EYn=["claude","codex","pi"];function Hyr(e){let[t,r]=e.includes(":")?e.split(":",2):["claude",e],n=EYn.find(o=>o===t),i=_Yn.find(o=>o===r);if(!(!n||!i)&&!(n==="claude"&&e.includes(":")))return{harness:n,window:i}}var Uyr={five_hour:{label:"5h",seconds:18e3},seven_day:{label:"7d",seconds:604800,tint:{light:"rgba(0, 0, 0, 0.1)",dark:"rgba(255, 255, 255, 0.1)"}}};function sF(e){let t=Hyr(e);if(!t)return Uyr.five_hour;let r=Uyr[t.window];return t.harness==="claude"?r:{...r,label:`${Eu(t.harness)} ${r.label}`}}var RYn={ok:"success.main",warn:"warning.main",over:"error.main"};function Jk(e){return RYn[e]}var xK=R(z(),1),AYn={ok:"success",warn:"warning",over:"error"};function Wyr({percentage:e,level:t}){return(0,xK.jsxs)(ie,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,xK.jsx)(p5,{variant:"determinate",value:Math.min(100,e),color:AYn[t],sx:{flexGrow:1,height:8,borderRadius:1}}),(0,xK.jsxs)(ie,{sx:{minWidth:40,textAlign:"right",color:Jk(t)},children:[Math.round(e),"%"]})]})}function Vyr(e){return e.avgContextPct==null?"\u2014":`${Math.round(e.avgContextPct)}%`}var PYn=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function qHe(e){return PYn.format(e)}var J0e=R(z(),1);function Gyr({peak:e}){return(0,J0e.jsx)(_n,{align:"right",sx:{whiteSpace:"nowrap"},children:(0,J0e.jsx)(sr,{title:`Cycle started ${qHe(new Date(e.createdAt))}`,children:(0,J0e.jsx)("span",{children:qHe(new Date(e.resetsAt*1e3))})})})}var jyr=R(z(),1);function qyr(){return(0,jyr.jsx)(en,{label:"reset",size:"small",color:"warning",variant:"outlined",title:"Quota reset mid-cycle \u2014 this is the peak reached before the reset.",sx:{ml:1}})}function Yyr(e){return!e.tokensUp&&!e.tokensDown?"\u2014":`\u2191 ${nh(e.tokensUp)} \u2193 ${nh(e.tokensDown)}`}var R0=R(z(),1);function Kyr({peak:e,now:t}){let{label:r,seconds:n,tint:i}=sF(e.window),o=Qk(e.usedPercentage,e.resetsAt,n,t);return(0,R0.jsxs)(cf,{sx:a=>({backgroundColor:i?a.palette.mode==="dark"?i.dark:i.light:void 0}),children:[(0,R0.jsxs)(_n,{children:[r,e.resetDetected&&(0,R0.jsx)(qyr,{})]}),(0,R0.jsx)(_n,{sx:{minWidth:160},children:(0,R0.jsx)(Wyr,{percentage:e.usedPercentage,level:o})}),(0,R0.jsx)(_n,{align:"right",sx:{whiteSpace:"nowrap"},children:Vyr(e)}),(0,R0.jsx)(_n,{align:"right",sx:{whiteSpace:"nowrap"},children:e.phaseCount??0}),(0,R0.jsx)(_n,{align:"right",sx:{whiteSpace:"nowrap"},children:Yyr(e)}),(0,R0.jsx)(Gyr,{peak:e})]})}var eye=R(he(),1);function e_(e){let[t,r]=(0,eye.useState)(()=>Math.floor(Date.now()/1e3));return(0,eye.useEffect)(()=>{let n=setInterval(()=>r(Math.floor(Date.now()/1e3)),e);return()=>clearInterval(n)},[e]),t}var Sc=R(z(),1);function Xyr({peaks:e}){let t=e_(3e4);return(0,Sc.jsx)(m5,{component:cn,children:(0,Sc.jsxs)(Yv,{size:"small",children:[(0,Sc.jsx)(g5,{sx:{"& th":{whiteSpace:"nowrap"}},children:(0,Sc.jsxs)(cf,{children:[(0,Sc.jsx)(_n,{children:"Window"}),(0,Sc.jsx)(_n,{children:"Peak usage"}),(0,Sc.jsx)(_n,{align:"right",children:(0,Sc.jsx)(sr,{title:"Mean context-window usage across all readings in this rate-limit cycle \u2014 distinct from the Peak usage quota above.",children:(0,Sc.jsx)("span",{children:"Avg context"})})}),(0,Sc.jsx)(_n,{align:"right",children:(0,Sc.jsx)(sr,{title:"Number of phase readings behind the average.",children:(0,Sc.jsx)("span",{children:"Phases"})})}),(0,Sc.jsx)(_n,{align:"right",children:"Tokens spent"}),(0,Sc.jsx)(_n,{align:"right",children:"Cycle reset"})]})}),(0,Sc.jsx)(Kv,{children:e.map(r=>(0,Sc.jsx)(Kyr,{peak:r,now:t},`${r.window}-${r.resetsAt}-${r.segment}`))})]})})}var t_=R(z(),1);function Zyr({rows:e,total:t,page:r,pageSize:n,onPageChange:i}){let{ref:o,height:a}=G0e(e.length,n);return(0,t_.jsxs)(t_.Fragment,{children:[(0,t_.jsx)(ie,{ref:o,sx:{minHeight:a},children:(0,t_.jsx)(Xyr,{peaks:e})}),(0,t_.jsx)(dz,{component:"div",count:t,page:r,rowsPerPage:n,rowsPerPageOptions:[n],onPageChange:(s,l)=>i(l)})]})}var TK=R(he(),1);function r_(){let[e,t]=(0,TK.useState)(!1),[r,n]=(0,TK.useState)(!1);return(0,TK.useEffect)(()=>{let i=!1;return(async()=>{try{let a=await(await fetch("/api/harness")).json();i||(t(!!a?.exposeCodexActions),n(!!a?.exposePiActions))}catch{t(!1),n(!1)}})(),()=>{i=!0}},[]),{exposeCodexActions:e,exposePiActions:r}}var jHe=R(z(),1),Qyr=["five_hour","seven_day"],LYn=["codex:five_hour","codex:seven_day"];function MYn(e){let t=e?[...Qyr,...LYn]:Qyr;return[{value:"all",label:"All"},...t.map(r=>({value:r,label:sF(r).label}))]}function Jyr({window:e,onChange:t}){let{exposeCodexActions:r}=r_();return(0,jHe.jsx)(Cu,{size:"small",exclusive:!0,value:e,onChange:(n,i)=>i&&t(i),"aria-label":"Filter peaks by rate-limit window",children:MYn(r).map(n=>(0,jHe.jsx)(bs,{value:n.value,children:n.label},n.value))})}var gv=R(z(),1);function e1r({history:e}){let{window:t,total:r}=e;return(0,gv.jsxs)(gv.Fragment,{children:[(0,gv.jsx)(Jyr,{window:t,onChange:e.selectWindow}),(0,gv.jsx)(ie,{sx:{height:4,my:1},children:e.fetching&&(0,gv.jsx)(p5,{})}),r===0?(0,gv.jsx)(Ie,{color:"text.secondary",align:"center",sx:{py:6},children:t==="all"?"No usage peaks recorded yet.":`No ${sF(t).label} usage peaks recorded yet.`}):(0,gv.jsx)(Zyr,{rows:e.rows,total:r,page:e.page,pageSize:e.pageSize,onPageChange:e.setPage})]})}var rye=R(he(),1);async function t1r(e,t,r){let n=new URLSearchParams({page:String(e),pageSize:String(t)});r!=="all"&&n.set("window",r);let i=await fetch(`/api/usage/history?${n}`);if(!i.ok)throw new Error(`Failed to load usage history (HTTP ${i.status}).`);return i.json()}var n_=R(he(),1);function tye(e,t,r=!0){let[n,i]=(0,n_.useState)(0),[o,a]=(0,n_.useState)(null),[s,l]=(0,n_.useState)(!1),[u,f]=(0,n_.useState)(null);(0,n_.useEffect)(()=>{if(!r)return;let p=!1;return l(!0),e(n,t).then(m=>{p||(a(m),l(!1))},m=>{p||(f(m instanceof Error?m:new Error(String(m))),l(!1))}),()=>{p=!0}},[e,n,t,r]);let d=o?.total??0;(0,n_.useEffect)(()=>{if(d===0)return;let p=Math.ceil(d/t)-1;n>p&&i(p)},[n,t,d]);let h=o?.rows??[];return{data:o,rows:h,total:d,loaded:o!==null,fetching:s,error:u,page:n,setPage:i,pageSize:t}}var IYn=30;function r1r(){let[e,t]=(0,rye.useState)("all"),r=(0,rye.useCallback)((o,a)=>t1r(o,a,e),[e]),n=tye(r,IYn);return{...n,window:e,selectWindow:o=>{t(o),n.setPage(0)}}}var lF=R(he(),1);function n1r(e,t){return e.field!==t?{field:t,direction:"desc"}:{field:t,direction:e.direction==="desc"?"asc":"desc"}}var DYn=30;function i1r(e){let[t,r]=(0,lF.useState)(hK),[n,i]=(0,lF.useState)(pK),[o,a]=(0,lF.useState)(dK),s=(0,lF.useCallback)((h,p)=>vyr(h,p,{origin:t,status:n,sort:o}),[t,n,o]),l=tye(s,DYn,e);return{...l,origin:t,selectOrigin:h=>{r(h),l.setPage(0)},status:n,selectStatus:h=>{i(h),l.setPage(0)},sort:o,sortBy:h=>{a(p=>n1r(p,h)),l.setPage(0)}}}var i_=R(z(),1),NYn={borderBottom:1,borderColor:"divider",mb:2};function a1r(){let[e,t]=(0,o1r.useState)("limits"),r=r1r(),n=i1r(e==="items");if(r.error)throw r.error;if(n.error)throw n.error;return(0,i_.jsxs)(ql,{loading:!r.loaded,title:"Usage history",maxWidth:"lg",children:[(0,i_.jsxs)(v5,{value:e,onChange:(i,o)=>t(o),textColor:"inherit",indicatorColor:"secondary",sx:NYn,"aria-label":"Usage history views",children:[(0,i_.jsx)(jv,{label:"Rate limits",value:"limits"}),(0,i_.jsx)(jv,{label:"Items",value:"items"})]}),e==="limits"?(0,i_.jsx)(e1r,{history:r}):(0,i_.jsx)(zyr,{items:n})]})}var nye=R(he(),1),YHe=(0,nye.createContext)([]);function iye(){return(0,nye.useContext)(YHe)}var mvr=R(he(),1);function ds(){let{selectedCwd:e}=Bn();return e||void 0}var Z2=R(he(),1);var l1r=R(he(),1);var OYn=new Set(["todo","done","all"]);function s1r(e){return e&&OYn.has(e)?e:"todo"}var c1r="backlog-filter",KHe=new Set,u1r=BYn();function BYn(){try{return s1r(localStorage.getItem(c1r))}catch{return"todo"}}function FYn(e){return KHe.add(e),()=>KHe.delete(e)}function $Yn(){return u1r}function zYn(e){u1r=e;try{localStorage.setItem(c1r,e)}catch{}for(let t of KHe)t()}function cF(){return[(0,l1r.useSyncExternalStore)(FYn,$Yn),zYn]}function f1r(){let e=ds(),t=br(),[r]=cF(),[n,i]=(0,Z2.useState)(""),[o,a]=(0,Z2.useState)(null),[s,l]=(0,Z2.useState)(!1),[u,f]=(0,Z2.useState)(e),d=(0,Z2.useRef)(void 0);return e!==u&&(f(e),a(null),l(n.trim().length>0)),(0,Z2.useEffect)(()=>{if(d.current!==void 0&&clearTimeout(d.current),!n.trim()){a(null),l(!1);return}let h=new AbortController,{signal:p}=h;return l(!0),d.current=setTimeout(async()=>{try{let m=await fS({query:n,cwd:e,node:t,signal:p,filter:r});if(p.aborted)return;a(m),l(!1)}catch(m){if(!p.aborted)throw m}},250),()=>{d.current!==void 0&&clearTimeout(d.current),h.abort()}},[n,e,t,r]),{query:n,setQuery:i,results:o,loading:s}}var m1r={position:"relative",display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",alignItems:"center",columnGap:1.5,width:"100%",p:2,mb:1,borderRadius:2,border:1,borderColor:"divider",bgcolor:"background.paper",transition:"box-shadow 0.2s","&:hover":{boxShadow:3}},HYn={"&::after":{content:'""',position:"absolute",inset:0,borderRadius:2,zIndex:1},"&:focus-visible":{outline:"none"},"&:focus-visible::after":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"2px"}},d1r={position:"relative",zIndex:2},h1r=8,XHe=24,UYn=$o`
|
|
4010
4010
|
from { background-position: 0 0; }
|
|
4011
4011
|
to { background-position: 0 ${XHe}px; }
|
|
4012
|
-
`,g1r={...m1r,borderColor:"warning.main",borderLeft:4,borderLeftColor:"warning.main",bgcolor:e=>zo(e.palette.warning.main,.08)},WYn={...g1r,borderLeftColor:"transparent",backgroundImage:e=>`repeating-linear-gradient(to bottom, ${e.palette.warning.main} 0 ${h1r}px, transparent ${h1r}px ${XHe}px)`,backgroundOrigin:"border-box",backgroundRepeat:"repeat-y",backgroundSize:`4px ${XHe}px`,animation:`${UYn} 0.9s linear infinite`,"@media (prefers-reduced-motion: reduce)":{animation:"none"}},p1r={"& .MuiButtonBase-root:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"2px"}},yv={card:m1r,inProgressCard:g1r,inProgressRunningCard:WYn,main:{minWidth:0,textAlign:"left"},stretchedNameLink:{display:"block",fontWeight:500,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...HYn},meta:{display:"flex",alignItems:"center",gap:1,...d1r,width:"fit-content",maxWidth:"100%",fontSize:"0.75rem",color:"text.secondary","& a, & p":{fontSize:"0.75rem"},...p1r},id:{color:"text.disabled"},actions:{display:"flex",alignItems:"center",gap:1,flexShrink:0,...d1r,...p1r}};function oye(e){let t=e.peakContextPct>0?` \xB7 \u2593 ${Math.round(e.peakContextPct)}%`:"";return`\u2191 ${nh(e.tokensUp)} \u2193 ${nh(e.tokensDown)} \xB7 \u23F1 ${_0(e.activeMs)}${t}`}var v1r=R(z(),1),VYn={width:6,height:6,borderRadius:"50%",bgcolor:"currentColor",flexShrink:0};function y1r(){return(0,v1r.jsx)(ie,{component:"span",sx:VYn})}var SK=R(z(),1),b1r={display:"inline-flex",alignItems:"center",gap:.625,color:"warning.main",fontWeight:500,fontSize:"0.75rem",whiteSpace:"nowrap",borderRadius:1};function x1r({item:e,openSession:t,onSelectSession:r}){let n=Li();if(e.status!=="in-progress"||e.currentPhase==null)return null;let i=`phase ${e.currentPhase} of ${e.totalPhases??e.currentPhase}`,o=(0,SK.jsx)(y1r,{});if(!t)return(0,SK.jsxs)(ie,{component:"span",sx:b1r,children:[o,i]});let a=()=>{r?.(t.id),n("/sessions")};return(0,SK.jsxs)(On,{sx:b1r,title:`Open the ${t.status} session`,onClick:a,children:[o,i]})}var Sp=R(z(),1),GYn={display:"inline-flex",alignItems:"center",gap:.5},qYn={width:8,height:8,borderRadius:"50%",flexShrink:0},jYn={whiteSpace:"nowrap"};function YYn({type:e}){let t=X0e[e];return(0,Sp.jsxs)(ie,{component:"span",sx:GYn,children:[(0,Sp.jsx)(ie,{component:"span",sx:{...qYn,bgcolor:`${t}.main`}}),e]})}function KYn({item:e}){return e.usageTotal?(0,Sp.jsx)(sr,{title:oye(e.usageTotal),children:(0,Sp.jsx)(ie,{component:"span",sx:jYn,children:`\u23F1 ${_0(e.usageTotal.activeMs)}`})}):null}function T1r({item:e,openSession:t,onSelectSession:r}){return(0,Sp.jsxs)(ie,{sx:yv.meta,children:[(0,Sp.jsx)(ie,{component:"span",sx:yv.id,children:ho(e.id)}),(0,Sp.jsx)(YYn,{type:e.type}),(0,Sp.jsx)(x1r,{item:e,openSession:t,onSelectSession:r}),(0,Sp.jsx)(JP,{jiraKey:e.jiraKey}),(0,Sp.jsx)(QP,{githubIssue:e.githubIssue,variant:"icon"}),(0,Sp.jsx)(KYn,{item:e})]})}function S1r(e,t){return e.filter(r=>yL(r)?.itemId===t).reduce((r,n)=>r&&r.startedAt>=n.startedAt?r:n,void 0)}var w1r=R(z(),1),XYn={todo:"\u25CB","in-progress":"\u25D4",done:"\u25CF",wontdo:"\u2715"},ZYn={todo:"text.disabled","in-progress":"warning.main",done:"success.main",wontdo:"error.main"};function QYn(e){return{fontSize:"1.125rem",flexShrink:0,color:ZYn[e]}}function C1r({status:e}){return(0,w1r.jsx)(Ie,{sx:QYn(e),children:XYn[e]})}function aye(e){return e.status==="todo"||e.status==="in-progress"}function JYn(e){if(e.status==="done")return e.totalPhases;if(e.status==="in-progress")return e.currentPhase}function eKn(e,t,r){return r?"complete":e<t?"done":e===t?"current":"remaining"}function k1r(e){let t=e.totalPhases,r=JYn(e);if(!t||r==null)return;let n=e.status==="done";return{reached:r,total:t,segments:Array.from({length:t},(i,o)=>({phase:o+1,kind:eKn(o+1,r,n)}))}}var uF=R(z(),1),tKn={done:"text.secondary",current:"warning.main",remaining:"divider",complete:"success.main"},rKn={display:"inline-flex",alignItems:"center",gap:.5,flexShrink:0},nKn={fontSize:"0.6875rem",color:"text.secondary",fontVariantNumeric:"tabular-nums"},iKn={display:"inline-flex",alignItems:"center",gap:"2px"},oKn={width:6,height:12,borderRadius:"1px",flexShrink:0};function _1r({item:e}){let t=k1r(e);return t?(0,uF.jsxs)(ie,{sx:rKn,title:`Phase ${t.reached} of ${t.total}`,children:[(0,uF.jsx)(ie,{component:"span",sx:nKn,children:`${t.reached}/${t.total}`}),(0,uF.jsx)(ie,{component:"span",sx:iKn,"aria-hidden":!0,children:t.segments.map(r=>(0,uF.jsx)(ie,{component:"span","data-segment":r.kind,sx:{...oKn,bgcolor:tKn[r.kind]}},r.phase))})]}):null}var Y1r=R(he(),1);var cye=R(he(),1);var CK=R(z(),1);function E1r({tooltip:e,disabled:t,onClick:r}){return(0,CK.jsx)(sr,{title:e,children:(0,CK.jsx)(ie,{component:"span",sx:{display:"flex"},children:(0,CK.jsx)(Ut,{startIcon:(0,CK.jsx)(tm,{}),disabled:t,onClick:r,children:"Build"})})})}var ZHe=R(z(),1);function sye(e){let t=[];return e.exposeCodexActions&&t.push({kind:"codex",label:"with Codex"}),e.exposePiActions&&t.push({kind:"pi",label:"with pi"}),t}function lye({anchorEl:e,open:t,onClose:r,options:n,onSelect:i,stop:o}){return(0,ZHe.jsx)(zl,{anchorEl:e,open:t,onClose:r,onClick:o,children:n.map(a=>(0,ZHe.jsx)(hn,{onClick:s=>{o(s),i(a.kind)},children:a.label},a.kind))})}var vv=R(z(),1);function R1r({tooltip:e,disabled:t,onBuild:r,onSelectHarness:n}){let i=sye(r_()),o=(0,cye.useRef)(null),[a,s]=(0,cye.useState)(!1),l=u=>u.stopPropagation();return(0,vv.jsxs)(vv.Fragment,{children:[(0,vv.jsxs)(wT,{ref:o,variant:"contained",color:"success",size:"small",disabled:t,children:[(0,vv.jsx)(E1r,{tooltip:e,disabled:t,onClick:u=>{l(u),r()}}),i.length>0&&(0,vv.jsx)(Ut,{"aria-label":"Build with a different harness",onClick:u=>{l(u),s(!0)},children:(0,vv.jsx)(om,{})})]}),(0,vv.jsx)(lye,{anchorEl:o.current,open:a,onClose:()=>s(!1),options:i,onSelect:u=>{s(!1),n(u)},stop:l})]})}var A1r=R(z(),1),fF=st((0,A1r.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3m-5.55-8h-2.9v3H8l4 4 4-4h-2.55z"}),"CloudDownloadOutlined");var o_=R(z(),1),aKn={vertical:"bottom",horizontal:"center"};function uye({clone:e}){let{prompt:t,confirm:r,cancel:n,error:i,dismissError:o}=e;return(0,o_.jsxs)(o_.Fragment,{children:[t&&(0,o_.jsx)(ro,{title:"Clone repository",message:`Clone ${t.displayName} over SSH into ${t.cloneTarget}${t.node?` on ${t.node}`:""}?`,confirmLabel:"Clone",confirmColor:"primary",onConfirm:r,onCancel:n}),(0,o_.jsx)(fl,{open:!!i,autoHideDuration:8e3,onClose:o,anchorOrigin:aKn,children:(0,o_.jsx)(oi,{severity:"error",onClose:o,variant:"filled",children:i})})]})}var A0=R(he(),1);function QHe(e){return["backlog","clone",e]}function fye(e,t){t(QHe(e.origin),void 0,{title:`Clone ${e.displayName}`,subtitle:e.origin,...e.node&&{node:e.node}})}function P1r(e,t){return!!e&&e.length===t.length&&e.every((r,n)=>r===t[n])}function L1r(e,t,r){let n=QHe(t.origin),i=new Set(e.filter(o=>P1r(o.assistArgs,n)).map(o=>o.id));return fye(t,r),{args:n,target:t.cloneTarget,node:t.node,preexisting:i}}function M1r(e,t){if(!t.id){let n=e.find(i=>P1r(i.assistArgs,t.args)&&!t.preexisting.has(i.id));return n?{type:"latch",id:n.id}:null}let r=e.find(n=>n.id===t.id);return r?r.status==="done"?{type:"done"}:r.status==="error"?{type:"error",message:r.error||"Clone failed."}:null:null}function dye(e){let{setSelectedCwd:t}=Bn(),{launchAssist:r}=Gl(),[n,i]=(0,A0.useState)(null),[o,a]=(0,A0.useState)(null),[s,l]=(0,A0.useState)(null),u=(0,A0.useCallback)(p=>{l(null),i(p)},[]),f=(0,A0.useCallback)(()=>i(null),[]),d=(0,A0.useCallback)(()=>l(null),[]),h=(0,A0.useCallback)(()=>{n&&(a(L1r(e,n,r)),i(null))},[n,e,r]);return(0,A0.useEffect)(()=>{if(!o)return;let p=M1r(e,o);p&&(p.type==="latch"?a(m=>m&&{...m,id:p.id}):p.type==="done"?(o.node?t(o.target,o.node):t(o.target),a(null)):(l(p.message),a(null)))},[e,o,t]),{prompt:n,requestClone:u,confirm:h,cancel:f,error:s,dismissError:d}}function dF(e,t){return`Not cloned ${e?`on ${e}`:"locally"} \u2014 click to clone into ${t}`}var Q2=R(z(),1),sKn={border:1,borderStyle:"dashed"};function I1r({target:e}){let t=dye(iye());return(0,Q2.jsxs)(Q2.Fragment,{children:[(0,Q2.jsx)(sr,{title:dF(e.node,e.cloneTarget),children:(0,Q2.jsx)(ir,{"aria-label":"Clone",size:"small",sx:sKn,onClick:r=>{r.stopPropagation(),t.requestClone(e)},children:(0,Q2.jsx)(fF,{fontSize:"small"})})}),(0,Q2.jsx)(uye,{clone:t})]})}var hye=R(he(),1),JHe=(0,hye.createContext)(()=>{});function D1r(){return(0,hye.useContext)(JHe)}var pye=R(z(),1);function N1r({session:e}){let t=wS(D1r());return(0,pye.jsxs)(Ut,{variant:"contained",size:"small",startIcon:(0,pye.jsx)(Mme,{}),onClick:r=>{r.stopPropagation(),t(e.id)},children:["Session ",e.id]})}function O1r(e,t,r,n){let i=r.node?[{node:r.node}]:[];e(["backlog","run",ho(t),...n],r.cwd,...i)}var wK=R(z(),1);function B1r({tooltip:e,disabled:t,onClick:r}){return(0,wK.jsx)(sr,{title:e,children:(0,wK.jsx)("span",{children:(0,wK.jsx)(ir,{"aria-label":"Build",color:"success",size:"small",disabled:t,onClick:r,children:(0,wK.jsx)(tm,{})})})})}function lKn(e,t){let r=e.assistArgs;if(r?.[0]!=="backlog"||r[1]!=="run"||!r[2])return!1;try{return Pee(r[2])===t}catch{return!1}}function F1r(e,t){return e.find(r=>r.status!=="done"&&r.status!=="error"&&(lKn(r,t)||yL(r)?.itemId===t))}var mye=R(he(),1),eUe=(0,mye.createContext)({nodes:null,names:[],visible:!1,selected:void 0,select:()=>{}});function Zu(){return(0,mye.useContext)(eUe)}function gye(){let{nodes:e,selected:t}=Zu();return t&&t!==e?.local?t:void 0}var H1r=R(he(),1);var yye=R(he(),1);function $1r(e,t){return Promise.all(t.map(async r=>{let n=await cKn(e,r).catch(()=>({}));return[r,n]}))}async function cKn(e,t){let r=await fetch(Xr(`/api/repo-location?origin=${encodeURIComponent(e)}`,t||void 0));return r.ok?r.json():{}}var tUe="\0";function z1r(e,t){let[r,n]=(0,yye.useState)(null);return(0,yye.useEffect)(()=>{if(!e||!t)return;let i=!1;return $1r(e,t.split(tUe)).then(o=>{i||n({origin:e,byNode:Object.fromEntries(o)})}),()=>{i=!0}},[e,t]),r}function vye(e,t){let{cloneOn:r,originOf:n}=Bn(),i=e?n(e):void 0,o=t.filter(s=>!e||!r(e,s)).map(s=>s??"").join(tUe),a=z1r(i,o);return(0,H1r.useCallback)(s=>{let l=e?r(e,s):void 0;if(l)return{kind:"cloned",cwd:l};let u=a&&a.origin===i?a.byNode[s??""]:void 0;return u?.cwd?{kind:"cloned",cwd:u.cwd}:i&&u?.cloneTarget?{kind:"clonable",origin:i,cloneTarget:u.cloneTarget}:{kind:"unavailable"}},[e,r,i,a])}var pF=R(he(),1);var U1r=R(z(),1);function hF({inputRef:e,value:t,onChange:r,onKeyDown:n,placeholder:i,autoFocus:o}){return(0,U1r.jsx)(qn,{autoFocus:o,inputRef:e,value:t,onChange:a=>r(a.target.value),onKeyDown:n,placeholder:i,size:"small",fullWidth:!0,slotProps:{input:{sx:{fontSize:12}}},sx:{p:.5}})}var bye=R(he(),1);function xye(e){let t=(0,bye.useRef)(null);return(0,bye.useEffect)(()=>{e&&t.current?.scrollIntoView({block:"nearest"})},[e]),t}var V1r=R(z(),1);function W1r({cwd:e,selected:t,highlighted:r,onHover:n,onSelect:i}){let o=xye(r);return(0,V1r.jsx)(hn,{ref:o,selected:t,title:e,onClick:i,onMouseEnter:n,sx:{fontSize:12,display:"flex",justifyContent:"space-between",gap:1,...r&&{bgcolor:"action.hover"}},children:bv(e)})}var rUe=R(z(),1);function Tye({repos:e,selected:t,highlight:r,onHighlight:n,onSelect:i}){return(0,rUe.jsx)($p,{dense:!0,children:e.map((o,a)=>(0,rUe.jsx)(W1r,{cwd:o,selected:o===t,highlighted:a===r,onHover:()=>n(a),onSelect:()=>i(o)},o))})}var Sye=R(he(),1);function a_(e,t,r,n){let[i,o]=(0,Sye.useState)(0);return(0,Sye.useEffect)(()=>{o(0)},[t]),{highlight:i,setHighlight:o,onKeyDown:s=>{let l=e.length;if(s.key==="ArrowDown")s.preventDefault(),l>0&&o(u=>(u+1)%l);else if(s.key==="ArrowUp")s.preventDefault(),l>0&&o(u=>(u-1+l)%l);else if(s.key==="Enter"){s.preventDefault();let u=e[i];u!==void 0&&(r(u),n())}else s.key==="Escape"&&(s.preventDefault(),n())}}}var kK=R(z(),1);function bv(e){let t=e.includes("\\")?"\\":"/";return e.split(t).filter(Boolean).pop()??e}var uKn={...wL};function G1r({repos:e,selected:t,onSelect:r,close:n,initialFilter:i=""}){let[o,a]=(0,pF.useState)(i),s=(0,pF.useRef)(null);(0,pF.useEffect)(()=>{s.current?.focus()},[]);let l=o.trim().toLowerCase(),u=l?e.filter(m=>m.toLowerCase().includes(l)):e,{highlight:f,setHighlight:d,onKeyDown:h}=a_(u,l,r,n);return(0,kK.jsxs)(cn,{elevation:4,sx:uKn,children:[(0,kK.jsx)(hF,{inputRef:s,value:o,onChange:a,onKeyDown:h,placeholder:"Filter repos..."}),(0,kK.jsx)(Tye,{repos:u,selected:t,highlight:f,onHighlight:d,onSelect:m=>{r(m),n()}})]})}function Cye(e,t){return{origin:e.origin,cloneTarget:e.cloneTarget,displayName:bv(e.origin),node:t}}function q1r(){let e=ds(),t=gye(),r=vye(e??"",[t])(t);return e?r.kind==="cloned"?{kind:"ready",cwd:r.cwd,node:t}:r.kind==="clonable"?{kind:"clone",prompt:Cye(r,t)}:{kind:"unavailable",node:t??"this machine"}:{kind:"ready",node:t}}function j1r(e){return e?`Not cloned on ${e}`:"Build"}var _K=R(z(),1);function wye({itemId:e,compact:t=!1}){let{launchAssist:r}=Gl(),n=q1r(),i=F1r(iye(),e),[o,a]=(0,Y1r.useState)(!1);if(n.kind==="clone")return(0,_K.jsx)(I1r,{target:n.prompt});if(i)return(0,_K.jsx)(N1r,{session:i});let s=n.kind==="unavailable"?n.node:void 0,l=o||!!s,u=d=>{l||n.kind!=="ready"||(a(!0),O1r(r,e,n,d))},f=j1r(s);return t?(0,_K.jsx)(B1r,{tooltip:f,disabled:l,onClick:d=>{d.stopPropagation(),u([])}}):(0,_K.jsx)(R1r,{tooltip:f,disabled:l,onBuild:()=>u([]),onSelectHarness:d=>u(["--harness",d])})}var K1r=R(he(),1);var mF=R(z(),1);function X1r({itemId:e,starred:t,onToggled:r}){let n=ds(),i=br(),[o,a]=(0,K1r.useState)(!1);return(0,mF.jsx)(sr,{title:t?"Unstar":"Star",children:(0,mF.jsx)("span",{children:(0,mF.jsx)(ir,{"aria-label":t?"Unstar":"Star","aria-pressed":t,color:t?"warning":"default",size:"small",disabled:o,onClick:async l=>{if(l.stopPropagation(),!o){a(!0);try{await Gee(e,!t,n,i),await r()}finally{a(!1)}}},children:t?(0,mF.jsx)(Kte,{}):(0,mF.jsx)(Xte,{})})})})}var Z1r=R(z(),1),Q1r=st((0,Z1r.jsx)("path",{d:"M22 7h-9v2h9zm0 8h-9v2h9zM5.54 11 2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41z"}),"Checklist");var EK=R(z(),1),fKn={display:"inline-flex",alignItems:"center",gap:.375,flexShrink:0,fontSize:"0.71875rem",color:"text.secondary","& svg":{fontSize:14}};function J1r({count:e}){return e<1?null:(0,EK.jsx)(sr,{title:`${e} incomplete subtask${e===1?"":"s"}`,children:(0,EK.jsxs)(ie,{component:"span",sx:fKn,children:[(0,EK.jsx)(Q1r,{}),e]})})}var J2=R(z(),1);function evr({item:e,onReload:t}){return(0,J2.jsxs)(J2.Fragment,{children:[(0,J2.jsx)(J1r,{count:e.incompleteSubtasks}),(0,J2.jsx)(_1r,{item:e}),(0,J2.jsx)(X1r,{itemId:e.id,starred:e.starred,onToggled:t}),aye(e)&&(0,J2.jsx)(wye,{itemId:e.id,compact:!0})]})}var eT=R(z(),1);function dKn(e,t){return e?t?yv.inProgressRunningCard:yv.inProgressCard:yv.card}function tvr({item:e,to:t,socket:r,onReload:n}){let i=S1r(r.sessions,e.id),o=e.status==="in-progress",a=o&&i?.status==="running";return(0,eT.jsxs)(ie,{sx:dKn(o,a),children:[(0,eT.jsx)(C1r,{status:e.status}),(0,eT.jsxs)(ie,{sx:yv.main,children:[(0,eT.jsx)(jr,{component:Cs,to:t,underline:"none",title:e.name,sx:yv.stretchedNameLink,children:e.name}),(0,eT.jsx)(T1r,{item:e,openSession:i,onSelectSession:r.selectSession})]}),(0,eT.jsx)(ie,{sx:yv.actions,children:(0,eT.jsx)(evr,{item:e,onReload:n})})]})}var nvr=R(z(),1),hKn={all:"items",story:"stories",bug:"bugs"},pKn={textAlign:"center",color:"text.disabled",py:6,px:2};function rvr({query:e,typeFilter:t}){let r=hKn[t],n=e.trim()?`No ${r} match your search.`:`No ${r} in the backlog.`;return(0,nvr.jsx)(ie,{sx:pKn,children:n})}var xv=R(z(),1),mKn={display:"flex",justifyContent:"center",py:6};function ivr({loading:e,error:t,query:r,typeFilter:n,items:i,socket:o,itemPath:a,onReload:s}){if(e)return(0,xv.jsx)(ie,{sx:mKn,children:(0,xv.jsx)(To,{})});let l=t&&(0,xv.jsx)(oi,{severity:"error",children:t});return i.length===0?l||(0,xv.jsx)(rvr,{query:r,typeFilter:n}):(0,xv.jsxs)(xv.Fragment,{children:[l,i.map(u=>(0,xv.jsx)(tvr,{item:u,to:a(u),socket:o,onReload:s},u.id))]})}var gF=R(he(),1);function gKn(e){let t=new URLSearchParams;for(let n of e)t.append("knownCwd",n);let r=t.toString();return r?`/api/backlog/summary?${r}`:"/api/backlog/summary"}async function ovr({cwd:e,node:t,knownCwds:r,signal:n}){return(await fetch(Vl(gKn(r),e,t),{signal:n})).json()}function avr(){let{repos:e,selectedCwd:t,cloneOn:r}=Bn(),n=gye(),[i,o]=(0,gF.useState)([]),a=(0,gF.useMemo)(()=>e.map(l=>r(l,n)).filter(l=>!!l),[e,r,n]),s=t?r(t,n):void 0;return(0,gF.useEffect)(()=>{let l=new AbortController;return ovr({cwd:s,node:n,knownCwds:a,signal:l.signal}).then(o).catch(()=>{}),()=>l.abort()},[a,s,n]),{summaries:i,node:n}}var kye=R(z(),1),yKn={borderStyle:"dashed"};function svr({summary:e,node:t,onSelectCwd:r,onRequestClone:n}){let{origin:i,displayName:o,openCount:a,isCurrent:s,cwd:l,cloneTarget:u}=e,f=!l&&!!u,d=l?()=>r(l):f&&u?()=>n({origin:i,cloneTarget:u,displayName:o,node:t}):void 0,h=(0,kye.jsx)(en,{label:`${o} (${a})`,size:"small",color:s?"primary":"default",variant:s?"filled":"outlined",disabled:!l&&!f,onClick:d,icon:f?(0,kye.jsx)(fF,{}):void 0,sx:f?yKn:void 0});return!f||!u?h:(0,kye.jsx)(sr,{describeChild:!0,title:dF(t,u),children:h})}var RK=R(z(),1),vKn={flexWrap:"wrap",gap:1,mb:2};function lvr({sessions:e}){let{summaries:t,node:r}=avr(),{setSelectedCwd:n}=Bn(),i=dye(e);return t.length===0?null:(0,RK.jsxs)(Rt,{direction:"row",sx:vKn,children:[t.map(o=>(0,RK.jsx)(svr,{summary:o,node:r,onSelectCwd:a=>r?n(a,r):n(a),onRequestClone:i.requestClone},o.origin)),(0,RK.jsx)(uye,{clone:i})]})}var uvr=R(z(),1);function cvr({value:e,onChange:t}){return(0,uvr.jsx)(qn,{"data-backlog-focus":"search",autoFocus:!0,fullWidth:!0,size:"small",placeholder:"Search backlog\u2026",value:e,onChange:r=>t(r.target.value),sx:{mb:2}})}var _ye=R(he(),1);var Eye=R(z(),1);async function bKn(){return(await(await fetch("/api/backups/list")).json())[0]}function fvr(){let[e,t]=(0,_ye.useState)();return(0,_ye.useEffect)(()=>{bKn().then(t)},[]),e?(0,Eye.jsx)(sr,{title:new Date(e.createdAt).toLocaleString(),children:(0,Eye.jsxs)(jr,{component:Cs,to:"/backups",underline:"hover",color:"text.secondary",variant:"body2",children:["Last backed up ",wo(String(e.createdAt))]})}):null}var yF=R(z(),1);function dvr(){let[e,t]=cF();return(0,yF.jsxs)(Cu,{value:e,exclusive:!0,size:"small","aria-label":"Status filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,yF.jsx)(bs,{value:"todo",children:"Todo"}),(0,yF.jsx)(bs,{value:"done",children:"Done"}),(0,yF.jsx)(bs,{value:"all",children:"All"})]})}var vF=R(z(),1);function hvr({value:e,onChange:t}){return(0,vF.jsxs)(Cu,{value:e,exclusive:!0,size:"small","aria-label":"Type filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,vF.jsx)(bs,{value:"all",children:"All"}),(0,vF.jsx)(bs,{value:"story",children:"Stories"}),(0,vF.jsx)(bs,{value:"bug",children:"Bugs"})]})}var s_=R(z(),1),xKn={justifyContent:"space-between",alignItems:"center",mb:3},TKn={fontWeight:600},SKn={alignItems:"center"};function pvr({typeFilter:e,onTypeFilterChange:t}){return(0,s_.jsxs)(Rt,{direction:"row",sx:xKn,children:[(0,s_.jsx)(Ie,{variant:"h5",sx:TKn,children:"Backlog"}),(0,s_.jsxs)(Rt,{direction:"row",spacing:2,sx:SKn,children:[(0,s_.jsx)(fvr,{}),(0,s_.jsx)(hvr,{value:e,onChange:t}),(0,s_.jsx)(dvr,{})]})]})}var tT=R(z(),1);function gvr({items:e,loading:t,error:r,socket:n,onReload:i}){let o=ds(),a=br(),{query:s,setQuery:l,results:u,loading:f}=f1r(),[d,h]=(0,mvr.useState)("all"),p=u??e,m=d==="all"?p:p.filter(g=>g.type===d);return(0,tT.jsxs)(tT.Fragment,{children:[(0,tT.jsx)(pvr,{typeFilter:d,onTypeFilterChange:h}),(0,tT.jsx)(cvr,{value:s,onChange:l}),(0,tT.jsx)(lvr,{sessions:n.sessions}),(0,tT.jsx)(ivr,{loading:t||f,error:u?null:r,query:s,typeFilter:d,items:m,socket:n,itemPath:g=>cS(g.id,o,a),onReload:i})]})}var Oye=R(he(),1);var aA=R(he(),1);async function nUe(e,t,r){let n=await fetch(Vl(`/api/items/${ho(e)}`,t.cwd,t.node),{signal:r});return n.ok?n.json():null}function yvr(e){let t=ds(),r=br(),[n,i]=(0,aA.useState)(null),[o,a]=(0,aA.useState)(!0),s=(0,aA.useCallback)(async()=>{i(await nUe(e,{cwd:t,node:r}))},[e,t,r]);return(0,aA.useEffect)(()=>{let l=new AbortController,{signal:u}=l;return a(!0),(async()=>{try{let f=await nUe(e,{cwd:t,node:r},u);if(u.aborted)return;i(f),a(!1)}catch(f){if(!u.aborted)throw f}})(),()=>l.abort()},[e,t,r]),{item:n,loading:o,reload:s}}var l_={description:"item-section-description",acceptanceCriteria:"item-section-acceptance-criteria",subtasks:"item-section-subtasks",plan:"item-section-plan",activity:"item-section-activity",comments:"item-section-comments"},AK=140,iUe="--pinned-header-height",Rye=`var(${iUe}, ${AK}px)`,vvr=`calc(${Rye} + 8px)`;function ag(e){return{id:l_[e],sx:{mb:2,scrollMarginTop:vvr}}}function Aye(e){return{id:`item-phase-${e}`,sx:{scrollMarginTop:vvr}}}var c_=R(z(),1);function bvr({criteria:e}){return e.length===0?null:(0,c_.jsxs)(ie,{...ag("acceptanceCriteria"),children:[(0,c_.jsx)(Ie,{variant:"overline",sx:{color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"},children:"Acceptance Criteria"}),(0,c_.jsx)(Q0,{disablePadding:!0,sx:{maxWidth:"72ch"},children:e.map((t,r)=>(0,c_.jsxs)(ET,{disableGutters:!0,disablePadding:!0,sx:{py:.5,display:"flex",alignItems:"baseline"},children:[(0,c_.jsxs)(Ie,{component:"span",sx:{color:"text.secondary",mr:1},children:[r+1,"."]}),(0,c_.jsx)(Au,{component:"span",className:"markdown",html:xL(t)})]},t))})]})}var PK=R(z(),1),CKn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function xvr({description:e}){return e?(0,PK.jsxs)(ie,{...ag("description"),children:[(0,PK.jsx)(Ie,{variant:"overline",sx:CKn,children:"Description"}),(0,PK.jsx)(Xw,{content:e,renderMermaid:!0})]}):null}var Avr=R(he(),1);function Tvr(e,t=10){let r=i=>e.filter(o=>o.kind===i).reverse(),n=r("commit");return{branches:r("branch"),commits:n.slice(0,t),overflowCommits:n.slice(t),prs:r("pr"),slacks:r("slack"),sessions:r("session")}}var Cvr=R(z(),1),wKn={color:"text.secondary",alignSelf:"flex-start",textAlign:"left"};function Svr({hiddenCount:e,expanded:t,onToggle:r}){return e===0?null:(0,Cvr.jsx)(jr,{component:"button",type:"button",variant:"body2",underline:"hover",sx:wKn,onClick:n=>{n.stopPropagation(),r()},children:t?"Show fewer commits":`\u2026 and ${e} more commits`})}var sA=R(z(),1),kKn={display:"flex",alignItems:"center",gap:1},_Kn={color:"text.secondary",fontFamily:"monospace"},EKn={flex:1,overflowWrap:"anywhere"},RKn={color:"text.disabled","&:hover":{color:"text.primary"}};function wvr({conversation:e}){let{resumeSession:t}=Gl(),r=n=>{n.stopPropagation(),t(e.sessionId,e.cwd??"",e.title,e.harness)};return(0,sA.jsxs)(ie,{sx:kKn,children:[(0,sA.jsx)(Ie,{variant:"body2",component:"span",sx:_Kn,children:"session"}),(0,sA.jsx)(Ie,{variant:"body2",component:"span",sx:EKn,children:e.title??e.sessionId}),(0,sA.jsx)(ir,{size:"small",title:"Resume",sx:RKn,onClick:r,children:(0,sA.jsx)(tm,{sx:{fontSize:14}})})]})}var _vr=R(z(),1),AKn={color:"text.disabled",ml:1};function kvr({gitRef:e}){return e.kind!=="commit"||!e.createdAt?null:(0,_vr.jsx)(ie,{component:"span",sx:AKn,children:PKn(e.createdAt)})}function PKn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Evr(e){if(e.kind==="commit"){let t=e.title?` ${e.title}`:"";return`${e.ref.slice(0,8)}${t}`}if(e.kind==="pr"){let t=e.title?` ${e.title}`:"",r=e.state?` (${e.state.toLowerCase()})`:"";return`#${e.ref}${t}${r}`}return e.kind==="slack"||e.kind==="session"?e.title??e.ref:e.ref}var Tv=R(z(),1),LKn={color:"text.secondary",mr:1,fontFamily:"monospace"};function MKn({gitRef:e}){let t=Evr(e);return!e.url||e.kind==="session"?(0,Tv.jsx)(Tv.Fragment,{children:t}):(0,Tv.jsx)(jr,{href:e.url,target:"_blank",rel:"noopener",onClick:r=>r.stopPropagation(),children:t})}function Rvr({gitRef:e}){return(0,Tv.jsxs)(Ie,{variant:"body2",children:[(0,Tv.jsx)(ie,{component:"span",sx:LKn,children:e.kind}),(0,Tv.jsx)(MKn,{gitRef:e}),(0,Tv.jsx)(kvr,{gitRef:e})]})}var u_=R(z(),1),IKn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function Pvr({gitRefs:e,conversations:t=[]}){let[r,n]=(0,Avr.useState)(!1),{branches:i,commits:o,overflowCommits:a,prs:s,slacks:l}=Tvr(e),u=[...i,...o,...r?a:[],...s,...l];return u.length===0&&t.length===0?null:(0,u_.jsxs)(ie,{...ag("activity"),children:[(0,u_.jsx)(Ie,{variant:"overline",sx:IKn,children:"Activity"}),(0,u_.jsxs)(Rt,{spacing:1,children:[u.map(f=>(0,u_.jsx)(Rvr,{gitRef:f},`${f.kind}:${f.ref}`)),t.map(f=>(0,u_.jsx)(wvr,{conversation:f},f.sessionId)),(0,u_.jsx)(Svr,{hiddenCount:a.length,expanded:r,onToggle:()=>n(f=>!f)})]})]})}var lA=R(z(),1),DKn={alignItems:"center",fontSize:"0.75rem",color:"text.secondary",mb:.5},NKn={color:"text.disabled"},OKn={fontWeight:500},BKn={summary:"Phase summary",comment:"Comment"};function Lvr({comment:e}){return(0,lA.jsxs)(Rt,{direction:"row",spacing:.5,sx:DKn,children:[e.id!==void 0&&(0,lA.jsxs)(Ie,{variant:"caption",sx:NKn,children:["#",e.id]}),(0,lA.jsx)(Ie,{variant:"caption",sx:OKn,children:BKn[e.type]}),e.phase!==void 0&&(0,lA.jsxs)(Ie,{variant:"caption",children:["\xB7 Phase ",e.phase]}),(0,lA.jsxs)(Ie,{variant:"caption",children:["\xB7 ",FKn(e.timestamp)]})]})}function FKn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}var Mvr=R(z(),1),Ivr=st((0,Mvr.jsx)("path",{d:"M16 9v10H8V9zm-1.5-6h-5l-1 1H5v2h14V4h-3.5zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2z"}),"DeleteOutlined");var oUe=R(he(),1);async function Dvr(e,t,r,n){let i=await fetch(Vl(`/api/items/${ho(e)}/comments/${t}`,r,n),{method:"DELETE"});if(!i.ok){let o=await i.json().catch(()=>{});throw new Error(o?.error??`Failed to delete comment (${i.status})`)}}var Sv=R(z(),1),$Kn={mt:-.5,mr:-.5,color:"text.secondary"};function Nvr({itemId:e,commentId:t,onDeleted:r}){let n=ds(),i=br(),[o,a]=(0,oUe.useState)(!1),[s,l]=(0,oUe.useState)(),u=()=>l(void 0);return(0,Sv.jsxs)(Sv.Fragment,{children:[o&&(0,Sv.jsx)(ro,{message:"Are you sure you want to delete this comment?",onConfirm:async()=>{a(!1);try{await Dvr(e,t,n,i),await r()}catch(f){l(f instanceof Error?f.message:"Failed to delete comment")}},onCancel:()=>a(!1)}),(0,Sv.jsx)(fl,{open:s!==void 0,autoHideDuration:6e3,onClose:u,children:(0,Sv.jsx)(oi,{severity:"error",variant:"filled",onClose:u,children:s})}),(0,Sv.jsx)(ir,{"aria-label":"Delete comment",size:"small",sx:$Kn,onClick:()=>a(!0),children:(0,Sv.jsx)(Ivr,{fontSize:"inherit"})})]})}var cA=R(z(),1),zKn={summary:{bgcolor:"warning.light",borderColor:"warning.dark"},comment:{bgcolor:"action.selected",borderColor:"divider"}},HKn={justifyContent:"space-between",alignItems:"flex-start"},UKn={color:"text.primary",whiteSpace:"pre-wrap"};function WKn(e){return{p:1.5,bgcolor:e.bgcolor,borderColor:e.borderColor}}function Ovr({comment:e,itemId:t,onDeleted:r}){return(0,cA.jsxs)(cn,{variant:"outlined",sx:WKn(zKn[e.type]),children:[(0,cA.jsxs)(Rt,{direction:"row",sx:HKn,children:[(0,cA.jsx)(Lvr,{comment:e}),e.id!==void 0&&t!==void 0&&r&&(0,cA.jsx)(Nvr,{itemId:t,commentId:e.id,onDeleted:r})]}),(0,cA.jsx)(Ie,{variant:"body2",sx:UKn,children:e.text})]})}var bF=R(z(),1),VKn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function Bvr({comments:e,itemId:t,onCommentDeleted:r}){return e.length===0?null:(0,bF.jsxs)(ie,{...ag("comments"),children:[(0,bF.jsx)(Ie,{variant:"overline",sx:VKn,children:"Comments"}),(0,bF.jsx)(Rt,{spacing:1,children:e.map((n,i)=>(0,bF.jsx)(Ovr,{comment:n,itemId:t,onDeleted:r},`${n.timestamp}-${i}`))})]})}var Fvr=R(z(),1);function xF({total:e,sx:t}){return(0,Fvr.jsx)(Ie,{sx:t,children:oye(e)})}var zvr=R(z(),1),GKn={color:"text.secondary",fontSize:"0.75rem"};function $vr({usage:e}){let t={tokensUp:e.reduce((r,n)=>r+n.tokensUp,0),tokensDown:e.reduce((r,n)=>r+n.tokensDown,0),activeMs:e.reduce((r,n)=>r+n.activeMs,0),peakContextPct:e.reduce((r,n)=>Math.max(r,n.peakContextPct),0)};return(0,zvr.jsx)(xF,{total:t,sx:GKn})}var rT=R(z(),1);function Hvr({checks:e}){return(0,rT.jsxs)(ie,{sx:{mt:1,pt:1},children:[(0,rT.jsx)(Ui,{sx:{mb:1}}),(0,rT.jsx)(Ie,{variant:"overline",sx:{color:"text.disabled",letterSpacing:"0.08em"},children:"Manual Checks"}),(0,rT.jsx)(Q0,{disablePadding:!0,sx:{ml:.5,mt:.5},children:e.map(t=>(0,rT.jsxs)(ET,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,rT.jsx)(Ie,{component:"span",sx:{mr:1,fontSize:"0.875rem",color:"text.secondary"},children:"\u2610"}),(0,rT.jsx)(Au,{component:"span",className:"markdown",sx:{fontSize:"0.875rem",color:"text.secondary"},html:xL(t)})]},t))})]})}var Pye={done:{borderColor:"success.light",bgcolor:"success.light"},current:{borderColor:"info.main",bgcolor:"info.light",ring:"info.light"},upcoming:{borderColor:"divider",bgcolor:"background.paper"}};function Uvr(e){let t=Pye[e];return{p:2,borderColor:t.ring?"info.main":t.borderColor,bgcolor:t.bgcolor,...t.ring?{boxShadow:"0 0 0 2px"}:{}}}var Wvr={done:"\u2713",current:"\u2022",upcoming:"\u2022"};var qvr=R(he(),1);var Vvr=R(he(),1),Cv=R(z(),1);function Gvr({phaseName:e,onConfirm:t,onCancel:r}){let[n,i]=(0,Vvr.useState)("");return(0,Cv.jsxs)($l,{open:!0,onClose:r,maxWidth:"xs",fullWidth:!0,children:[(0,Cv.jsxs)(xu,{children:["Rewind to ",e,"?"]}),(0,Cv.jsxs)(bu,{children:[(0,Cv.jsx)(Ie,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This will mark all later phases as incomplete."}),(0,Cv.jsx)(qn,{fullWidth:!0,multiline:!0,rows:3,size:"small",placeholder:"Reason for rewinding...",value:n,onChange:o=>i(o.target.value)})]}),(0,Cv.jsxs)(id,{children:[(0,Cv.jsx)(Ut,{onClick:r,children:"Cancel"}),(0,Cv.jsx)(Ut,{variant:"contained",color:"warning",disabled:n.trim().length===0,onClick:()=>t(n.trim()),children:"Rewind"})]})]})}var uA=R(z(),1);function jvr({itemId:e,phaseNumber:t,phaseName:r,onRewound:n}){let i=ds(),o=br(),[a,s]=(0,qvr.useState)(!1);return(0,uA.jsxs)(uA.Fragment,{children:[(0,uA.jsx)(Ut,{size:"small",color:"warning",variant:"outlined",onClick:()=>s(!0),sx:{ml:"auto",textTransform:"none",fontSize:"0.75rem"},children:"Rewind"}),a&&(0,uA.jsx)(Gvr,{phaseName:r,onConfirm:async l=>{await Krt(e,t,l,i,o),await n()},onCancel:()=>s(!1)})]})}var TF=R(z(),1),qKn={done:{label:"Done",color:"success"},current:{label:"In Progress",color:"info"},upcoming:{label:"Upcoming",color:"default"}},jKn={alignItems:"center",mb:1},YKn={fontWeight:500},KKn={fontWeight:500,fontSize:"0.75rem"};function Yvr({phase:e,index:t,status:r,itemId:n,onRewind:i}){let o=qKn[r],a=r==="done"&&n!==void 0&&i;return(0,TF.jsxs)(Rt,{direction:"row",spacing:1,sx:jKn,children:[(0,TF.jsxs)(Ie,{sx:YKn,children:["Phase ",t+1,": ",e.name]}),(0,TF.jsx)(en,{label:o.label,size:"small",color:o.color,sx:KKn}),a&&(0,TF.jsx)(jvr,{itemId:n,phaseNumber:t+1,phaseName:e.name,onRewound:i})]})}var LK=R(z(),1),XKn={color:"text.secondary",fontSize:"0.75rem",letterSpacing:"0.08em",display:"block"},ZKn={color:"text.secondary",fontSize:"0.75rem",fontFamily:"monospace",display:"block"};function Kvr({sessions:e}){return(0,LK.jsxs)(ie,{sx:{mb:1},children:[(0,LK.jsx)(Ie,{variant:"overline",sx:XKn,children:"Sessions"}),e.map(t=>(0,LK.jsx)(Ie,{sx:ZKn,children:`${t.hostname} / ${t.osUser} / ${t.claudeSessionId}`},t.claudeSessionId))]})}var Zvr=R(z(),1),QKn={color:"text.secondary",fontSize:"0.75rem",mb:1,display:"block"};function Xvr({usage:e}){return(0,Zvr.jsx)(xF,{total:e,sx:QKn})}var SF=R(z(),1);function Qvr({tasks:e,marker:t}){return(0,SF.jsx)(Q0,{disablePadding:!0,sx:{ml:.5},children:e.map(r=>(0,SF.jsxs)(ET,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,SF.jsx)(Ie,{component:"span",sx:{color:"text.secondary",mr:1},children:t}),(0,SF.jsx)(Au,{component:"span",className:"markdown",html:xL(r.task)})]},r.task))})}var f_=R(z(),1);function Jvr({phase:e,index:t,status:r,itemId:n,usage:i,sessions:o,onRewind:a}){let s=e.manualChecks??[],l=Aye(t);return(0,f_.jsxs)(cn,{variant:"outlined",id:l.id,sx:{...Uvr(r),...l.sx},children:[(0,f_.jsx)(Yvr,{phase:e,index:t,status:r,itemId:n,onRewind:a}),i&&(0,f_.jsx)(Xvr,{usage:i}),(0,f_.jsx)(Qvr,{tasks:e.tasks,marker:Wvr[r]}),s.length>0&&(0,f_.jsx)(Hvr,{checks:s}),o&&o.length>0&&(0,f_.jsx)(Kvr,{sessions:o})]})}var MK={name:"Review",tasks:[]};function Lye(e){return e.at(-1)?.name===MK.name?e.length-1:e.length}function Mye(e,t){if(t===void 0)return"upcoming";let r=e+1;return r<t?"done":r===t?"current":"upcoming"}function ebr(e=[]){return new Map(e.map(t=>[t.phaseIdx,t]))}function tbr(e=[]){let t=new Map;for(let r of e){let n=t.get(r.phaseIdx);n?n.push(r):t.set(r.phaseIdx,[r])}return t}var aUe=R(z(),1);function rbr({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){let a=ebr(n),s=tbr(i),l=Lye(e),u=(i??[]).filter(d=>d.phaseIdx>=l),f=l===e.length&&u.length>0?[...e,MK]:e;return(0,aUe.jsx)(Rt,{spacing:1.5,children:f.map((d,h)=>(0,aUe.jsx)(Jvr,{phase:d,index:h,status:Mye(h,t),itemId:r,usage:a.get(h),sessions:h===l?u:s.get(h),onRewind:h<e.length?o:void 0},d.name))})}var fA=R(z(),1),JKn={alignItems:"baseline",justifyContent:"space-between",mb:1},eXn={color:"text.secondary",display:"block",letterSpacing:"0.08em"};function nbr({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){return e.length===0?null:(0,fA.jsxs)(ie,{...ag("plan"),children:[(0,fA.jsxs)(Rt,{direction:"row",sx:JKn,children:[(0,fA.jsx)(Ie,{variant:"overline",sx:eXn,children:"Plan"}),n&&n.length>0&&(0,fA.jsx)($vr,{usage:n})]}),(0,fA.jsx)(rbr,{phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o})]})}var sUe=R(z(),1),Iye=e=>{let{value:t,options:r,colors:n,onChange:i}=e;return(0,sUe.jsx)(PT,{value:t,onChange:o=>i(o.target.value),size:"small",sx:{fontSize:"0.75rem",fontWeight:500,borderRadius:4,bgcolor:n[t].bg,color:n[t].text,"& .MuiSelect-select":{py:.5,px:1.5},"& .MuiSelect-icon":{color:"inherit"}},children:r.map(o=>(0,sUe.jsx)(hn,{value:o,children:o},o))})};var obr=R(z(),1),tXn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"}},rXn=["todo","in-progress","done"];function ibr({current:e,onStatusChange:t}){return(0,obr.jsx)(Iye,{value:e,options:rXn,colors:tXn,onChange:t})}var d_=R(z(),1);function abr({subtask:e,onStatusChange:t}){let r=e.status==="done";return(0,d_.jsxs)(Rt,{direction:"row",spacing:1,sx:{alignItems:"flex-start",justifyContent:"space-between"},children:[(0,d_.jsxs)(ie,{sx:{flex:1},children:[(0,d_.jsx)(Ie,{variant:"body2",sx:{textDecoration:r?"line-through":"none",color:r?"text.disabled":"text.primary"},children:e.title}),e.description&&(0,d_.jsx)(ie,{sx:{mt:.5,fontSize:"0.8125rem",color:r?"text.disabled":"text.secondary"},children:(0,d_.jsx)(Xw,{content:e.description})})]}),(0,d_.jsx)(ibr,{current:e.status,onStatusChange:t})]})}var dA=R(z(),1),nXn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function sbr({subtasks:e,onStatusChange:t}){if(e.length===0)return null;let r=e.filter(n=>n.status!=="done").length;return(0,dA.jsxs)(ie,{...ag("subtasks"),children:[(0,dA.jsx)(Ie,{variant:"overline",sx:nXn,children:"Sub-tasks"}),(0,dA.jsx)(Rt,{spacing:1,children:e.map((n,i)=>(0,dA.jsx)(abr,{subtask:n,onStatusChange:o=>t(i,o)},`${n.title}-${i}`))}),r>0&&(0,dA.jsxs)(oi,{severity:"warning",sx:{mt:1},children:[r," sub-task",r===1?"":"s"," not yet done."]})]})}var nT=R(z(),1);function lbr({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,nT.jsxs)(nT.Fragment,{children:[e.subtasks&&n&&(0,nT.jsx)(sbr,{subtasks:e.subtasks,onStatusChange:n}),e.plan&&(0,nT.jsx)(nbr,{phases:e.plan,currentPhase:e.currentPhase,itemId:e.id,usage:e.phaseUsage,sessions:e.phaseSessions,onRewind:t}),(0,nT.jsx)(Pvr,{gitRefs:e.gitRefs??[],conversations:e.conversations}),e.comments&&(0,nT.jsx)(Bvr,{comments:e.comments,itemId:e.id,onCommentDeleted:r})]})}var CF=R(z(),1);function cbr({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,CF.jsxs)(ie,{sx:{pt:2,flex:1,minWidth:0},children:[(0,CF.jsx)(xvr,{description:e.description}),(0,CF.jsx)(bvr,{criteria:e.acceptanceCriteria}),(0,CF.jsx)(lbr,{item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n})]})}var ubr="item-detail";var IK={wideQuery:`@container ${ubr} (min-width: 760px)`,containerSx:{containerType:"inline-size",containerName:ubr},columnsSx:{display:"flex",columnGap:3}};function iXn(e){let t=e.plan??[];if(t.length===0)return[];let r=Lye(t),i=r===t.length&&(e.phaseSessions??[]).some(o=>o.phaseIdx>=r)?[...t,MK]:t;return[{id:l_.plan,label:"Phases"},...i.map((o,a)=>({id:Aye(a).id,label:`${a+1}`,title:o.name,status:Mye(a,e.currentPhase),nested:!0}))]}function fbr(e){let t=[];return e.description&&t.push({id:l_.description,label:"Description"}),e.acceptanceCriteria.length>0&&t.push({id:l_.acceptanceCriteria,label:"Acceptance Criteria"}),(e.subtasks?.length??0)>0&&t.push({id:l_.subtasks,label:"Sub-tasks"}),t.push(...iXn(e)),(e.gitRefs?.length??0)+(e.conversations?.length??0)>0&&t.push({id:l_.activity,label:"Activity"}),(e.comments?.length??0)>0&&t.push({id:l_.comments,label:"Comments"}),t}var dbr="1.3125rem",hbr={position:"relative",borderRadius:1,"&::after":{content:'""',position:"absolute",inset:0,borderRadius:"inherit",pointerEvents:"none"},"&:hover::after":{bgcolor:"action.hover"},"&:active::after":{bgcolor:"action.selected"}},oXn={...hbr,display:"block",flexShrink:0,maxWidth:"100%",px:1,py:.5,border:0,bgcolor:"transparent",fontSize:dbr,lineHeight:1.2,letterSpacing:"0.02em",textAlign:"left",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"text.secondary"},aXn={...hbr,display:"flex",alignItems:"center",justifyContent:"center",fontSize:dbr,width:"2em",height:"2em",flexShrink:0,lineHeight:1,borderRadius:"50%",border:1,color:"text.primary"},sXn={borderColor:"text.primary",borderWidth:3},lXn={color:"text.primary",fontWeight:700,"&::after":{bgcolor:"action.selected"}};function pbr(e,t){let r=e.status&&Pye[e.status];return r?{...aXn,ml:1.5,bgcolor:r.bgcolor,borderColor:r.borderColor,borderWidth:r.ring?3:1,...t&&sXn}:{...oXn,...t&&lXn}}var gbr=R(z(),1);function mbr({section:e,active:t,onSelect:r}){return(0,gbr.jsx)(On,{sx:pbr(e,t),onClick:()=>r(e.id),title:e.title??e.label,"aria-current":t?"true":void 0,children:e.label})}function ybr(e,t=AK){return hme(e,t)}var lUe=R(z(),1),cXn=48,uXn=260,fXn={display:"none",[IK.wideQuery]:{display:"flex"},position:"sticky",top:Rye,alignSelf:"flex-start",width:uXn,flexShrink:0,maxHeight:`calc(100vh - ${cXn}px - ${Rye})`,alignItems:"flex-start",overflowY:"auto",overflowX:"hidden",py:2};function dXn(e){document.getElementById(e)?.scrollIntoView({behavior:"smooth",block:"start"})}function vbr({item:e,headerHeight:t}){let r=fbr(e),n=ybr(r.map(i=>i.id),t);return r.length===0?null:(0,lUe.jsx)(Rt,{component:"nav",spacing:1,sx:fXn,children:r.map(i=>(0,lUe.jsx)(mbr,{section:i,active:i.id===n,onSelect:dXn},i.id))})}var xbr=R(z(),1);function bbr({to:e}){let t=Li();return(0,xbr.jsx)(Ut,{"data-backlog-focus":"back",variant:"text",size:"small",onClick:()=>t(e),sx:{mb:2,textTransform:"none"},children:"\u2190 Back"})}var Tbr=R(he(),1);var hA=R(z(),1);function Sbr({itemId:e,onDeleted:t}){let r=ds(),n=br(),[i,o]=(0,Tbr.useState)(!1);return(0,hA.jsxs)(hA.Fragment,{children:[i&&(0,hA.jsx)(ro,{onConfirm:async()=>{await jrt(e,r,n),await t()},onCancel:()=>o(!1)}),(0,hA.jsx)(Ut,{variant:"contained",color:"error",size:"small",onClick:()=>o(!0),children:"Delete"})]})}var cUe=R(z(),1),hXn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"},wontdo:{bg:"error.main",text:"error.contrastText"}},pXn=["todo","in-progress","done","wontdo"];function Cbr({current:e,onStatusChange:t}){return t?(0,cUe.jsx)(Iye,{value:e,options:pXn,colors:hXn,onChange:t}):(0,cUe.jsx)(en,{label:e,size:"small",color:Z0e[e],sx:{fontWeight:500,fontSize:"0.75rem"}})}var iT=R(z(),1),mXn={alignItems:"center",color:"text.disabled",fontSize:"0.875rem"},gXn={fontWeight:500,fontSize:"0.75rem"},yXn={color:"text.secondary",fontSize:"0.75rem"};function wbr({item:e,onStatusChange:t}){let r=X0e[e.type];return(0,iT.jsxs)(Rt,{direction:"row",spacing:1,sx:mXn,children:[(0,iT.jsx)(Ie,{variant:"body2",color:"text.disabled",children:ho(e.id)}),r&&(0,iT.jsx)(en,{label:e.type,size:"small",color:r,sx:gXn}),(0,iT.jsx)(Cbr,{current:e.status,onStatusChange:t}),(0,iT.jsx)(JP,{jiraKey:e.jiraKey}),(0,iT.jsx)(QP,{githubIssue:e.githubIssue,origin:e.origin}),e.usageTotal&&(0,iT.jsx)(xF,{total:e.usageTotal,sx:yXn})]})}var kbr=R(z(),1),_br=st((0,kbr.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune");var Dye=R(he(),1);var Ebr=R(he(),1);function Rbr(e){let{launchAssist:t}=Gl(),r=Li(),n=ds(),i=br(),[o,a]=(0,Ebr.useState)(!1);return{launched:o,launch:l=>{if(o)return;a(!0);let u=i?[{node:i}]:[];t(["refine","--once",...l,ho(e)],n,...u),r("/sessions")}}}var P0=R(z(),1);function Abr({itemId:e}){let{launched:t,launch:r}=Rbr(e),n=r_(),i=(0,Dye.useRef)(null),[o,a]=(0,Dye.useState)(!1),s=u=>u.stopPropagation(),l=sye(n);return(0,P0.jsxs)(P0.Fragment,{children:[(0,P0.jsxs)(wT,{ref:i,variant:"outlined",size:"small",disabled:t,children:[(0,P0.jsx)(Ut,{startIcon:(0,P0.jsx)(_br,{}),onClick:u=>{s(u),r([])},children:"Refine"}),l.length>0&&(0,P0.jsx)(Ut,{size:"small","aria-label":"Refine with a different harness",onClick:u=>{s(u),a(!0)},children:(0,P0.jsx)(om,{})})]}),(0,P0.jsx)(lye,{anchorEl:i.current,open:o,onClose:()=>a(!1),options:l,onSelect:u=>{a(!1),r(["--harness",u])},stop:s})]})}var wF=R(he(),1);function Pbr(){let e=(0,wF.useRef)(null),[t,r]=(0,wF.useState)(!1);return(0,wF.useEffect)(()=>{let n=e.current;if(!n)return;let i=new IntersectionObserver(([o])=>r(!o.isIntersecting),{threshold:0});return i.observe(n),()=>i.disconnect()},[]),{sentinelRef:e,stuck:t}}var Jf=R(z(),1),vXn={justifyContent:"space-between",alignItems:"center",mb:2};function bXn(e){return e.palette.mode==="dark"?"0 8px 8px -9px rgba(0, 0, 0, 0.8)":"0 6px 6px -7px rgba(0, 0, 0, 0.2)"}function xXn(e){return t=>({position:"sticky",top:0,zIndex:1,bgcolor:"background.default",mx:-2,px:2,pb:2,borderBottom:1,borderColor:"divider",boxShadow:e?bXn(t):"none",transition:t.transitions.create("box-shadow")})}function Lbr({item:e,onDeleted:t,onStatusChange:r,ref:n}){let{sentinelRef:i,stuck:o}=Pbr();return(0,Jf.jsxs)(Jf.Fragment,{children:[(0,Jf.jsx)(ie,{ref:i,sx:{height:0}}),(0,Jf.jsxs)(ie,{ref:n,sx:xXn(o),children:[(0,Jf.jsxs)(Rt,{direction:"row",sx:vXn,children:[(0,Jf.jsx)(bbr,{to:"/backlog"}),(0,Jf.jsxs)(Rt,{direction:"row",spacing:1,children:[aye(e)&&(0,Jf.jsx)(wye,{itemId:e.id}),(0,Jf.jsx)(Abr,{itemId:e.id}),(0,Jf.jsx)(Sbr,{itemId:e.id,onDeleted:t})]})]}),(0,Jf.jsx)(Ie,{variant:"h5",component:"h2",children:e.name}),(0,Jf.jsx)(wbr,{item:e,onStatusChange:r})]})]})}var Ibr=R(he(),1);var Nye=R(he(),1);function Mbr(e,t){let[r,n]=(0,Nye.useState)(t);return(0,Nye.useEffect)(()=>{let i=e.current;if(!i||(n(i.offsetHeight),typeof ResizeObserver>"u"))return;let o=new ResizeObserver(()=>n(i.offsetHeight));return o.observe(i),()=>o.disconnect()},[e]),r}function Dbr(){let e=(0,Ibr.useRef)(null),t=Mbr(e,AK),r={[iUe]:`${t}px`};return{headerRef:e,headerHeight:t,style:r}}var h_=R(z(),1);function Nbr({item:e,onReload:t}){let r=Li(),n=ds(),i=br(),{headerRef:o,headerHeight:a,style:s}=Dbr();ky("ItemDetail");let l=async()=>{await t(),r("/backlog")},u=async d=>{await Vee(e.id,d,n,i),await t()},f=async(d,h)=>{await Yrt(e.id,d,h,n,i),await t()};return(0,h_.jsxs)(ie,{style:s,children:[(0,h_.jsx)(Lbr,{ref:o,item:e,onDeleted:l,onStatusChange:u}),(0,h_.jsx)(ie,{sx:IK.containerSx,children:(0,h_.jsxs)(ie,{sx:IK.columnsSx,children:[(0,h_.jsx)(cbr,{item:e,onRewind:t,onCommentDeleted:t,onSubtaskStatusChange:f}),(0,h_.jsx)(vbr,{item:e,headerHeight:a})]})})]})}var pA=R(z(),1),TXn={display:"flex",justifyContent:"center",py:6};function Obr({onReload:e}){let[t]=Fc(),r=t.get("cwd")||void 0,n=t.get("node")||void 0,i=Bn(),o=(0,Oye.useMemo)(()=>r?{...i,selectedCwd:r,selectedNode:n}:i,[i,r,n]);return ky("ItemRoute"),(0,pA.jsx)(RH.Provider,{value:o,children:(0,pA.jsx)(df.Provider,{value:o.selectedNode,children:(0,pA.jsx)(SXn,{onReload:e})})})}function SXn({onReload:e}){let{id:t}=oSe(),r=Number.NaN;try{r=Pee(t??"")}catch{r=Number.NaN}let{item:n,loading:i,reload:o}=yvr(r),a=(0,Oye.useCallback)(async()=>{await Promise.all([o(),e()])},[o,e]);return i?(0,pA.jsx)(ie,{sx:TXn,children:(0,pA.jsx)(To,{})}):n?(0,pA.jsx)(Nbr,{item:n,onReload:a}):null}var mA=R(z(),1);function Bbr({items:e,loading:t,error:r,socket:n,onReload:i}){return(0,mA.jsxs)(G5,{children:[(0,mA.jsx)(Ss,{index:!0,element:(0,mA.jsx)(gvr,{items:e,loading:t,error:r,socket:n,onReload:i})}),(0,mA.jsx)(Ss,{path:"items/:id",element:(0,mA.jsx)(Obr,{onReload:i})})]})}var L0=R(he(),1);var Fbr=new Map;function $br(e,t,r){return JSON.stringify([e??null,t,r??null])}var DK={get(e,t,r){return Fbr.get($br(e,t,r))},set(e,t,r,n){Fbr.set($br(e,t,n),r)}};function CXn(e,t){return e===t?!0:!e||!t?!1:e.tokensUp===t.tokensUp&&e.tokensDown===t.tokensDown&&e.activeMs===t.activeMs&&e.peakContextPct===t.peakContextPct}function zbr(e,t){return e===t?!0:e.length!==t.length?!1:e.every((r,n)=>{let i=t[n];return r.id===i.id&&r.type===i.type&&r.name===i.name&&r.status===i.status&&r.starred===i.starred&&r.incompleteSubtasks===i.incompleteSubtasks&&CXn(r.usageTotal,i.usageTotal)})}function Hbr({setItems:e,setLoading:t,setError:r}){return{onLoaded:n=>{e(i=>zbr(i,n)?i:n),t(!1),r(null)},onError:n=>{t(!1),r(n)}}}async function Ubr(e,t,r,n){let i=await fS({cwd:e,node:n,signal:r,filter:t});return r.aborted||DK.set(e,t,i,n),i}function Wbr(e,t,r,{onLoaded:n,onError:i},o){return(async()=>{try{let a=await Ubr(e,t,r,o);r.aborted||n(a)}catch(a){r.aborted||i(a instanceof Error?a.message:"Failed to load.")}})()}var wXn=5e3;function Vbr(e,t,r,n){let i=new AbortController,o=!1,a=()=>{o||(o=!0,Wbr(e,t,i.signal,r,n).finally(()=>{o=!1}))};a();let s=setInterval(a,wXn);return()=>{i.abort(),clearInterval(s)}}function Gbr(){let e=ds(),t=br(),[r]=cF(),n=DK.get(e,r,t),i=n??[],o=n===void 0,[a,s]=(0,L0.useState)(i),[l,u]=(0,L0.useState)(o),[f,d]=(0,L0.useState)(null),[h,p]=(0,L0.useState)(e),[m,g]=(0,L0.useState)(t),[y,v]=(0,L0.useState)(r);(e!==h||t!==m||r!==y)&&(p(e),g(t),v(r),s(i),u(o),d(null));let b=(0,L0.useCallback)(async()=>{let x=await fS({cwd:e,node:t,filter:r});s(x),DK.set(e,r,x,t),u(!1)},[e,t,r]);return(0,L0.useEffect)(()=>Vbr(e,r,Hbr({setItems:s,setLoading:u,setError:d}),t),[e,t,r]),{items:a,loading:l,error:f,reload:b}}var kF=R(z(),1);function qbr({socket:e}){let{items:t,loading:r,error:n,reload:i}=Gbr();return Cre(!r),(0,kF.jsx)(YHe.Provider,{value:e.sessions,children:(0,kF.jsx)(JHe.Provider,{value:e.selectSession,children:(0,kF.jsx)(G5,{children:(0,kF.jsx)(Ss,{path:"/*",element:(0,kF.jsx)(Bbr,{items:t,loading:r,error:n,socket:e,onReload:i})})})})})}var uUe=R(z(),1);function jbr({socket:e}){return(0,uUe.jsx)(H$,{maxWidth:"lg",sx:{py:3,px:2},children:(0,uUe.jsx)(qbr,{socket:e})})}var Ri=R(z(),1);function Ybr({socket:e}){return ky("AppRoutes"),(0,Ri.jsxs)(Ri.Fragment,{children:[(0,Ri.jsx)(Qsr,{}),(0,Ri.jsx)(G5,{children:(0,Ri.jsxs)(Ss,{element:(0,Ri.jsx)(Xat,{socket:e}),children:[(0,Ri.jsx)(Ss,{path:"sessions",element:(0,Ri.jsx)(k0r,{socket:e})}),(0,Ri.jsx)(Ss,{path:"backlog/*",element:(0,Ri.jsx)(jbr,{socket:e})}),(0,Ri.jsx)(Ss,{path:"next",element:(0,Ri.jsx)(Qar,{sessions:e.sessions,selectSession:e.selectSession})}),(0,Ri.jsx)(Ss,{path:"news",element:(0,Ri.jsx)(aar,{})}),(0,Ri.jsx)(Ss,{path:"releases",element:(0,Ri.jsx)(Ysr,{})}),(0,Ri.jsx)(Ss,{path:"usage",element:(0,Ri.jsx)(a1r,{})}),(0,Ri.jsx)(Ss,{path:"backups",element:(0,Ri.jsx)(ist,{})}),(0,Ri.jsx)(Ss,{path:"config",element:(0,Ri.jsx)(ect,{})}),(0,Ri.jsx)(Ss,{path:"updates",element:(0,Ri.jsx)(yyr,{reconnecting:e.reconnecting,selectSession:e.selectSession})}),(0,Ri.jsx)(Ss,{path:"diff",element:(0,Ri.jsx)(kor,{socket:e})}),(0,Ri.jsx)(Ss,{path:"file",element:(0,Ri.jsx)(tar,{socket:e})}),(0,Ri.jsx)(Ss,{path:"*",element:(0,Ri.jsx)(fSe,{to:"/sessions",replace:!0})})]})})]})}var Hye=R(he(),1);var zye=R(he(),1);function Kbr(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var p_=R(z(),1),kXn={display:"flex",gap:1,alignItems:"center",minWidth:0},_Xn={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},EXn={fontFamily:"monospace",fontSize:13,whiteSpace:"nowrap"},RXn={fontFamily:"monospace",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function AXn(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function Xbr({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,p_.jsx)($p,{dense:!0,sx:{py:0},children:e.map((i,o)=>{let{dir:a,basename:s}=AXn(i);return(0,p_.jsxs)(hn,{selected:o===t,onMouseEnter:()=>r(o),onClick:()=>n(i),sx:kXn,children:[(0,p_.jsx)(G9,{path:i}),(0,p_.jsxs)(ie,{sx:_Xn,children:[(0,p_.jsx)(Ie,{component:"span",sx:EXn,children:s}),(0,p_.jsx)(Ie,{component:"span",color:"text.secondary",sx:RXn,children:a})]})]},i)})})}var Bye=R(z(),1),PXn={maxHeight:420,overflowY:"auto"},LXn={px:2,py:2,fontSize:13};function Zbr({message:e,files:t,highlight:r,onHighlight:n,onSelect:i}){return(0,Bye.jsx)(ie,{sx:PXn,children:e?(0,Bye.jsx)(Ie,{color:"text.secondary",sx:LXn,children:e}):(0,Bye.jsx)(Xbr,{files:t,highlight:r,onHighlight:n,onSelect:i})})}var Qbr=R(z(),1),MXn={mt:6,alignSelf:"flex-start"};function Fye({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,Qbr.jsx)($l,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:MXn},transition:{onEntered:t}},children:n})}var $ye=R(he(),1);var Jbr={files:[],loading:!1,error:!1};function exr(e,t){let[r,n]=(0,$ye.useState)(Jbr),i=br();return(0,$ye.useEffect)(()=>{if(!e){n(Jbr);return}let o=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await fetch(Xr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,i));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(o)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch{o||n({files:[],loading:!1,error:!0})}})(),()=>{o=!0}},[e,t,i]),r}var gA=R(z(),1);function IXn(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function txr({onClose:e}){let{worktreeNode:t}=Bn();return(0,gA.jsx)(df.Provider,{value:t,children:(0,gA.jsx)(DXn,{onClose:e})})}function DXn({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=Bn(),[n,i]=(0,zye.useState)(""),o=exr(t,n),a=Li(),s=(0,zye.useRef)(null),l=p=>a(IXn(p,t,r)),{highlight:u,setHighlight:f,onKeyDown:d}=a_(o.files,n,l,e),h=p=>{l(p),e()};return(0,gA.jsxs)(Fye,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,gA.jsx)(hF,{autoFocus:!0,inputRef:s,value:n,onChange:i,onKeyDown:d,placeholder:"Search files by name..."}),(0,gA.jsx)(Zbr,{message:Kbr(t,n,o),files:o.files,highlight:u,onHighlight:f,onSelect:h})]})}function rxr(e){_o(jn("quickOpen").matches,e)}var ixr=R(z(),1);function nxr(){let[e,t]=(0,Hye.useState)(!1);return rxr((0,Hye.useCallback)(()=>t(!0),[])),e?(0,ixr.jsx)(txr,{onClose:()=>t(!1)}):null}var Uye=R(z(),1);function oxr({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,Uye.jsx)(fl,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,Uye.jsx)(oi,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,Uye.jsx)(Ut,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var Yye=R(he(),1);function axr(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var bxr=R(he(),1);var sxr=R(z(),1),lxr=st((0,sxr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var m_="0.834.0";var NXn={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function cxr(e){return e?NXn[e]:"success.main"}function uxr(e){return e.split("-")[0].split(".").map(Number)}function fxr(e,t){if(!e||!t||e===t)return;let r=uxr(e),n=uxr(t);for(let i=0;i<Math.max(r.length,n.length);i++){let o=(r[i]??0)-(n[i]??0);if(Number.isNaN(o))return;if(o!==0)return o<0?"behind":"ahead"}}var Wye=R(he(),1),fUe=(0,Wye.createContext)(null);function Vye(){return(0,Wye.useContext)(fUe)}var yA=R(z(),1),OXn={height:16,fontSize:10},BXn={opacity:.6,fontSize:"0.85em"};function FXn(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function NK({nodes:e,name:t,showVersion:r=!1}){let n=Vye()??m_,i=e.links.find(a=>a.name===t),o=fxr(i?.peerVersion,n);return(0,yA.jsx)(sr,{title:FXn(e,t),placement:"right",children:(0,yA.jsxs)(ie,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,yA.jsx)(lxr,{sx:{fontSize:8,color:cxr(i?.state)}}),t,r&&i?.peerVersion&&(0,yA.jsxs)(ie,{component:"span",sx:BXn,children:["v",i.peerVersion]}),o&&(0,yA.jsx)(en,{label:o,size:"small",color:o==="behind"?"warning":"info",sx:OXn})]})})}var vA=R(z(),1),$Xn={opacity:.6},zXn={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function dxr({nodes:e,name:t,clone:r}){let n=(0,vA.jsx)(NK,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,vA.jsx)(ie,{component:"span",sx:$Xn,children:n}):(0,vA.jsx)(sr,{title:dF(t,r.cloneTarget),children:(0,vA.jsxs)(ie,{component:"span",sx:zXn,children:[(0,vA.jsx)(fF,{sx:{fontSize:14}}),n]})})}var pxr=R(z(),1),HXn={px:1.5,borderRadius:.75,fontSize:12,fontWeight:600,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"},"&[aria-checked='true']":{color:"primary.main",bgcolor:"action.selected"},"&.Mui-focusVisible":{outline:2,outlineColor:"primary.main"}};function hxr({value:e,label:t,checked:r,autoFocus:n,onSelect:i}){return(0,pxr.jsx)(On,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:i,sx:HXn,children:t})}var mxr={ArrowRight:1,ArrowLeft:-1};function UXn(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+mxr[e.key]+r)%r}function gxr(e,t,r,n){return i=>{if(i.key==="ArrowUp"||i.key==="ArrowDown"){if(!n)return;i.preventDefault(),n();return}if(i.key!=="Tab"&&!mxr[i.key]){Pb(i);return}let o=UXn(i,e.indexOf(t),e.length);o!==void 0&&(i.preventDefault(),r(e[o]),i.currentTarget.querySelector(`[data-value="${e[o]}"]`)?.focus())}}var yxr=R(he(),1);function _F(e){return e?.querySelector('[aria-checked="true"]')}function vxr(e,t){(0,yxr.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=_F(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var dUe=R(z(),1),WXn={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function Gye({label:e,options:t,value:r,onChange:n,optionLabel:i=u=>u,groupRef:o,autoFocus:a,onTrack:s,onToggleRow:l}){return vxr(o,r),(0,dUe.jsx)(Rt,{ref:o,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:gxr(t,r,n,l),sx:WXn,children:t.map(u=>(0,dUe.jsx)(hxr,{value:u,label:i(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var hUe=R(z(),1);function xxr({value:e,onChange:t,cloneState:r}){let{nodes:n,names:i,visible:o}=Zu(),a=(0,bxr.useRef)(null);return!o||!n||!e?null:(0,hUe.jsx)(Gye,{label:"Machine",options:i,value:e,onChange:t,optionLabel:s=>(0,hUe.jsx)(dxr,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var Sxr=R(z(),1);function Txr({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:i,onTrack:o}){return(0,Sxr.jsx)(qn,{value:e,onChange:a=>t(a.target.value),onKeyDown:Pb,onFocus:o,onSelect:o,inputRef:n,placeholder:r,autoFocus:i,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"},input:{sx:{fontSize:14}}}})}var _xr=R(he(),1);var oT={draft:{placeholder:"Describe the backlog item to draft...",submitLabel:"Start draft",sessionMode:"assist-draft"},bug:{placeholder:"Describe the bug: what happened, what you expected...",submitLabel:"File bug",sessionMode:"assist-bug"},prompt:{placeholder:Qte,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},Cxr=Object.keys(oT);var pUe=R(z(),1);function wxr({anchor:e,harness:t,harnesses:r,onPick:n,onClose:i}){return(0,pUe.jsx)(zl,{open:e!==null,anchorEl:e,onClose:i,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(o=>(0,pUe.jsx)(hn,{role:"menuitemradio","aria-checked":o===t,selected:o===t,onClick:()=>{n(o),i()},sx:{fontSize:13},children:Eu(o)},o))})}var bA=R(z(),1);function kxr(e){return t=>t==="prompt"&&e?(0,bA.jsxs)(bA.Fragment,{children:["prompt",(0,bA.jsx)(ie,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${Eu(e)}`}),(0,bA.jsx)(om,{sx:{fontSize:18,mr:-.75}})]}):t}var xA=R(z(),1);function Exr({draft:e,harness:t,harnesses:r,focus:n}){let[i,o]=(0,_xr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>o(_F(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,xA.jsxs)(xA.Fragment,{children:[(0,xA.jsx)(Gye,{label:"Mode",options:Cxr,value:e.mode,onChange:l,optionLabel:kxr(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,xA.jsx)(wxr,{anchor:i,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>o(null)})]})}var Fxr=R(he(),1);var mUe=R(z(),1),VXn={zIndex:e=>e.zIndex.modal+1};function Rxr({open:e,anchor:t,children:r}){return(0,mUe.jsx)(_6,{open:e,anchorEl:t,placement:"bottom-start",sx:VXn,children:(0,mUe.jsx)(cn,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}function Axr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:{fontSize:13,height:40}}}}var Pxr=R(y$(),1);function Lxr({open:e,highlighted:t,accept:r,close:n,navigate:i,openList:o}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),o();return}Pb(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,Pxr.flushSync)(()=>{r(t),n()}),Pb(a);return}if(a.key!=="Tab"){i(a);return}t!==void 0&&r(t),n()}}}function Mxr(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>bv(n).toLowerCase().includes(r)):e}var gUe=R(he(),1);function Ixr(){let[e,t]=(0,gUe.useState)(!1),[r,n]=(0,gUe.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:i=>{n(i),t(!0)},close:()=>{t(!1),n("")}}}var Nxr=R(he(),1);var Dxr=e=>e?bv(e):"";function Oxr(e){let[t,r]=(0,Nxr.useState)(()=>Dxr(e));return{text:t,setText:r,showRepo:n=>r(Dxr(n))}}function Bxr(e,t,r){let n=Ixr(),i=Oxr(t),o=Mxr(e,n.query),a=f=>{r(f),i.showRepo(f)},s=a_(o,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:i.text,filtered:o,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:Lxr({open:n.open,highlighted:o[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:f=>{i.setText(f),n.filterBy(f)},onFocus:l,onBlur:()=>{n.close(),i.showRepo(t)},pick:f=>{a(f),n.close()}}}var EF=R(z(),1);function $xr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:i,onTrack:o}){let a=Bxr(e,t,r),s=(0,Fxr.useRef)(null);return(0,EF.jsxs)(ie,{ref:s,sx:{flex:1,minWidth:0},children:[(0,EF.jsx)(qn,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),o()},inputRef:n,autoFocus:i,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:Axr(a.open)}),(0,EF.jsx)(Rxr,{open:a.open,anchor:s.current,children:(0,EF.jsx)(Tye,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var g_=R(z(),1);function zxr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:i}=Bn();return(0,g_.jsxs)(Rt,{spacing:1,sx:{p:1},children:[(0,g_.jsx)(Txr,{value:r.prompt,onChange:r.setPrompt,placeholder:oT[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),(0,g_.jsxs)(Rt,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,g_.jsx)($xr,{repos:i,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,g_.jsx)(Exr,{...t})]}),(0,g_.jsx)(xxr,{value:r.node,onChange:r.setNode,cloneState:e})]})}var RF=R(z(),1),GXn=["Enter start","Shift+Enter newline","Esc close"],qXn={alignItems:"center",px:1.5,py:1,borderTop:1,borderColor:"divider",bgcolor:"action.hover"};function Hxr({submitLabel:e,disabled:t=!1}){return(0,RF.jsxs)(Rt,{direction:"row",spacing:1.5,sx:qXn,children:[(0,RF.jsx)(Rt,{direction:"row",spacing:1.5,sx:{mr:"auto"},children:GXn.map(r=>(0,RF.jsx)(Ie,{variant:"caption",color:"text.secondary",children:r},r))}),(0,RF.jsx)(Ut,{type:"submit",variant:"contained",size:"small",disabled:t,children:e})]})}function Uxr({mode:e,harness:t,prompt:r,cwd:n,node:i},o){let a=n||void 0,s=i?[i]:[];if(e==="prompt"){t==="claude"?o.onCreate(r,a,...s):o.onCreateHarness(t,r,a,...s);return}if(e==="design"){o.onCreateDesign(r,a,...s);return}let l=i?[{node:i}]:[];Bot(oT[e].sessionMode,n,(u,f)=>o.onCreateAssist(u,f,...l),()=>{},r)}function Wxr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(fye(r.prompt,n.onCreateAssist),!0):(Uxr({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var TA=R(he(),1);function Vxr(e,t){let r=(0,TA.useRef)(e),n=(0,TA.useRef)(null),i=(0,TA.useRef)(null),o=(0,TA.useRef)(null),a=(0,TA.useCallback)(u=>{n.current=u;let{field:f,selectionStart:d,selectionEnd:h}=r.current;u&&f==="prompt"&&u.setSelectionRange(d,h)},[]),s=u=>{let f=u.target;t({field:"prompt",selectionStart:f.selectionStart,selectionEnd:f.selectionEnd})},l=()=>{if(o.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:i.current,mode:_F(o.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:i,modeRef:o,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function jXn(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:Cye(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function Gxr(e,t){let{names:r,visible:n}=Zu(),i=vye(t,n?r:[void 0]);return{cloneState:i,target:jXn(t,e,i(e))}}var qye=R(he(),1);function qxr(e,t){let[r,n]=(0,qye.useState)(!1);return(0,qye.useEffect)(()=>{!r||e.modePending||(n(!1),!(e.mode==="prompt"&&!e.prompt.trim())&&t())},[r,e.modePending,e.mode,e.prompt,t]),()=>{e.modePending?n(!0):t()}}var AF=R(z(),1);function jxr({draft:e,launchers:t,onClose:r}){let n=Vxr(e.focus,e.setFocus),i=axr(r_()),o=i.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=Gxr(e.node,e.cwd),l=qxr(e,()=>{Wxr(e,o,a,t)&&r()}),u=f=>{f.preventDefault(),l()};return(0,AF.jsx)(Fye,{onClose:r,onEntered:n.restore,centered:!0,children:(0,AF.jsxs)("form",{onSubmit:u,children:[(0,AF.jsx)(zxr,{draft:e,harness:o,harnesses:i,focus:n,cloneState:s}),(0,AF.jsx)(Hxr,{submitLabel:a.kind==="clone"?"Clone":oT[e.mode].submitLabel,disabled:a.kind==="blocked"})]})})}var jye=R(he(),1);function Yxr(e){let[t,r]=(0,jye.useState)(null);return(0,jye.useEffect)(()=>{let n=!1;return(async()=>{let i="draft";try{let o=e?`?cwd=${encodeURIComponent(e)}`:"",s=await(await fetch(`/api/new-session-defaults${o}`)).json();Object.hasOwn(oT,s?.mode)&&(i=s.mode)}catch{}n||r({cwd:e,mode:i})})(),()=>{n=!0}},[e]),t}function Kxr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var aT=R(he(),1),Xxr={field:"prompt",selectionStart:0,selectionEnd:0};function Zxr(){let[e,t]=(0,aT.useState)(""),[r,n]=(0,aT.useState)(),[i,o]=(0,aT.useState)(),[a,s]=(0,aT.useState)("claude"),[l,u]=(0,aT.useState)(),[f,d]=(0,aT.useState)(Xxr),h=(0,aT.useCallback)(()=>{t(""),n(void 0),o(void 0),u(void 0),d(Xxr)},[]);return{prompt:e,cwd:r,mode:i,harness:a,node:l,focus:f,setPrompt:t,setNode:u,setCwd:n,setMode:o,setHarness:s,setFocus:d,clear:h}}function Qxr(e=Yxr){let{selectedCwd:t}=Bn(),r=Zu(),n=Zxr(),i=n.cwd??t,o=e(i);return o?{...n,cwd:i,mode:n.mode??o.mode,modePending:n.mode===void 0&&o.cwd!==i,node:Kxr(n.node,r)}:null}function Jxr(e){_o(jn("newSession").matches,e)}var e2r=R(he(),1);function t2r(e,t){let{selectedCwd:r}=Bn(),[n,i]=Fc(),o=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,e2r.useEffect)(()=>{o===null||!s||!l||!u||(o&&(s(o),l(a),u({field:"prompt",selectionStart:o.length,selectionEnd:o.length})),t(),i(f=>(f.delete("new"),f.delete("newCwd"),f),{replace:!0}))},[o,a,s,l,u,t,i])}var n2r=R(z(),1);function r2r({launchers:e}){let[t,r]=(0,Yye.useState)(!1),n=Qxr(),i=(0,Yye.useCallback)(()=>r(!0),[]);return Jxr(i),t2r(n,i),!t||!n?null:(0,n2r.jsx)(jxr,{draft:n,launchers:e,onClose:()=>r(!1)})}var Kye=R(z(),1);function i2r({reconnecting:e}){return(0,Kye.jsx)(fl,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,Kye.jsx)(oi,{severity:"info",variant:"filled",icon:(0,Kye.jsx)(To,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var wv=R(z(),1);function o2r({socket:e,onViewLaunchedSession:t}){return(0,wv.jsxs)(wv.Fragment,{children:[(0,wv.jsx)(nxr,{}),(0,wv.jsx)(r2r,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,wv.jsx)(i2r,{reconnecting:e.reconnecting}),(0,wv.jsx)(Pu,{error:e.error,onClose:e.clearError}),(0,wv.jsx)(oxr,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var M0=R(he(),1);var YXn=6e4;function a2r(e){let t=e.nodes?.local,r=e.names.join(`
|
|
4012
|
+
`,g1r={...m1r,borderColor:"warning.main",borderLeft:4,borderLeftColor:"warning.main",bgcolor:e=>zo(e.palette.warning.main,.08)},WYn={...g1r,borderLeftColor:"transparent",backgroundImage:e=>`repeating-linear-gradient(to bottom, ${e.palette.warning.main} 0 ${h1r}px, transparent ${h1r}px ${XHe}px)`,backgroundOrigin:"border-box",backgroundRepeat:"repeat-y",backgroundSize:`4px ${XHe}px`,animation:`${UYn} 0.9s linear infinite`,"@media (prefers-reduced-motion: reduce)":{animation:"none"}},p1r={"& .MuiButtonBase-root:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"2px"}},yv={card:m1r,inProgressCard:g1r,inProgressRunningCard:WYn,main:{minWidth:0,textAlign:"left"},stretchedNameLink:{display:"block",fontWeight:500,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...HYn},meta:{display:"flex",alignItems:"center",gap:1,...d1r,width:"fit-content",maxWidth:"100%",fontSize:"0.75rem",color:"text.secondary","& a, & p":{fontSize:"0.75rem"},...p1r},id:{color:"text.disabled"},actions:{display:"flex",alignItems:"center",gap:1,flexShrink:0,...d1r,...p1r}};function oye(e){let t=e.peakContextPct>0?` \xB7 \u2593 ${Math.round(e.peakContextPct)}%`:"";return`\u2191 ${nh(e.tokensUp)} \u2193 ${nh(e.tokensDown)} \xB7 \u23F1 ${_0(e.activeMs)}${t}`}var v1r=R(z(),1),VYn={width:6,height:6,borderRadius:"50%",bgcolor:"currentColor",flexShrink:0};function y1r(){return(0,v1r.jsx)(ie,{component:"span",sx:VYn})}var SK=R(z(),1),b1r={display:"inline-flex",alignItems:"center",gap:.625,color:"warning.main",fontWeight:500,fontSize:"0.75rem",whiteSpace:"nowrap",borderRadius:1};function x1r({item:e,openSession:t,onSelectSession:r}){let n=Li();if(e.status!=="in-progress"||e.currentPhase==null)return null;let i=`phase ${e.currentPhase} of ${e.totalPhases??e.currentPhase}`,o=(0,SK.jsx)(y1r,{});if(!t)return(0,SK.jsxs)(ie,{component:"span",sx:b1r,children:[o,i]});let a=()=>{r?.(t.id),n("/sessions")};return(0,SK.jsxs)(On,{sx:b1r,title:`Open the ${t.status} session`,onClick:a,children:[o,i]})}var Sp=R(z(),1),GYn={display:"inline-flex",alignItems:"center",gap:.5},qYn={width:8,height:8,borderRadius:"50%",flexShrink:0},jYn={whiteSpace:"nowrap"};function YYn({type:e}){let t=X0e[e];return(0,Sp.jsxs)(ie,{component:"span",sx:GYn,children:[(0,Sp.jsx)(ie,{component:"span",sx:{...qYn,bgcolor:`${t}.main`}}),e]})}function KYn({item:e}){return e.usageTotal?(0,Sp.jsx)(sr,{title:oye(e.usageTotal),children:(0,Sp.jsx)(ie,{component:"span",sx:jYn,children:`\u23F1 ${_0(e.usageTotal.activeMs)}`})}):null}function T1r({item:e,openSession:t,onSelectSession:r}){return(0,Sp.jsxs)(ie,{sx:yv.meta,children:[(0,Sp.jsx)(ie,{component:"span",sx:yv.id,children:ho(e.id)}),(0,Sp.jsx)(YYn,{type:e.type}),(0,Sp.jsx)(x1r,{item:e,openSession:t,onSelectSession:r}),(0,Sp.jsx)(JP,{jiraKey:e.jiraKey}),(0,Sp.jsx)(QP,{githubIssue:e.githubIssue,variant:"icon"}),(0,Sp.jsx)(KYn,{item:e})]})}function S1r(e,t){return e.filter(r=>yL(r)?.itemId===t).reduce((r,n)=>r&&r.startedAt>=n.startedAt?r:n,void 0)}var w1r=R(z(),1),XYn={todo:"\u25CB","in-progress":"\u25D4",done:"\u25CF",wontdo:"\u2715"},ZYn={todo:"text.disabled","in-progress":"warning.main",done:"success.main",wontdo:"error.main"};function QYn(e){return{fontSize:"1.125rem",flexShrink:0,color:ZYn[e]}}function C1r({status:e}){return(0,w1r.jsx)(Ie,{sx:QYn(e),children:XYn[e]})}function aye(e){return e.status==="todo"||e.status==="in-progress"}function JYn(e){if(e.status==="done")return e.totalPhases;if(e.status==="in-progress")return e.currentPhase}function eKn(e,t,r){return r?"complete":e<t?"done":e===t?"current":"remaining"}function k1r(e){let t=e.totalPhases,r=JYn(e);if(!t||r==null)return;let n=e.status==="done";return{reached:r,total:t,segments:Array.from({length:t},(i,o)=>({phase:o+1,kind:eKn(o+1,r,n)}))}}var uF=R(z(),1),tKn={done:"text.secondary",current:"warning.main",remaining:"divider",complete:"success.main"},rKn={display:"inline-flex",alignItems:"center",gap:.5,flexShrink:0},nKn={fontSize:"0.6875rem",color:"text.secondary",fontVariantNumeric:"tabular-nums"},iKn={display:"inline-flex",alignItems:"center",gap:"2px"},oKn={width:6,height:12,borderRadius:"1px",flexShrink:0};function _1r({item:e}){let t=k1r(e);return t?(0,uF.jsxs)(ie,{sx:rKn,title:`Phase ${t.reached} of ${t.total}`,children:[(0,uF.jsx)(ie,{component:"span",sx:nKn,children:`${t.reached}/${t.total}`}),(0,uF.jsx)(ie,{component:"span",sx:iKn,"aria-hidden":!0,children:t.segments.map(r=>(0,uF.jsx)(ie,{component:"span","data-segment":r.kind,sx:{...oKn,bgcolor:tKn[r.kind]}},r.phase))})]}):null}var Y1r=R(he(),1);var cye=R(he(),1);var CK=R(z(),1);function E1r({tooltip:e,disabled:t,onClick:r}){return(0,CK.jsx)(sr,{title:e,children:(0,CK.jsx)(ie,{component:"span",sx:{display:"flex"},children:(0,CK.jsx)(Ut,{startIcon:(0,CK.jsx)(tm,{}),disabled:t,onClick:r,children:"Build"})})})}var ZHe=R(z(),1);function sye(e){let t=[];return e.exposeCodexActions&&t.push({kind:"codex",label:"with Codex"}),e.exposePiActions&&t.push({kind:"pi",label:"with pi"}),t}function lye({anchorEl:e,open:t,onClose:r,options:n,onSelect:i,stop:o}){return(0,ZHe.jsx)(zl,{anchorEl:e,open:t,onClose:r,onClick:o,children:n.map(a=>(0,ZHe.jsx)(hn,{onClick:s=>{o(s),i(a.kind)},children:a.label},a.kind))})}var vv=R(z(),1);function R1r({tooltip:e,disabled:t,onBuild:r,onSelectHarness:n}){let i=sye(r_()),o=(0,cye.useRef)(null),[a,s]=(0,cye.useState)(!1),l=u=>u.stopPropagation();return(0,vv.jsxs)(vv.Fragment,{children:[(0,vv.jsxs)(wT,{ref:o,variant:"contained",color:"success",size:"small",disabled:t,children:[(0,vv.jsx)(E1r,{tooltip:e,disabled:t,onClick:u=>{l(u),r()}}),i.length>0&&(0,vv.jsx)(Ut,{"aria-label":"Build with a different harness",onClick:u=>{l(u),s(!0)},children:(0,vv.jsx)(om,{})})]}),(0,vv.jsx)(lye,{anchorEl:o.current,open:a,onClose:()=>s(!1),options:i,onSelect:u=>{s(!1),n(u)},stop:l})]})}var A1r=R(z(),1),fF=st((0,A1r.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3m-5.55-8h-2.9v3H8l4 4 4-4h-2.55z"}),"CloudDownloadOutlined");var o_=R(z(),1),aKn={vertical:"bottom",horizontal:"center"};function uye({clone:e}){let{prompt:t,confirm:r,cancel:n,error:i,dismissError:o}=e;return(0,o_.jsxs)(o_.Fragment,{children:[t&&(0,o_.jsx)(ro,{title:"Clone repository",message:`Clone ${t.displayName} over SSH into ${t.cloneTarget}${t.node?` on ${t.node}`:""}?`,confirmLabel:"Clone",confirmColor:"primary",onConfirm:r,onCancel:n}),(0,o_.jsx)(fl,{open:!!i,autoHideDuration:8e3,onClose:o,anchorOrigin:aKn,children:(0,o_.jsx)(oi,{severity:"error",onClose:o,variant:"filled",children:i})})]})}var A0=R(he(),1);function QHe(e){return["backlog","clone",e]}function fye(e,t){t(QHe(e.origin),void 0,{title:`Clone ${e.displayName}`,subtitle:e.origin,...e.node&&{node:e.node}})}function P1r(e,t){return!!e&&e.length===t.length&&e.every((r,n)=>r===t[n])}function L1r(e,t,r){let n=QHe(t.origin),i=new Set(e.filter(o=>P1r(o.assistArgs,n)).map(o=>o.id));return fye(t,r),{args:n,target:t.cloneTarget,node:t.node,preexisting:i}}function M1r(e,t){if(!t.id){let n=e.find(i=>P1r(i.assistArgs,t.args)&&!t.preexisting.has(i.id));return n?{type:"latch",id:n.id}:null}let r=e.find(n=>n.id===t.id);return r?r.status==="done"?{type:"done"}:r.status==="error"?{type:"error",message:r.error||"Clone failed."}:null:null}function dye(e){let{setSelectedCwd:t}=Bn(),{launchAssist:r}=Gl(),[n,i]=(0,A0.useState)(null),[o,a]=(0,A0.useState)(null),[s,l]=(0,A0.useState)(null),u=(0,A0.useCallback)(p=>{l(null),i(p)},[]),f=(0,A0.useCallback)(()=>i(null),[]),d=(0,A0.useCallback)(()=>l(null),[]),h=(0,A0.useCallback)(()=>{n&&(a(L1r(e,n,r)),i(null))},[n,e,r]);return(0,A0.useEffect)(()=>{if(!o)return;let p=M1r(e,o);p&&(p.type==="latch"?a(m=>m&&{...m,id:p.id}):p.type==="done"?(o.node?t(o.target,o.node):t(o.target),a(null)):(l(p.message),a(null)))},[e,o,t]),{prompt:n,requestClone:u,confirm:h,cancel:f,error:s,dismissError:d}}function dF(e,t){return`Not cloned ${e?`on ${e}`:"locally"} \u2014 click to clone into ${t}`}var Q2=R(z(),1),sKn={border:1,borderStyle:"dashed"};function I1r({target:e}){let t=dye(iye());return(0,Q2.jsxs)(Q2.Fragment,{children:[(0,Q2.jsx)(sr,{title:dF(e.node,e.cloneTarget),children:(0,Q2.jsx)(ir,{"aria-label":"Clone",size:"small",sx:sKn,onClick:r=>{r.stopPropagation(),t.requestClone(e)},children:(0,Q2.jsx)(fF,{fontSize:"small"})})}),(0,Q2.jsx)(uye,{clone:t})]})}var hye=R(he(),1),JHe=(0,hye.createContext)(()=>{});function D1r(){return(0,hye.useContext)(JHe)}var pye=R(z(),1);function N1r({session:e}){let t=wS(D1r());return(0,pye.jsxs)(Ut,{variant:"contained",size:"small",startIcon:(0,pye.jsx)(Mme,{}),onClick:r=>{r.stopPropagation(),t(e.id)},children:["Session ",e.id]})}function O1r(e,t,r,n){let i=r.node?[{node:r.node}]:[];e(["backlog","run",ho(t),...n],r.cwd,...i)}var wK=R(z(),1);function B1r({tooltip:e,disabled:t,onClick:r}){return(0,wK.jsx)(sr,{title:e,children:(0,wK.jsx)("span",{children:(0,wK.jsx)(ir,{"aria-label":"Build",color:"success",size:"small",disabled:t,onClick:r,children:(0,wK.jsx)(tm,{})})})})}function lKn(e,t){let r=e.assistArgs;if(r?.[0]!=="backlog"||r[1]!=="run"||!r[2])return!1;try{return Pee(r[2])===t}catch{return!1}}function F1r(e,t){return e.find(r=>r.status!=="done"&&r.status!=="error"&&(lKn(r,t)||yL(r)?.itemId===t))}var mye=R(he(),1),eUe=(0,mye.createContext)({nodes:null,names:[],visible:!1,selected:void 0,select:()=>{}});function Zu(){return(0,mye.useContext)(eUe)}function gye(){let{nodes:e,selected:t}=Zu();return t&&t!==e?.local?t:void 0}var H1r=R(he(),1);var yye=R(he(),1);function $1r(e,t){return Promise.all(t.map(async r=>{let n=await cKn(e,r).catch(()=>({}));return[r,n]}))}async function cKn(e,t){let r=await fetch(Xr(`/api/repo-location?origin=${encodeURIComponent(e)}`,t||void 0));return r.ok?r.json():{}}var tUe="\0";function z1r(e,t){let[r,n]=(0,yye.useState)(null);return(0,yye.useEffect)(()=>{if(!e||!t)return;let i=!1;return $1r(e,t.split(tUe)).then(o=>{i||n({origin:e,byNode:Object.fromEntries(o)})}),()=>{i=!0}},[e,t]),r}function vye(e,t){let{cloneOn:r,originOf:n}=Bn(),i=e?n(e):void 0,o=t.filter(s=>!e||!r(e,s)).map(s=>s??"").join(tUe),a=z1r(i,o);return(0,H1r.useCallback)(s=>{let l=e?r(e,s):void 0;if(l)return{kind:"cloned",cwd:l};let u=a&&a.origin===i?a.byNode[s??""]:void 0;return u?.cwd?{kind:"cloned",cwd:u.cwd}:i&&u?.cloneTarget?{kind:"clonable",origin:i,cloneTarget:u.cloneTarget}:{kind:"unavailable"}},[e,r,i,a])}var pF=R(he(),1);var U1r=R(z(),1);function hF({inputRef:e,value:t,onChange:r,onKeyDown:n,placeholder:i,autoFocus:o}){return(0,U1r.jsx)(qn,{autoFocus:o,inputRef:e,value:t,onChange:a=>r(a.target.value),onKeyDown:n,placeholder:i,size:"small",fullWidth:!0,slotProps:{input:{sx:{fontSize:12}}},sx:{p:.5}})}var bye=R(he(),1);function xye(e){let t=(0,bye.useRef)(null);return(0,bye.useEffect)(()=>{e&&t.current?.scrollIntoView({block:"nearest"})},[e]),t}var V1r=R(z(),1);function W1r({cwd:e,selected:t,highlighted:r,onHover:n,onSelect:i}){let o=xye(r);return(0,V1r.jsx)(hn,{ref:o,selected:t,title:e,onClick:i,onMouseEnter:n,sx:{fontSize:12,display:"flex",justifyContent:"space-between",gap:1,...r&&{bgcolor:"action.hover"}},children:bv(e)})}var rUe=R(z(),1);function Tye({repos:e,selected:t,highlight:r,onHighlight:n,onSelect:i}){return(0,rUe.jsx)($p,{dense:!0,children:e.map((o,a)=>(0,rUe.jsx)(W1r,{cwd:o,selected:o===t,highlighted:a===r,onHover:()=>n(a),onSelect:()=>i(o)},o))})}var Sye=R(he(),1);function a_(e,t,r,n){let[i,o]=(0,Sye.useState)(0);return(0,Sye.useEffect)(()=>{o(0)},[t]),{highlight:i,setHighlight:o,onKeyDown:s=>{let l=e.length;if(s.key==="ArrowDown")s.preventDefault(),l>0&&o(u=>(u+1)%l);else if(s.key==="ArrowUp")s.preventDefault(),l>0&&o(u=>(u-1+l)%l);else if(s.key==="Enter"){s.preventDefault();let u=e[i];u!==void 0&&(r(u),n())}else s.key==="Escape"&&(s.preventDefault(),n())}}}var kK=R(z(),1);function bv(e){let t=e.includes("\\")?"\\":"/";return e.split(t).filter(Boolean).pop()??e}var uKn={...wL};function G1r({repos:e,selected:t,onSelect:r,close:n,initialFilter:i=""}){let[o,a]=(0,pF.useState)(i),s=(0,pF.useRef)(null);(0,pF.useEffect)(()=>{s.current?.focus()},[]);let l=o.trim().toLowerCase(),u=l?e.filter(m=>m.toLowerCase().includes(l)):e,{highlight:f,setHighlight:d,onKeyDown:h}=a_(u,l,r,n);return(0,kK.jsxs)(cn,{elevation:4,sx:uKn,children:[(0,kK.jsx)(hF,{inputRef:s,value:o,onChange:a,onKeyDown:h,placeholder:"Filter repos..."}),(0,kK.jsx)(Tye,{repos:u,selected:t,highlight:f,onHighlight:d,onSelect:m=>{r(m),n()}})]})}function Cye(e,t){return{origin:e.origin,cloneTarget:e.cloneTarget,displayName:bv(e.origin),node:t}}function q1r(){let e=ds(),t=gye(),r=vye(e??"",[t])(t);return e?r.kind==="cloned"?{kind:"ready",cwd:r.cwd,node:t}:r.kind==="clonable"?{kind:"clone",prompt:Cye(r,t)}:{kind:"unavailable",node:t??"this machine"}:{kind:"ready",node:t}}function j1r(e){return e?`Not cloned on ${e}`:"Build"}var _K=R(z(),1);function wye({itemId:e,compact:t=!1}){let{launchAssist:r}=Gl(),n=q1r(),i=F1r(iye(),e),[o,a]=(0,Y1r.useState)(!1);if(n.kind==="clone")return(0,_K.jsx)(I1r,{target:n.prompt});if(i)return(0,_K.jsx)(N1r,{session:i});let s=n.kind==="unavailable"?n.node:void 0,l=o||!!s,u=d=>{l||n.kind!=="ready"||(a(!0),O1r(r,e,n,d))},f=j1r(s);return t?(0,_K.jsx)(B1r,{tooltip:f,disabled:l,onClick:d=>{d.stopPropagation(),u([])}}):(0,_K.jsx)(R1r,{tooltip:f,disabled:l,onBuild:()=>u([]),onSelectHarness:d=>u(["--harness",d])})}var K1r=R(he(),1);var mF=R(z(),1);function X1r({itemId:e,starred:t,onToggled:r}){let n=ds(),i=br(),[o,a]=(0,K1r.useState)(!1);return(0,mF.jsx)(sr,{title:t?"Unstar":"Star",children:(0,mF.jsx)("span",{children:(0,mF.jsx)(ir,{"aria-label":t?"Unstar":"Star","aria-pressed":t,color:t?"warning":"default",size:"small",disabled:o,onClick:async l=>{if(l.stopPropagation(),!o){a(!0);try{await Gee(e,!t,n,i),await r()}finally{a(!1)}}},children:t?(0,mF.jsx)(Kte,{}):(0,mF.jsx)(Xte,{})})})})}var Z1r=R(z(),1),Q1r=st((0,Z1r.jsx)("path",{d:"M22 7h-9v2h9zm0 8h-9v2h9zM5.54 11 2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41z"}),"Checklist");var EK=R(z(),1),fKn={display:"inline-flex",alignItems:"center",gap:.375,flexShrink:0,fontSize:"0.71875rem",color:"text.secondary","& svg":{fontSize:14}};function J1r({count:e}){return e<1?null:(0,EK.jsx)(sr,{title:`${e} incomplete subtask${e===1?"":"s"}`,children:(0,EK.jsxs)(ie,{component:"span",sx:fKn,children:[(0,EK.jsx)(Q1r,{}),e]})})}var J2=R(z(),1);function evr({item:e,onReload:t}){return(0,J2.jsxs)(J2.Fragment,{children:[(0,J2.jsx)(J1r,{count:e.incompleteSubtasks}),(0,J2.jsx)(_1r,{item:e}),(0,J2.jsx)(X1r,{itemId:e.id,starred:e.starred,onToggled:t}),aye(e)&&(0,J2.jsx)(wye,{itemId:e.id,compact:!0})]})}var eT=R(z(),1);function dKn(e,t){return e?t?yv.inProgressRunningCard:yv.inProgressCard:yv.card}function tvr({item:e,to:t,socket:r,onReload:n}){let i=S1r(r.sessions,e.id),o=e.status==="in-progress",a=o&&i?.status==="running";return(0,eT.jsxs)(ie,{sx:dKn(o,a),children:[(0,eT.jsx)(C1r,{status:e.status}),(0,eT.jsxs)(ie,{sx:yv.main,children:[(0,eT.jsx)(jr,{component:Cs,to:t,underline:"none",title:e.name,sx:yv.stretchedNameLink,children:e.name}),(0,eT.jsx)(T1r,{item:e,openSession:i,onSelectSession:r.selectSession})]}),(0,eT.jsx)(ie,{sx:yv.actions,children:(0,eT.jsx)(evr,{item:e,onReload:n})})]})}var nvr=R(z(),1),hKn={all:"items",story:"stories",bug:"bugs"},pKn={textAlign:"center",color:"text.disabled",py:6,px:2};function rvr({query:e,typeFilter:t}){let r=hKn[t],n=e.trim()?`No ${r} match your search.`:`No ${r} in the backlog.`;return(0,nvr.jsx)(ie,{sx:pKn,children:n})}var xv=R(z(),1),mKn={display:"flex",justifyContent:"center",py:6};function ivr({loading:e,error:t,query:r,typeFilter:n,items:i,socket:o,itemPath:a,onReload:s}){if(e)return(0,xv.jsx)(ie,{sx:mKn,children:(0,xv.jsx)(To,{})});let l=t&&(0,xv.jsx)(oi,{severity:"error",children:t});return i.length===0?l||(0,xv.jsx)(rvr,{query:r,typeFilter:n}):(0,xv.jsxs)(xv.Fragment,{children:[l,i.map(u=>(0,xv.jsx)(tvr,{item:u,to:a(u),socket:o,onReload:s},u.id))]})}var gF=R(he(),1);function gKn(e){let t=new URLSearchParams;for(let n of e)t.append("knownCwd",n);let r=t.toString();return r?`/api/backlog/summary?${r}`:"/api/backlog/summary"}async function ovr({cwd:e,node:t,knownCwds:r,signal:n}){return(await fetch(Vl(gKn(r),e,t),{signal:n})).json()}function avr(){let{repos:e,selectedCwd:t,cloneOn:r}=Bn(),n=gye(),[i,o]=(0,gF.useState)([]),a=(0,gF.useMemo)(()=>e.map(l=>r(l,n)).filter(l=>!!l),[e,r,n]),s=t?r(t,n):void 0;return(0,gF.useEffect)(()=>{let l=new AbortController;return ovr({cwd:s,node:n,knownCwds:a,signal:l.signal}).then(o).catch(()=>{}),()=>l.abort()},[a,s,n]),{summaries:i,node:n}}var kye=R(z(),1),yKn={borderStyle:"dashed"};function svr({summary:e,node:t,onSelectCwd:r,onRequestClone:n}){let{origin:i,displayName:o,openCount:a,isCurrent:s,cwd:l,cloneTarget:u}=e,f=!l&&!!u,d=l?()=>r(l):f&&u?()=>n({origin:i,cloneTarget:u,displayName:o,node:t}):void 0,h=(0,kye.jsx)(en,{label:`${o} (${a})`,size:"small",color:s?"primary":"default",variant:s?"filled":"outlined",disabled:!l&&!f,onClick:d,icon:f?(0,kye.jsx)(fF,{}):void 0,sx:f?yKn:void 0});return!f||!u?h:(0,kye.jsx)(sr,{describeChild:!0,title:dF(t,u),children:h})}var RK=R(z(),1),vKn={flexWrap:"wrap",gap:1,mb:2};function lvr({sessions:e}){let{summaries:t,node:r}=avr(),{setSelectedCwd:n}=Bn(),i=dye(e);return t.length===0?null:(0,RK.jsxs)(Rt,{direction:"row",sx:vKn,children:[t.map(o=>(0,RK.jsx)(svr,{summary:o,node:r,onSelectCwd:a=>r?n(a,r):n(a),onRequestClone:i.requestClone},o.origin)),(0,RK.jsx)(uye,{clone:i})]})}var uvr=R(z(),1);function cvr({value:e,onChange:t}){return(0,uvr.jsx)(qn,{"data-backlog-focus":"search",autoFocus:!0,fullWidth:!0,size:"small",placeholder:"Search backlog\u2026",value:e,onChange:r=>t(r.target.value),sx:{mb:2}})}var _ye=R(he(),1);var Eye=R(z(),1);async function bKn(){return(await(await fetch("/api/backups/list")).json())[0]}function fvr(){let[e,t]=(0,_ye.useState)();return(0,_ye.useEffect)(()=>{bKn().then(t)},[]),e?(0,Eye.jsx)(sr,{title:new Date(e.createdAt).toLocaleString(),children:(0,Eye.jsxs)(jr,{component:Cs,to:"/backups",underline:"hover",color:"text.secondary",variant:"body2",children:["Last backed up ",wo(String(e.createdAt))]})}):null}var yF=R(z(),1);function dvr(){let[e,t]=cF();return(0,yF.jsxs)(Cu,{value:e,exclusive:!0,size:"small","aria-label":"Status filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,yF.jsx)(bs,{value:"todo",children:"Todo"}),(0,yF.jsx)(bs,{value:"done",children:"Done"}),(0,yF.jsx)(bs,{value:"all",children:"All"})]})}var vF=R(z(),1);function hvr({value:e,onChange:t}){return(0,vF.jsxs)(Cu,{value:e,exclusive:!0,size:"small","aria-label":"Type filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,vF.jsx)(bs,{value:"all",children:"All"}),(0,vF.jsx)(bs,{value:"story",children:"Stories"}),(0,vF.jsx)(bs,{value:"bug",children:"Bugs"})]})}var s_=R(z(),1),xKn={justifyContent:"space-between",alignItems:"center",mb:3},TKn={fontWeight:600},SKn={alignItems:"center"};function pvr({typeFilter:e,onTypeFilterChange:t}){return(0,s_.jsxs)(Rt,{direction:"row",sx:xKn,children:[(0,s_.jsx)(Ie,{variant:"h5",sx:TKn,children:"Backlog"}),(0,s_.jsxs)(Rt,{direction:"row",spacing:2,sx:SKn,children:[(0,s_.jsx)(fvr,{}),(0,s_.jsx)(hvr,{value:e,onChange:t}),(0,s_.jsx)(dvr,{})]})]})}var tT=R(z(),1);function gvr({items:e,loading:t,error:r,socket:n,onReload:i}){let o=ds(),a=br(),{query:s,setQuery:l,results:u,loading:f}=f1r(),[d,h]=(0,mvr.useState)("all"),p=u??e,m=d==="all"?p:p.filter(g=>g.type===d);return(0,tT.jsxs)(tT.Fragment,{children:[(0,tT.jsx)(pvr,{typeFilter:d,onTypeFilterChange:h}),(0,tT.jsx)(cvr,{value:s,onChange:l}),(0,tT.jsx)(lvr,{sessions:n.sessions}),(0,tT.jsx)(ivr,{loading:t||f,error:u?null:r,query:s,typeFilter:d,items:m,socket:n,itemPath:g=>cS(g.id,o,a),onReload:i})]})}var Oye=R(he(),1);var aA=R(he(),1);async function nUe(e,t,r){let n=await fetch(Vl(`/api/items/${ho(e)}`,t.cwd,t.node),{signal:r});return n.ok?n.json():null}function yvr(e){let t=ds(),r=br(),[n,i]=(0,aA.useState)(null),[o,a]=(0,aA.useState)(!0),s=(0,aA.useCallback)(async()=>{i(await nUe(e,{cwd:t,node:r}))},[e,t,r]);return(0,aA.useEffect)(()=>{let l=new AbortController,{signal:u}=l;return a(!0),(async()=>{try{let f=await nUe(e,{cwd:t,node:r},u);if(u.aborted)return;i(f),a(!1)}catch(f){if(!u.aborted)throw f}})(),()=>l.abort()},[e,t,r]),{item:n,loading:o,reload:s}}var l_={description:"item-section-description",acceptanceCriteria:"item-section-acceptance-criteria",subtasks:"item-section-subtasks",plan:"item-section-plan",activity:"item-section-activity",comments:"item-section-comments"},AK=140,iUe="--pinned-header-height",Rye=`var(${iUe}, ${AK}px)`,vvr=`calc(${Rye} + 8px)`;function ag(e){return{id:l_[e],sx:{mb:2,scrollMarginTop:vvr}}}function Aye(e){return{id:`item-phase-${e}`,sx:{scrollMarginTop:vvr}}}var c_=R(z(),1);function bvr({criteria:e}){return e.length===0?null:(0,c_.jsxs)(ie,{...ag("acceptanceCriteria"),children:[(0,c_.jsx)(Ie,{variant:"overline",sx:{color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"},children:"Acceptance Criteria"}),(0,c_.jsx)(Q0,{disablePadding:!0,sx:{maxWidth:"72ch"},children:e.map((t,r)=>(0,c_.jsxs)(ET,{disableGutters:!0,disablePadding:!0,sx:{py:.5,display:"flex",alignItems:"baseline"},children:[(0,c_.jsxs)(Ie,{component:"span",sx:{color:"text.secondary",mr:1},children:[r+1,"."]}),(0,c_.jsx)(Au,{component:"span",className:"markdown",html:xL(t)})]},t))})]})}var PK=R(z(),1),CKn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function xvr({description:e}){return e?(0,PK.jsxs)(ie,{...ag("description"),children:[(0,PK.jsx)(Ie,{variant:"overline",sx:CKn,children:"Description"}),(0,PK.jsx)(Xw,{content:e,renderMermaid:!0})]}):null}var Avr=R(he(),1);function Tvr(e,t=10){let r=i=>e.filter(o=>o.kind===i).reverse(),n=r("commit");return{branches:r("branch"),commits:n.slice(0,t),overflowCommits:n.slice(t),prs:r("pr"),slacks:r("slack"),sessions:r("session")}}var Cvr=R(z(),1),wKn={color:"text.secondary",alignSelf:"flex-start",textAlign:"left"};function Svr({hiddenCount:e,expanded:t,onToggle:r}){return e===0?null:(0,Cvr.jsx)(jr,{component:"button",type:"button",variant:"body2",underline:"hover",sx:wKn,onClick:n=>{n.stopPropagation(),r()},children:t?"Show fewer commits":`\u2026 and ${e} more commits`})}var sA=R(z(),1),kKn={display:"flex",alignItems:"center",gap:1},_Kn={color:"text.secondary",fontFamily:"monospace"},EKn={flex:1,overflowWrap:"anywhere"},RKn={color:"text.disabled","&:hover":{color:"text.primary"}};function wvr({conversation:e}){let{resumeSession:t}=Gl(),r=n=>{n.stopPropagation(),t(e.sessionId,e.cwd??"",e.title,e.harness)};return(0,sA.jsxs)(ie,{sx:kKn,children:[(0,sA.jsx)(Ie,{variant:"body2",component:"span",sx:_Kn,children:"session"}),(0,sA.jsx)(Ie,{variant:"body2",component:"span",sx:EKn,children:e.title??e.sessionId}),(0,sA.jsx)(ir,{size:"small",title:"Resume",sx:RKn,onClick:r,children:(0,sA.jsx)(tm,{sx:{fontSize:14}})})]})}var _vr=R(z(),1),AKn={color:"text.disabled",ml:1};function kvr({gitRef:e}){return e.kind!=="commit"||!e.createdAt?null:(0,_vr.jsx)(ie,{component:"span",sx:AKn,children:PKn(e.createdAt)})}function PKn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Evr(e){if(e.kind==="commit"){let t=e.title?` ${e.title}`:"";return`${e.ref.slice(0,8)}${t}`}if(e.kind==="pr"){let t=e.title?` ${e.title}`:"",r=e.state?` (${e.state.toLowerCase()})`:"";return`#${e.ref}${t}${r}`}return e.kind==="slack"||e.kind==="session"?e.title??e.ref:e.ref}var Tv=R(z(),1),LKn={color:"text.secondary",mr:1,fontFamily:"monospace"};function MKn({gitRef:e}){let t=Evr(e);return!e.url||e.kind==="session"?(0,Tv.jsx)(Tv.Fragment,{children:t}):(0,Tv.jsx)(jr,{href:e.url,target:"_blank",rel:"noopener",onClick:r=>r.stopPropagation(),children:t})}function Rvr({gitRef:e}){return(0,Tv.jsxs)(Ie,{variant:"body2",children:[(0,Tv.jsx)(ie,{component:"span",sx:LKn,children:e.kind}),(0,Tv.jsx)(MKn,{gitRef:e}),(0,Tv.jsx)(kvr,{gitRef:e})]})}var u_=R(z(),1),IKn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function Pvr({gitRefs:e,conversations:t=[]}){let[r,n]=(0,Avr.useState)(!1),{branches:i,commits:o,overflowCommits:a,prs:s,slacks:l}=Tvr(e),u=[...i,...o,...r?a:[],...s,...l];return u.length===0&&t.length===0?null:(0,u_.jsxs)(ie,{...ag("activity"),children:[(0,u_.jsx)(Ie,{variant:"overline",sx:IKn,children:"Activity"}),(0,u_.jsxs)(Rt,{spacing:1,children:[u.map(f=>(0,u_.jsx)(Rvr,{gitRef:f},`${f.kind}:${f.ref}`)),t.map(f=>(0,u_.jsx)(wvr,{conversation:f},f.sessionId)),(0,u_.jsx)(Svr,{hiddenCount:a.length,expanded:r,onToggle:()=>n(f=>!f)})]})]})}var lA=R(z(),1),DKn={alignItems:"center",fontSize:"0.75rem",color:"text.secondary",mb:.5},NKn={color:"text.disabled"},OKn={fontWeight:500},BKn={summary:"Phase summary",comment:"Comment"};function Lvr({comment:e}){return(0,lA.jsxs)(Rt,{direction:"row",spacing:.5,sx:DKn,children:[e.id!==void 0&&(0,lA.jsxs)(Ie,{variant:"caption",sx:NKn,children:["#",e.id]}),(0,lA.jsx)(Ie,{variant:"caption",sx:OKn,children:BKn[e.type]}),e.phase!==void 0&&(0,lA.jsxs)(Ie,{variant:"caption",children:["\xB7 Phase ",e.phase]}),(0,lA.jsxs)(Ie,{variant:"caption",children:["\xB7 ",FKn(e.timestamp)]})]})}function FKn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}var Mvr=R(z(),1),Ivr=st((0,Mvr.jsx)("path",{d:"M16 9v10H8V9zm-1.5-6h-5l-1 1H5v2h14V4h-3.5zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2z"}),"DeleteOutlined");var oUe=R(he(),1);async function Dvr(e,t,r,n){let i=await fetch(Vl(`/api/items/${ho(e)}/comments/${t}`,r,n),{method:"DELETE"});if(!i.ok){let o=await i.json().catch(()=>{});throw new Error(o?.error??`Failed to delete comment (${i.status})`)}}var Sv=R(z(),1),$Kn={mt:-.5,mr:-.5,color:"text.secondary"};function Nvr({itemId:e,commentId:t,onDeleted:r}){let n=ds(),i=br(),[o,a]=(0,oUe.useState)(!1),[s,l]=(0,oUe.useState)(),u=()=>l(void 0);return(0,Sv.jsxs)(Sv.Fragment,{children:[o&&(0,Sv.jsx)(ro,{message:"Are you sure you want to delete this comment?",onConfirm:async()=>{a(!1);try{await Dvr(e,t,n,i),await r()}catch(f){l(f instanceof Error?f.message:"Failed to delete comment")}},onCancel:()=>a(!1)}),(0,Sv.jsx)(fl,{open:s!==void 0,autoHideDuration:6e3,onClose:u,children:(0,Sv.jsx)(oi,{severity:"error",variant:"filled",onClose:u,children:s})}),(0,Sv.jsx)(ir,{"aria-label":"Delete comment",size:"small",sx:$Kn,onClick:()=>a(!0),children:(0,Sv.jsx)(Ivr,{fontSize:"inherit"})})]})}var cA=R(z(),1),zKn={summary:{bgcolor:"warning.light",borderColor:"warning.dark"},comment:{bgcolor:"action.selected",borderColor:"divider"}},HKn={justifyContent:"space-between",alignItems:"flex-start"},UKn={color:"text.primary",whiteSpace:"pre-wrap"};function WKn(e){return{p:1.5,bgcolor:e.bgcolor,borderColor:e.borderColor}}function Ovr({comment:e,itemId:t,onDeleted:r}){return(0,cA.jsxs)(cn,{variant:"outlined",sx:WKn(zKn[e.type]),children:[(0,cA.jsxs)(Rt,{direction:"row",sx:HKn,children:[(0,cA.jsx)(Lvr,{comment:e}),e.id!==void 0&&t!==void 0&&r&&(0,cA.jsx)(Nvr,{itemId:t,commentId:e.id,onDeleted:r})]}),(0,cA.jsx)(Ie,{variant:"body2",sx:UKn,children:e.text})]})}var bF=R(z(),1),VKn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function Bvr({comments:e,itemId:t,onCommentDeleted:r}){return e.length===0?null:(0,bF.jsxs)(ie,{...ag("comments"),children:[(0,bF.jsx)(Ie,{variant:"overline",sx:VKn,children:"Comments"}),(0,bF.jsx)(Rt,{spacing:1,children:e.map((n,i)=>(0,bF.jsx)(Ovr,{comment:n,itemId:t,onDeleted:r},`${n.timestamp}-${i}`))})]})}var Fvr=R(z(),1);function xF({total:e,sx:t}){return(0,Fvr.jsx)(Ie,{sx:t,children:oye(e)})}var zvr=R(z(),1),GKn={color:"text.secondary",fontSize:"0.75rem"};function $vr({usage:e}){let t={tokensUp:e.reduce((r,n)=>r+n.tokensUp,0),tokensDown:e.reduce((r,n)=>r+n.tokensDown,0),activeMs:e.reduce((r,n)=>r+n.activeMs,0),peakContextPct:e.reduce((r,n)=>Math.max(r,n.peakContextPct),0)};return(0,zvr.jsx)(xF,{total:t,sx:GKn})}var rT=R(z(),1);function Hvr({checks:e}){return(0,rT.jsxs)(ie,{sx:{mt:1,pt:1},children:[(0,rT.jsx)(Ui,{sx:{mb:1}}),(0,rT.jsx)(Ie,{variant:"overline",sx:{color:"text.disabled",letterSpacing:"0.08em"},children:"Manual Checks"}),(0,rT.jsx)(Q0,{disablePadding:!0,sx:{ml:.5,mt:.5},children:e.map(t=>(0,rT.jsxs)(ET,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,rT.jsx)(Ie,{component:"span",sx:{mr:1,fontSize:"0.875rem",color:"text.secondary"},children:"\u2610"}),(0,rT.jsx)(Au,{component:"span",className:"markdown",sx:{fontSize:"0.875rem",color:"text.secondary"},html:xL(t)})]},t))})]})}var Pye={done:{borderColor:"success.light",bgcolor:"success.light"},current:{borderColor:"info.main",bgcolor:"info.light",ring:"info.light"},upcoming:{borderColor:"divider",bgcolor:"background.paper"}};function Uvr(e){let t=Pye[e];return{p:2,borderColor:t.ring?"info.main":t.borderColor,bgcolor:t.bgcolor,...t.ring?{boxShadow:"0 0 0 2px"}:{}}}var Wvr={done:"\u2713",current:"\u2022",upcoming:"\u2022"};var qvr=R(he(),1);var Vvr=R(he(),1),Cv=R(z(),1);function Gvr({phaseName:e,onConfirm:t,onCancel:r}){let[n,i]=(0,Vvr.useState)("");return(0,Cv.jsxs)($l,{open:!0,onClose:r,maxWidth:"xs",fullWidth:!0,children:[(0,Cv.jsxs)(xu,{children:["Rewind to ",e,"?"]}),(0,Cv.jsxs)(bu,{children:[(0,Cv.jsx)(Ie,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This will mark all later phases as incomplete."}),(0,Cv.jsx)(qn,{fullWidth:!0,multiline:!0,rows:3,size:"small",placeholder:"Reason for rewinding...",value:n,onChange:o=>i(o.target.value)})]}),(0,Cv.jsxs)(id,{children:[(0,Cv.jsx)(Ut,{onClick:r,children:"Cancel"}),(0,Cv.jsx)(Ut,{variant:"contained",color:"warning",disabled:n.trim().length===0,onClick:()=>t(n.trim()),children:"Rewind"})]})]})}var uA=R(z(),1);function jvr({itemId:e,phaseNumber:t,phaseName:r,onRewound:n}){let i=ds(),o=br(),[a,s]=(0,qvr.useState)(!1);return(0,uA.jsxs)(uA.Fragment,{children:[(0,uA.jsx)(Ut,{size:"small",color:"warning",variant:"outlined",onClick:()=>s(!0),sx:{ml:"auto",textTransform:"none",fontSize:"0.75rem"},children:"Rewind"}),a&&(0,uA.jsx)(Gvr,{phaseName:r,onConfirm:async l=>{await Krt(e,t,l,i,o),await n()},onCancel:()=>s(!1)})]})}var TF=R(z(),1),qKn={done:{label:"Done",color:"success"},current:{label:"In Progress",color:"info"},upcoming:{label:"Upcoming",color:"default"}},jKn={alignItems:"center",mb:1},YKn={fontWeight:500},KKn={fontWeight:500,fontSize:"0.75rem"};function Yvr({phase:e,index:t,status:r,itemId:n,onRewind:i}){let o=qKn[r],a=r==="done"&&n!==void 0&&i;return(0,TF.jsxs)(Rt,{direction:"row",spacing:1,sx:jKn,children:[(0,TF.jsxs)(Ie,{sx:YKn,children:["Phase ",t+1,": ",e.name]}),(0,TF.jsx)(en,{label:o.label,size:"small",color:o.color,sx:KKn}),a&&(0,TF.jsx)(jvr,{itemId:n,phaseNumber:t+1,phaseName:e.name,onRewound:i})]})}var LK=R(z(),1),XKn={color:"text.secondary",fontSize:"0.75rem",letterSpacing:"0.08em",display:"block"},ZKn={color:"text.secondary",fontSize:"0.75rem",fontFamily:"monospace",display:"block"};function Kvr({sessions:e}){return(0,LK.jsxs)(ie,{sx:{mb:1},children:[(0,LK.jsx)(Ie,{variant:"overline",sx:XKn,children:"Sessions"}),e.map(t=>(0,LK.jsx)(Ie,{sx:ZKn,children:`${t.hostname} / ${t.osUser} / ${t.claudeSessionId}`},t.claudeSessionId))]})}var Zvr=R(z(),1),QKn={color:"text.secondary",fontSize:"0.75rem",mb:1,display:"block"};function Xvr({usage:e}){return(0,Zvr.jsx)(xF,{total:e,sx:QKn})}var SF=R(z(),1);function Qvr({tasks:e,marker:t}){return(0,SF.jsx)(Q0,{disablePadding:!0,sx:{ml:.5},children:e.map(r=>(0,SF.jsxs)(ET,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,SF.jsx)(Ie,{component:"span",sx:{color:"text.secondary",mr:1},children:t}),(0,SF.jsx)(Au,{component:"span",className:"markdown",html:xL(r.task)})]},r.task))})}var f_=R(z(),1);function Jvr({phase:e,index:t,status:r,itemId:n,usage:i,sessions:o,onRewind:a}){let s=e.manualChecks??[],l=Aye(t);return(0,f_.jsxs)(cn,{variant:"outlined",id:l.id,sx:{...Uvr(r),...l.sx},children:[(0,f_.jsx)(Yvr,{phase:e,index:t,status:r,itemId:n,onRewind:a}),i&&(0,f_.jsx)(Xvr,{usage:i}),(0,f_.jsx)(Qvr,{tasks:e.tasks,marker:Wvr[r]}),s.length>0&&(0,f_.jsx)(Hvr,{checks:s}),o&&o.length>0&&(0,f_.jsx)(Kvr,{sessions:o})]})}var MK={name:"Review",tasks:[]};function Lye(e){return e.at(-1)?.name===MK.name?e.length-1:e.length}function Mye(e,t){if(t===void 0)return"upcoming";let r=e+1;return r<t?"done":r===t?"current":"upcoming"}function ebr(e=[]){return new Map(e.map(t=>[t.phaseIdx,t]))}function tbr(e=[]){let t=new Map;for(let r of e){let n=t.get(r.phaseIdx);n?n.push(r):t.set(r.phaseIdx,[r])}return t}var aUe=R(z(),1);function rbr({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){let a=ebr(n),s=tbr(i),l=Lye(e),u=(i??[]).filter(d=>d.phaseIdx>=l),f=l===e.length&&u.length>0?[...e,MK]:e;return(0,aUe.jsx)(Rt,{spacing:1.5,children:f.map((d,h)=>(0,aUe.jsx)(Jvr,{phase:d,index:h,status:Mye(h,t),itemId:r,usage:a.get(h),sessions:h===l?u:s.get(h),onRewind:h<e.length?o:void 0},d.name))})}var fA=R(z(),1),JKn={alignItems:"baseline",justifyContent:"space-between",mb:1},eXn={color:"text.secondary",display:"block",letterSpacing:"0.08em"};function nbr({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){return e.length===0?null:(0,fA.jsxs)(ie,{...ag("plan"),children:[(0,fA.jsxs)(Rt,{direction:"row",sx:JKn,children:[(0,fA.jsx)(Ie,{variant:"overline",sx:eXn,children:"Plan"}),n&&n.length>0&&(0,fA.jsx)($vr,{usage:n})]}),(0,fA.jsx)(rbr,{phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o})]})}var sUe=R(z(),1),Iye=e=>{let{value:t,options:r,colors:n,onChange:i}=e;return(0,sUe.jsx)(PT,{value:t,onChange:o=>i(o.target.value),size:"small",sx:{fontSize:"0.75rem",fontWeight:500,borderRadius:4,bgcolor:n[t].bg,color:n[t].text,"& .MuiSelect-select":{py:.5,px:1.5},"& .MuiSelect-icon":{color:"inherit"}},children:r.map(o=>(0,sUe.jsx)(hn,{value:o,children:o},o))})};var obr=R(z(),1),tXn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"}},rXn=["todo","in-progress","done"];function ibr({current:e,onStatusChange:t}){return(0,obr.jsx)(Iye,{value:e,options:rXn,colors:tXn,onChange:t})}var d_=R(z(),1);function abr({subtask:e,onStatusChange:t}){let r=e.status==="done";return(0,d_.jsxs)(Rt,{direction:"row",spacing:1,sx:{alignItems:"flex-start",justifyContent:"space-between"},children:[(0,d_.jsxs)(ie,{sx:{flex:1},children:[(0,d_.jsx)(Ie,{variant:"body2",sx:{textDecoration:r?"line-through":"none",color:r?"text.disabled":"text.primary"},children:e.title}),e.description&&(0,d_.jsx)(ie,{sx:{mt:.5,fontSize:"0.8125rem",color:r?"text.disabled":"text.secondary"},children:(0,d_.jsx)(Xw,{content:e.description})})]}),(0,d_.jsx)(ibr,{current:e.status,onStatusChange:t})]})}var dA=R(z(),1),nXn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function sbr({subtasks:e,onStatusChange:t}){if(e.length===0)return null;let r=e.filter(n=>n.status!=="done").length;return(0,dA.jsxs)(ie,{...ag("subtasks"),children:[(0,dA.jsx)(Ie,{variant:"overline",sx:nXn,children:"Sub-tasks"}),(0,dA.jsx)(Rt,{spacing:1,children:e.map((n,i)=>(0,dA.jsx)(abr,{subtask:n,onStatusChange:o=>t(i,o)},`${n.title}-${i}`))}),r>0&&(0,dA.jsxs)(oi,{severity:"warning",sx:{mt:1},children:[r," sub-task",r===1?"":"s"," not yet done."]})]})}var nT=R(z(),1);function lbr({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,nT.jsxs)(nT.Fragment,{children:[e.subtasks&&n&&(0,nT.jsx)(sbr,{subtasks:e.subtasks,onStatusChange:n}),e.plan&&(0,nT.jsx)(nbr,{phases:e.plan,currentPhase:e.currentPhase,itemId:e.id,usage:e.phaseUsage,sessions:e.phaseSessions,onRewind:t}),(0,nT.jsx)(Pvr,{gitRefs:e.gitRefs??[],conversations:e.conversations}),e.comments&&(0,nT.jsx)(Bvr,{comments:e.comments,itemId:e.id,onCommentDeleted:r})]})}var CF=R(z(),1);function cbr({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,CF.jsxs)(ie,{sx:{pt:2,flex:1,minWidth:0},children:[(0,CF.jsx)(xvr,{description:e.description}),(0,CF.jsx)(bvr,{criteria:e.acceptanceCriteria}),(0,CF.jsx)(lbr,{item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n})]})}var ubr="item-detail";var IK={wideQuery:`@container ${ubr} (min-width: 760px)`,containerSx:{containerType:"inline-size",containerName:ubr},columnsSx:{display:"flex",columnGap:3}};function iXn(e){let t=e.plan??[];if(t.length===0)return[];let r=Lye(t),i=r===t.length&&(e.phaseSessions??[]).some(o=>o.phaseIdx>=r)?[...t,MK]:t;return[{id:l_.plan,label:"Phases"},...i.map((o,a)=>({id:Aye(a).id,label:`${a+1}`,title:o.name,status:Mye(a,e.currentPhase),nested:!0}))]}function fbr(e){let t=[];return e.description&&t.push({id:l_.description,label:"Description"}),e.acceptanceCriteria.length>0&&t.push({id:l_.acceptanceCriteria,label:"Acceptance Criteria"}),(e.subtasks?.length??0)>0&&t.push({id:l_.subtasks,label:"Sub-tasks"}),t.push(...iXn(e)),(e.gitRefs?.length??0)+(e.conversations?.length??0)>0&&t.push({id:l_.activity,label:"Activity"}),(e.comments?.length??0)>0&&t.push({id:l_.comments,label:"Comments"}),t}var dbr="1.3125rem",hbr={position:"relative",borderRadius:1,"&::after":{content:'""',position:"absolute",inset:0,borderRadius:"inherit",pointerEvents:"none"},"&:hover::after":{bgcolor:"action.hover"},"&:active::after":{bgcolor:"action.selected"}},oXn={...hbr,display:"block",flexShrink:0,maxWidth:"100%",px:1,py:.5,border:0,bgcolor:"transparent",fontSize:dbr,lineHeight:1.2,letterSpacing:"0.02em",textAlign:"left",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"text.secondary"},aXn={...hbr,display:"flex",alignItems:"center",justifyContent:"center",fontSize:dbr,width:"2em",height:"2em",flexShrink:0,lineHeight:1,borderRadius:"50%",border:1,color:"text.primary"},sXn={borderColor:"text.primary",borderWidth:3},lXn={color:"text.primary",fontWeight:700,"&::after":{bgcolor:"action.selected"}};function pbr(e,t){let r=e.status&&Pye[e.status];return r?{...aXn,ml:1.5,bgcolor:r.bgcolor,borderColor:r.borderColor,borderWidth:r.ring?3:1,...t&&sXn}:{...oXn,...t&&lXn}}var gbr=R(z(),1);function mbr({section:e,active:t,onSelect:r}){return(0,gbr.jsx)(On,{sx:pbr(e,t),onClick:()=>r(e.id),title:e.title??e.label,"aria-current":t?"true":void 0,children:e.label})}function ybr(e,t=AK){return hme(e,t)}var lUe=R(z(),1),cXn=48,uXn=260,fXn={display:"none",[IK.wideQuery]:{display:"flex"},position:"sticky",top:Rye,alignSelf:"flex-start",width:uXn,flexShrink:0,maxHeight:`calc(100vh - ${cXn}px - ${Rye})`,alignItems:"flex-start",overflowY:"auto",overflowX:"hidden",py:2};function dXn(e){document.getElementById(e)?.scrollIntoView({behavior:"smooth",block:"start"})}function vbr({item:e,headerHeight:t}){let r=fbr(e),n=ybr(r.map(i=>i.id),t);return r.length===0?null:(0,lUe.jsx)(Rt,{component:"nav",spacing:1,sx:fXn,children:r.map(i=>(0,lUe.jsx)(mbr,{section:i,active:i.id===n,onSelect:dXn},i.id))})}var xbr=R(z(),1);function bbr({to:e}){let t=Li();return(0,xbr.jsx)(Ut,{"data-backlog-focus":"back",variant:"text",size:"small",onClick:()=>t(e),sx:{mb:2,textTransform:"none"},children:"\u2190 Back"})}var Tbr=R(he(),1);var hA=R(z(),1);function Sbr({itemId:e,onDeleted:t}){let r=ds(),n=br(),[i,o]=(0,Tbr.useState)(!1);return(0,hA.jsxs)(hA.Fragment,{children:[i&&(0,hA.jsx)(ro,{onConfirm:async()=>{await jrt(e,r,n),await t()},onCancel:()=>o(!1)}),(0,hA.jsx)(Ut,{variant:"contained",color:"error",size:"small",onClick:()=>o(!0),children:"Delete"})]})}var cUe=R(z(),1),hXn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"},wontdo:{bg:"error.main",text:"error.contrastText"}},pXn=["todo","in-progress","done","wontdo"];function Cbr({current:e,onStatusChange:t}){return t?(0,cUe.jsx)(Iye,{value:e,options:pXn,colors:hXn,onChange:t}):(0,cUe.jsx)(en,{label:e,size:"small",color:Z0e[e],sx:{fontWeight:500,fontSize:"0.75rem"}})}var iT=R(z(),1),mXn={alignItems:"center",color:"text.disabled",fontSize:"0.875rem"},gXn={fontWeight:500,fontSize:"0.75rem"},yXn={color:"text.secondary",fontSize:"0.75rem"};function wbr({item:e,onStatusChange:t}){let r=X0e[e.type];return(0,iT.jsxs)(Rt,{direction:"row",spacing:1,sx:mXn,children:[(0,iT.jsx)(Ie,{variant:"body2",color:"text.disabled",children:ho(e.id)}),r&&(0,iT.jsx)(en,{label:e.type,size:"small",color:r,sx:gXn}),(0,iT.jsx)(Cbr,{current:e.status,onStatusChange:t}),(0,iT.jsx)(JP,{jiraKey:e.jiraKey}),(0,iT.jsx)(QP,{githubIssue:e.githubIssue,origin:e.origin}),e.usageTotal&&(0,iT.jsx)(xF,{total:e.usageTotal,sx:yXn})]})}var kbr=R(z(),1),_br=st((0,kbr.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune");var Dye=R(he(),1);var Ebr=R(he(),1);function Rbr(e){let{launchAssist:t}=Gl(),r=Li(),n=ds(),i=br(),[o,a]=(0,Ebr.useState)(!1);return{launched:o,launch:l=>{if(o)return;a(!0);let u=i?[{node:i}]:[];t(["refine","--once",...l,ho(e)],n,...u),r("/sessions")}}}var P0=R(z(),1);function Abr({itemId:e}){let{launched:t,launch:r}=Rbr(e),n=r_(),i=(0,Dye.useRef)(null),[o,a]=(0,Dye.useState)(!1),s=u=>u.stopPropagation(),l=sye(n);return(0,P0.jsxs)(P0.Fragment,{children:[(0,P0.jsxs)(wT,{ref:i,variant:"outlined",size:"small",disabled:t,children:[(0,P0.jsx)(Ut,{startIcon:(0,P0.jsx)(_br,{}),onClick:u=>{s(u),r([])},children:"Refine"}),l.length>0&&(0,P0.jsx)(Ut,{size:"small","aria-label":"Refine with a different harness",onClick:u=>{s(u),a(!0)},children:(0,P0.jsx)(om,{})})]}),(0,P0.jsx)(lye,{anchorEl:i.current,open:o,onClose:()=>a(!1),options:l,onSelect:u=>{a(!1),r(["--harness",u])},stop:s})]})}var wF=R(he(),1);function Pbr(){let e=(0,wF.useRef)(null),[t,r]=(0,wF.useState)(!1);return(0,wF.useEffect)(()=>{let n=e.current;if(!n)return;let i=new IntersectionObserver(([o])=>r(!o.isIntersecting),{threshold:0});return i.observe(n),()=>i.disconnect()},[]),{sentinelRef:e,stuck:t}}var Jf=R(z(),1),vXn={justifyContent:"space-between",alignItems:"center",mb:2};function bXn(e){return e.palette.mode==="dark"?"0 8px 8px -9px rgba(0, 0, 0, 0.8)":"0 6px 6px -7px rgba(0, 0, 0, 0.2)"}function xXn(e){return t=>({position:"sticky",top:0,zIndex:1,bgcolor:"background.default",mx:-2,px:2,pb:2,borderBottom:1,borderColor:"divider",boxShadow:e?bXn(t):"none",transition:t.transitions.create("box-shadow")})}function Lbr({item:e,onDeleted:t,onStatusChange:r,ref:n}){let{sentinelRef:i,stuck:o}=Pbr();return(0,Jf.jsxs)(Jf.Fragment,{children:[(0,Jf.jsx)(ie,{ref:i,sx:{height:0}}),(0,Jf.jsxs)(ie,{ref:n,sx:xXn(o),children:[(0,Jf.jsxs)(Rt,{direction:"row",sx:vXn,children:[(0,Jf.jsx)(bbr,{to:"/backlog"}),(0,Jf.jsxs)(Rt,{direction:"row",spacing:1,children:[aye(e)&&(0,Jf.jsx)(wye,{itemId:e.id}),(0,Jf.jsx)(Abr,{itemId:e.id}),(0,Jf.jsx)(Sbr,{itemId:e.id,onDeleted:t})]})]}),(0,Jf.jsx)(Ie,{variant:"h5",component:"h2",children:e.name}),(0,Jf.jsx)(wbr,{item:e,onStatusChange:r})]})]})}var Ibr=R(he(),1);var Nye=R(he(),1);function Mbr(e,t){let[r,n]=(0,Nye.useState)(t);return(0,Nye.useEffect)(()=>{let i=e.current;if(!i||(n(i.offsetHeight),typeof ResizeObserver>"u"))return;let o=new ResizeObserver(()=>n(i.offsetHeight));return o.observe(i),()=>o.disconnect()},[e]),r}function Dbr(){let e=(0,Ibr.useRef)(null),t=Mbr(e,AK),r={[iUe]:`${t}px`};return{headerRef:e,headerHeight:t,style:r}}var h_=R(z(),1);function Nbr({item:e,onReload:t}){let r=Li(),n=ds(),i=br(),{headerRef:o,headerHeight:a,style:s}=Dbr();ky("ItemDetail");let l=async()=>{await t(),r("/backlog")},u=async d=>{await Vee(e.id,d,n,i),await t()},f=async(d,h)=>{await Yrt(e.id,d,h,n,i),await t()};return(0,h_.jsxs)(ie,{style:s,children:[(0,h_.jsx)(Lbr,{ref:o,item:e,onDeleted:l,onStatusChange:u}),(0,h_.jsx)(ie,{sx:IK.containerSx,children:(0,h_.jsxs)(ie,{sx:IK.columnsSx,children:[(0,h_.jsx)(cbr,{item:e,onRewind:t,onCommentDeleted:t,onSubtaskStatusChange:f}),(0,h_.jsx)(vbr,{item:e,headerHeight:a})]})})]})}var pA=R(z(),1),TXn={display:"flex",justifyContent:"center",py:6};function Obr({onReload:e}){let[t]=Fc(),r=t.get("cwd")||void 0,n=t.get("node")||void 0,i=Bn(),o=(0,Oye.useMemo)(()=>r?{...i,selectedCwd:r,selectedNode:n}:i,[i,r,n]);return ky("ItemRoute"),(0,pA.jsx)(RH.Provider,{value:o,children:(0,pA.jsx)(df.Provider,{value:o.selectedNode,children:(0,pA.jsx)(SXn,{onReload:e})})})}function SXn({onReload:e}){let{id:t}=oSe(),r=Number.NaN;try{r=Pee(t??"")}catch{r=Number.NaN}let{item:n,loading:i,reload:o}=yvr(r),a=(0,Oye.useCallback)(async()=>{await Promise.all([o(),e()])},[o,e]);return i?(0,pA.jsx)(ie,{sx:TXn,children:(0,pA.jsx)(To,{})}):n?(0,pA.jsx)(Nbr,{item:n,onReload:a}):null}var mA=R(z(),1);function Bbr({items:e,loading:t,error:r,socket:n,onReload:i}){return(0,mA.jsxs)(G5,{children:[(0,mA.jsx)(Ss,{index:!0,element:(0,mA.jsx)(gvr,{items:e,loading:t,error:r,socket:n,onReload:i})}),(0,mA.jsx)(Ss,{path:"items/:id",element:(0,mA.jsx)(Obr,{onReload:i})})]})}var L0=R(he(),1);var Fbr=new Map;function $br(e,t,r){return JSON.stringify([e??null,t,r??null])}var DK={get(e,t,r){return Fbr.get($br(e,t,r))},set(e,t,r,n){Fbr.set($br(e,t,n),r)}};function CXn(e,t){return e===t?!0:!e||!t?!1:e.tokensUp===t.tokensUp&&e.tokensDown===t.tokensDown&&e.activeMs===t.activeMs&&e.peakContextPct===t.peakContextPct}function zbr(e,t){return e===t?!0:e.length!==t.length?!1:e.every((r,n)=>{let i=t[n];return r.id===i.id&&r.type===i.type&&r.name===i.name&&r.status===i.status&&r.starred===i.starred&&r.incompleteSubtasks===i.incompleteSubtasks&&CXn(r.usageTotal,i.usageTotal)})}function Hbr({setItems:e,setLoading:t,setError:r}){return{onLoaded:n=>{e(i=>zbr(i,n)?i:n),t(!1),r(null)},onError:n=>{t(!1),r(n)}}}async function Ubr(e,t,r,n){let i=await fS({cwd:e,node:n,signal:r,filter:t});return r.aborted||DK.set(e,t,i,n),i}function Wbr(e,t,r,{onLoaded:n,onError:i},o){return(async()=>{try{let a=await Ubr(e,t,r,o);r.aborted||n(a)}catch(a){r.aborted||i(a instanceof Error?a.message:"Failed to load.")}})()}var wXn=5e3;function Vbr(e,t,r,n){let i=new AbortController,o=!1,a=()=>{o||(o=!0,Wbr(e,t,i.signal,r,n).finally(()=>{o=!1}))};a();let s=setInterval(a,wXn);return()=>{i.abort(),clearInterval(s)}}function Gbr(){let e=ds(),t=br(),[r]=cF(),n=DK.get(e,r,t),i=n??[],o=n===void 0,[a,s]=(0,L0.useState)(i),[l,u]=(0,L0.useState)(o),[f,d]=(0,L0.useState)(null),[h,p]=(0,L0.useState)(e),[m,g]=(0,L0.useState)(t),[y,v]=(0,L0.useState)(r);(e!==h||t!==m||r!==y)&&(p(e),g(t),v(r),s(i),u(o),d(null));let b=(0,L0.useCallback)(async()=>{let x=await fS({cwd:e,node:t,filter:r});s(x),DK.set(e,r,x,t),u(!1)},[e,t,r]);return(0,L0.useEffect)(()=>Vbr(e,r,Hbr({setItems:s,setLoading:u,setError:d}),t),[e,t,r]),{items:a,loading:l,error:f,reload:b}}var kF=R(z(),1);function qbr({socket:e}){let{items:t,loading:r,error:n,reload:i}=Gbr();return Cre(!r),(0,kF.jsx)(YHe.Provider,{value:e.sessions,children:(0,kF.jsx)(JHe.Provider,{value:e.selectSession,children:(0,kF.jsx)(G5,{children:(0,kF.jsx)(Ss,{path:"/*",element:(0,kF.jsx)(Bbr,{items:t,loading:r,error:n,socket:e,onReload:i})})})})})}var uUe=R(z(),1);function jbr({socket:e}){return(0,uUe.jsx)(H$,{maxWidth:"lg",sx:{py:3,px:2},children:(0,uUe.jsx)(qbr,{socket:e})})}var Ri=R(z(),1);function Ybr({socket:e}){return ky("AppRoutes"),(0,Ri.jsxs)(Ri.Fragment,{children:[(0,Ri.jsx)(Qsr,{}),(0,Ri.jsx)(G5,{children:(0,Ri.jsxs)(Ss,{element:(0,Ri.jsx)(Xat,{socket:e}),children:[(0,Ri.jsx)(Ss,{path:"sessions",element:(0,Ri.jsx)(k0r,{socket:e})}),(0,Ri.jsx)(Ss,{path:"backlog/*",element:(0,Ri.jsx)(jbr,{socket:e})}),(0,Ri.jsx)(Ss,{path:"next",element:(0,Ri.jsx)(Qar,{sessions:e.sessions,selectSession:e.selectSession})}),(0,Ri.jsx)(Ss,{path:"news",element:(0,Ri.jsx)(aar,{})}),(0,Ri.jsx)(Ss,{path:"releases",element:(0,Ri.jsx)(Ysr,{})}),(0,Ri.jsx)(Ss,{path:"usage",element:(0,Ri.jsx)(a1r,{})}),(0,Ri.jsx)(Ss,{path:"backups",element:(0,Ri.jsx)(ist,{})}),(0,Ri.jsx)(Ss,{path:"config",element:(0,Ri.jsx)(ect,{})}),(0,Ri.jsx)(Ss,{path:"updates",element:(0,Ri.jsx)(yyr,{reconnecting:e.reconnecting,selectSession:e.selectSession})}),(0,Ri.jsx)(Ss,{path:"diff",element:(0,Ri.jsx)(kor,{socket:e})}),(0,Ri.jsx)(Ss,{path:"file",element:(0,Ri.jsx)(tar,{socket:e})}),(0,Ri.jsx)(Ss,{path:"*",element:(0,Ri.jsx)(fSe,{to:"/sessions",replace:!0})})]})})]})}var Hye=R(he(),1);var zye=R(he(),1);function Kbr(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var p_=R(z(),1),kXn={display:"flex",gap:1,alignItems:"center",minWidth:0},_Xn={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},EXn={fontFamily:"monospace",fontSize:13,whiteSpace:"nowrap"},RXn={fontFamily:"monospace",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function AXn(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function Xbr({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,p_.jsx)($p,{dense:!0,sx:{py:0},children:e.map((i,o)=>{let{dir:a,basename:s}=AXn(i);return(0,p_.jsxs)(hn,{selected:o===t,onMouseEnter:()=>r(o),onClick:()=>n(i),sx:kXn,children:[(0,p_.jsx)(G9,{path:i}),(0,p_.jsxs)(ie,{sx:_Xn,children:[(0,p_.jsx)(Ie,{component:"span",sx:EXn,children:s}),(0,p_.jsx)(Ie,{component:"span",color:"text.secondary",sx:RXn,children:a})]})]},i)})})}var Bye=R(z(),1),PXn={maxHeight:420,overflowY:"auto"},LXn={px:2,py:2,fontSize:13};function Zbr({message:e,files:t,highlight:r,onHighlight:n,onSelect:i}){return(0,Bye.jsx)(ie,{sx:PXn,children:e?(0,Bye.jsx)(Ie,{color:"text.secondary",sx:LXn,children:e}):(0,Bye.jsx)(Xbr,{files:t,highlight:r,onHighlight:n,onSelect:i})})}var Qbr=R(z(),1),MXn={mt:6,alignSelf:"flex-start"};function Fye({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,Qbr.jsx)($l,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:MXn},transition:{onEntered:t}},children:n})}var $ye=R(he(),1);var Jbr={files:[],loading:!1,error:!1};function exr(e,t){let[r,n]=(0,$ye.useState)(Jbr),i=br();return(0,$ye.useEffect)(()=>{if(!e){n(Jbr);return}let o=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await fetch(Xr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,i));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(o)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch{o||n({files:[],loading:!1,error:!0})}})(),()=>{o=!0}},[e,t,i]),r}var gA=R(z(),1);function IXn(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function txr({onClose:e}){let{worktreeNode:t}=Bn();return(0,gA.jsx)(df.Provider,{value:t,children:(0,gA.jsx)(DXn,{onClose:e})})}function DXn({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=Bn(),[n,i]=(0,zye.useState)(""),o=exr(t,n),a=Li(),s=(0,zye.useRef)(null),l=p=>a(IXn(p,t,r)),{highlight:u,setHighlight:f,onKeyDown:d}=a_(o.files,n,l,e),h=p=>{l(p),e()};return(0,gA.jsxs)(Fye,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,gA.jsx)(hF,{autoFocus:!0,inputRef:s,value:n,onChange:i,onKeyDown:d,placeholder:"Search files by name..."}),(0,gA.jsx)(Zbr,{message:Kbr(t,n,o),files:o.files,highlight:u,onHighlight:f,onSelect:h})]})}function rxr(e){_o(jn("quickOpen").matches,e)}var ixr=R(z(),1);function nxr(){let[e,t]=(0,Hye.useState)(!1);return rxr((0,Hye.useCallback)(()=>t(!0),[])),e?(0,ixr.jsx)(txr,{onClose:()=>t(!1)}):null}var Uye=R(z(),1);function oxr({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,Uye.jsx)(fl,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,Uye.jsx)(oi,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,Uye.jsx)(Ut,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var Yye=R(he(),1);function axr(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var bxr=R(he(),1);var sxr=R(z(),1),lxr=st((0,sxr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var m_="0.836.0";var NXn={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function cxr(e){return e?NXn[e]:"success.main"}function uxr(e){return e.split("-")[0].split(".").map(Number)}function fxr(e,t){if(!e||!t||e===t)return;let r=uxr(e),n=uxr(t);for(let i=0;i<Math.max(r.length,n.length);i++){let o=(r[i]??0)-(n[i]??0);if(Number.isNaN(o))return;if(o!==0)return o<0?"behind":"ahead"}}var Wye=R(he(),1),fUe=(0,Wye.createContext)(null);function Vye(){return(0,Wye.useContext)(fUe)}var yA=R(z(),1),OXn={height:16,fontSize:10},BXn={opacity:.6,fontSize:"0.85em"};function FXn(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function NK({nodes:e,name:t,showVersion:r=!1}){let n=Vye()??m_,i=e.links.find(a=>a.name===t),o=fxr(i?.peerVersion,n);return(0,yA.jsx)(sr,{title:FXn(e,t),placement:"right",children:(0,yA.jsxs)(ie,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,yA.jsx)(lxr,{sx:{fontSize:8,color:cxr(i?.state)}}),t,r&&i?.peerVersion&&(0,yA.jsxs)(ie,{component:"span",sx:BXn,children:["v",i.peerVersion]}),o&&(0,yA.jsx)(en,{label:o,size:"small",color:o==="behind"?"warning":"info",sx:OXn})]})})}var vA=R(z(),1),$Xn={opacity:.6},zXn={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function dxr({nodes:e,name:t,clone:r}){let n=(0,vA.jsx)(NK,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,vA.jsx)(ie,{component:"span",sx:$Xn,children:n}):(0,vA.jsx)(sr,{title:dF(t,r.cloneTarget),children:(0,vA.jsxs)(ie,{component:"span",sx:zXn,children:[(0,vA.jsx)(fF,{sx:{fontSize:14}}),n]})})}var pxr=R(z(),1),HXn={px:1.5,borderRadius:.75,fontSize:12,fontWeight:600,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"},"&[aria-checked='true']":{color:"primary.main",bgcolor:"action.selected"},"&.Mui-focusVisible":{outline:2,outlineColor:"primary.main"}};function hxr({value:e,label:t,checked:r,autoFocus:n,onSelect:i}){return(0,pxr.jsx)(On,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:i,sx:HXn,children:t})}var mxr={ArrowRight:1,ArrowLeft:-1};function UXn(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+mxr[e.key]+r)%r}function gxr(e,t,r,n){return i=>{if(i.key==="ArrowUp"||i.key==="ArrowDown"){if(!n)return;i.preventDefault(),n();return}if(i.key!=="Tab"&&!mxr[i.key]){Pb(i);return}let o=UXn(i,e.indexOf(t),e.length);o!==void 0&&(i.preventDefault(),r(e[o]),i.currentTarget.querySelector(`[data-value="${e[o]}"]`)?.focus())}}var yxr=R(he(),1);function _F(e){return e?.querySelector('[aria-checked="true"]')}function vxr(e,t){(0,yxr.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=_F(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var dUe=R(z(),1),WXn={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function Gye({label:e,options:t,value:r,onChange:n,optionLabel:i=u=>u,groupRef:o,autoFocus:a,onTrack:s,onToggleRow:l}){return vxr(o,r),(0,dUe.jsx)(Rt,{ref:o,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:gxr(t,r,n,l),sx:WXn,children:t.map(u=>(0,dUe.jsx)(hxr,{value:u,label:i(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var hUe=R(z(),1);function xxr({value:e,onChange:t,cloneState:r}){let{nodes:n,names:i,visible:o}=Zu(),a=(0,bxr.useRef)(null);return!o||!n||!e?null:(0,hUe.jsx)(Gye,{label:"Machine",options:i,value:e,onChange:t,optionLabel:s=>(0,hUe.jsx)(dxr,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var Sxr=R(z(),1);function Txr({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:i,onTrack:o}){return(0,Sxr.jsx)(qn,{value:e,onChange:a=>t(a.target.value),onKeyDown:Pb,onFocus:o,onSelect:o,inputRef:n,placeholder:r,autoFocus:i,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"},input:{sx:{fontSize:14}}}})}var _xr=R(he(),1);var oT={draft:{placeholder:"Describe the backlog item to draft...",submitLabel:"Start draft",sessionMode:"assist-draft"},bug:{placeholder:"Describe the bug: what happened, what you expected...",submitLabel:"File bug",sessionMode:"assist-bug"},prompt:{placeholder:Qte,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},Cxr=Object.keys(oT);var pUe=R(z(),1);function wxr({anchor:e,harness:t,harnesses:r,onPick:n,onClose:i}){return(0,pUe.jsx)(zl,{open:e!==null,anchorEl:e,onClose:i,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(o=>(0,pUe.jsx)(hn,{role:"menuitemradio","aria-checked":o===t,selected:o===t,onClick:()=>{n(o),i()},sx:{fontSize:13},children:Eu(o)},o))})}var bA=R(z(),1);function kxr(e){return t=>t==="prompt"&&e?(0,bA.jsxs)(bA.Fragment,{children:["prompt",(0,bA.jsx)(ie,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${Eu(e)}`}),(0,bA.jsx)(om,{sx:{fontSize:18,mr:-.75}})]}):t}var xA=R(z(),1);function Exr({draft:e,harness:t,harnesses:r,focus:n}){let[i,o]=(0,_xr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>o(_F(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,xA.jsxs)(xA.Fragment,{children:[(0,xA.jsx)(Gye,{label:"Mode",options:Cxr,value:e.mode,onChange:l,optionLabel:kxr(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,xA.jsx)(wxr,{anchor:i,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>o(null)})]})}var Fxr=R(he(),1);var mUe=R(z(),1),VXn={zIndex:e=>e.zIndex.modal+1};function Rxr({open:e,anchor:t,children:r}){return(0,mUe.jsx)(_6,{open:e,anchorEl:t,placement:"bottom-start",sx:VXn,children:(0,mUe.jsx)(cn,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}function Axr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:{fontSize:13,height:40}}}}var Pxr=R(y$(),1);function Lxr({open:e,highlighted:t,accept:r,close:n,navigate:i,openList:o}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),o();return}Pb(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,Pxr.flushSync)(()=>{r(t),n()}),Pb(a);return}if(a.key!=="Tab"){i(a);return}t!==void 0&&r(t),n()}}}function Mxr(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>bv(n).toLowerCase().includes(r)):e}var gUe=R(he(),1);function Ixr(){let[e,t]=(0,gUe.useState)(!1),[r,n]=(0,gUe.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:i=>{n(i),t(!0)},close:()=>{t(!1),n("")}}}var Nxr=R(he(),1);var Dxr=e=>e?bv(e):"";function Oxr(e){let[t,r]=(0,Nxr.useState)(()=>Dxr(e));return{text:t,setText:r,showRepo:n=>r(Dxr(n))}}function Bxr(e,t,r){let n=Ixr(),i=Oxr(t),o=Mxr(e,n.query),a=f=>{r(f),i.showRepo(f)},s=a_(o,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:i.text,filtered:o,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:Lxr({open:n.open,highlighted:o[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:f=>{i.setText(f),n.filterBy(f)},onFocus:l,onBlur:()=>{n.close(),i.showRepo(t)},pick:f=>{a(f),n.close()}}}var EF=R(z(),1);function $xr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:i,onTrack:o}){let a=Bxr(e,t,r),s=(0,Fxr.useRef)(null);return(0,EF.jsxs)(ie,{ref:s,sx:{flex:1,minWidth:0},children:[(0,EF.jsx)(qn,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),o()},inputRef:n,autoFocus:i,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:Axr(a.open)}),(0,EF.jsx)(Rxr,{open:a.open,anchor:s.current,children:(0,EF.jsx)(Tye,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var g_=R(z(),1);function zxr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:i}=Bn();return(0,g_.jsxs)(Rt,{spacing:1,sx:{p:1},children:[(0,g_.jsx)(Txr,{value:r.prompt,onChange:r.setPrompt,placeholder:oT[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),(0,g_.jsxs)(Rt,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,g_.jsx)($xr,{repos:i,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,g_.jsx)(Exr,{...t})]}),(0,g_.jsx)(xxr,{value:r.node,onChange:r.setNode,cloneState:e})]})}var RF=R(z(),1),GXn=["Enter start","Shift+Enter newline","Esc close"],qXn={alignItems:"center",px:1.5,py:1,borderTop:1,borderColor:"divider",bgcolor:"action.hover"};function Hxr({submitLabel:e,disabled:t=!1}){return(0,RF.jsxs)(Rt,{direction:"row",spacing:1.5,sx:qXn,children:[(0,RF.jsx)(Rt,{direction:"row",spacing:1.5,sx:{mr:"auto"},children:GXn.map(r=>(0,RF.jsx)(Ie,{variant:"caption",color:"text.secondary",children:r},r))}),(0,RF.jsx)(Ut,{type:"submit",variant:"contained",size:"small",disabled:t,children:e})]})}function Uxr({mode:e,harness:t,prompt:r,cwd:n,node:i},o){let a=n||void 0,s=i?[i]:[];if(e==="prompt"){t==="claude"?o.onCreate(r,a,...s):o.onCreateHarness(t,r,a,...s);return}if(e==="design"){o.onCreateDesign(r,a,...s);return}let l=i?[{node:i}]:[];Bot(oT[e].sessionMode,n,(u,f)=>o.onCreateAssist(u,f,...l),()=>{},r)}function Wxr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(fye(r.prompt,n.onCreateAssist),!0):(Uxr({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var TA=R(he(),1);function Vxr(e,t){let r=(0,TA.useRef)(e),n=(0,TA.useRef)(null),i=(0,TA.useRef)(null),o=(0,TA.useRef)(null),a=(0,TA.useCallback)(u=>{n.current=u;let{field:f,selectionStart:d,selectionEnd:h}=r.current;u&&f==="prompt"&&u.setSelectionRange(d,h)},[]),s=u=>{let f=u.target;t({field:"prompt",selectionStart:f.selectionStart,selectionEnd:f.selectionEnd})},l=()=>{if(o.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:i.current,mode:_F(o.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:i,modeRef:o,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function jXn(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:Cye(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function Gxr(e,t){let{names:r,visible:n}=Zu(),i=vye(t,n?r:[void 0]);return{cloneState:i,target:jXn(t,e,i(e))}}var qye=R(he(),1);function qxr(e,t){let[r,n]=(0,qye.useState)(!1);return(0,qye.useEffect)(()=>{!r||e.modePending||(n(!1),!(e.mode==="prompt"&&!e.prompt.trim())&&t())},[r,e.modePending,e.mode,e.prompt,t]),()=>{e.modePending?n(!0):t()}}var AF=R(z(),1);function jxr({draft:e,launchers:t,onClose:r}){let n=Vxr(e.focus,e.setFocus),i=axr(r_()),o=i.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=Gxr(e.node,e.cwd),l=qxr(e,()=>{Wxr(e,o,a,t)&&r()}),u=f=>{f.preventDefault(),l()};return(0,AF.jsx)(Fye,{onClose:r,onEntered:n.restore,centered:!0,children:(0,AF.jsxs)("form",{onSubmit:u,children:[(0,AF.jsx)(zxr,{draft:e,harness:o,harnesses:i,focus:n,cloneState:s}),(0,AF.jsx)(Hxr,{submitLabel:a.kind==="clone"?"Clone":oT[e.mode].submitLabel,disabled:a.kind==="blocked"})]})})}var jye=R(he(),1);function Yxr(e){let[t,r]=(0,jye.useState)(null);return(0,jye.useEffect)(()=>{let n=!1;return(async()=>{let i="draft";try{let o=e?`?cwd=${encodeURIComponent(e)}`:"",s=await(await fetch(`/api/new-session-defaults${o}`)).json();Object.hasOwn(oT,s?.mode)&&(i=s.mode)}catch{}n||r({cwd:e,mode:i})})(),()=>{n=!0}},[e]),t}function Kxr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var aT=R(he(),1),Xxr={field:"prompt",selectionStart:0,selectionEnd:0};function Zxr(){let[e,t]=(0,aT.useState)(""),[r,n]=(0,aT.useState)(),[i,o]=(0,aT.useState)(),[a,s]=(0,aT.useState)("claude"),[l,u]=(0,aT.useState)(),[f,d]=(0,aT.useState)(Xxr),h=(0,aT.useCallback)(()=>{t(""),n(void 0),o(void 0),u(void 0),d(Xxr)},[]);return{prompt:e,cwd:r,mode:i,harness:a,node:l,focus:f,setPrompt:t,setNode:u,setCwd:n,setMode:o,setHarness:s,setFocus:d,clear:h}}function Qxr(e=Yxr){let{selectedCwd:t}=Bn(),r=Zu(),n=Zxr(),i=n.cwd??t,o=e(i);return o?{...n,cwd:i,mode:n.mode??o.mode,modePending:n.mode===void 0&&o.cwd!==i,node:Kxr(n.node,r)}:null}function Jxr(e){_o(jn("newSession").matches,e)}var e2r=R(he(),1);function t2r(e,t){let{selectedCwd:r}=Bn(),[n,i]=Fc(),o=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,e2r.useEffect)(()=>{o===null||!s||!l||!u||(o&&(s(o),l(a),u({field:"prompt",selectionStart:o.length,selectionEnd:o.length})),t(),i(f=>(f.delete("new"),f.delete("newCwd"),f),{replace:!0}))},[o,a,s,l,u,t,i])}var n2r=R(z(),1);function r2r({launchers:e}){let[t,r]=(0,Yye.useState)(!1),n=Qxr(),i=(0,Yye.useCallback)(()=>r(!0),[]);return Jxr(i),t2r(n,i),!t||!n?null:(0,n2r.jsx)(jxr,{draft:n,launchers:e,onClose:()=>r(!1)})}var Kye=R(z(),1);function i2r({reconnecting:e}){return(0,Kye.jsx)(fl,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,Kye.jsx)(oi,{severity:"info",variant:"filled",icon:(0,Kye.jsx)(To,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var wv=R(z(),1);function o2r({socket:e,onViewLaunchedSession:t}){return(0,wv.jsxs)(wv.Fragment,{children:[(0,wv.jsx)(nxr,{}),(0,wv.jsx)(r2r,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,wv.jsx)(i2r,{reconnecting:e.reconnecting}),(0,wv.jsx)(Pu,{error:e.error,onClose:e.clearError}),(0,wv.jsx)(oxr,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var M0=R(he(),1);var YXn=6e4;function a2r(e){let t=e.nodes?.local,r=e.names.join(`
|
|
4013
4013
|
`),[n,i]=(0,M0.useState)([]),[o,a]=(0,M0.useState)(!0),s=(0,M0.useRef)(0),l=(0,M0.useCallback)(()=>{let u=r?r.split(`
|
|
4014
4014
|
`):[];if(u.length===0)return;let f=++s.current;Promise.all(u.map(d=>V0e(d,d===t))).then(d=>{f===s.current&&(i(d),a(!1))})},[r,t]);return(0,M0.useEffect)(()=>{l();let u=setInterval(l,YXn);return()=>clearInterval(u)},[l]),(0,M0.useMemo)(()=>({entries:n,loading:o,refresh:l}),[n,o,l])}var y_=R(z(),1);function s2r({shell:e,children:t}){let{socket:r,selection:n,launch:i,topBar:o,sidebarCollapse:a}=e,s=a2r(r.nodeSelection);return(0,y_.jsx)(OHe.Provider,{value:s,children:(0,y_.jsx)(LSe.Provider,{value:o,children:(0,y_.jsx)(xCe.Provider,{value:a,children:(0,y_.jsx)(RH.Provider,{value:n,children:(0,y_.jsx)(eUe.Provider,{value:r.nodeSelection,children:(0,y_.jsx)(df.Provider,{value:n.selectedNode,children:(0,y_.jsx)(YSe.Provider,{value:i,children:t})})})})})})})}var l2r=R(z(),1),c2r=st((0,l2r.jsx)("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"}),"Computer");var u2r=R(he(),1);var I0=R(z(),1),KXn={ml:1,textTransform:"none",fontSize:12};function f2r(){let{nodes:e,names:t,visible:r,selected:n,select:i}=Zu(),[o,a]=(0,u2r.useState)(null);return!r||!e||!n?null:(0,I0.jsxs)(I0.Fragment,{children:[(0,I0.jsx)(Ut,{size:"small",color:"inherit",startIcon:(0,I0.jsx)(c2r,{fontSize:"small"}),"aria-label":"Machine","aria-haspopup":"menu",onClick:s=>a(s.currentTarget),sx:KXn,children:(0,I0.jsx)(NK,{nodes:e,name:n})}),(0,I0.jsx)(zl,{anchorEl:o,open:!!o,onClose:()=>a(null),children:t.map(s=>(0,I0.jsx)(hn,{selected:s===n,onClick:()=>{i(s),a(null)},sx:{fontSize:13},children:(0,I0.jsx)(NK,{nodes:e,name:s,showVersion:!0})},s))})]})}var OK=R(he(),1);function d2r(e,t){return[...e[0].slice(0,-1),String(t+1)]}var Xye=R(z(),1);function h2r({index:e,label:t,...r}){let{chords:n}=jn("navTab");return(0,Xye.jsx)(sr,{describeChild:!0,title:(0,Xye.jsx)(Ru,{label:t,chords:[d2r(n,e)]}),children:(0,Xye.jsx)(jv,{label:t,...r})})}var yUe=R(he(),1);function p2r(e,t){let{bound:r}=jn("navTab"),n=e.length,i=(0,yUe.useCallback)(a=>(NH(a,r)??n)<n,[r,n]),o=(0,yUe.useCallback)(a=>{let s=e[NH(a,r)??-1];s&&t(s)},[e,t,r]);_o(i,o)}var Zye=R(he(),1);function m2r(){let[e,t]=(0,Zye.useState)(!1);return(0,Zye.useEffect)(()=>{let r=!1;return(async()=>{try{let i=await(await fetch("/api/news/nav")).json();r||t(i?.showInNav===!0)}catch{r||t(!1)}})(),()=>{r=!0}},[]),e}var Qye=R(he(),1);async function XXn(e,t){let r=await fetch(Xr(`/api/releases/configured?cwd=${encodeURIComponent(e)}`,t));return r.ok?(await r.json())?.configured===!0:void 0}function g2r(e){let[t,r]=(0,Qye.useState)(null),n=br(),i=`${n??""}\0${e}`;return(0,Qye.useEffect)(()=>{if(!e)return;let o=!1;return XXn(e,n).catch(()=>{}).then(a=>{o||r({key:i,configured:a})}),()=>{o=!0}},[e,n,i]),t?.key===i?t.configured:void 0}var y2r=R(he(),1);function v2r(e){let{pathname:t}=Uo(),r=Li(),n=t==="/releases"||t.startsWith("/releases/");(0,y2r.useEffect)(()=>{e===!1&&n&&r("/sessions",{replace:!0})},[e,n,r])}var ZXn={path:"/sessions",label:"Sessions"},QXn={path:"/backlog",label:"Backlog"},JXn={path:"/next",label:"Next"},eZn={path:"/releases",label:"Releases"},tZn={path:"/news",label:"News"};function b2r(e,t){return[ZXn,QXn,JXn,...e?[eZn]:[],...t?[tZn]:[]]}var vUe=R(z(),1);function x2r({cwd:e}){let t=Uo(),r=Li(),n=g2r(e),i=m2r();v2r(n);let o=n===!0,a=(0,OK.useMemo)(()=>b2r(o,i),[o,i]),s=(0,OK.useMemo)(()=>a.map(f=>f.path),[a]),l=a.findIndex(f=>t.pathname.startsWith(f.path)),u=(0,OK.useCallback)(f=>{t.pathname!==f&&r(f)},[t.pathname,r]);return p2r(s,u),(0,vUe.jsx)(v5,{value:l===-1?!1:l,textColor:"inherit",indicatorColor:"secondary",children:a.map((f,d)=>(0,vUe.jsx)(h2r,{index:d,label:f.label,onClick:()=>u(f.path)},f.path))})}var T2r=R(z(),1),S2r=st((0,T2r.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m5 11h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddCircle");var BK=R(z(),1),rZn={color:"success.light"};function C2r(){let[,e]=Fc(),{label:t,chords:r}=jn("newSession");return(0,BK.jsx)(sr,{title:(0,BK.jsx)(Ru,{label:t,chords:r}),children:(0,BK.jsx)(ir,{size:"small",sx:rZn,"aria-label":"New session",onClick:()=>e(i=>(i.set("new",""),i),{replace:!0}),children:(0,BK.jsx)(S2r,{})})})}var e1e=R(he(),1);var Jye=R(z(),1),nZn={color:"inherit"};function w2r({cwd:e}){let[t,r]=(0,e1e.useState)(null),n=br();return(0,e1e.useEffect)(()=>{if(!e){r(null);return}let i=!1;return(async()=>{try{let a=await(await fetch(Xr(`/api/github-url?cwd=${encodeURIComponent(e)}`,n))).json();i||r(a?.url??null)}catch{i||r(null)}})(),()=>{i=!0}},[e,n]),t?(0,Jye.jsx)(sr,{title:"Open in GitHub",children:(0,Jye.jsx)(ir,{sx:nZn,onClick:()=>window.open(t,"_blank"),children:(0,Jye.jsx)(KP,{})})}):null}var E2r=R(he(),1);var _2r=R(he(),1);var t1e=R(z(),1);function k2r({window:e,windowSeconds:t,fallbackLabel:r,now:n}){let i=e?.used_percentage;if(i==null)return null;let o=Qk(i,e?.resets_at,t,n),a=e?.resets_at!=null?Q0e(e.resets_at,n):r;return(0,t1e.jsxs)(ie,{component:"span",children:[(0,t1e.jsxs)(ie,{component:"span",sx:{color:Jk(o)},children:[Math.round(i),"%"]})," ",(0,t1e.jsxs)(ie,{component:"span",sx:{color:"text.secondary"},children:["(",a,")"]})]})}var v_=R(z(),1);function r1e({rateLimits:e}){let t=e_(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(n=>n.window?.used_percentage!=null);return(0,v_.jsx)(v_.Fragment,{children:r.map((n,i)=>(0,v_.jsxs)(_2r.Fragment,{children:[i>0?(0,v_.jsx)(ie,{component:"span",sx:{color:"text.secondary",mr:.5},children:","}):null,(0,v_.jsx)(k2r,{window:n.window,windowSeconds:n.windowSeconds,fallbackLabel:n.fallbackLabel,now:t})]},n.fallbackLabel))})}var b_=R(z(),1);function R2r({groups:e}){return(0,b_.jsx)(b_.Fragment,{children:e.map((t,r)=>(0,b_.jsxs)(E2r.Fragment,{children:[(0,b_.jsx)(ie,{component:"span",sx:{color:"text.secondary",ml:r>0?1:0,mr:.5},children:Eu(t.harness)}),(0,b_.jsx)(r1e,{rateLimits:t.rateLimits})]},t.harness))})}function iZn(e){if(e==="over")return{level:"warn",boundary:100};if(e==="warn")return{level:"ok",boundary:75}}function oZn(e){if(e==="ok")return{level:"warn",boundary:75};if(e==="warn")return{level:"over",boundary:100}}function aZn(e,t,r,n){if(e>=t)return;let i=e/t;return Math.round(r-n*(1-i))}function L2r(e,t,r,n){if(t==null)return{kind:"unprojectable"};let i=GHe(t,r,n);if(i==null)return{kind:"unprojectable"};let o=Qk(e,t,r,n),a=iZn(o),s=oZn(o);return{kind:"projected",recovery:a&&{level:a.level,pct:a.boundary*i,at:aZn(e,a.boundary,t,r)},worse:s&&{level:s.level,pct:s.boundary*i}}}function M2r(e,t){return e.at==null?"not before reset":`${e.level==="ok"?"green":"under"} in ${Q0e(e.at,t)}`}var D0=R(z(),1);function bUe({direction:e,threshold:t}){let r=e==="back",n={display:"inline-flex",gap:.5,minWidth:"6ch",justifyContent:r?"flex-end":"flex-start"};if(!t)return(0,D0.jsx)(ie,{component:"span",sx:n});let i=(0,D0.jsx)(ie,{component:"span",sx:{opacity:.6},children:r?"\u2190":"\u2192"}),o=(0,D0.jsxs)(ie,{component:"span",sx:{color:Jk(t.level)},children:[Math.round(t.pct),"%"]});return(0,D0.jsx)(ie,{component:"span",sx:n,children:r?(0,D0.jsxs)(D0.Fragment,{children:[o,i]}):(0,D0.jsxs)(D0.Fragment,{children:[i,o]})})}var x_=R(z(),1);function I2r({label:e,pct:t,resetsAt:r,windowSeconds:n,now:i}){let o=Qk(t,r,n,i),a=L2r(t,r,n,i),s=a.kind==="projected"?a:void 0;return(0,x_.jsxs)(ie,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[(0,x_.jsx)(ie,{component:"span",sx:{minWidth:"2ch"},children:e}),(0,x_.jsx)(bUe,{direction:"back",threshold:s?.recovery}),(0,x_.jsxs)(ie,{component:"span",sx:{minWidth:"4ch",textAlign:"right",color:Jk(o)},children:[Math.round(t),"%"]}),(0,x_.jsx)(bUe,{direction:"forward",threshold:s?.worse}),(0,x_.jsx)(ie,{component:"span",sx:{opacity:.6},children:s?s.recovery&&M2r(s.recovery,i):"no projection yet"})]})}function D2r(e){return[{label:"5h",window:e.five_hour,windowSeconds:18e3},{label:"7d",window:e.seven_day,windowSeconds:604800}].flatMap(t=>t.window?.used_percentage==null?[]:[{label:t.label,pct:t.window.used_percentage,resetsAt:t.window.resets_at,windowSeconds:t.windowSeconds}])}var N2r=R(z(),1);function n1e({rateLimits:e,now:t}){return D2r(e).map(r=>(0,N2r.jsx)(I2r,{label:r.label,pct:r.pct,resetsAt:r.resetsAt,windowSeconds:r.windowSeconds,now:t},r.label))}var SA=R(z(),1);function O2r({groups:e}){let t=e_(3e4);return(0,SA.jsxs)(ie,{sx:{fontFamily:"monospace",fontSize:12},children:[e.map(r=>(0,SA.jsxs)(ie,{sx:{mb:.5},children:[(0,SA.jsx)(ie,{sx:{opacity:.8},children:Eu(r.harness)}),(0,SA.jsx)(n1e,{rateLimits:r.rateLimits,now:t})]},r.harness)),(0,SA.jsx)(ie,{sx:{mt:.5,opacity:.6},children:"Account usage per harness \u2014 view history"})]})}function B2r(e){return e?.five_hour?.used_percentage!=null||e?.seven_day?.used_percentage!=null}function F2r(e,t){let r=[];B2r(e)&&r.push({harness:"claude",rateLimits:e});for(let[n,i]of Object.entries(t))B2r(i)&&r.push({harness:n,rateLimits:i});return r}var FK=R(z(),1),xUe="Claude account usage (5h / 7d windows) \u2014 view history";function $2r({rateLimits:e}){let t=e_(3e4);return(0,FK.jsxs)(ie,{sx:{fontFamily:"monospace",fontSize:12},children:[(0,FK.jsx)(n1e,{rateLimits:e,now:t}),(0,FK.jsx)(ie,{sx:{mt:.5,opacity:.6},children:xUe})]})}var CA=R(z(),1),sZn={display:"flex",alignItems:"center",ml:2,fontFamily:"monospace",fontSize:13},lZn={};function z2r({rateLimits:e,harnessRateLimits:t=lZn}){let r=F2r(e,t),n=r.every(s=>s.harness==="claude"),i=e,o=xUe,a="Usage";return r.length>0&&n?(o=(0,CA.jsx)($2r,{rateLimits:i}),a=(0,CA.jsx)(r1e,{rateLimits:i})):r.length>0&&(o=(0,CA.jsx)(O2r,{groups:r}),a=(0,CA.jsx)(R2r,{groups:r})),(0,CA.jsx)(sr,{title:o,children:(0,CA.jsx)(jr,{component:Cs,to:"/usage",underline:"hover",color:"inherit",sx:sZn,children:a})})}var N0=R(z(),1),cZn={color:"inherit",mr:1.5};function H2r({reconnecting:e}){let{pending:t,error:r,clearError:n,restart:i}=Zk("webserver",e);return(0,N0.jsxs)(N0.Fragment,{children:[(0,N0.jsx)(sr,{title:"Restart web server",children:(0,N0.jsx)("span",{children:(0,N0.jsx)(ir,{sx:cZn,disabled:t,onClick:i,children:t?(0,N0.jsx)(To,{size:24}):(0,N0.jsx)(U0e,{})})})}),(0,N0.jsx)(Pu,{error:r,onClose:n})]})}var V2r=R(he(),1);var U2r=R(he(),1);function W2r(e){let t=zi().palette.primary.main;_o(jn("focusRepoPicker").matches,(0,U2r.useCallback)(()=>Lu({locate:()=>e.current?.querySelector("button")??null,focus:r=>r.focus()},t),[e,t]))}var $K=R(z(),1),uZn={width:240,ml:2};function G2r({repos:e,selected:t,onSelect:r}){let n=(0,V2r.useRef)(null);W2r(n);let{chords:i}=jn("focusRepoPicker");return(0,$K.jsx)(ie,{ref:n,sx:uZn,children:(0,$K.jsx)(Jte,{label:t?bv(t):"Select repo...",tooltip:(0,$K.jsx)(Ru,{label:"Repo",chords:i}),typeToOpen:!0,children:(o,a)=>(0,$K.jsx)(G1r,{repos:e,selected:t,onSelect:r,close:o,initialFilter:a})})})}var tTr=R(he(),1);var zK=R(he(),1);function i1e(e){let[t,r]=(0,zK.useState)([]),[n,i]=(0,zK.useState)(!0),o=br();return(0,zK.useEffect)(()=>{if(!e){r([]),i(!1);return}let a=!1;return i(!0),fetch(Xr(`/api/pr-list?cwd=${encodeURIComponent(e)}`,o)).then(s=>s.json()).then(s=>{a||(r(Array.isArray(s?.prs)?s.prs:[]),i(!1))}).catch(()=>{a||(r([]),i(!1))}),()=>{a=!0}},[e,o]),{prs:t,loading:n}}var TUe=R(z(),1);function SUe({text:e}){return(0,TUe.jsx)(ie,{sx:{p:1.5},children:(0,TUe.jsx)(Ie,{sx:{fontSize:13,color:"text.secondary"},children:e})})}var wA=R(z(),1);function q2r({pr:e,highlighted:t,onHover:r,onPick:n}){let i=xye(t);return(0,wA.jsx)(hn,{ref:i,selected:t,onMouseDown:o=>o.preventDefault(),onMouseEnter:r,onClick:()=>n(e),sx:{alignItems:"flex-start",py:.75,whiteSpace:"normal"},children:(0,wA.jsxs)(Rt,{spacing:.25,sx:{minWidth:0},children:[(0,wA.jsxs)(Ie,{sx:{fontSize:13,lineHeight:1.3,fontWeight:500},children:[e.title,e.isDraft&&(0,wA.jsx)(en,{label:"Draft",size:"small",variant:"outlined",sx:{ml:.75,height:18,fontSize:10,verticalAlign:"middle"}})]}),(0,wA.jsxs)(Ie,{sx:{fontSize:11,color:"text.secondary"},children:["#",e.number," \xB7 ",e.author," \xB7 ",wo(e.createdAt)]})]})})}var CUe=R(z(),1);function j2r({prs:e,highlight:t,onHighlight:r,onPick:n}){return(0,CUe.jsx)($p,{dense:!0,disablePadding:!0,sx:{maxHeight:200,overflowY:"auto"},children:e.map((i,o)=>(0,CUe.jsx)(q2r,{pr:i,highlighted:o===t,onHover:()=>r(o),onPick:n},i.number))})}var K2r=R(he(),1);function Y2r(e,t){let r=t.trim().toLowerCase();if(!r)return e;let n=r.replace(/^#/,"");return e.filter(i=>i.title.toLowerCase().includes(r)||i.author.toLowerCase().includes(r)||n!==""&&String(i.number).includes(n))}function X2r(e,t,r){let[n,i]=(0,K2r.useState)(""),o=Y2r(e,n),{highlight:a,setHighlight:s,onKeyDown:l}=a_(o,n,t,r);return{filter:n,setFilter:i,filtered:o,highlight:a,setHighlight:s,onKeyDown:l,select:f=>{t(f),r()}}}var T_=R(z(),1),Z2r={...wL,left:"auto",width:320,maxHeight:"none",overflowY:"visible"};function Q2r({cwd:e,onPick:t,close:r}){let{prs:n,loading:i}=i1e(e),o=X2r(n,t,r);return i||n.length===0?(0,T_.jsx)(cn,{elevation:4,sx:Z2r,children:(0,T_.jsx)(SUe,{text:i?"Loading open PRs\u2026":"No open PRs"})}):(0,T_.jsxs)(cn,{elevation:4,sx:Z2r,children:[(0,T_.jsx)(hF,{autoFocus:!0,value:o.filter,onChange:o.setFilter,onKeyDown:o.onKeyDown,placeholder:"Filter PRs..."}),o.filtered.length===0?(0,T_.jsx)(SUe,{text:"No PRs match"}):(0,T_.jsx)(j2r,{prs:o.filtered,highlight:o.highlight,onHighlight:o.setHighlight,onPick:o.select})]})}var eTr=R(z(),1);function J2r({cwd:e,onPick:t,close:r}){return(0,eTr.jsx)(Q2r,{cwd:e,onPick:t,close:r})}var S_=R(z(),1);function rTr({cwd:e,disabled:t,onSelect:r}){let{prs:n,loading:i}=i1e(e),[o,a]=(0,tTr.useState)(null);return i||n.length===0?null:(0,S_.jsxs)(S_.Fragment,{children:[(0,S_.jsx)(Jte,{label:"prs",disabled:t,children:s=>(0,S_.jsx)(J2r,{cwd:e,onPick:a,close:s})}),o&&(0,S_.jsx)(Wme,{pr:o,onSelect:s=>{r(o,s),a(null)},onCancel:()=>a(null)})]})}var iTr=R(z(),1);function nTr({onStartRun:e,cwd:t}){let r=Yte(t);return!t||r.length===0?null:(0,iTr.jsx)(qte,{runs:r,onSelect:n=>e(n,t)})}var HK=R(z(),1);function oTr({onCreateAssist:e,onStartRun:t}){let{selectedCwd:r,selectedNode:n}=Bn();return(0,HK.jsxs)(Rt,{direction:"row",spacing:.5,sx:{alignItems:"center","&:not(:empty)":{ml:2}},children:[(0,HK.jsx)(rTr,{cwd:r,disabled:!r,onSelect:(i,o)=>e([...o,String(i.number)],r,{...vL(i),node:n})}),(0,HK.jsx)(nTr,{onStartRun:(i,o)=>t(i,o,void 0,void 0,n),cwd:r})]})}var ih=R(z(),1),fZn={minHeight:48,pl:1,pr:14};function aTr({socket:e,selection:t}){let{collapsed:r,onToggleCollapsed:n}=CS();return(0,ih.jsxs)(y5,{variant:"dense",disableGutters:!0,sx:fZn,children:[r&&(0,ih.jsx)(cre,{collapsed:r,onToggleCollapsed:n}),(0,ih.jsx)(H2r,{reconnecting:e.reconnecting}),(0,ih.jsx)(x2r,{cwd:t.selectedCwd}),(0,ih.jsx)(f2r,{}),(0,ih.jsx)(G2r,{repos:t.repos,selected:t.selectedCwd,onSelect:t.setSelectedCwd}),(0,ih.jsxs)(ie,{sx:{display:"flex",alignItems:"center",ml:1},children:[(0,ih.jsx)(tre,{cwd:t.selectedCwd}),(0,ih.jsx)(w2r,{cwd:t.selectedCwd}),(0,ih.jsx)(C2r,{})]}),(0,ih.jsx)(oTr,{onCreateAssist:e.createAssistSession,onStartRun:e.startRun}),(0,ih.jsx)(z2r,{rateLimits:e.rateLimits,harnessRateLimits:e.harnessRateLimits})]})}var o1e=R(he(),1);function sTr(){let[e,t]=(0,o1e.useState)(null);return(0,o1e.useEffect)(()=>{let r=!1;return(async()=>{try{let i=await(await fetch("/api/health")).json();!r&&typeof i?.nodeName=="string"&&t(i.nodeName)}catch{}})(),()=>{r=!0}},[]),e}var cTr=R(z(),1),dZn={lineHeight:"32px",bgcolor:"transparent"};function lTr(){let e=sTr();return e?(0,cTr.jsx)(ube,{sx:dZn,children:e}):null}var uTr=R(z(),1),fTr=st((0,uTr.jsx)("path",{d:"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-1 2H5v-2h2zm0-3H5V8h2zm9 7H8v-2h8zm0-4h-2v-2h2zm0-3h-2V8h2zm3 3h-2v-2h2zm0-3h-2V8h2z"}),"Keyboard");var dTr=R(z(),1),hTr=st((0,dTr.jsx)("path",{d:"m12 16.5 4-4h-3v-9h-2v9H8zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2"}),"SystemUpdateAlt");var pTr=R(z(),1),mTr=st((0,pTr.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6"}),"Brightness4");var gTr=R(z(),1),yTr=st((0,gTr.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6m0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4"}),"Brightness7");var wUe=R(z(),1);function vTr({mode:e}){return e==="dark"?(0,wUe.jsx)(yTr,{fontSize:"small"}):(0,wUe.jsx)(mTr,{fontSize:"small"})}var bTr=R(z(),1),xTr=st((0,bTr.jsx)("path",{d:"m20.38 8.57-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83"}),"Speed");var PF=R(z(),1);function TTr(){let e=Zme();return(0,PF.jsxs)(hn,{onClick:()=>Qht(!e),children:[(0,PF.jsx)(RT,{children:(0,PF.jsx)(xTr,{fontSize:"small"})}),(0,PF.jsx)(Fp,{children:e?"Hide render HUD":"Show render HUD"})]})}var al=R(z(),1);function STr({mode:e,restartLabel:t,updateLabel:r,onToggleColorMode:n,onShowShortcuts:i,onRestart:o,onUpdate:a}){return[(0,al.jsxs)(hn,{onClick:n,children:[(0,al.jsx)(RT,{children:(0,al.jsx)(vTr,{mode:e})}),(0,al.jsx)(Fp,{children:"Toggle dark mode"})]},"color-mode"),(0,al.jsx)(TTr,{},"render-hud"),(0,al.jsxs)(hn,{onClick:i,children:[(0,al.jsx)(RT,{children:(0,al.jsx)(fTr,{fontSize:"small"})}),(0,al.jsx)(Fp,{children:"Keyboard shortcuts"})]},"shortcuts"),(0,al.jsx)(Ui,{},"restart-divider"),(0,al.jsxs)(hn,{onClick:o,children:[(0,al.jsx)(RT,{children:(0,al.jsx)(gL,{fontSize:"small"})}),(0,al.jsx)(Fp,{children:t})]},"restart"),(0,al.jsxs)(hn,{onClick:a,children:[(0,al.jsx)(RT,{children:(0,al.jsx)(hTr,{fontSize:"small"})}),(0,al.jsx)(Fp,{children:r})]},"update")]}var CTr=R(he(),1);var kTr=R(z(),1);function wTr({peer:e,onRestart:t,onClose:r}){let[n,i]=(0,CTr.useState)(!1);return(0,kTr.jsx)(ro,{title:`Restart ${e}?`,message:`Restarts the sessions daemon and web server on ${e}. Its sessions resume when the daemon is back. This page stays open.`,confirmLabel:"Restart",busy:n,autoFocusConfirm:!0,onConfirm:()=>{i(!0),t(e).finally(r)},onCancel:r})}function _Tr(e){let t=new Map;for(let r of e){let n=t.get(r.group)??[];n.push(r),t.set(r.group,n)}return[...t].map(([r,n])=>({name:r,shortcuts:n}))}var hZn=Object.keys(sL);function ETr(){let e=lL();return _Tr(hZn.map(t=>pS(t,e)))}var Cp=R(z(),1),pZn={display:"flex",alignItems:"center",justifyContent:"space-between",pr:1},mZn={display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,py:.5};function RTr({onClose:e}){let t=ETr();return(0,Cp.jsxs)($l,{open:!0,onClose:e,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"shortcuts-dialog-title",children:[(0,Cp.jsxs)(xu,{id:"shortcuts-dialog-title",sx:pZn,children:["Keyboard shortcuts",(0,Cp.jsx)(ir,{size:"small","aria-label":"Close",onClick:e,children:(0,Cp.jsx)(ba,{fontSize:"small"})})]}),(0,Cp.jsx)(bu,{dividers:!0,children:t.map(r=>(0,Cp.jsxs)(ie,{component:"section",sx:{mb:1.5},children:[(0,Cp.jsx)(Ie,{variant:"overline",color:"text.secondary",children:r.name}),r.shortcuts.map(n=>(0,Cp.jsxs)(ie,{sx:mZn,children:[(0,Cp.jsx)(Ie,{variant:"body2",children:n.label}),(0,Cp.jsx)(Rt,{direction:"row",spacing:.5,children:(0,Cp.jsx)(ote,{chords:n.chords})})]},n.label))]},r.name))})]})}var kA=R(z(),1);function ATr({reconnecting:e,onClose:t}){let{pending:r,error:n,clearError:i,restart:o}=Zk(rF.target,e);return(0,kA.jsxs)(kA.Fragment,{children:[(0,kA.jsx)(ro,{title:rF.label,message:rF.message,confirmLabel:"Restart",busy:r,autoFocusConfirm:!0,onConfirm:()=>{o()},onCancel:t}),(0,kA.jsx)(Pu,{error:n,onClose:i})]})}var LTr=R(z(),1);function gZn(e){return e?{title:`Update assist on ${e}?`,message:`This runs 'assist update' on ${e} as a new session, then restarts its web server. This page stays open.`}:{title:"Update assist",message:"This starts a new session running 'assist update'. Its output will appear in the terminal."}}function PTr({peer:e,onConfirm:t,onClose:r}){return(0,LTr.jsx)(ro,{...gZn(e),confirmLabel:"Update",onConfirm:()=>{t(),r()},onCancel:r})}var O0=R(he(),1);async function yZn(e){try{let t=await fetch(`/api/node-doctor?link=${encodeURIComponent(e)}`);return t.ok?(await t.json()).hop:null}catch{return null}}async function MTr(e,t){let r=await yZn(e);if(!r)return t;let n=r.remediation?` \u2014 ${r.remediation}`:"";return`${t}: ${r.hop} hop failed: ${r.error}${n}`}var sT=R(he(),1);function ITr(e){let{nodes:t}=Zu(),[r,n]=(0,sT.useState)(null),i=(0,sT.useRef)(!1),o=r?t?.links.find(l=>l.name===r.peer):void 0;(0,sT.useEffect)(()=>{if(!(!r||!o)){if(o.state!=="connected"){i.current=!0;return}i.current&&(n(null),e(r.describe(r.peer,o.peerVersion)))}},[r,o,e]);let a=(0,sT.useCallback)((l,u)=>{i.current=!1,n({peer:l,describe:u})},[]),s=(0,sT.useCallback)(()=>n(null),[]);return{watch:a,stop:s}}var vZn=9e4;function a1e(){let[e,t]=(0,O0.useState)(null),[r,n]=(0,O0.useState)(null),i=(0,O0.useRef)(void 0),o=(0,O0.useCallback)(f=>{clearTimeout(i.current),t(f)},[]),{watch:a,stop:s}=ITr(o);(0,O0.useEffect)(()=>()=>clearTimeout(i.current),[]);let l=(0,O0.useCallback)(async(f,d)=>{n(await MTr(f,d))},[]);return{requestThenAwait:(0,O0.useCallback)(async(f,d,h,p)=>{let m;try{m=await h()}catch{}return m?.ok?(a(f,p),clearTimeout(i.current),i.current=setTimeout(()=>{s(),l(f,`${f} did not come back`)},vZn),!0):(await l(f,`${d} failed (${await tF(m)})`),!1)},[l,a,s]),back:e,clearBack:()=>t(null),error:r,clearError:()=>n(null)}}var bZn=(e,t)=>t?`${e} is back (v${t})`:`${e} is back`;function DTr(){let{requestThenAwait:e,...t}=a1e();return{restart:n=>e(n,`Restart ${n}`,()=>Xk("both",n),bZn),...t}}var UK=R(he(),1);var B0=R(he(),1);function NTr(e){return e.commandType==="assist"&&e.assistArgs?.[0]==="update"&&e.status==="done"}function s1e(e,t,r){let[n,i]=(0,B0.useState)(!1),[o,a]=(0,B0.useState)(!1),s=(0,B0.useRef)(!1),l=(0,B0.useRef)(e);l.current=e;let u=(0,B0.useRef)(new Set),f=(0,B0.useCallback)(()=>{s.current=!1,a(!1),u.current=new Set(l.current.filter(NTr).map(d=>d.id)),i(!0)},[]);return(0,B0.useEffect)(()=>{if(!n||o)return;if(t){s.current=!0;return}if(!s.current)return;e.some(h=>NTr(h)&&h.node===r&&!u.current.has(h.id))&&a(!0)},[n,o,t,e,r]),{arm:f,completed:o}}var OTr=(e,t)=>t?`${e} updated to v${t}`:`${e} updated`;function xZn(e){return fetch(`/api/self-update?node=${encodeURIComponent(e)}`,{method:"POST"})}function BTr(e){let{nodes:t}=Zu(),{launchAssist:r}=Gl(),{requestThenAwait:n,...i}=a1e(),[o,a]=(0,UK.useState)(null),[s,l]=(0,UK.useState)(),u=m=>t?.links.find(g=>g.name===m)?.state,{arm:f,completed:d}=s1e(e,u(s)!=="connected",s);(0,UK.useEffect)(()=>{!d||!s||(l(void 0),n(s,`Restart ${s}'s web server`,()=>Xk("webserver",s),OTr))},[d,s,n]);let h=async m=>{a(`Updating assist on ${m}\u2026`),await n(m,`Update ${m}`,()=>xZn(m),OTr),a(null)};return{update:m=>{if(u(m)!=="connected"){h(m);return}l(m),f(),r(["update"],void 0,{node:m})},progress:o,...i}}var F0=R(z(),1);function FTr({dialog:e,peer:t,sessions:r,reconnecting:n,onClose:i}){let{launchAssist:o,armUpdateReload:a}=Gl(),s=DTr(),l=BTr(r);return(0,F0.jsxs)(F0.Fragment,{children:[e==="shortcuts"&&(0,F0.jsx)(RTr,{onClose:i}),e==="restart"&&t&&(0,F0.jsx)(wTr,{peer:t,onRestart:s.restart,onClose:i}),e==="restart"&&!t&&(0,F0.jsx)(ATr,{reconnecting:n,onClose:i}),e==="update"&&(0,F0.jsx)(PTr,{peer:t,onConfirm:()=>{if(t){l.update(t);return}a(),o(["update"])},onClose:i}),(0,F0.jsx)(cK,{notices:s}),(0,F0.jsx)(cK,{notices:l})]})}var $Tr=R(z(),1),zTr=st((0,$Tr.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");var HTr=R(he(),1);var WK=R(z(),1);function UTr(){let e=Li(),t=(0,HTr.useCallback)(()=>e("/config"),[e]),{matches:r,chords:n}=jn("openConfig");return _o(r,t),(0,WK.jsx)(sr,{describeChild:!0,title:(0,WK.jsx)(Ru,{label:"Config",chords:n}),children:(0,WK.jsx)(ir,{size:"small",sx:{color:"inherit"},"aria-label":"Config",onClick:t,children:(0,WK.jsx)(zTr,{fontSize:"small"})})})}var WTr=R(z(),1),VTr=st((0,WTr.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var l1e=R(he(),1);var VK=R(z(),1);function GTr({open:e,onOpen:t}){let r=(0,l1e.useRef)(null),{matches:n,chords:i}=jn("openMenu");return _o(n,(0,l1e.useCallback)(()=>{r.current&&t(r.current)},[t])),(0,VK.jsx)(sr,{describeChild:!0,title:(0,VK.jsx)(Ru,{label:"Menu",chords:i}),children:(0,VK.jsx)(ir,{ref:r,onClick:o=>t(o.currentTarget),size:"small",sx:{color:"inherit"},"aria-label":"Open menu","aria-haspopup":"true","aria-expanded":e?"true":void 0,children:(0,VK.jsx)(VTr,{fontSize:"small"})})})}var KTr=R(he(),1);var kUe=R(z(),1),qTr=st([(0,kUe.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,kUe.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber");var _Ue=R(z(),1);function jTr(){let e=Vye();return!e||e===m_?null:(0,_Ue.jsx)(sr,{title:`Daemon is running v${e}, but this page was served by v${m_}. Restart the daemon to match.`,children:(0,_Ue.jsx)(qTr,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})}var YTr=e=>({display:"inline-flex",alignItems:"center",gap:.75,px:1,py:.25,borderRadius:999,fontSize:12,lineHeight:1.5,color:"inherit",opacity:e?1:.55,bgcolor:e?"rgba(255,255,255,0.16)":"transparent",transition:"opacity .2s ease, background-color .2s ease","&:hover, &:focus-visible":{opacity:1,bgcolor:"rgba(255,255,255,0.12)"},"& .ready-dot":{width:8,height:8,borderRadius:"50%",bgcolor:"#ffb74d",boxShadow:"0 0 0 2px rgba(0,0,0,.15)"},"& .ready-count":{fontWeight:500}});var sg=R(z(),1);function XTr(){let{entries:e}=qB(),t=Li(),r=(0,KTr.useCallback)(()=>t("/updates"),[t]),{matches:n,chords:i}=jn("openUpdates");if(_o(n,r),!m_)return null;let o=e.filter(JB).length;return(0,sg.jsxs)(sg.Fragment,{children:[(0,sg.jsx)(sr,{describeChild:!0,title:(0,sg.jsx)(Ru,{label:"Updates",chords:i}),children:(0,sg.jsxs)(On,{component:Cs,to:"/updates","aria-label":o?`Updates: ${o} node${o>1?"s have":" has"} an update ready`:"Updates",sx:YTr(o>0),children:[o>0&&(0,sg.jsx)("span",{className:"ready-dot","aria-hidden":!0}),(0,sg.jsxs)("span",{children:["v",m_]}),o>0&&(0,sg.jsxs)("span",{className:"ready-count",children:[o," ready"]})]})}),(0,sg.jsx)(jTr,{})]})}var LF=R(z(),1);function ZTr({open:e,onOpen:t}){return(0,LF.jsxs)(ie,{sx:{position:"fixed",top:8,right:16,zIndex:r=>r.zIndex.drawer+2,display:"flex",alignItems:"center",gap:.5,color:"inherit"},children:[(0,LF.jsx)(XTr,{}),(0,LF.jsx)(UTr,{}),(0,LF.jsx)(GTr,{open:e,onOpen:t})]})}var _A=R(he(),1);var JTr=R(he(),1);var QTr=!0,TZn=new Set(["openMenu","cycleCards"]),SZn=Object.keys(sL).filter(e=>!TZn.has(e));function eSr(e,t){let r=lL();(0,JTr.useEffect)(()=>{if(!e)return;let n=i=>{SZn.some(o=>pS(o,r).matches(i))&&t()};return globalThis.addEventListener("keydown",n,QTr),()=>globalThis.removeEventListener("keydown",n,QTr)},[e,t,r])}function tSr(){let[e,t]=(0,_A.useState)(null),[r,n]=(0,_A.useState)(!0),i=!!e,o=(0,_A.useCallback)(()=>t(null),[]),a=(0,_A.useCallback)(s=>{n(!0),t(s)},[]);return eSr(i,(0,_A.useCallback)(()=>{n(!1),t(null)},[])),{anchorEl:e,open:i,close:o,openAt:a,restoreFocus:r}}var GK=R(he(),1);function rSr(e){_o(jn("shortcutsSheet").matches,e)}function nSr(){let[e,t]=(0,GK.useState)(null);rSr((0,GK.useCallback)(()=>t("shortcuts"),[]));let r=(0,GK.useCallback)(()=>t(null),[]);return{dialog:e,showDialog:t,closeDialog:r}}function iSr(){let{nodes:e,selected:t}=Zu();return e&&t&&t!==e.local?t:void 0}function oSr(e){return{restartLabel:e?`Restart ${e}`:rF.label,updateLabel:e?`Update assist on ${e}`:"Update assist"}}var lT=R(z(),1);function aSr({mode:e,toggle:t,sessions:r,reconnecting:n}){let{anchorEl:i,open:o,close:a,openAt:s,restoreFocus:l}=tSr(),{dialog:u,showDialog:f,closeDialog:d}=nSr(),h=iSr(),p=m=>()=>{a(),f(m)};return(0,lT.jsxs)(lT.Fragment,{children:[(0,lT.jsx)(ZTr,{open:o,onOpen:s}),(0,lT.jsxs)(zl,{anchorEl:i,open:o,onClose:a,disableRestoreFocus:!l,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,lT.jsx)(lTr,{}),STr({mode:e,...oSr(h),onToggleColorMode:()=>{t(),a()},onShowShortcuts:p("shortcuts"),onRestart:p("restart"),onUpdate:p("update")})]}),(0,lT.jsx)(FTr,{dialog:u,peer:h,sessions:r,reconnecting:n,onClose:d})]})}var cSr=R(he(),1);var lSr=R(z(),1);function sSr({conflict:e,onConfirm:t,onCancel:r}){let{name:n,cwd:i,port:o,group:a}=e.existing,s=rm(i),l=o?` on port ${o}`:"",u=s?` in ${s}`:"",f=a?`, holding the ${a} server slot`:"";return(0,lSr.jsx)(ro,{title:a?`Replace the ${a} server?`:"Replace running server?",message:`"${n}" is already serving${l}${u}${f}. Replace it \u2014 stop the running server and start this one?`,confirmLabel:"Replace",confirmColor:"error",onConfirm:t,onCancel:r})}var c1e=R(z(),1);function uSr({socket:e,children:t}){let{serverConflict:r,clearServerConflict:n,retrySession:i,stopSession:o,startRun:a,discardSession:s}=e,l=(0,cSr.useMemo)(()=>({onStop:o,onStart:a,onDiscard:s}),[o,a,s]),u=()=>{r&&(r.runName?a(r.runName,r.cwd,!0,r.launchedFrom,r.node):r.sessionId&&i(r.sessionId,!0),n())};return(0,c1e.jsxs)(WSe.Provider,{value:l,children:[t,r&&(0,c1e.jsx)(sSr,{conflict:r,onConfirm:u,onCancel:n})]})}var fSr=new Map;function dSr(e,t){if(!Xne())return;let r=fSr.get(e);if(fSr.set(e,t),!!r)for(let[n,i]of Object.entries(t))Object.is(i,r[n])||ky(`\u0394 ${e}.${n}`)}var f1e=R(he(),1);function hSr(e,t,r){if(!t)return null;let n=e[t];if(!n)return null;let i=r.find(o=>o.id===n);return!i||nm(i)!==t?null:n}function kv(e,t,r){if(e)return t.find(n=>n.id===e)??r.find(n=>n.sessionId===e)}function u1e(){let{pathname:e}=Uo();return e.startsWith("/backlog")||e.startsWith("/usage")}function pSr({selectedCwd:e,selectedCardId:t,sessions:r,history:n,activeByRepo:i,onSelect:o}){let a=kv(t,r,n),s=a&&nm(a),l=!!(s&&s===e),u=hSr(i,e,r),f=(0,f1e.useRef)(t),d=u1e();(0,f1e.useEffect)(()=>{let h=f.current!==t&&!!s;f.current=t,!(d||h||l||!u)&&o(u)},[t,s,l,u,o,d])}var p1e=R(he(),1);function mSr(e,t,r,n){return kv(e,t,r)?.cwd||n}function gSr(e,t,r,n){let i=mSr(e,t,r,n.cwd),o=kv(e,t,r);return{cwd:i,node:o?.cwd?o.node:n.node}}function ySr(e,t){let r=new Set,n=new Set,i=[];for(let o of t){if(o.cwdMissing)continue;let a=nL(o),s=nm(o);!a||!s||r.has(a)||n.has(s)||(r.add(a),n.add(s),i.push(s))}return e&&!r.has(iL(e,t))&&!n.has(e)&&i.unshift(e),i}var wp="";function CZn(e){let t=new Map([[wp,[]]]);for(let r of e){let n=r.node??wp;t.set(n,[...t.get(n)??[],r])}return t}function vSr(e,t){var n;let r=new Map;for(let[i,o]of CZn(t)){let a=i===wp?e:"";for(let s of ySr(a,o)){let l=iL(s,o),u=r.get(l)??{key:l,origin:l===s?void 0:l,clones:{}};(n=u.clones)[i]??(n[i]=s),r.set(l,u)}}return[...r.values()]}function bSr(e,t){return e.clones[t]??e.clones[wp]??Object.values(e.clones)[0]}function qK(e,t){return e.find(r=>Object.values(r.clones).includes(t))}function MF(e,t){return!e||e===t?wp:e}var EUe=R(he(),1);function xSr(e,t){let r=(0,EUe.useCallback)((i,o)=>{let a=MF(o,t),s=qK(e,i);return s?s.clones[a]:a===wp?i:void 0},[e,t]),n=(0,EUe.useCallback)(i=>qK(e,i)?.origin,[e]);return{cloneOn:r,originOf:n}}var d1e=R(he(),1);function TSr(e,t,r,n){let i=(0,d1e.useRef)(e);(0,d1e.useEffect)(()=>{if(i.current===e)return;i.current=e;let o=qK(t,r)?.clones[e];o&&n(o,e)},[e,t,r,n])}var IF=R(he(),1);function SSr(e,t,r){if(t.node!==void 0)return t.node;let n=new Set(e.flatMap(i=>Object.entries(i.clones).filter(([,o])=>o===t.cwd).map(([o])=>o)));return n.has(r)?r:n.size===0||n.has(wp)?wp:[...n][0]}function CSr(e,t,r,n){let[i,o]=(0,IF.useState)({cwd:e}),a=(0,IF.useCallback)((l,u)=>o({cwd:l,node:u}),[]);(0,IF.useEffect)(()=>{e&&!i.cwd&&o({cwd:e})},[e,i.cwd]);let s=SSr(t,{cwd:i.cwd,node:i.node===void 0?void 0:MF(i.node,n)},r);return{selectedCwd:i.cwd,selectedNode:s||void 0,setSelectedCwd:a}}var wSr=R(he(),1);function h1e(e,t,r){let n=kv(e,t,r);return n&&nm(n)}function kSr(e,t,r,n){let i=h1e(e,t,r),o=kv(e,t,r)?.node??wp;(0,wSr.useEffect)(()=>{i&&n(i,o)},[i,o,n])}function _Sr(e,t,r,n,i){let o=i.nodes?.local,a=MF(i.selected,o),s=(0,p1e.useMemo)(()=>vSr(e,t),[e,t]),{selectedCwd:l,selectedNode:u,setSelectedCwd:f}=CSr(e,s,a,o);kSr(r,n,t,f),TSr(a,s,l,f);let{cloneOn:d,originOf:h}=xSr(s,o),p=(0,p1e.useMemo)(()=>s.map(y=>bSr(y,a)),[s,a]),{cwd:m,node:g}=gSr(r,n,t,{cwd:l,node:u});return(0,p1e.useMemo)(()=>({repos:p,selectedCwd:l,selectedNode:u,worktreeCwd:m,worktreeNode:g,setSelectedCwd:f,cloneOn:d,originOf:h}),[p,l,u,m,g,f,d,h])}var g1e=R(he(),1);var C_=R(he(),1);var ESr=R(he(),1),m1e="assist:reloaded-after-update";function RSr(e){(0,ESr.useEffect)(()=>{globalThis.sessionStorage?.getItem(m1e)&&(globalThis.sessionStorage.removeItem(m1e),e({message:"Reloaded after updating assist",sessionId:null}))},[e])}function ASr(e,t,r,n){let{arm:i,completed:o}=s1e(e,t),a=(0,C_.useRef)(!1),s=(0,C_.useCallback)(()=>{globalThis.sessionStorage?.setItem(m1e,"1")},[]),{error:l,restart:u}=Zk("webserver",t,s);return RSr(r),(0,C_.useEffect)(()=>{l&&n(l)},[l,n]),(0,C_.useEffect)(()=>{!o||a.current||(a.current=!0,u())},[o,u]),{armUpdateReload:(0,C_.useCallback)(()=>{a.current=!1,i()},[i])}}function PSr(e){let{armUpdateReload:t}=ASr(e.sessions,e.reconnecting,e.setSuccess,e.setError),r=(0,g1e.useMemo)(()=>({launchAssist:e.createAssistSession,launchAgentInStream:e.createSessionInStream,resumeSession:e.resumeSession,armUpdateReload:t}),[e.createAssistSession,e.createSessionInStream,e.resumeSession,t]),n=Li(),i=(0,g1e.useCallback)(o=>{e.selectSession(o),n("/sessions"),e.clearSuccess()},[n,e.selectSession,e.clearSuccess]);return{launch:r,viewLaunchedSession:i}}var LSr=R(he(),1);function MSr(e,t,r,n){let i=h1e(e,t,r);(0,LSr.useEffect)(()=>{e&&i&&n({type:"set-active",cwd:i,sessionId:e})},[e,i,n])}var y1e=R(he(),1);function ISr(e,t){let r=(0,y1e.useRef)(new Map);(0,y1e.useEffect)(()=>{let n=new Set;for(let{id:i,status:o}of e)n.add(i),r.current.get(i)!==o&&(r.current.set(i,o),console.debug(`[sessions] render session ${i} status=${o}`),t({type:"ui-status",sessionId:i,status:o}));for(let i of r.current.keys())n.has(i)||r.current.delete(i)},[e,t])}var DF=R(he(),1),DSr="assist.sessions.node";function wZn(){try{return localStorage.getItem(DSr)}catch{return null}}function kZn(e){try{localStorage.setItem(DSr,e)}catch{}}function NSr(e){let[t,r]=(0,DF.useState)(wZn),n=(0,DF.useCallback)(i=>{r(i),kZn(i)},[]);return(0,DF.useMemo)(()=>{let i=e?[e.local,...e.links.map(o=>o.name)]:[];return{nodes:e,names:i,visible:i.length>1,selected:t&&i.includes(t)?t:e?.local,select:n}},[e,t,n])}var BSr=R(he(),1);function OSr(e){let t=e;if(t.type==="create")return{cwd:t.cwd,title:t.prompt?.trim()||(t.design?"New design session":"New session"),node:t.node};if(t.type==="create-assist"){let r=t.title?.trim();return{cwd:t.cwd,title:r||"New session",named:!!r,node:t.node}}return null}function FSr(e,t){return(0,BSr.useCallback)(r=>{let n=e.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r));let i=OSr(r);i&&t(i)},[e,t])}var cT=R(he(),1);function v1e(e,t,r,n,i){e({type:"create",prompt:r||void 0,cwd:n,...t,...i?{node:i}:{}})}function $Sr(e){return(t,r,n)=>v1e(e,{design:!0},t,r,n)}function zSr(e){return(t,r,n,i)=>v1e(e,{harness:t},r,n,i)}function HSr(e){return(t,r,n)=>v1e(e,{auto:!0},t,r,n)}function USr(e){return(t,r,n)=>e({type:"create-assist",assistArgs:t,cwd:r,...n})}function WSr(e){return(t,r,n,i,o)=>e({type:"resume",sessionId:t,cwd:r,name:n,harness:i,node:o})}function VSr(e,t){return(r,n)=>{t.delete(r),e({type:"retry",sessionId:r,replace:n})}}function GSr(e,t){return r=>{t.delete(r),e({type:"restart",sessionId:r})}}function qSr(e,t){return r=>{e({type:"dismiss",sessionId:r}),t.delete(r)}}function jSr(e,t){return r=>{e({type:"discard",sessionId:r}),t.delete(r)}}function YSr(e){return t=>e({type:"stop",sessionId:t})}function KSr(e){return(t,r,n,i,o)=>e({type:"create-run",runName:t,cwd:r,replace:n,launchedFrom:i,node:o})}function XSr(e){return(t,r)=>e({type:"set-autoadvance",sessionId:t,enabled:r})}function ZSr(e){return(t,r)=>e({type:"set-starred",sessionId:t,starred:r})}function QSr(e){return(t,r)=>e({type:"input",sessionId:t,data:r,viewerId:lK})}function JSr(e){return(t,r,n,i)=>e({type:"resize",sessionId:t,cols:r,rows:n,viewerId:lK,claim:i==="claim",refresh:i==="refresh"})}function eCr(e){return(t,r,n,i)=>e({type:"pr-decision",sessionId:t,requestId:r,decision:n,...i})}var EA=R(he(),1);function tCr(e){return(t,r,n)=>e({type:"create",prompt:r||void 0,cwd:n,joinSessionId:t,auto:!0})}function rCr(e){return{createSession:(0,EA.useMemo)(()=>HSr(e),[e]),createSessionInStream:(0,EA.useMemo)(()=>tCr(e),[e]),createDesignSession:(0,EA.useMemo)(()=>$Sr(e),[e]),createHarnessSession:(0,EA.useMemo)(()=>zSr(e),[e]),createAssistSession:(0,EA.useMemo)(()=>USr(e),[e]),resumeSession:(0,EA.useMemo)(()=>WSr(e),[e])}}var jK=R(he(),1);function nCr(e,t){let r=(0,jK.useCallback)((a,s)=>{VSr(e,t.current)(a,s)},[e,t]),n=(0,jK.useCallback)(a=>{GSr(e,t.current)(a)},[e,t]),i=(0,jK.useCallback)(a=>{qSr(e,t.current)(a)},[e,t]),o=(0,jK.useCallback)(a=>{jSr(e,t.current)(a)},[e,t]);return{retrySession:r,restartSession:n,dismissSession:i,discardSession:o}}function iCr(e,t,r){return(n,i)=>{let o=t.get(n);return o&&(i(o),e({type:"snapshot",sessionId:n})),r.set(n,i),()=>r.delete(n)}}function oCr(e,t,r){let n={...rCr(e),sendInput:(0,cT.useMemo)(()=>QSr(e),[e]),sendResize:(0,cT.useMemo)(()=>JSr(e),[e]),sendPrDecision:(0,cT.useMemo)(()=>eCr(e),[e]),setAutoAdvance:(0,cT.useMemo)(()=>XSr(e),[e]),setStarred:(0,cT.useMemo)(()=>ZSr(e),[e]),stopSession:(0,cT.useMemo)(()=>YSr(e),[e]),startRun:(0,cT.useMemo)(()=>KSr(e),[e])},i=(0,cT.useMemo)(()=>iCr(e,t.current,r.current),[e,t,r]);return{...n,...nCr(e,t),onOutput:i}}var YK=R(he(),1);function aCr(e,t,r){let n=(0,YK.useCallback)(s=>{r(s),e({type:"fetch-transcript",sessionId:s})},[e,r]),i=(0,YK.useCallback)(s=>e({type:"fetch-user-messages",sessionId:s}),[e]),o=(0,YK.useCallback)(()=>{r(null)},[r]),a=(0,YK.useCallback)(s=>{r(null),t(s)},[t,r]);return{viewTranscript:n,fetchUserMessages:i,clearTranscript:o,selectSession:a}}var S1e=R(he(),1);function sCr(e,t){let r=new Set(t.map(i=>i.id)),n=null;for(let i of Object.values(e))r.has(i)&&(n=i);return n}var NF=R(he(),1);function lCr(){let[e,t]=(0,NF.useState)(null),r=(0,NF.useRef)(e);r.current=e;let n=(0,NF.useCallback)(()=>r.current,[]);return{activeId:e,setActiveId:t,getActiveId:n}}var uCr=R(he(),1);function cCr(e,t,r=null){return t!==null?e.some(n=>n.id===t)?t:e[0]?.id??null:r&&e.some(n=>n.id===r)?r:e[0]?.id??null}function fCr(e,t,r){let n=u1e();(0,uCr.useEffect)(()=>{if(n){t(null);return}t(i=>cCr(e,i,r))},[e,t,r,n])}var b1e=R(he(),1);function dCr(){let[e,t]=(0,b1e.useState)({}),[r,n]=(0,b1e.useState)(null),[i,o]=(0,b1e.useState)(null);return{activeByRepo:e,setActiveByRepo:t,daemonVersion:r,setDaemonVersion:n,nodes:i,setNodes:o}}var $0=R(he(),1);function hCr(e,t){if(!t.some(n=>e.has(n)))return e;let r=new Set(e);for(let n of t)r.delete(n);return r}function pCr(e,t){let r=[];for(let n of t){let i=e.get(n.id);i!==void 0&&i!==n.startedAt&&r.push(n.id)}return r}function mCr(e,t){return t.filter(r=>r.commandType==="run"&&e.get(r.id)!==r.startedAt).map(r=>r.id)}var _Zn=1500;function gCr(){let[e,t]=(0,$0.useState)(new Set),r=(0,$0.useRef)(new Map),n=(0,$0.useRef)(new Map),i=(0,$0.useCallback)(s=>{t(l=>l.has(s)?l:new Set(l).add(s))},[]),o=(0,$0.useCallback)(s=>{let l=n.current;for(let u of s)clearTimeout(l.get(u)),l.set(u,setTimeout(()=>{l.delete(u),i(u)},_Zn))},[i]);(0,$0.useEffect)(()=>{let s=n.current;return()=>{for(let l of s.values())clearTimeout(l)}},[]);let a=(0,$0.useCallback)(s=>{let l=pCr(r.current,s),u=mCr(r.current,s);r.current=new Map(s.map(f=>[f.id,f.startedAt])),l.length&&t(f=>hCr(f,l)),o(u)},[o]);return{initialized:e,markInitialized:i,syncSessions:a}}var w_=R(he(),1);function yCr(){let[e,t]=(0,w_.useState)(null),[r,n]=(0,w_.useState)(null),[i,o]=(0,w_.useState)(null),a=(0,w_.useCallback)(()=>t(null),[]),s=(0,w_.useCallback)(()=>n(null),[]),l=(0,w_.useCallback)(()=>o(null),[]);return{error:e,setError:t,clearError:a,success:r,setSuccess:n,clearSuccess:s,serverConflict:i,setServerConflict:o,clearServerConflict:l}}var _v=R(he(),1);function vCr(e,t){return[...e,{...t,status:"launching"}]}function x1e(e){return e.find(t=>t.status==="launching")}function bCr(e){let t=x1e(e);return t?e.filter(r=>r.id!==t.id):e}function xCr(e,t){let r=x1e(e);return r?RUe(e,r.id,t):e}function RUe(e,t,r){return e.map(n=>n.id===t&&n.status==="launching"?{...n,status:"error",error:r}:n)}function TCr(e,t){return e.filter(r=>r.id!==t)}var SCr=R(he(),1);var EZn=6e4,RZn="Launch timed out \u2014 the session did not start.";function CCr(e,t){(0,SCr.useEffect)(()=>{let r=e.filter(i=>i.status==="launching");if(r.length===0)return;let n=r.map(i=>setTimeout(()=>t(o=>RUe(o,i.id,RZn)),Math.max(0,EZn-(Date.now()-i.startedAt))));return()=>n.forEach(clearTimeout)},[e,t])}function wCr(){let[e,t]=(0,_v.useState)([]),r=(0,_v.useRef)([]),n=(0,_v.useCallback)(l=>{r.current=l(r.current),t(r.current)},[]),i=(0,_v.useCallback)(l=>{n(u=>vCr(u,{id:crypto.randomUUID(),startedAt:Date.now(),...l}))},[n]),o=(0,_v.useCallback)(()=>{let l=x1e(r.current);return n(bCr),l?.named?l.title:void 0},[n]),a=(0,_v.useCallback)(l=>n(u=>xCr(u,l)),[n]),s=(0,_v.useCallback)(l=>n(u=>TCr(u,l)),[n]);return CCr(e,n),{pendingLaunches:e,addPendingLaunch:i,resolvePendingLaunch:o,failPendingLaunch:a,dismissPendingLaunch:s}}var KK=R(he(),1);function kCr(){let[e,t]=(0,KK.useState)(null),[r,n]=(0,KK.useState)({}),i=(0,KK.useCallback)((o,a)=>{o!=="claude"&&n(s=>({...s,[o]:a}))},[]);return{rateLimits:e,setRateLimits:t,harnessRateLimits:r,setHarnessRateLimits:i}}var _Cr=R(he(),1);function ECr(e,t){return(0,_Cr.useCallback)(r=>{e(r),t(r)},[e,t])}var AUe=R(he(),1);function RCr(){let e=(0,AUe.useRef)(new Map),t=(0,AUe.useRef)(new Map);return{buffers:e,handlers:t}}var T1e=R(he(),1);function ACr(){let[e,t]=(0,T1e.useState)(null),[r,n]=(0,T1e.useState)(null),[i,o]=(0,T1e.useState)(null);return{transcript:e,setTranscript:t,viewingTranscriptSessionId:r,setViewingTranscriptSessionId:n,userMessages:i,setUserMessages:o}}var k_=R(he(),1);function PCr(e,t){let r=e.sessionId;t.buffers.current?.delete(r),t.handlers.current?.get(r)?.("\x1Bc")}function LCr(e,t){let r=e.sessionId,n=t.resolvePendingLaunch();e.isNew&&t.getActiveId()!==null||(t.setViewingTranscriptSessionId(null),t.setActiveId(r)),e.isNew&&t.setSuccess({message:n?`Started ${n}`:"New session started",sessionId:r})}function MCr(e,t){let r=e.message;t.setError(r),t.failPendingLaunch(r)}function ICr(e,t){let r=e.rateLimits,n=e.harness;!n||n==="claude"?t.setRateLimits(r):t.setHarnessRateLimits?.(n,r)}function DCr(e,t){t.setNodes({local:e.local,links:e.links??[]})}function NCr(e,t){t.setSuccess({message:e.message,sessionId:null})}function OCr(e,t){let r=e.sessionId,n=t.buffers.current?.get(r)??"";t.buffers.current?.set(r,n+e.data),t.handlers.current?.get(r)?.(e.data),t.markInitialized(r)}function BCr(e,t){t.setServerConflict({existing:e.existing,runName:e.runName,cwd:e.cwd,sessionId:e.sessionId,launchedFrom:e.launchedFrom,node:e.node})}function FCr(e,t){let r=e.sessions;t.setSessions(r),e.cwd&&t.setCurrentCwd(e.cwd),t.setActiveByRepo(e.active??{})}function $Cr(e,t){let r=e.sessionId,n=e.data;t.buffers.current?.set(r,n),t.handlers.current?.get(r)?.(`\x1Bc${n}`)}var AZn={sessions:FCr,created:LCr,history:(e,t)=>t.setHistory(e.sessions),transcript:(e,t)=>t.setTranscript({sessionId:e.sessionId,messages:e.messages}),"user-messages":(e,t)=>t.setUserMessages({sessionId:e.sessionId,messages:e.messages}),hello:(e,t)=>t.setDaemonVersion(e.version),nodes:DCr,error:MCr,notice:NCr,"run-conflict":BCr,limits:ICr,clear:PCr,output:OCr,snapshot:$Cr};function zCr(e,t){AZn[e.type]?.(e,t)}function HCr(e,t={}){let r=location.protocol==="https:"?"wss:":"ws:",n=new WebSocket(`${r}//${location.host}/ws`);return n.onopen=()=>{t.onOpen?.(),n.send(JSON.stringify({type:"hello"})),n.send(JSON.stringify({type:"history"}))},n.onmessage=i=>{zCr(JSON.parse(i.data),e)},n.onclose=()=>t.onClose?.(),n}function UCr(e,t,r,n){let i=!1,o,a=0,s=!1,l=()=>{i||t(HCr(e,{onOpen:()=>{s&&r(),s=!1,n(!1),a=0},onClose:()=>{if(i)return;s=!0,n(!0);let u=Math.min(300*2**a,2e3);a+=1,o=setTimeout(l,u)}}))};return l(),()=>{i=!0,o&&clearTimeout(o)}}function WCr(e){let t=(0,k_.useRef)(null),[r,n]=(0,k_.useState)(!1),{handleSessions:i,markInitialized:o,buffers:a,handlers:s}=e;(0,k_.useEffect)(()=>{let u=()=>{a.current?.clear();let d=s.current;if(d)for(let h of d.values())h("\x1Bc")},f=UCr({...e,setSessions:i},d=>{t.current=d},u,n);return()=>{f(),t.current?.close()}},[i,o,a,s]);let l=(0,k_.useCallback)(()=>{let u=t.current;u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"history"}))},[]);return{wsRef:t,requestHistory:l,reconnecting:r}}function VCr(){let[e,t]=(0,S1e.useState)([]),[r,n]=(0,S1e.useState)([]),{activeId:i,setActiveId:o,getActiveId:a}=lCr(),s=dCr(),l=ACr(),[u,f]=(0,S1e.useState)(""),d=yCr(),h=wCr(),p=kCr(),{initialized:m,markInitialized:g,syncSessions:y}=gCr(),v=RCr(),b=ECr(y,t),{wsRef:x,requestHistory:C,reconnecting:S}=WCr({handleSessions:b,setHistory:n,getActiveId:a,setActiveId:o,...s,...l,setCurrentCwd:f,...d,...h,...p,markInitialized:g,...v});return fCr(e,o,sCr(s.activeByRepo,e)),{sessions:e,history:r,activeId:i,setActiveId:o,...s,...l,currentCwd:u,...d,...h,...p,initialized:m,wsRef:x,...v,requestHistory:C,reconnecting:S}}function GCr(){let e=VCr(),{wsRef:t,buffers:r,handlers:n,addPendingLaunch:i,activeId:o,sessions:a}=e,s=NSr(e.nodes),l=FSr(t,i),u=oCr(l,r,n);MSr(o,a,e.history,l),ISr(a,l);let f=aCr(l,e.setActiveId,e.setViewingTranscriptSessionId);return{...e,...u,...f,nodeSelection:s}}var OF=R(he(),1);var qCr="assist:sidebar-collapsed";function jCr(){let[e,t]=(0,OF.useState)(()=>qu(qCr).length>0),r=(0,OF.useCallback)(()=>{t(n=>{let i=!n;return ju(qCr,i?[!0]:[]),i})},[]);return(0,OF.useMemo)(()=>({collapsed:e,onToggleCollapsed:r}),[e,r])}var YCr=R(he(),1);function KCr(){(0,YCr.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/hotkeys");if(!t.ok)return;let r=await t.json();e||q5.set(r)}catch{}})(),()=>{e=!0}},[])}var C1e=R(he(),1);function XCr(){let[e,t]=(0,C1e.useState)(!0);return(0,C1e.useEffect)(()=>{let r=!1;return(async()=>{try{let i=await(await fetch("/api/session-layout")).json();r||t(!!i?.topBar)}catch{t(!0)}})(),()=>{r=!0}},[]),e}function ZCr(){let e=GCr(),t=wme(e),r=_Sr(e.currentCwd,e.history,t,e.sessions,e.nodeSelection);pSr({selectedCwd:r.selectedCwd,selectedCardId:t,sessions:e.sessions,history:e.history,activeByRepo:e.activeByRepo,onSelect:e.selectSession});let{launch:n,viewLaunchedSession:i}=PSr(e),o=XCr();KCr();let a=jCr();return dSr("shell",{...e,selection:r,launch:n,topBar:o,sidebarCollapse:a}),{socket:e,selection:r,launch:n,viewLaunchedSession:i,topBar:o,sidebarCollapse:a}}var z0=R(z(),1),PZn={zIndex:e=>e.zIndex.drawer+1},LZn={minHeight:48};function QCr({mode:e,toggle:t}){let r=ZCr(),{socket:n,selection:i,viewLaunchedSession:o}=r;return(0,z0.jsx)(s2r,{shell:r,children:(0,z0.jsxs)(fUe.Provider,{value:n.daemonVersion,children:[(0,z0.jsx)(aSr,{mode:e,toggle:t,sessions:n.sessions,reconnecting:n.reconnecting}),(0,z0.jsx)(Yve,{position:"fixed",elevation:1,sx:PZn,children:(0,z0.jsx)(aTr,{socket:n,selection:i})}),(0,z0.jsx)(y5,{variant:"dense",sx:LZn}),(0,z0.jsx)(uSr,{socket:n,children:(0,z0.jsx)(Ybr,{socket:n})}),(0,z0.jsx)(o2r,{socket:n,onViewLaunchedSession:o})]})})}var JCr=R(he(),1);function ewr(){let[e,t]=(0,JCr.useState)(()=>{try{return localStorage.getItem("theme-mode")??"dark"}catch{return"dark"}});return{mode:e,toggle:()=>t(n=>{let i=n==="dark"?"light":"dark";try{localStorage.setItem("theme-mode",i)}catch{}return i})}}var __=R(z(),1),MZn={MuiButtonBase:{styleOverrides:{root:{cursor:"pointer","&.Mui-disabled":{cursor:"default"}}}},MuiLink:{styleOverrides:{root:{cursor:"pointer"}}}};function IZn(){let{mode:e,toggle:t}=ewr(),r=(0,rwr.useMemo)(()=>j0({palette:{mode:e,...e==="dark"&&{background:{default:"#1e1e1e",paper:"#252526"}}},components:MZn}),[e]);return(0,__.jsxs)(nZ,{theme:r,children:[(0,__.jsx)(VZ,{}),(0,__.jsx)(QCr,{mode:e,toggle:t})]})}var DZn=vSe([{path:"*",element:(0,__.jsx)(IZn,{})}]);function NZn(){return(0,__.jsx)(uSe,{router:DZn})}var twr=document.getElementById("app");twr&&(0,nwr.createRoot)(twr).render((0,__.jsx)(NZn,{}));})();
|
|
4015
4015
|
/*! Bundled license information:
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.836.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -18267,7 +18267,7 @@ function createCssHandler(packageEntry) {
|
|
|
18267
18267
|
var htmlHandler = createHtmlHandler(getHtml);
|
|
18268
18268
|
var faviconHandler = (size) => createBundleHandler(
|
|
18269
18269
|
import.meta.url,
|
|
18270
|
-
`commands/
|
|
18270
|
+
`commands/extension/extension/icons/assist-${size}.png`,
|
|
18271
18271
|
"image/png"
|
|
18272
18272
|
);
|
|
18273
18273
|
var routes2 = {
|
|
@@ -22454,29 +22454,24 @@ function registerConfig(program2) {
|
|
|
22454
22454
|
).action((filter) => configKeys(filter));
|
|
22455
22455
|
}
|
|
22456
22456
|
|
|
22457
|
-
// src/commands/
|
|
22457
|
+
// src/commands/extension/extension.ts
|
|
22458
22458
|
import { cp } from "fs/promises";
|
|
22459
22459
|
import chalk141 from "chalk";
|
|
22460
22460
|
|
|
22461
|
-
// src/commands/
|
|
22461
|
+
// src/commands/extension/extensionDir.ts
|
|
22462
22462
|
import { existsSync as existsSync47 } from "fs";
|
|
22463
22463
|
import { dirname as dirname27, join as join53 } from "path";
|
|
22464
22464
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
22465
22465
|
var moduleDir = dirname27(fileURLToPath6(import.meta.url));
|
|
22466
|
-
function
|
|
22467
|
-
const bundled = join53(
|
|
22468
|
-
moduleDir,
|
|
22469
|
-
"commands",
|
|
22470
|
-
"criteriaExtension",
|
|
22471
|
-
"criteria-extension"
|
|
22472
|
-
);
|
|
22466
|
+
function extensionDir() {
|
|
22467
|
+
const bundled = join53(moduleDir, "commands", "extension", "extension");
|
|
22473
22468
|
if (existsSync47(bundled)) return bundled;
|
|
22474
|
-
return join53(moduleDir, "..", "..", "..", "
|
|
22469
|
+
return join53(moduleDir, "..", "..", "..", "extension");
|
|
22475
22470
|
}
|
|
22476
22471
|
|
|
22477
|
-
// src/commands/
|
|
22478
|
-
var WSL_WINDOWS_DIR = "/mnt/c/tools/
|
|
22479
|
-
var WSL_WINDOWS_PATH = String.raw`C:\tools\
|
|
22472
|
+
// src/commands/extension/extension.ts
|
|
22473
|
+
var WSL_WINDOWS_DIR = "/mnt/c/tools/extension";
|
|
22474
|
+
var WSL_WINDOWS_PATH = String.raw`C:\tools\extension`;
|
|
22480
22475
|
async function loadPath(source) {
|
|
22481
22476
|
if (detectPlatform() !== "wsl") return source;
|
|
22482
22477
|
try {
|
|
@@ -22489,34 +22484,32 @@ async function loadPath(source) {
|
|
|
22489
22484
|
return source;
|
|
22490
22485
|
}
|
|
22491
22486
|
}
|
|
22492
|
-
async function
|
|
22493
|
-
const path109 = await loadPath(
|
|
22494
|
-
console.log(
|
|
22495
|
-
chalk141.bold("acceptance criteria outliner \u2014 GitHub browser extension")
|
|
22496
|
-
);
|
|
22487
|
+
async function extension() {
|
|
22488
|
+
const path109 = await loadPath(extensionDir());
|
|
22489
|
+
console.log(chalk141.bold("assist \u2014 GitHub browser extension"));
|
|
22497
22490
|
console.log(chalk141.dim(`load the unpacked extension from ${path109}`));
|
|
22498
22491
|
}
|
|
22499
22492
|
|
|
22500
|
-
// src/commands/
|
|
22493
|
+
// src/commands/extension/printExtensionUrl.ts
|
|
22501
22494
|
import { readFile as readFile4 } from "fs/promises";
|
|
22502
22495
|
import { join as join54 } from "path";
|
|
22503
22496
|
import chalk142 from "chalk";
|
|
22504
22497
|
|
|
22505
|
-
// src/commands/
|
|
22498
|
+
// src/commands/extension/latestUpdate.ts
|
|
22506
22499
|
function latestUpdate(manifest, updates2) {
|
|
22507
22500
|
const { id } = JSON.parse(manifest).browser_specific_settings.gecko;
|
|
22508
22501
|
return JSON.parse(updates2).addons[id]?.updates.at(-1);
|
|
22509
22502
|
}
|
|
22510
22503
|
|
|
22511
|
-
// src/commands/
|
|
22504
|
+
// src/commands/extension/latestUpdateLink.ts
|
|
22512
22505
|
function latestUpdateLink(manifest, updates2) {
|
|
22513
22506
|
return latestUpdate(manifest, updates2)?.update_link;
|
|
22514
22507
|
}
|
|
22515
22508
|
|
|
22516
|
-
// src/commands/
|
|
22517
|
-
async function
|
|
22509
|
+
// src/commands/extension/printExtensionUrl.ts
|
|
22510
|
+
async function printExtensionUrl() {
|
|
22518
22511
|
const manifest = await readFile4(
|
|
22519
|
-
join54(
|
|
22512
|
+
join54(extensionDir(), "manifest.json"),
|
|
22520
22513
|
"utf8"
|
|
22521
22514
|
);
|
|
22522
22515
|
const { update_url } = JSON.parse(manifest).browser_specific_settings.gecko;
|
|
@@ -22530,16 +22523,16 @@ async function printCriteriaExtensionUrl() {
|
|
|
22530
22523
|
console.log(link3);
|
|
22531
22524
|
}
|
|
22532
22525
|
|
|
22533
|
-
// src/commands/
|
|
22526
|
+
// src/commands/extension/signExtension.ts
|
|
22534
22527
|
import { rm as rm2 } from "fs/promises";
|
|
22535
22528
|
import { homedir as homedir21, tmpdir as tmpdir3 } from "os";
|
|
22536
22529
|
import { join as join60 } from "path";
|
|
22537
22530
|
import chalk144 from "chalk";
|
|
22538
22531
|
|
|
22539
|
-
// src/commands/
|
|
22532
|
+
// src/commands/extension/copySignedXpi.ts
|
|
22540
22533
|
import { copyFile } from "fs/promises";
|
|
22541
22534
|
import { join as join55 } from "path";
|
|
22542
|
-
var SIGNED_XPI_NAME = "
|
|
22535
|
+
var SIGNED_XPI_NAME = "assist-extension.xpi";
|
|
22543
22536
|
async function copySignedXpi(xpi, dir) {
|
|
22544
22537
|
const fixed2 = join55(dir, SIGNED_XPI_NAME);
|
|
22545
22538
|
if (fixed2 === xpi) return fixed2;
|
|
@@ -22547,7 +22540,7 @@ async function copySignedXpi(xpi, dir) {
|
|
|
22547
22540
|
return fixed2;
|
|
22548
22541
|
}
|
|
22549
22542
|
|
|
22550
|
-
// src/commands/
|
|
22543
|
+
// src/commands/extension/findSignedXpi.ts
|
|
22551
22544
|
import { existsSync as existsSync48 } from "fs";
|
|
22552
22545
|
import { readdir } from "fs/promises";
|
|
22553
22546
|
import { join as join56 } from "path";
|
|
@@ -22557,11 +22550,11 @@ async function findSignedXpi(dir) {
|
|
|
22557
22550
|
return name ? join56(dir, name) : null;
|
|
22558
22551
|
}
|
|
22559
22552
|
|
|
22560
|
-
// src/commands/
|
|
22553
|
+
// src/commands/extension/signedAddonInstallPath.ts
|
|
22561
22554
|
import { cp as cp2 } from "fs/promises";
|
|
22562
22555
|
import chalk143 from "chalk";
|
|
22563
|
-
var WSL_WINDOWS_XPI = "/mnt/c/tools/
|
|
22564
|
-
var WSL_WINDOWS_PATH2 = String.raw`C:\tools\
|
|
22556
|
+
var WSL_WINDOWS_XPI = "/mnt/c/tools/assist-extension.xpi";
|
|
22557
|
+
var WSL_WINDOWS_PATH2 = String.raw`C:\tools\assist-extension.xpi`;
|
|
22565
22558
|
async function signedAddonInstallPath(xpi) {
|
|
22566
22559
|
if (detectPlatform() !== "wsl") return xpi;
|
|
22567
22560
|
try {
|
|
@@ -22575,7 +22568,7 @@ async function signedAddonInstallPath(xpi) {
|
|
|
22575
22568
|
}
|
|
22576
22569
|
}
|
|
22577
22570
|
|
|
22578
|
-
// src/commands/
|
|
22571
|
+
// src/commands/extension/signPreflightProblem.ts
|
|
22579
22572
|
import { existsSync as existsSync49 } from "fs";
|
|
22580
22573
|
import { join as join57 } from "path";
|
|
22581
22574
|
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
@@ -22593,19 +22586,19 @@ function signPreflightProblem(source) {
|
|
|
22593
22586
|
return null;
|
|
22594
22587
|
}
|
|
22595
22588
|
|
|
22596
|
-
// src/commands/
|
|
22589
|
+
// src/commands/extension/stageExtension.ts
|
|
22597
22590
|
import { cp as cp3, mkdir as mkdir5, readFile as readFile5, rm, writeFile as writeFile4 } from "fs/promises";
|
|
22598
22591
|
import { basename as basename15, join as join58 } from "path";
|
|
22599
22592
|
|
|
22600
|
-
// src/commands/
|
|
22593
|
+
// src/commands/extension/stampManifestVersion.ts
|
|
22601
22594
|
function stampManifestVersion(manifest, version2) {
|
|
22602
22595
|
const parsed = JSON.parse(manifest);
|
|
22603
22596
|
return `${JSON.stringify({ ...parsed, version: version2 }, null, " ")}
|
|
22604
22597
|
`;
|
|
22605
22598
|
}
|
|
22606
22599
|
|
|
22607
|
-
// src/commands/
|
|
22608
|
-
async function
|
|
22600
|
+
// src/commands/extension/stageExtension.ts
|
|
22601
|
+
async function stageExtension(source, staging, version2) {
|
|
22609
22602
|
await rm(staging, { recursive: true, force: true });
|
|
22610
22603
|
await mkdir5(staging, { recursive: true });
|
|
22611
22604
|
await cp3(source, staging, {
|
|
@@ -22620,11 +22613,11 @@ async function stageCriteriaExtension(source, staging, version2) {
|
|
|
22620
22613
|
await writeFile4(manifest, stamped);
|
|
22621
22614
|
}
|
|
22622
22615
|
|
|
22623
|
-
// src/commands/
|
|
22616
|
+
// src/commands/extension/writeUpdateManifest.ts
|
|
22624
22617
|
import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
22625
22618
|
import { join as join59 } from "path";
|
|
22626
22619
|
|
|
22627
|
-
// src/commands/
|
|
22620
|
+
// src/commands/extension/buildUpdateManifest.ts
|
|
22628
22621
|
var RELEASE_DOWNLOAD_URL = "https://github.com/staff0rd/assist/releases/download";
|
|
22629
22622
|
function buildUpdateManifest(manifest, version2) {
|
|
22630
22623
|
const { id } = JSON.parse(manifest).browser_specific_settings.gecko;
|
|
@@ -22634,7 +22627,7 @@ function buildUpdateManifest(manifest, version2) {
|
|
|
22634
22627
|
updates: [
|
|
22635
22628
|
{
|
|
22636
22629
|
version: version2,
|
|
22637
|
-
update_link: `${RELEASE_DOWNLOAD_URL}/v${version2}/
|
|
22630
|
+
update_link: `${RELEASE_DOWNLOAD_URL}/v${version2}/assist-extension.xpi`
|
|
22638
22631
|
}
|
|
22639
22632
|
]
|
|
22640
22633
|
}
|
|
@@ -22644,7 +22637,7 @@ function buildUpdateManifest(manifest, version2) {
|
|
|
22644
22637
|
`;
|
|
22645
22638
|
}
|
|
22646
22639
|
|
|
22647
|
-
// src/commands/
|
|
22640
|
+
// src/commands/extension/writeUpdateManifest.ts
|
|
22648
22641
|
async function writeUpdateManifest(source, dir, version2) {
|
|
22649
22642
|
await writeFile5(
|
|
22650
22643
|
join59(dir, "updates.json"),
|
|
@@ -22655,11 +22648,11 @@ async function writeUpdateManifest(source, dir, version2) {
|
|
|
22655
22648
|
);
|
|
22656
22649
|
}
|
|
22657
22650
|
|
|
22658
|
-
// src/commands/
|
|
22659
|
-
var ARTIFACTS_DIR = join60(homedir21(), ".assist", "
|
|
22660
|
-
var STAGING_DIR = join60(tmpdir3(), "assist-
|
|
22661
|
-
async function
|
|
22662
|
-
const source =
|
|
22651
|
+
// src/commands/extension/signExtension.ts
|
|
22652
|
+
var ARTIFACTS_DIR = join60(homedir21(), ".assist", "extension");
|
|
22653
|
+
var STAGING_DIR = join60(tmpdir3(), "assist-extension");
|
|
22654
|
+
async function signExtension() {
|
|
22655
|
+
const source = extensionDir();
|
|
22663
22656
|
const problem = signPreflightProblem(source);
|
|
22664
22657
|
if (problem) {
|
|
22665
22658
|
console.log(chalk144.red(problem.message));
|
|
@@ -22668,7 +22661,7 @@ async function signCriteriaExtension() {
|
|
|
22668
22661
|
return;
|
|
22669
22662
|
}
|
|
22670
22663
|
const { version: version2 } = package_default;
|
|
22671
|
-
await
|
|
22664
|
+
await stageExtension(source, STAGING_DIR, version2);
|
|
22672
22665
|
await rm2(ARTIFACTS_DIR, { recursive: true, force: true });
|
|
22673
22666
|
console.log(chalk144.bold(`signing version ${version2} for self-distribution`));
|
|
22674
22667
|
const { done: done2 } = spawnInherit("npx", [
|
|
@@ -22697,9 +22690,9 @@ async function signCriteriaExtension() {
|
|
|
22697
22690
|
console.log(chalk144.dim(`install the signed add-on from ${path109}`));
|
|
22698
22691
|
}
|
|
22699
22692
|
|
|
22700
|
-
// src/commands/
|
|
22701
|
-
function
|
|
22702
|
-
program2.command("
|
|
22693
|
+
// src/commands/registerExtension.ts
|
|
22694
|
+
function registerExtension(program2) {
|
|
22695
|
+
program2.command("extension").description(
|
|
22703
22696
|
"Print the directory to load the acceptance criteria outliner browser extension from (load unpacked)"
|
|
22704
22697
|
).option(
|
|
22705
22698
|
"--sign",
|
|
@@ -22708,8 +22701,8 @@ function registerCriteriaExtension(program2) {
|
|
|
22708
22701
|
"--url",
|
|
22709
22702
|
"Print the download URL of the latest signed Firefox build, read from the update manifest on main"
|
|
22710
22703
|
).action((options2) => {
|
|
22711
|
-
if (options2.url) return
|
|
22712
|
-
return options2.sign ?
|
|
22704
|
+
if (options2.url) return printExtensionUrl();
|
|
22705
|
+
return options2.sign ? signExtension() : extension();
|
|
22713
22706
|
});
|
|
22714
22707
|
}
|
|
22715
22708
|
|
|
@@ -35253,14 +35246,14 @@ function countByDirectory(files) {
|
|
|
35253
35246
|
for (const file of files) {
|
|
35254
35247
|
const directory = dirname37(file) === "." ? "(repo root)" : dirname37(file);
|
|
35255
35248
|
const extensions = directories.get(directory) ?? /* @__PURE__ */ new Map();
|
|
35256
|
-
const
|
|
35257
|
-
extensions.set(
|
|
35249
|
+
const extension2 = extname6(file) === "" ? "(no extension)" : extname6(file);
|
|
35250
|
+
extensions.set(extension2, (extensions.get(extension2) ?? 0) + 1);
|
|
35258
35251
|
directories.set(directory, extensions);
|
|
35259
35252
|
}
|
|
35260
35253
|
return directories;
|
|
35261
35254
|
}
|
|
35262
35255
|
function formatExtensions(extensions) {
|
|
35263
|
-
return extensions.slice(0, MAX_EXTENSIONS_PER_DIRECTORY).map(([
|
|
35256
|
+
return extensions.slice(0, MAX_EXTENSIONS_PER_DIRECTORY).map(([extension2, count8]) => `${extension2}(${count8})`).join(", ");
|
|
35264
35257
|
}
|
|
35265
35258
|
|
|
35266
35259
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
@@ -50530,7 +50523,7 @@ registerComplexity(program);
|
|
|
50530
50523
|
registerDotnet(program);
|
|
50531
50524
|
registerNews(program);
|
|
50532
50525
|
registerNetcap(program);
|
|
50533
|
-
|
|
50526
|
+
registerExtension(program);
|
|
50534
50527
|
registerLitellm(program);
|
|
50535
50528
|
registerRavendb(program);
|
|
50536
50529
|
registerSeq(program);
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(()=>{function o(s){let{type:t,url:n}=s??{};return t==="assist-send"&&typeof n=="string"}function r(){return globalThis.browser?.runtime}async function a(s,{url:t,instructions:n}){let e;try{e=await fetch(`${s}/api/sessions/from-github`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t,instructions:n})})}catch{return{ok:!1,message:`assist web server unreachable at ${s}`}}let i=await e.json().catch(()=>({}));return e.ok?{ok:!0,message:`assist session started in ${i.cwd}`}:{ok:!1,message:i.error??`assist web server returned ${e.status}`}}var u="http://localhost:3100";function d(){r()?.onMessage.addListener(s=>{if(o(s))return a(u,s)})}d();})();
|
/package/dist/commands/{criteriaExtension/criteria-extension → extension/extension}/content.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|