@staff0rd/assist 0.1021.2 → 0.1022.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.
@@ -4058,7 +4058,7 @@ ${d.join(`
4058
4058
  `,i3o=Bi`
4059
4059
  0%, 100% { transform: scale(1); }
4060
4060
  50% { transform: scale(1.08); }
4061
- `,j9r={content:'""',position:"absolute",borderRadius:"inherit",background:"conic-gradient(from calc(var(--rainbow-pill-h) * 1deg) in oklch longer hue, oklch(66% 0.21 0), oklch(66% 0.21 0))",animation:`${o3o} 1.8s linear infinite`},a3o={display:"inline-flex",alignItems:"center",px:1.5,py:"3px",borderRadius:999,position:"relative",isolation:"isolate",fontWeight:700,animation:`${i3o} 1.6s ease-in-out infinite`,"&::before":{...j9r,inset:0,zIndex:-1},"&::after":{...j9r,inset:"-5px",zIndex:-2,filter:"blur(9px)",opacity:.85},"& span":{color:zl.rainbowPill.text,textShadow:zl.rainbowPill.shadow},"@media (prefers-reduced-motion: reduce)":{animation:"none","&::before, &::after":{animation:"none"}}};function Y9r({children:e}){return(0,MI.jsxs)(MI.Fragment,{children:[(0,MI.jsx)(_3,{styles:n3o}),(0,MI.jsx)(G,{component:"span","data-testid":"rainbow-pill",sx:a3o,children:e})]})}function K9r({pct:e,timeLabel:t}){return[Math.round(e),...(t.match(/\d+/g)??[]).map(Number)].join(",")}function X9r(e){if(e.length!==2)return!1;let[t,r]=e;return K9r(t)===K9r(r)}var Rw=k(P(),1);function Q9r({rateLimits:e}){let t=x0(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(i=>i.window?.used_percentage!=null),n=X9r(r.map(i=>({pct:i.window?.used_percentage??0,timeLabel:b_e(i.window?.resets_at,i.fallbackLabel,t)}))),o=r.map((i,a)=>(0,Rw.jsxs)(Z9r.Fragment,{children:[a>0?(0,Rw.jsx)(G,{component:"span",sx:{color:mG,mr:.5},children:","}):null,(0,Rw.jsx)(q9r,{window:i.window,windowSeconds:i.windowSeconds,fallbackLabel:i.fallbackLabel,now:t})]},i.fallbackLabel));return n?(0,Rw.jsx)(Y9r,{children:o}):(0,Rw.jsx)(Rw.Fragment,{children:o})}var R5=k(P(),1);function e$r({groups:e}){return(0,R5.jsx)(R5.Fragment,{children:e.map((t,r)=>(0,R5.jsxs)(J9r.Fragment,{children:[(0,R5.jsx)(G,{component:"span",sx:{color:mG,ml:r>0?1:0,mr:.5},children:Dc(t.harness)}),(0,R5.jsx)(Q9r,{rateLimits:t.rateLimits})]},t.harness))})}var t$r={root:{fontFamily:"fontFamilyMono",fontSize:12,display:"grid",gap:1},group:{display:"grid",gap:"2px"},heading:{color:e=>e.tokens.color.onAppBar.secondary},foot:{pt:.75,opacity:.6,borderTop:"1px solid color-mix(in srgb, currentColor 18%, transparent)"}};function s3o(e){if(e==="over")return{level:"warn",boundary:100};if(e==="warn")return{level:"ok",boundary:75}}function l3o(e){if(e==="ok")return{level:"warn",boundary:75};if(e==="warn")return{level:"over",boundary:100}}function c3o(e,t,r,n){if(e>=t)return;let o=e/t;return Math.round(r-n*(1-o))}function o$r(e,t,r,n){if(t==null)return{kind:"unprojectable"};let o=lit(t,r,n);if(o==null)return{kind:"unprojectable"};let i=lx(e,t,r,n),a=s3o(i),s=l3o(i);return{kind:"projected",recovery:a&&{level:a.level,pct:a.boundary*o,at:c3o(e,a.boundary,t,r)},worse:s&&{level:s.level,pct:s.boundary*o}}}function S_e(e){return t=>t.tokens.color.onAppBar.level[e]}function i$r(e,t){return e.at==null?"not before reset":`${e.level==="ok"?"green":"under"} in ${VW(e.at,t)}`}var A5=k(P(),1),a$r={display:"contents"};function Ait({direction:e,threshold:t}){let r=e==="back";if(!t)return(0,A5.jsxs)(G,{component:"span",sx:a$r,children:[(0,A5.jsx)("span",{}),(0,A5.jsx)("span",{})]});let n=(0,A5.jsx)(G,{component:"span",sx:{opacity:.6},children:r?"\u2190":"\u2192"}),o=(0,A5.jsxs)(G,{component:"span",sx:{color:S_e(t.level),textAlign:"right"},children:[Math.round(t.pct),"%"]});return(0,A5.jsxs)(G,{component:"span",sx:a$r,children:[r?o:n,r?n:o]})}var s$r={row:{display:"grid",gridTemplateColumns:"2.5ch 4ch 1ch 4ch 1ch 4ch auto",alignItems:"baseline",gap:.75,fontVariantNumeric:"tabular-nums"},pctWeight:500,note:{pl:.75,color:e=>e.tokens.color.onAppBar.secondary}};var P5=k(P(),1);function l$r({label:e,pct:t,resetsAt:r,windowSeconds:n,now:o}){let i=s$r,a=lx(t,r,n,o),s=o$r(t,r,n,o),l=s.kind==="projected"?s:void 0;return(0,P5.jsxs)(G,{sx:i.row,children:[(0,P5.jsx)(G,{component:"span",sx:{minWidth:"2ch"},children:e}),(0,P5.jsx)(Ait,{direction:"back",threshold:l?.recovery}),(0,P5.jsxs)(G,{component:"span",sx:{minWidth:"4ch",textAlign:"right",fontWeight:i.pctWeight,color:S_e(a)},children:[Math.round(t),"%"]}),(0,P5.jsx)(Ait,{direction:"forward",threshold:l?.worse}),(0,P5.jsx)(G,{component:"span",sx:i.note,children:l?l.recovery&&i$r(l.recovery,o):"no projection yet"})]})}function T_e(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 u$r=k(P(),1);function c$r({rateLimits:e,now:t}){return T_e(e).map(r=>(0,u$r.jsx)(l$r,{label:r.label,pct:r.pct,resetsAt:r.resetsAt,windowSeconds:r.windowSeconds,now:t},r.label))}var DI=k(P(),1);function d$r({groups:e}){let t=x0(3e4),r=t$r;return(0,DI.jsxs)(G,{sx:r.root,children:[e.map(n=>(0,DI.jsxs)(G,{sx:r.group,children:[(0,DI.jsx)(G,{sx:r.heading,children:Dc(n.harness)}),(0,DI.jsx)(c$r,{rateLimits:n.rateLimits,now:t})]},n.harness)),(0,DI.jsx)(G,{sx:r.foot,children:"Account usage per harness \u2014 view history"})]})}var Pit=k(P(),1),u3o="Claude account usage (5h / 7d windows) \u2014 view history";function f$r(e){return e.length===0?{title:u3o,content:"Usage"}:{title:(0,Pit.jsx)(d$r,{groups:e}),content:(0,Pit.jsx)(e$r,{groups:e})}}var p$r={display:"flex",alignItems:"center",height:22,px:1,borderRadius:1,fontSize:"inherit","&:hover, &:focus-visible":{bgcolor:e=>e.tokens.color.statusBar.hover,color:e=>e.tokens.color.statusBar.hoverText}},h$r={tooltip:{sx:{p:"10px 12px",minWidth:300,maxWidth:"none"}}};var Lit=k(P(),1),d3o={};function m$r({rateLimits:e,harnessRateLimits:t=d3o}){let{title:r,content:n}=f$r(v_e(e,t));return(0,Lit.jsx)(ar,{title:r,placement:"top-start",slotProps:h$r,children:(0,Lit.jsx)(Kr,{component:ca,to:"/usage",underline:"none",color:"inherit",sx:p$r,children:n})})}var v$r=k(re(),1);var ah="0.1021.2";var w_e=k(re(),1),Iit=(0,w_e.createContext)(null);function C_e(){return(0,w_e.useContext)(Iit)}var Mit=k(P(),1);function g$r(){let e=C_e();return!e||e===ah?null:(0,Mit.jsx)(ar,{title:`Daemon is running v${e}, but this page was served by v${ah}. Restart the daemon to match.`,children:(0,Mit.jsx)(a_e,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})}var y$r=e=>({display:"inline-flex",alignItems:"center",gap:.75,px:1,py:0,height:22,borderRadius:1,fontSize:"inherit",lineHeight:1.5,color:"inherit",opacity:1,bgcolor:t=>e?Sx(t).active:"transparent",transition:"opacity .2s ease, background-color .2s ease, color .2s ease","&:hover, &:focus-visible":{bgcolor:t=>Sx(t).hover,color:t=>Sx(t).hoverText},"& .ready-dot":{width:6,height:6,borderRadius:"50%",bgcolor:t=>Sx(t).dot,boxShadow:t=>`0 0 0 3px ${Sx(t).dotRing}`},"& .ready-count":{fontWeight:500,color:t=>Sx(t).readyText}});var C0=k(P(),1);function b$r(){let{entries:e}=s5(),t=nn(),r=(0,v$r.useCallback)(()=>t("/updates"),[t]),{matches:n,chords:o}=fo("openUpdates");if(Ki(n,r),!ah)return null;let i=e.filter(u5).length;return(0,C0.jsxs)(C0.Fragment,{children:[(0,C0.jsx)(ar,{describeChild:!0,placement:"top-end",title:(0,C0.jsx)(Td,{label:"Updates",chords:o}),children:(0,C0.jsxs)(ur,{component:ca,to:"/updates","aria-label":i?`Updates: ${i} node${i>1?"s have":" has"} an update ready`:"Updates",sx:y$r(i>0),children:[i>0&&(0,C0.jsx)("span",{className:"ready-dot","aria-hidden":!0}),(0,C0.jsxs)("span",{children:["v",ah]}),i>0&&(0,C0.jsxs)("span",{className:"ready-count",children:[i," ready"]})]})}),(0,C0.jsx)(g$r,{})]})}var Aw=k(P(),1);function x$r({socket:e}){return(0,Aw.jsx)(I9r,{start:(0,Aw.jsx)(m$r,{rateLimits:e.rateLimits,harnessRateLimits:e.harnessRateLimits}),end:(0,Aw.jsxs)(Aw.Fragment,{children:[(0,Aw.jsx)(W9r,{}),(0,Aw.jsx)(b$r,{})]})})}var S$r=k(re(),1);var Pw=k(P(),1),f3o=2e4;function T$r(){let{entries:e,refresh:t}=s5(),[r,n]=(0,S$r.useState)(),o=e.find(l=>l.local)?.status?.extension,i=o?.behind&&o.updateLink&&o.latest?o:void 0,a=i!==void 0&&r!==i.latest,s=()=>n(i?.latest);return(0,Pw.jsx)(Lu,{open:a,children:(0,Pw.jsxs)(ro,{severity:"info",variant:"filled",action:(0,Pw.jsxs)(Pw.Fragment,{children:[(0,Pw.jsx)(vt,{color:"inherit",size:"small",href:i?.updateLink,onClick:()=>setTimeout(t,f3o),children:"Install"}),(0,Pw.jsx)(vt,{color:"inherit",size:"small",onClick:s,children:"Dismiss"})]}),children:["assist extension v",i?.connected," \u2192 v",i?.latest]})})}var A_e=k(re(),1);var R_e=k(re(),1);function w$r(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 L5=k(P(),1),p3o={display:"flex",gap:1,alignItems:"center",minWidth:0},h3o={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},m3o={fontFamily:"fontFamilyMono",fontSize:13,whiteSpace:"nowrap"},g3o={fontFamily:"fontFamilyMono",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function y3o(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function C$r({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,L5.jsx)(Ym,{dense:!0,sx:{py:0},children:e.map((o,i)=>{let{dir:a,basename:s}=y3o(o);return(0,L5.jsxs)(Qr,{selected:i===t,onMouseEnter:()=>r(i),onClick:()=>n(o),sx:p3o,children:[(0,L5.jsx)(t2e,{path:o}),(0,L5.jsxs)(G,{sx:h3o,children:[(0,L5.jsx)(_e,{component:"span",sx:m3o,children:s}),(0,L5.jsx)(_e,{component:"span",color:"text.secondary",sx:g3o,children:a})]})]},o)})})}var k_e=k(P(),1),v3o={maxHeight:420,overflowY:"auto"},b3o={px:2,py:2,fontSize:13};function k$r({message:e,files:t,highlight:r,onHighlight:n,onSelect:o}){return(0,k_e.jsx)(G,{sx:v3o,children:e?(0,k_e.jsx)(_e,{color:"text.secondary",sx:b3o,children:e}):(0,k_e.jsx)(C$r,{files:t,highlight:r,onHighlight:n,onSelect:o})})}var _$r=k(P(),1),x3o={mt:6,alignSelf:"flex-start"};function __e({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,_$r.jsx)(Ac,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:x3o},transition:{onEntered:t}},children:n})}var E_e=k(re(),1);var E$r={files:[],loading:!1,error:!1};function R$r(e,t){let[r,n]=(0,E_e.useState)(E$r),o=br();return(0,E_e.useEffect)(()=>{if(!e){n(E$r);return}let i=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await tr(Jr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,o));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(i)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch(s){Pr(s,"file search"),i||n({files:[],loading:!1,error:!0})}})(),()=>{i=!0}},[e,t,o]),r}var NI=k(P(),1);function S3o(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function A$r({onClose:e}){let{worktreeNode:t}=eo();return(0,NI.jsx)(ec.Provider,{value:t,children:(0,NI.jsx)(T3o,{onClose:e})})}function T3o({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=eo(),[n,o]=(0,R_e.useState)(""),i=R$r(t,n),a=nn(),s=(0,R_e.useRef)(null),l=h=>a(S3o(h,t,r)),{highlight:u,setHighlight:d,onKeyDown:f}=b5(i.files,n,l,e),p=h=>{l(h),e()};return(0,NI.jsxs)(__e,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,NI.jsx)(rk,{autoFocus:!0,inputRef:s,value:n,onChange:o,onKeyDown:f,placeholder:"Search files by name..."}),(0,NI.jsx)(k$r,{message:w$r(t,n,i),files:i.files,highlight:u,onHighlight:d,onSelect:p})]})}function P$r(e){Ki(fo("quickOpen").matches,e)}var I$r=k(P(),1);function L$r(){let[e,t]=(0,A_e.useState)(!1);return P$r((0,A_e.useCallback)(()=>t(!0),[])),e?(0,I$r.jsx)(A$r,{onClose:()=>t(!1)}):null}var P_e=k(P(),1);function M$r({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,P_e.jsx)(Lu,{open:e!==null,autoHideDuration:6e3,onClose:t,children:(0,P_e.jsx)(ro,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,P_e.jsx)(vt,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var ene=k(re(),1);function gG(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var q$r=k(re(),1);var D$r=k(P(),1),N$r=nt((0,D$r.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 w3o={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function O$r(e){return e?w3o[e]:"success.main"}function B$r(e){return e.split("-")[0].split(".").map(Number)}function $$r(e,t){if(!e||!t||e===t)return;let r=B$r(e),n=B$r(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var OI=k(P(),1),C3o={height:16,fontSize:10},k3o={opacity:.6,fontSize:"0.85em"};function _3o(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 Qre({nodes:e,name:t,showVersion:r=!1}){let n=C_e()??ah,o=e.links.find(a=>a.name===t),i=$$r(o?.peerVersion,n);return(0,OI.jsx)(ar,{title:_3o(e,t),placement:"right",children:(0,OI.jsxs)(G,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,OI.jsx)(N$r,{sx:{fontSize:8,color:O$r(o?.state)}}),t,r&&o?.peerVersion&&(0,OI.jsxs)(G,{component:"span",sx:k3o,children:["v",o.peerVersion]}),i&&(0,OI.jsx)(Zn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:C3o})]})})}var BI=k(P(),1),E3o={opacity:.6},R3o={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function F$r({nodes:e,name:t,clone:r}){let n=(0,BI.jsx)(Qre,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,BI.jsx)(G,{component:"span",sx:E3o,children:n}):(0,BI.jsx)(ar,{title:QW(t,r.cloneTarget),children:(0,BI.jsxs)(G,{component:"span",sx:R3o,children:[(0,BI.jsx)(ZW,{sx:{fontSize:14}}),n]})})}var U$r=k(P(),1),A3o={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 z$r({value:e,label:t,checked:r,autoFocus:n,onSelect:o}){return(0,U$r.jsx)(ur,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:o,sx:A3o,children:t})}var H$r={ArrowRight:1,ArrowLeft:-1};function P3o(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+H$r[e.key]+r)%r}function W$r(e,t,r,n){return o=>{if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!n)return;o.preventDefault(),n();return}if(o.key!=="Tab"&&!H$r[o.key]){FT(o);return}let i=P3o(o,e.indexOf(t),e.length);i!==void 0&&(o.preventDefault(),r(e[i]),o.currentTarget.querySelector(`[data-value="${e[i]}"]`)?.focus())}}var G$r=k(re(),1);function yG(e){return e?.querySelector('[aria-checked="true"]')}function V$r(e,t){(0,G$r.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=yG(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var Dit=k(P(),1),L3o={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function L_e({label:e,options:t,value:r,onChange:n,optionLabel:o=u=>u,groupRef:i,autoFocus:a,onTrack:s,onToggleRow:l}){return V$r(i,r),(0,Dit.jsx)(_t,{ref:i,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:W$r(t,r,n,l),sx:L3o,children:t.map(u=>(0,Dit.jsx)(z$r,{value:u,label:o(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var Nit=k(P(),1);function j$r({value:e,onChange:t,cloneState:r}){let{nodes:n,names:o,visible:i}=Sl(),a=(0,q$r.useRef)(null);return!i||!n||!e?null:(0,Nit.jsx)(L_e,{label:"Machine",options:o,value:e,onChange:t,optionLabel:s=>(0,Nit.jsx)(F$r,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var I_e=k(P(),1);function Y$r({prompt:e,children:t}){return(0,I_e.jsxs)(_t,{children:[e,(0,I_e.jsx)(_t,{spacing:1,sx:{px:1.5,pb:1.5},children:t})]})}var X$r=k(P(),1),I3o=".MuiOutlinedInput-notchedOutline",M3o={"& .MuiOutlinedInput-root":{px:"18px",py:2,minHeight:92,alignItems:"flex-start",bgcolor:"transparent",borderRadius:0,fontSize:15},[`&&& ${I3o}`]:{border:0},"& textarea::placeholder":{color:"text.disabled",opacity:1}};function K$r({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:o,onTrack:i}){return(0,X$r.jsx)(Gn,{sx:M3o,value:e,onChange:a=>t(a.target.value),onKeyDown:FT,onFocus:i,onSelect:i,inputRef:n,placeholder:r,autoFocus:o,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"}}})}var eFr=k(re(),1);var av={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:rSe,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},Z$r=Object.keys(av);var Oit=k(P(),1);function Q$r({anchor:e,harness:t,harnesses:r,onPick:n,onClose:o}){return(0,Oit.jsx)(ks,{open:e!==null,anchorEl:e,onClose:o,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(i=>(0,Oit.jsx)(Qr,{role:"menuitemradio","aria-checked":i===t,selected:i===t,onClick:()=>{n(i),o()},sx:{fontSize:13},children:Dc(i)},i))})}var $I=k(P(),1);function J$r(e){return t=>t==="prompt"&&e?(0,$I.jsxs)($I.Fragment,{children:["prompt",(0,$I.jsx)(G,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${Dc(e)}`}),(0,$I.jsx)(hp,{sx:{fontSize:18,mr:-.75}})]}):t}var FI=k(P(),1);function tFr({draft:e,harness:t,harnesses:r,focus:n}){let[o,i]=(0,eFr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>i(yG(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,FI.jsxs)(FI.Fragment,{children:[(0,FI.jsx)(L_e,{label:"Mode",options:Z$r,value:e.mode,onChange:l,optionLabel:J$r(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,FI.jsx)(Q$r,{anchor:o,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>i(null)})]})}var pFr=k(re(),1);var Bit=k(P(),1),D3o={zIndex:e=>e.zIndex.modal+1};function rFr({open:e,anchor:t,children:r}){return(0,Bit.jsx)(fD,{open:e,anchorEl:t,placement:"bottom-start",sx:D3o,children:(0,Bit.jsx)(dn,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}var nFr=k(P(),1),oFr=nt((0,nFr.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown");var $it=k(P(),1),N3o={fontSize:13,height:36,pr:1,cursor:"pointer","& input":{cursor:"text"}},O3o={fontSize:16,color:"text.disabled"};function iFr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:N3o,endAdornment:(0,$it.jsx)(u3e,{position:"end",children:(0,$it.jsx)(oFr,{sx:O3o})})}}}var aFr=k(ZM(),1);function sFr({open:e,highlighted:t,accept:r,close:n,navigate:o,openList:i}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),i();return}FT(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,aFr.flushSync)(()=>{r(t),n()}),FT(a);return}if(a.key!=="Tab"){o(a);return}t!==void 0&&r(t),n()}}}function M_e(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>fx(n).toLowerCase().includes(r)):e}var Fit=k(re(),1);function lFr(){let[e,t]=(0,Fit.useState)(!1),[r,n]=(0,Fit.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:o=>{n(o),t(!0)},close:()=>{t(!1),n("")}}}var uFr=k(re(),1);var cFr=e=>e?fx(e):"";function dFr(e){let[t,r]=(0,uFr.useState)(()=>cFr(e));return{text:t,setText:r,showRepo:n=>r(cFr(n))}}function fFr(e,t,r){let n=lFr(),o=dFr(t),i=M_e(e,n.query),a=d=>{r(d),o.showRepo(d)},s=b5(i,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:o.text,filtered:i,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:sFr({open:n.open,highlighted:i[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:d=>{o.setText(d),n.filterBy(d)},onFocus:l,onBlur:()=>{n.close(),o.showRepo(t)},pick:d=>{a(d),n.close()}}}var vG=k(P(),1);function hFr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:o,onTrack:i}){let a=fFr(e,t,r),s=(0,pFr.useRef)(null);return(0,vG.jsxs)(G,{ref:s,sx:{flex:1,minWidth:0},children:[(0,vG.jsx)(Gn,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),i()},inputRef:n,autoFocus:o,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:iFr(a.open)}),(0,vG.jsx)(rFr,{open:a.open,anchor:s.current,children:(0,vG.jsx)(e_e,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var I5=k(P(),1);function mFr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:o}=eo();return(0,I5.jsxs)(Y$r,{prompt:(0,I5.jsx)(K$r,{value:r.prompt,onChange:r.setPrompt,placeholder:av[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),children:[(0,I5.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,I5.jsx)(hFr,{repos:o,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,I5.jsx)(tFr,{...t})]}),(0,I5.jsx)(j$r,{value:r.node,onChange:r.setNode,cloneState:e})]})}var vFr=k(P(),1),gFr=[["Enter","start"],["Shift+Enter","newline"],["Esc","close"]];function yFr({submitLabel:e,disabled:t=!1,loading:r=!1}){return(0,vFr.jsx)(vt,{type:"submit",variant:"contained",disabled:t,loading:r,children:e})}var zI=k(P(),1),B3o=e=>({alignItems:"center",flexWrap:"wrap",gap:"14px",py:"10px",pl:"18px",pr:1.5,borderTop:1,borderColor:e.tokens.color.lineSoft,bgcolor:"background.default",fontSize:12,color:"text.secondary"}),$3o=e=>({mr:.5,px:"5px",border:1,borderColor:"divider",borderRadius:"4px",fontFamily:e.typography.fontFamilyMono,fontSize:10.5,color:"text.primary"});function bFr(e){return(0,zI.jsxs)(_t,{direction:"row",sx:B3o,children:[gFr.map(([t,r])=>(0,zI.jsxs)("span",{children:[(0,zI.jsx)(G,{component:"kbd",sx:$3o,children:t}),r]},t)),(0,zI.jsx)(G,{sx:{flex:1}}),(0,zI.jsx)(yFr,{...e})]})}var UI=k(re(),1);function xFr(e,t){let r=(0,UI.useRef)(e),n=(0,UI.useRef)(null),o=(0,UI.useRef)(null),i=(0,UI.useRef)(null),a=(0,UI.useCallback)(u=>{n.current=u;let{field:d,selectionStart:f,selectionEnd:p}=r.current;u&&d==="prompt"&&u.setSelectionRange(f,p)},[]),s=u=>{let d=u.target;t({field:"prompt",selectionStart:d.selectionStart,selectionEnd:d.selectionEnd})},l=()=>{if(i.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:o.current,mode:yG(i.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:o,modeRef:i,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function F3o(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:r_e(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function SFr(e,t){let{names:r,visible:n}=Sl(),o=Zke(t,n?r:[void 0]);return{cloneState:o,target:F3o(t,e,o(e))}}function D_e({mode:e,harness:t,prompt:r,cwd:n,node:o},i){let a=n||void 0,s=o?[o]:[];if(e==="prompt"){t==="claude"?i.onCreate(r,a,...s):i.onCreateHarness(t,r,a,...s);return}if(e==="design"){i.onCreateDesign(r,a,...s);return}let l=o?[{node:o}]:[];Hkr(av[e].sessionMode,n,(u,d)=>i.onCreateAssist(u,d,...l),()=>{},r)}function TFr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(Wke(r.prompt,n.onCreateAssist),!0):(D_e({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var N_e=k(re(),1);function wFr(e,t){let[r,n]=(0,N_e.useState)(!1);return(0,N_e.useEffect)(()=>{!r||e.modePending||(n(!1),e.modeError||t())},[r,e.modePending,e.modeError,t]),()=>{e.modePending?n(!0):t()}}function CFr(e,t,r,n,o){let i=wFr(e,()=>{TFr(e,t,r,n)&&o()});return a=>{a.preventDefault(),i()}}var Jre=k(re(),1);function kFr(e,t){let r=(0,Jre.useRef)(e),n=(0,Jre.useRef)(null);return(0,Jre.useEffect)(()=>{if(r.current&&!e){let o=n.current;o?.isConnected?o.focus():t()}r.current=e},[e,t]),o=>{n.current=o.target}}var EFr=k(P(),1),z3o={border:0,margin:0,padding:0,minWidth:0};function _Fr({loading:e,restoreFocus:t,children:r}){let n=kFr(e,t);return(0,EFr.jsx)("fieldset",{disabled:e,style:z3o,onFocus:n,children:r})}var B_e=k(P(),1);function O_e({error:e,onRetry:t}){return e?(0,B_e.jsxs)(ro,{severity:"error",sx:{mx:2,my:1},action:t&&(0,B_e.jsx)(vt,{color:"inherit",size:"small",onClick:t,children:"Retry"}),children:["Couldn't load this repo's default mode (",e,"). Pick a mode or retry."]}):null}var M5=k(P(),1);function RFr({draft:e,launchers:t,onClose:r}){let n=xFr(e.focus,e.setFocus),o=gG(S0()),i=o.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=SFr(e.node,e.cwd),l=CFr(e,i,a,t,r);return(0,M5.jsx)(__e,{onClose:r,onEntered:n.restore,centered:!0,children:(0,M5.jsx)("form",{onSubmit:l,children:(0,M5.jsxs)(_Fr,{loading:e.modePending,restoreFocus:n.restore,children:[(0,M5.jsx)(mFr,{draft:e,harness:i,harnesses:o,focus:n,cloneState:s}),(0,M5.jsx)(O_e,{error:e.modeError,onRetry:e.retryMode}),(0,M5.jsx)(bFr,{submitLabel:a.kind==="clone"?"Clone":av[e.mode].submitLabel,disabled:a.kind==="blocked",loading:e.modePending})]})})})}var HI=k(re(),1);async function U3o(e){try{let t=e?`?cwd=${encodeURIComponent(e)}`:"",r=await tr(`/api/new-session-defaults${t}`);if(!r.ok)return{error:`HTTP ${r.status}`};let n=await r.json();if(Object.hasOwn(av,n?.mode))return{mode:n.mode};throw new Error(`unknown mode ${JSON.stringify(n?.mode)}`)}catch(t){return Pr(t,"new-session defaults"),{error:t instanceof Error?t.message:String(t)}}}function $_e(e,t=0){let[r,n]=(0,HI.useState)(0),[o,i]=(0,HI.useState)(null),a=(0,HI.useCallback)(()=>n(l=>l+1),[]);if((0,HI.useEffect)(()=>{let l=!1;return U3o(e).then(u=>{l||i({cwd:e,opens:t,attempt:r,outcome:u})}),()=>{l=!0}},[e,t,r]),!o)return null;let{outcome:s}=o;return{mode:"mode"in s?s.mode:"prompt",pending:o.cwd!==e||o.opens!==t||o.attempt!==r,error:"error"in s?s.error:void 0,retry:a}}function F_e(e,t){if(!(e!==void 0||!t||t.pending))return t.error}function AFr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var D5=k(re(),1);var PFr={field:"prompt",selectionStart:0,selectionEnd:0};function LFr(){let[e,t]=dH("new-session"),[r,n]=(0,D5.useState)(),[o,i]=(0,D5.useState)(),[a,s]=(0,D5.useState)("claude"),[l,u]=(0,D5.useState)(),[d,f]=(0,D5.useState)(PFr),p=(0,D5.useCallback)(()=>{t(""),n(void 0),i(void 0),u(void 0),f(PFr)},[t]);return{prompt:e,cwd:r,mode:o,harness:a,node:l,focus:d,setPrompt:t,setNode:u,setCwd:n,setMode:i,setHarness:s,setFocus:f,clear:p}}function IFr(e,t=$_e){let{selectedCwd:r}=eo(),n=Sl(),o=LFr(),i=o.cwd??r,a=t(i,e);return a?{...o,cwd:i,mode:o.mode??a.mode,modePending:o.mode===void 0&&a.pending,modeError:F_e(o.mode,a),retryMode:a.retry,node:AFr(o.node,n)}:null}function MFr(e){Ki(fo("newSession").matches,e)}var DFr=k(re(),1);function NFr(e,t){let{selectedCwd:r}=eo(),[n,o]=rl(),i=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,DFr.useEffect)(()=>{i===null||!s||!l||!u||(i&&(s(i),l(a),u({field:"prompt",selectionStart:i.length,selectionEnd:i.length})),t(),o(d=>(d.delete("new"),d.delete("newCwd"),d),{replace:!0}))},[i,a,s,l,u,t,o])}var BFr=k(P(),1);function OFr({launchers:e}){let[t,r]=(0,ene.useState)(!1),[n,o]=(0,ene.useState)(0),i=IFr(n),a=(0,ene.useCallback)(()=>{r(!0),o(s=>s+1)},[]);return MFr(a),NFr(i,a),!t||!i?null:(0,BFr.jsx)(RFr,{draft:i,launchers:e,onClose:()=>r(!1)})}var z_e=k(P(),1);function $Fr({reconnecting:e}){return(0,z_e.jsx)(Lu,{open:e,children:(0,z_e.jsx)(ro,{severity:"info",variant:"filled",icon:(0,z_e.jsx)(Ao,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var sv=k(P(),1);function FFr({socket:e,onViewLaunchedSession:t}){return(0,sv.jsxs)(sv.Fragment,{children:[(0,sv.jsx)(L$r,{}),(0,sv.jsx)(OFr,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,sv.jsx)($Fr,{reconnecting:e.reconnecting}),(0,sv.jsx)(T$r,{}),(0,sv.jsx)(Tl,{error:e.error,onClose:e.clearError}),(0,sv.jsx)(M$r,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var Tx=k(re(),1);var H3o=6e4;function W3o(e,t,r){return t.map(n=>e.find(o=>o.name===n)??{name:n,local:n===r,loading:!0})}function U_e(e){let t=e.nodes?.local,r=e.names.join(`
4061
+ `,j9r={content:'""',position:"absolute",borderRadius:"inherit",background:"conic-gradient(from calc(var(--rainbow-pill-h) * 1deg) in oklch longer hue, oklch(66% 0.21 0), oklch(66% 0.21 0))",animation:`${o3o} 1.8s linear infinite`},a3o={display:"inline-flex",alignItems:"center",px:1.5,py:"3px",borderRadius:999,position:"relative",isolation:"isolate",fontWeight:700,animation:`${i3o} 1.6s ease-in-out infinite`,"&::before":{...j9r,inset:0,zIndex:-1},"&::after":{...j9r,inset:"-5px",zIndex:-2,filter:"blur(9px)",opacity:.85},"& span":{color:zl.rainbowPill.text,textShadow:zl.rainbowPill.shadow},"@media (prefers-reduced-motion: reduce)":{animation:"none","&::before, &::after":{animation:"none"}}};function Y9r({children:e}){return(0,MI.jsxs)(MI.Fragment,{children:[(0,MI.jsx)(_3,{styles:n3o}),(0,MI.jsx)(G,{component:"span","data-testid":"rainbow-pill",sx:a3o,children:e})]})}function K9r({pct:e,timeLabel:t}){return[Math.round(e),...(t.match(/\d+/g)??[]).map(Number)].join(",")}function X9r(e){if(e.length!==2)return!1;let[t,r]=e;return K9r(t)===K9r(r)}var Rw=k(P(),1);function Q9r({rateLimits:e}){let t=x0(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(i=>i.window?.used_percentage!=null),n=X9r(r.map(i=>({pct:i.window?.used_percentage??0,timeLabel:b_e(i.window?.resets_at,i.fallbackLabel,t)}))),o=r.map((i,a)=>(0,Rw.jsxs)(Z9r.Fragment,{children:[a>0?(0,Rw.jsx)(G,{component:"span",sx:{color:mG,mr:.5},children:","}):null,(0,Rw.jsx)(q9r,{window:i.window,windowSeconds:i.windowSeconds,fallbackLabel:i.fallbackLabel,now:t})]},i.fallbackLabel));return n?(0,Rw.jsx)(Y9r,{children:o}):(0,Rw.jsx)(Rw.Fragment,{children:o})}var R5=k(P(),1);function e$r({groups:e}){return(0,R5.jsx)(R5.Fragment,{children:e.map((t,r)=>(0,R5.jsxs)(J9r.Fragment,{children:[(0,R5.jsx)(G,{component:"span",sx:{color:mG,ml:r>0?1:0,mr:.5},children:Dc(t.harness)}),(0,R5.jsx)(Q9r,{rateLimits:t.rateLimits})]},t.harness))})}var t$r={root:{fontFamily:"fontFamilyMono",fontSize:12,display:"grid",gap:1},group:{display:"grid",gap:"2px"},heading:{color:e=>e.tokens.color.onAppBar.secondary},foot:{pt:.75,opacity:.6,borderTop:"1px solid color-mix(in srgb, currentColor 18%, transparent)"}};function s3o(e){if(e==="over")return{level:"warn",boundary:100};if(e==="warn")return{level:"ok",boundary:75}}function l3o(e){if(e==="ok")return{level:"warn",boundary:75};if(e==="warn")return{level:"over",boundary:100}}function c3o(e,t,r,n){if(e>=t)return;let o=e/t;return Math.round(r-n*(1-o))}function o$r(e,t,r,n){if(t==null)return{kind:"unprojectable"};let o=lit(t,r,n);if(o==null)return{kind:"unprojectable"};let i=lx(e,t,r,n),a=s3o(i),s=l3o(i);return{kind:"projected",recovery:a&&{level:a.level,pct:a.boundary*o,at:c3o(e,a.boundary,t,r)},worse:s&&{level:s.level,pct:s.boundary*o}}}function S_e(e){return t=>t.tokens.color.onAppBar.level[e]}function i$r(e,t){return e.at==null?"not before reset":`${e.level==="ok"?"green":"under"} in ${VW(e.at,t)}`}var A5=k(P(),1),a$r={display:"contents"};function Ait({direction:e,threshold:t}){let r=e==="back";if(!t)return(0,A5.jsxs)(G,{component:"span",sx:a$r,children:[(0,A5.jsx)("span",{}),(0,A5.jsx)("span",{})]});let n=(0,A5.jsx)(G,{component:"span",sx:{opacity:.6},children:r?"\u2190":"\u2192"}),o=(0,A5.jsxs)(G,{component:"span",sx:{color:S_e(t.level),textAlign:"right"},children:[Math.round(t.pct),"%"]});return(0,A5.jsxs)(G,{component:"span",sx:a$r,children:[r?o:n,r?n:o]})}var s$r={row:{display:"grid",gridTemplateColumns:"2.5ch 4ch 1ch 4ch 1ch 4ch auto",alignItems:"baseline",gap:.75,fontVariantNumeric:"tabular-nums"},pctWeight:500,note:{pl:.75,color:e=>e.tokens.color.onAppBar.secondary}};var P5=k(P(),1);function l$r({label:e,pct:t,resetsAt:r,windowSeconds:n,now:o}){let i=s$r,a=lx(t,r,n,o),s=o$r(t,r,n,o),l=s.kind==="projected"?s:void 0;return(0,P5.jsxs)(G,{sx:i.row,children:[(0,P5.jsx)(G,{component:"span",sx:{minWidth:"2ch"},children:e}),(0,P5.jsx)(Ait,{direction:"back",threshold:l?.recovery}),(0,P5.jsxs)(G,{component:"span",sx:{minWidth:"4ch",textAlign:"right",fontWeight:i.pctWeight,color:S_e(a)},children:[Math.round(t),"%"]}),(0,P5.jsx)(Ait,{direction:"forward",threshold:l?.worse}),(0,P5.jsx)(G,{component:"span",sx:i.note,children:l?l.recovery&&i$r(l.recovery,o):"no projection yet"})]})}function T_e(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 u$r=k(P(),1);function c$r({rateLimits:e,now:t}){return T_e(e).map(r=>(0,u$r.jsx)(l$r,{label:r.label,pct:r.pct,resetsAt:r.resetsAt,windowSeconds:r.windowSeconds,now:t},r.label))}var DI=k(P(),1);function d$r({groups:e}){let t=x0(3e4),r=t$r;return(0,DI.jsxs)(G,{sx:r.root,children:[e.map(n=>(0,DI.jsxs)(G,{sx:r.group,children:[(0,DI.jsx)(G,{sx:r.heading,children:Dc(n.harness)}),(0,DI.jsx)(c$r,{rateLimits:n.rateLimits,now:t})]},n.harness)),(0,DI.jsx)(G,{sx:r.foot,children:"Account usage per harness \u2014 view history"})]})}var Pit=k(P(),1),u3o="Claude account usage (5h / 7d windows) \u2014 view history";function f$r(e){return e.length===0?{title:u3o,content:"Usage"}:{title:(0,Pit.jsx)(d$r,{groups:e}),content:(0,Pit.jsx)(e$r,{groups:e})}}var p$r={display:"flex",alignItems:"center",height:22,px:1,borderRadius:1,fontSize:"inherit","&:hover, &:focus-visible":{bgcolor:e=>e.tokens.color.statusBar.hover,color:e=>e.tokens.color.statusBar.hoverText}},h$r={tooltip:{sx:{p:"10px 12px",minWidth:300,maxWidth:"none"}}};var Lit=k(P(),1),d3o={};function m$r({rateLimits:e,harnessRateLimits:t=d3o}){let{title:r,content:n}=f$r(v_e(e,t));return(0,Lit.jsx)(ar,{title:r,placement:"top-start",slotProps:h$r,children:(0,Lit.jsx)(Kr,{component:ca,to:"/usage",underline:"none",color:"inherit",sx:p$r,children:n})})}var v$r=k(re(),1);var ah="0.1022.0";var w_e=k(re(),1),Iit=(0,w_e.createContext)(null);function C_e(){return(0,w_e.useContext)(Iit)}var Mit=k(P(),1);function g$r(){let e=C_e();return!e||e===ah?null:(0,Mit.jsx)(ar,{title:`Daemon is running v${e}, but this page was served by v${ah}. Restart the daemon to match.`,children:(0,Mit.jsx)(a_e,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})}var y$r=e=>({display:"inline-flex",alignItems:"center",gap:.75,px:1,py:0,height:22,borderRadius:1,fontSize:"inherit",lineHeight:1.5,color:"inherit",opacity:1,bgcolor:t=>e?Sx(t).active:"transparent",transition:"opacity .2s ease, background-color .2s ease, color .2s ease","&:hover, &:focus-visible":{bgcolor:t=>Sx(t).hover,color:t=>Sx(t).hoverText},"& .ready-dot":{width:6,height:6,borderRadius:"50%",bgcolor:t=>Sx(t).dot,boxShadow:t=>`0 0 0 3px ${Sx(t).dotRing}`},"& .ready-count":{fontWeight:500,color:t=>Sx(t).readyText}});var C0=k(P(),1);function b$r(){let{entries:e}=s5(),t=nn(),r=(0,v$r.useCallback)(()=>t("/updates"),[t]),{matches:n,chords:o}=fo("openUpdates");if(Ki(n,r),!ah)return null;let i=e.filter(u5).length;return(0,C0.jsxs)(C0.Fragment,{children:[(0,C0.jsx)(ar,{describeChild:!0,placement:"top-end",title:(0,C0.jsx)(Td,{label:"Updates",chords:o}),children:(0,C0.jsxs)(ur,{component:ca,to:"/updates","aria-label":i?`Updates: ${i} node${i>1?"s have":" has"} an update ready`:"Updates",sx:y$r(i>0),children:[i>0&&(0,C0.jsx)("span",{className:"ready-dot","aria-hidden":!0}),(0,C0.jsxs)("span",{children:["v",ah]}),i>0&&(0,C0.jsxs)("span",{className:"ready-count",children:[i," ready"]})]})}),(0,C0.jsx)(g$r,{})]})}var Aw=k(P(),1);function x$r({socket:e}){return(0,Aw.jsx)(I9r,{start:(0,Aw.jsx)(m$r,{rateLimits:e.rateLimits,harnessRateLimits:e.harnessRateLimits}),end:(0,Aw.jsxs)(Aw.Fragment,{children:[(0,Aw.jsx)(W9r,{}),(0,Aw.jsx)(b$r,{})]})})}var S$r=k(re(),1);var Pw=k(P(),1),f3o=2e4;function T$r(){let{entries:e,refresh:t}=s5(),[r,n]=(0,S$r.useState)(),o=e.find(l=>l.local)?.status?.extension,i=o?.behind&&o.updateLink&&o.latest?o:void 0,a=i!==void 0&&r!==i.latest,s=()=>n(i?.latest);return(0,Pw.jsx)(Lu,{open:a,children:(0,Pw.jsxs)(ro,{severity:"info",variant:"filled",action:(0,Pw.jsxs)(Pw.Fragment,{children:[(0,Pw.jsx)(vt,{color:"inherit",size:"small",href:i?.updateLink,onClick:()=>setTimeout(t,f3o),children:"Install"}),(0,Pw.jsx)(vt,{color:"inherit",size:"small",onClick:s,children:"Dismiss"})]}),children:["assist extension v",i?.connected," \u2192 v",i?.latest]})})}var A_e=k(re(),1);var R_e=k(re(),1);function w$r(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 L5=k(P(),1),p3o={display:"flex",gap:1,alignItems:"center",minWidth:0},h3o={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},m3o={fontFamily:"fontFamilyMono",fontSize:13,whiteSpace:"nowrap"},g3o={fontFamily:"fontFamilyMono",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function y3o(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function C$r({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,L5.jsx)(Ym,{dense:!0,sx:{py:0},children:e.map((o,i)=>{let{dir:a,basename:s}=y3o(o);return(0,L5.jsxs)(Qr,{selected:i===t,onMouseEnter:()=>r(i),onClick:()=>n(o),sx:p3o,children:[(0,L5.jsx)(t2e,{path:o}),(0,L5.jsxs)(G,{sx:h3o,children:[(0,L5.jsx)(_e,{component:"span",sx:m3o,children:s}),(0,L5.jsx)(_e,{component:"span",color:"text.secondary",sx:g3o,children:a})]})]},o)})})}var k_e=k(P(),1),v3o={maxHeight:420,overflowY:"auto"},b3o={px:2,py:2,fontSize:13};function k$r({message:e,files:t,highlight:r,onHighlight:n,onSelect:o}){return(0,k_e.jsx)(G,{sx:v3o,children:e?(0,k_e.jsx)(_e,{color:"text.secondary",sx:b3o,children:e}):(0,k_e.jsx)(C$r,{files:t,highlight:r,onHighlight:n,onSelect:o})})}var _$r=k(P(),1),x3o={mt:6,alignSelf:"flex-start"};function __e({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,_$r.jsx)(Ac,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:x3o},transition:{onEntered:t}},children:n})}var E_e=k(re(),1);var E$r={files:[],loading:!1,error:!1};function R$r(e,t){let[r,n]=(0,E_e.useState)(E$r),o=br();return(0,E_e.useEffect)(()=>{if(!e){n(E$r);return}let i=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await tr(Jr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,o));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(i)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch(s){Pr(s,"file search"),i||n({files:[],loading:!1,error:!0})}})(),()=>{i=!0}},[e,t,o]),r}var NI=k(P(),1);function S3o(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function A$r({onClose:e}){let{worktreeNode:t}=eo();return(0,NI.jsx)(ec.Provider,{value:t,children:(0,NI.jsx)(T3o,{onClose:e})})}function T3o({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=eo(),[n,o]=(0,R_e.useState)(""),i=R$r(t,n),a=nn(),s=(0,R_e.useRef)(null),l=h=>a(S3o(h,t,r)),{highlight:u,setHighlight:d,onKeyDown:f}=b5(i.files,n,l,e),p=h=>{l(h),e()};return(0,NI.jsxs)(__e,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,NI.jsx)(rk,{autoFocus:!0,inputRef:s,value:n,onChange:o,onKeyDown:f,placeholder:"Search files by name..."}),(0,NI.jsx)(k$r,{message:w$r(t,n,i),files:i.files,highlight:u,onHighlight:d,onSelect:p})]})}function P$r(e){Ki(fo("quickOpen").matches,e)}var I$r=k(P(),1);function L$r(){let[e,t]=(0,A_e.useState)(!1);return P$r((0,A_e.useCallback)(()=>t(!0),[])),e?(0,I$r.jsx)(A$r,{onClose:()=>t(!1)}):null}var P_e=k(P(),1);function M$r({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,P_e.jsx)(Lu,{open:e!==null,autoHideDuration:6e3,onClose:t,children:(0,P_e.jsx)(ro,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,P_e.jsx)(vt,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var ene=k(re(),1);function gG(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var q$r=k(re(),1);var D$r=k(P(),1),N$r=nt((0,D$r.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 w3o={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function O$r(e){return e?w3o[e]:"success.main"}function B$r(e){return e.split("-")[0].split(".").map(Number)}function $$r(e,t){if(!e||!t||e===t)return;let r=B$r(e),n=B$r(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var OI=k(P(),1),C3o={height:16,fontSize:10},k3o={opacity:.6,fontSize:"0.85em"};function _3o(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 Qre({nodes:e,name:t,showVersion:r=!1}){let n=C_e()??ah,o=e.links.find(a=>a.name===t),i=$$r(o?.peerVersion,n);return(0,OI.jsx)(ar,{title:_3o(e,t),placement:"right",children:(0,OI.jsxs)(G,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,OI.jsx)(N$r,{sx:{fontSize:8,color:O$r(o?.state)}}),t,r&&o?.peerVersion&&(0,OI.jsxs)(G,{component:"span",sx:k3o,children:["v",o.peerVersion]}),i&&(0,OI.jsx)(Zn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:C3o})]})})}var BI=k(P(),1),E3o={opacity:.6},R3o={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function F$r({nodes:e,name:t,clone:r}){let n=(0,BI.jsx)(Qre,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,BI.jsx)(G,{component:"span",sx:E3o,children:n}):(0,BI.jsx)(ar,{title:QW(t,r.cloneTarget),children:(0,BI.jsxs)(G,{component:"span",sx:R3o,children:[(0,BI.jsx)(ZW,{sx:{fontSize:14}}),n]})})}var U$r=k(P(),1),A3o={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 z$r({value:e,label:t,checked:r,autoFocus:n,onSelect:o}){return(0,U$r.jsx)(ur,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:o,sx:A3o,children:t})}var H$r={ArrowRight:1,ArrowLeft:-1};function P3o(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+H$r[e.key]+r)%r}function W$r(e,t,r,n){return o=>{if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!n)return;o.preventDefault(),n();return}if(o.key!=="Tab"&&!H$r[o.key]){FT(o);return}let i=P3o(o,e.indexOf(t),e.length);i!==void 0&&(o.preventDefault(),r(e[i]),o.currentTarget.querySelector(`[data-value="${e[i]}"]`)?.focus())}}var G$r=k(re(),1);function yG(e){return e?.querySelector('[aria-checked="true"]')}function V$r(e,t){(0,G$r.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=yG(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var Dit=k(P(),1),L3o={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function L_e({label:e,options:t,value:r,onChange:n,optionLabel:o=u=>u,groupRef:i,autoFocus:a,onTrack:s,onToggleRow:l}){return V$r(i,r),(0,Dit.jsx)(_t,{ref:i,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:W$r(t,r,n,l),sx:L3o,children:t.map(u=>(0,Dit.jsx)(z$r,{value:u,label:o(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var Nit=k(P(),1);function j$r({value:e,onChange:t,cloneState:r}){let{nodes:n,names:o,visible:i}=Sl(),a=(0,q$r.useRef)(null);return!i||!n||!e?null:(0,Nit.jsx)(L_e,{label:"Machine",options:o,value:e,onChange:t,optionLabel:s=>(0,Nit.jsx)(F$r,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var I_e=k(P(),1);function Y$r({prompt:e,children:t}){return(0,I_e.jsxs)(_t,{children:[e,(0,I_e.jsx)(_t,{spacing:1,sx:{px:1.5,pb:1.5},children:t})]})}var X$r=k(P(),1),I3o=".MuiOutlinedInput-notchedOutline",M3o={"& .MuiOutlinedInput-root":{px:"18px",py:2,minHeight:92,alignItems:"flex-start",bgcolor:"transparent",borderRadius:0,fontSize:15},[`&&& ${I3o}`]:{border:0},"& textarea::placeholder":{color:"text.disabled",opacity:1}};function K$r({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:o,onTrack:i}){return(0,X$r.jsx)(Gn,{sx:M3o,value:e,onChange:a=>t(a.target.value),onKeyDown:FT,onFocus:i,onSelect:i,inputRef:n,placeholder:r,autoFocus:o,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"}}})}var eFr=k(re(),1);var av={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:rSe,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},Z$r=Object.keys(av);var Oit=k(P(),1);function Q$r({anchor:e,harness:t,harnesses:r,onPick:n,onClose:o}){return(0,Oit.jsx)(ks,{open:e!==null,anchorEl:e,onClose:o,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(i=>(0,Oit.jsx)(Qr,{role:"menuitemradio","aria-checked":i===t,selected:i===t,onClick:()=>{n(i),o()},sx:{fontSize:13},children:Dc(i)},i))})}var $I=k(P(),1);function J$r(e){return t=>t==="prompt"&&e?(0,$I.jsxs)($I.Fragment,{children:["prompt",(0,$I.jsx)(G,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${Dc(e)}`}),(0,$I.jsx)(hp,{sx:{fontSize:18,mr:-.75}})]}):t}var FI=k(P(),1);function tFr({draft:e,harness:t,harnesses:r,focus:n}){let[o,i]=(0,eFr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>i(yG(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,FI.jsxs)(FI.Fragment,{children:[(0,FI.jsx)(L_e,{label:"Mode",options:Z$r,value:e.mode,onChange:l,optionLabel:J$r(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,FI.jsx)(Q$r,{anchor:o,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>i(null)})]})}var pFr=k(re(),1);var Bit=k(P(),1),D3o={zIndex:e=>e.zIndex.modal+1};function rFr({open:e,anchor:t,children:r}){return(0,Bit.jsx)(fD,{open:e,anchorEl:t,placement:"bottom-start",sx:D3o,children:(0,Bit.jsx)(dn,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}var nFr=k(P(),1),oFr=nt((0,nFr.jsx)("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"}),"KeyboardArrowDown");var $it=k(P(),1),N3o={fontSize:13,height:36,pr:1,cursor:"pointer","& input":{cursor:"text"}},O3o={fontSize:16,color:"text.disabled"};function iFr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:N3o,endAdornment:(0,$it.jsx)(u3e,{position:"end",children:(0,$it.jsx)(oFr,{sx:O3o})})}}}var aFr=k(ZM(),1);function sFr({open:e,highlighted:t,accept:r,close:n,navigate:o,openList:i}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),i();return}FT(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,aFr.flushSync)(()=>{r(t),n()}),FT(a);return}if(a.key!=="Tab"){o(a);return}t!==void 0&&r(t),n()}}}function M_e(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>fx(n).toLowerCase().includes(r)):e}var Fit=k(re(),1);function lFr(){let[e,t]=(0,Fit.useState)(!1),[r,n]=(0,Fit.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:o=>{n(o),t(!0)},close:()=>{t(!1),n("")}}}var uFr=k(re(),1);var cFr=e=>e?fx(e):"";function dFr(e){let[t,r]=(0,uFr.useState)(()=>cFr(e));return{text:t,setText:r,showRepo:n=>r(cFr(n))}}function fFr(e,t,r){let n=lFr(),o=dFr(t),i=M_e(e,n.query),a=d=>{r(d),o.showRepo(d)},s=b5(i,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:o.text,filtered:i,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:sFr({open:n.open,highlighted:i[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:d=>{o.setText(d),n.filterBy(d)},onFocus:l,onBlur:()=>{n.close(),o.showRepo(t)},pick:d=>{a(d),n.close()}}}var vG=k(P(),1);function hFr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:o,onTrack:i}){let a=fFr(e,t,r),s=(0,pFr.useRef)(null);return(0,vG.jsxs)(G,{ref:s,sx:{flex:1,minWidth:0},children:[(0,vG.jsx)(Gn,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),i()},inputRef:n,autoFocus:o,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:iFr(a.open)}),(0,vG.jsx)(rFr,{open:a.open,anchor:s.current,children:(0,vG.jsx)(e_e,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var I5=k(P(),1);function mFr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:o}=eo();return(0,I5.jsxs)(Y$r,{prompt:(0,I5.jsx)(K$r,{value:r.prompt,onChange:r.setPrompt,placeholder:av[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),children:[(0,I5.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,I5.jsx)(hFr,{repos:o,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,I5.jsx)(tFr,{...t})]}),(0,I5.jsx)(j$r,{value:r.node,onChange:r.setNode,cloneState:e})]})}var vFr=k(P(),1),gFr=[["Enter","start"],["Shift+Enter","newline"],["Esc","close"]];function yFr({submitLabel:e,disabled:t=!1,loading:r=!1}){return(0,vFr.jsx)(vt,{type:"submit",variant:"contained",disabled:t,loading:r,children:e})}var zI=k(P(),1),B3o=e=>({alignItems:"center",flexWrap:"wrap",gap:"14px",py:"10px",pl:"18px",pr:1.5,borderTop:1,borderColor:e.tokens.color.lineSoft,bgcolor:"background.default",fontSize:12,color:"text.secondary"}),$3o=e=>({mr:.5,px:"5px",border:1,borderColor:"divider",borderRadius:"4px",fontFamily:e.typography.fontFamilyMono,fontSize:10.5,color:"text.primary"});function bFr(e){return(0,zI.jsxs)(_t,{direction:"row",sx:B3o,children:[gFr.map(([t,r])=>(0,zI.jsxs)("span",{children:[(0,zI.jsx)(G,{component:"kbd",sx:$3o,children:t}),r]},t)),(0,zI.jsx)(G,{sx:{flex:1}}),(0,zI.jsx)(yFr,{...e})]})}var UI=k(re(),1);function xFr(e,t){let r=(0,UI.useRef)(e),n=(0,UI.useRef)(null),o=(0,UI.useRef)(null),i=(0,UI.useRef)(null),a=(0,UI.useCallback)(u=>{n.current=u;let{field:d,selectionStart:f,selectionEnd:p}=r.current;u&&d==="prompt"&&u.setSelectionRange(f,p)},[]),s=u=>{let d=u.target;t({field:"prompt",selectionStart:d.selectionStart,selectionEnd:d.selectionEnd})},l=()=>{if(i.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:o.current,mode:yG(i.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:o,modeRef:i,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function F3o(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:r_e(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function SFr(e,t){let{names:r,visible:n}=Sl(),o=Zke(t,n?r:[void 0]);return{cloneState:o,target:F3o(t,e,o(e))}}function D_e({mode:e,harness:t,prompt:r,cwd:n,node:o},i){let a=n||void 0,s=o?[o]:[];if(e==="prompt"){t==="claude"?i.onCreate(r,a,...s):i.onCreateHarness(t,r,a,...s);return}if(e==="design"){i.onCreateDesign(r,a,...s);return}let l=o?[{node:o}]:[];Hkr(av[e].sessionMode,n,(u,d)=>i.onCreateAssist(u,d,...l),()=>{},r)}function TFr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(Wke(r.prompt,n.onCreateAssist),!0):(D_e({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var N_e=k(re(),1);function wFr(e,t){let[r,n]=(0,N_e.useState)(!1);return(0,N_e.useEffect)(()=>{!r||e.modePending||(n(!1),e.modeError||t())},[r,e.modePending,e.modeError,t]),()=>{e.modePending?n(!0):t()}}function CFr(e,t,r,n,o){let i=wFr(e,()=>{TFr(e,t,r,n)&&o()});return a=>{a.preventDefault(),i()}}var Jre=k(re(),1);function kFr(e,t){let r=(0,Jre.useRef)(e),n=(0,Jre.useRef)(null);return(0,Jre.useEffect)(()=>{if(r.current&&!e){let o=n.current;o?.isConnected?o.focus():t()}r.current=e},[e,t]),o=>{n.current=o.target}}var EFr=k(P(),1),z3o={border:0,margin:0,padding:0,minWidth:0};function _Fr({loading:e,restoreFocus:t,children:r}){let n=kFr(e,t);return(0,EFr.jsx)("fieldset",{disabled:e,style:z3o,onFocus:n,children:r})}var B_e=k(P(),1);function O_e({error:e,onRetry:t}){return e?(0,B_e.jsxs)(ro,{severity:"error",sx:{mx:2,my:1},action:t&&(0,B_e.jsx)(vt,{color:"inherit",size:"small",onClick:t,children:"Retry"}),children:["Couldn't load this repo's default mode (",e,"). Pick a mode or retry."]}):null}var M5=k(P(),1);function RFr({draft:e,launchers:t,onClose:r}){let n=xFr(e.focus,e.setFocus),o=gG(S0()),i=o.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=SFr(e.node,e.cwd),l=CFr(e,i,a,t,r);return(0,M5.jsx)(__e,{onClose:r,onEntered:n.restore,centered:!0,children:(0,M5.jsx)("form",{onSubmit:l,children:(0,M5.jsxs)(_Fr,{loading:e.modePending,restoreFocus:n.restore,children:[(0,M5.jsx)(mFr,{draft:e,harness:i,harnesses:o,focus:n,cloneState:s}),(0,M5.jsx)(O_e,{error:e.modeError,onRetry:e.retryMode}),(0,M5.jsx)(bFr,{submitLabel:a.kind==="clone"?"Clone":av[e.mode].submitLabel,disabled:a.kind==="blocked",loading:e.modePending})]})})})}var HI=k(re(),1);async function U3o(e){try{let t=e?`?cwd=${encodeURIComponent(e)}`:"",r=await tr(`/api/new-session-defaults${t}`);if(!r.ok)return{error:`HTTP ${r.status}`};let n=await r.json();if(Object.hasOwn(av,n?.mode))return{mode:n.mode};throw new Error(`unknown mode ${JSON.stringify(n?.mode)}`)}catch(t){return Pr(t,"new-session defaults"),{error:t instanceof Error?t.message:String(t)}}}function $_e(e,t=0){let[r,n]=(0,HI.useState)(0),[o,i]=(0,HI.useState)(null),a=(0,HI.useCallback)(()=>n(l=>l+1),[]);if((0,HI.useEffect)(()=>{let l=!1;return U3o(e).then(u=>{l||i({cwd:e,opens:t,attempt:r,outcome:u})}),()=>{l=!0}},[e,t,r]),!o)return null;let{outcome:s}=o;return{mode:"mode"in s?s.mode:"prompt",pending:o.cwd!==e||o.opens!==t||o.attempt!==r,error:"error"in s?s.error:void 0,retry:a}}function F_e(e,t){if(!(e!==void 0||!t||t.pending))return t.error}function AFr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var D5=k(re(),1);var PFr={field:"prompt",selectionStart:0,selectionEnd:0};function LFr(){let[e,t]=dH("new-session"),[r,n]=(0,D5.useState)(),[o,i]=(0,D5.useState)(),[a,s]=(0,D5.useState)("claude"),[l,u]=(0,D5.useState)(),[d,f]=(0,D5.useState)(PFr),p=(0,D5.useCallback)(()=>{t(""),n(void 0),i(void 0),u(void 0),f(PFr)},[t]);return{prompt:e,cwd:r,mode:o,harness:a,node:l,focus:d,setPrompt:t,setNode:u,setCwd:n,setMode:i,setHarness:s,setFocus:f,clear:p}}function IFr(e,t=$_e){let{selectedCwd:r}=eo(),n=Sl(),o=LFr(),i=o.cwd??r,a=t(i,e);return a?{...o,cwd:i,mode:o.mode??a.mode,modePending:o.mode===void 0&&a.pending,modeError:F_e(o.mode,a),retryMode:a.retry,node:AFr(o.node,n)}:null}function MFr(e){Ki(fo("newSession").matches,e)}var DFr=k(re(),1);function NFr(e,t){let{selectedCwd:r}=eo(),[n,o]=rl(),i=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,DFr.useEffect)(()=>{i===null||!s||!l||!u||(i&&(s(i),l(a),u({field:"prompt",selectionStart:i.length,selectionEnd:i.length})),t(),o(d=>(d.delete("new"),d.delete("newCwd"),d),{replace:!0}))},[i,a,s,l,u,t,o])}var BFr=k(P(),1);function OFr({launchers:e}){let[t,r]=(0,ene.useState)(!1),[n,o]=(0,ene.useState)(0),i=IFr(n),a=(0,ene.useCallback)(()=>{r(!0),o(s=>s+1)},[]);return MFr(a),NFr(i,a),!t||!i?null:(0,BFr.jsx)(RFr,{draft:i,launchers:e,onClose:()=>r(!1)})}var z_e=k(P(),1);function $Fr({reconnecting:e}){return(0,z_e.jsx)(Lu,{open:e,children:(0,z_e.jsx)(ro,{severity:"info",variant:"filled",icon:(0,z_e.jsx)(Ao,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var sv=k(P(),1);function FFr({socket:e,onViewLaunchedSession:t}){return(0,sv.jsxs)(sv.Fragment,{children:[(0,sv.jsx)(L$r,{}),(0,sv.jsx)(OFr,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,sv.jsx)($Fr,{reconnecting:e.reconnecting}),(0,sv.jsx)(T$r,{}),(0,sv.jsx)(Tl,{error:e.error,onClose:e.clearError}),(0,sv.jsx)(M$r,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var Tx=k(re(),1);var H3o=6e4;function W3o(e,t,r){return t.map(n=>e.find(o=>o.name===n)??{name:n,local:n===r,loading:!0})}function U_e(e){let t=e.nodes?.local,r=e.names.join(`
4062
4062
  `),[n,o]=(0,Tx.useState)([]),i=(0,Tx.useRef)(0),a=(0,Tx.useCallback)(()=>{let l=r?r.split(`
4063
4063
  `):[];if(l.length===0)return;let u=++i.current;o(d=>W3o(d,l,t));for(let d of l)vke(d,d===t).then(f=>{u===i.current&&o(p=>p.map(h=>h.name===d?f:h))})},[r,t]);(0,Tx.useEffect)(()=>{a();let l=setInterval(a,H3o);return()=>clearInterval(l)},[a]);let s=n.length===0;return(0,Tx.useMemo)(()=>({entries:n,loading:s,refresh:a}),[n,s,a])}var N5=k(P(),1);function zFr({shell:e,children:t}){let{socket:r,selection:n,launch:o,sidebarCollapse:i}=e,a=U_e(r.nodeSelection);return(0,N5.jsx)(Jot.Provider,{value:a,children:(0,N5.jsx)(W6e.Provider,{value:i,children:(0,N5.jsx)(Kj.Provider,{value:n,children:(0,N5.jsx)(S6e.Provider,{value:r.nodeSelection,children:(0,N5.jsx)(ec.Provider,{value:n.selectedNode,children:(0,N5.jsx)($Xe.Provider,{value:o,children:(0,N5.jsx)(F1t,{children:t})})})})})})})}var UFr=k(P(),1),HFr=nt((0,UFr.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 WFr=k(re(),1);var lv=k(P(),1),G3o={ml:1,textTransform:"none",fontSize:12};function GFr(){let{nodes:e,names:t,visible:r,selected:n,select:o}=Sl(),[i,a]=(0,WFr.useState)(null);return!r||!e||!n?null:(0,lv.jsxs)(lv.Fragment,{children:[(0,lv.jsx)(vt,{size:"small",color:"inherit",startIcon:(0,lv.jsx)(HFr,{fontSize:"small"}),"aria-label":"Machine","aria-haspopup":"menu",onClick:s=>a(s.currentTarget),sx:G3o,children:(0,lv.jsx)(Qre,{nodes:e,name:n})}),(0,lv.jsx)(ks,{anchorEl:i,open:!!i,onClose:()=>a(null),children:t.map(s=>(0,lv.jsx)(Qr,{selected:s===n,onClick:()=>{o(s),a(null)},sx:{fontSize:13},children:(0,lv.jsx)(Qre,{nodes:e,name:s,showVersion:!0})},s))})]})}var tne=k(re(),1);function VFr(e,t){return[...e[0].slice(0,-1),String(t+1)]}var WI=k(P(),1),V3o=[Ai("secondary"),{ml:.75}];function qFr({index:e,label:t,count:r,...n}){let{chords:o}=fo("navTab");return(0,WI.jsx)(ar,{describeChild:!0,title:(0,WI.jsx)(Td,{label:t,chords:[VFr(o,e)]}),children:(0,WI.jsx)(i2,{label:r?(0,WI.jsxs)("span",{children:[t,(0,WI.jsx)(G,{component:"span",sx:V3o,children:r})]}):t,...n})})}var jFr=k(re(),1);var q3o=6e4;function YFr(){let e=p2e();return(0,jFr.useEffect)(()=>{Ws.refresh();let t=setInterval(()=>{Ws.refresh()},q3o);return()=>clearInterval(t)},[]),e?.length??0}var zit=k(re(),1);function KFr(e,t){let{bound:r}=fo("navTab"),n=e.length,o=(0,zit.useCallback)(a=>(oY(a,r)??n)<n,[r,n]),i=(0,zit.useCallback)(a=>{let s=e[oY(a,r)??-1];s&&t(s)},[e,t,r]);Ki(o,i)}var H_e=k(re(),1);function XFr(){let[e,t]=(0,H_e.useState)(!1);return(0,H_e.useEffect)(()=>{let r=!1;return(async()=>{try{let o=await(await tr("/api/news/nav")).json();r||t(o?.showInNav===!0)}catch(n){Pr(n,"news nav"),r||t(!1)}})(),()=>{r=!0}},[]),e}var W_e=k(re(),1);async function j3o(e,t){let r=await tr(Jr(`/api/releases/configured?cwd=${encodeURIComponent(e)}`,t));return r.ok?(await r.json())?.configured===!0:void 0}function ZFr(e){let[t,r]=(0,W_e.useState)(null),n=br(),o=`${n??""}\0${e}`;return(0,W_e.useEffect)(()=>{if(!e)return;let i=!1;return j3o(e,n).catch(a=>{Pr(a,"releases configured")}).then(a=>{i||r({key:o,configured:a})}),()=>{i=!0}},[e,n,o]),t?.key===o?t.configured:void 0}var QFr=k(re(),1);function JFr(e){let{pathname:t}=mi(),r=nn(),n=t==="/releases"||t.startsWith("/releases/");(0,QFr.useEffect)(()=>{e===!1&&n&&r("/sessions",{replace:!0})},[e,n,r])}var Y3o={path:"/sessions",label:"Sessions"},K3o={path:"/backlog",label:"Backlog"},X3o={path:"/next",label:"Next"},Z3o={path:"/releases",label:"Releases"},Q3o={path:"/news",label:"News"},J3o={path:"/inbox",label:"Inbox"};function ezr(e,t){return[Y3o,K3o,X3o,...e?[Z3o]:[],...t?[Q3o]:[],J3o]}var Uit=k(P(),1),eRo={mx:"6px"};function tzr({cwd:e}){let t=mi(),r=nn(),n=ZFr(e),o=XFr(),i=YFr();JFr(n);let a=n===!0,s=(0,tne.useMemo)(()=>ezr(a,o),[a,o]),l=(0,tne.useMemo)(()=>s.map(f=>f.path),[s]),u=s.findIndex(f=>t.pathname.startsWith(f.path)),d=(0,tne.useCallback)(f=>{t.pathname!==f&&r(f)},[t.pathname,r]);return KFr(l,d),(0,Uit.jsx)(nR,{sx:eRo,value:u===-1?!1:u,textColor:"inherit",indicatorColor:"secondary",children:s.map((f,p)=>(0,Uit.jsx)(qFr,{index:p,label:f.label,count:f.path==="/inbox"?i:void 0,onClick:()=>d(f.path)},f.path))})}var rne=k(P(),1),rzr=(e,t)=>({bgcolor:e,color:t,"& .MuiSvgIcon-root":{color:t},transition:"filter 0.2s ease, transform 0.2s ease","&:hover":{bgcolor:e,color:t,filter:"brightness(1.08)"},"&:active":{transform:"translateY(1px)"}}),tRo=e=>({ml:.75,...e.tokens.color.appBar?rzr("primary.main","primary.contrastText"):rzr("primary.contrastText","primary.main")});function nzr(){let[,e]=rl(),{label:t,chords:r}=fo("newSession");return(0,rne.jsx)(ar,{title:(0,rne.jsx)(Td,{label:t,chords:r}),children:(0,rne.jsx)(jt,{sx:tRo,"aria-label":"New session",onClick:()=>e(o=>(o.set("new",""),o),{replace:!0}),children:(0,rne.jsx)(pp,{})})})}var G_e=k(re(),1);var nne=k(P(),1),rRo={strokeWidth:2};function ozr(e){return(0,nne.jsxs)(aSe,{viewBox:"0 0 24 24",sx:rRo,...e,children:[(0,nne.jsx)("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 3.5c-.3 1.15-.3 2.35 0 3.5A5.4 5.4 0 0 0 4 10.5c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),(0,nne.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}var one=k(P(),1);function izr({cwd:e}){let[t,r]=(0,G_e.useState)(null),n=br();return(0,G_e.useEffect)(()=>{if(!e){r(null);return}let o=!1;return(async()=>{try{let a=await(await tr(Jr(`/api/github-url?cwd=${encodeURIComponent(e)}`,n))).json();o||r(a?.url??null)}catch(i){Pr(i,"GitHub URL"),o||r(null)}})(),()=>{o=!0}},[e,n]),t?(0,one.jsx)(ar,{title:"Open in GitHub",children:(0,one.jsx)(G,{component:"span",sx:sSe,children:(0,one.jsx)(jt,{onClick:()=>window.open(t,"_blank"),children:(0,one.jsx)(ozr,{})})})}):null}var cv=k(P(),1),nRo={color:"inherit",mr:1.5};function azr({reconnecting:e}){let{pending:t,error:r,clearError:n,restart:o}=p5("webserver",e);return(0,cv.jsxs)(cv.Fragment,{children:[(0,cv.jsx)(ar,{title:"Restart web server",children:(0,cv.jsx)("span",{children:(0,cv.jsx)(jt,{sx:nRo,disabled:t,onClick:o,children:t?(0,cv.jsx)(Ao,{size:24}):(0,cv.jsx)(HU,{})})})}),(0,cv.jsx)(Tl,{error:r,onClose:n})]})}var czr=k(re(),1);var szr=k(re(),1);function lzr(e){let t=Rn().palette.primary.main;Ki(fo("focusRepoPicker").matches,(0,szr.useCallback)(()=>Nc({locate:()=>e.current?.querySelector("button")??null,focus:r=>r.focus()},t),[e,t]))}var ine=k(P(),1),oRo={width:240,ml:2};function uzr({repos:e,selected:t,onSelect:r}){let n=(0,czr.useRef)(null);lzr(n);let{chords:o}=fo("focusRepoPicker");return(0,ine.jsx)(G,{ref:n,sx:oRo,children:(0,ine.jsx)(nSe,{label:t?fx(t):"Select repo...",tooltip:(0,ine.jsx)(Td,{label:"Repo",chords:o}),typeToOpen:!0,children:(i,a)=>(0,ine.jsx)(gOr,{repos:e,selected:t,onSelect:r,close:i,initialFilter:a})})})}var xzr=k(re(),1);var ane=k(re(),1);function V_e(e){let[t,r]=(0,ane.useState)([]),[n,o]=(0,ane.useState)(!0),i=br();return(0,ane.useEffect)(()=>{if(!e){r([]),o(!1);return}let a=!1;return o(!0),tr(Jr(`/api/pr-list?cwd=${encodeURIComponent(e)}`,i)).then(s=>s.json()).then(s=>{a||(r(Array.isArray(s?.prs)?s.prs:[]),o(!1))}).catch(s=>{Pr(s,"open PRs"),!a&&(r([]),o(!1))}),()=>{a=!0}},[e,i]),{prs:t,loading:n}}var Hit=k(P(),1);function Wit({text:e}){return(0,Hit.jsx)(G,{sx:{p:1.5},children:(0,Hit.jsx)(_e,{sx:{fontSize:13,color:"text.secondary"},children:e})})}var GI=k(P(),1);function dzr({pr:e,highlighted:t,onHover:r,onPick:n}){let o=Jke(t);return(0,GI.jsx)(Qr,{ref:o,selected:t,onMouseDown:i=>i.preventDefault(),onMouseEnter:r,onClick:()=>n(e),sx:{alignItems:"flex-start",py:.75,whiteSpace:"normal"},children:(0,GI.jsxs)(_t,{spacing:.25,sx:{minWidth:0},children:[(0,GI.jsxs)(_e,{sx:{fontSize:13,lineHeight:1.3,fontWeight:500},children:[e.title,e.isDraft&&(0,GI.jsx)(Zn,{label:"Draft",size:"small",variant:"outlined",sx:{ml:.75,height:18,fontSize:10,verticalAlign:"middle"}})]}),(0,GI.jsxs)(_e,{sx:{fontSize:11,color:"text.secondary"},children:["#",e.number," \xB7 ",e.author," \xB7 ",zo(e.createdAt)]})]})})}var Git=k(P(),1);function fzr({prs:e,highlight:t,onHighlight:r,onPick:n}){return(0,Git.jsx)(Ym,{dense:!0,disablePadding:!0,sx:{maxHeight:200,overflowY:"auto"},children:e.map((o,i)=>(0,Git.jsx)(dzr,{pr:o,highlighted:i===t,onHover:()=>r(i),onPick:n},o.number))})}var hzr=k(re(),1);function pzr(e,t){let r=t.trim().toLowerCase();if(!r)return e;let n=r.replace(/^#/,"");return e.filter(o=>o.title.toLowerCase().includes(r)||o.author.toLowerCase().includes(r)||n!==""&&String(o.number).includes(n))}function mzr(e,t,r){let[n,o]=(0,hzr.useState)(""),i=pzr(e,n),{highlight:a,setHighlight:s,onKeyDown:l}=b5(i,n,t,r);return{filter:n,setFilter:o,filtered:i,highlight:a,setHighlight:s,onKeyDown:l,select:d=>{t(d),r()}}}var O5=k(P(),1),gzr={...uH,left:"auto",width:320,maxHeight:"none",overflowY:"visible"};function yzr({cwd:e,onPick:t,close:r}){let{prs:n,loading:o}=V_e(e),i=mzr(n,t,r);return o||n.length===0?(0,O5.jsx)(dn,{elevation:4,sx:gzr,children:(0,O5.jsx)(Wit,{text:o?"Loading open PRs\u2026":"No open PRs"})}):(0,O5.jsxs)(dn,{elevation:4,sx:gzr,children:[(0,O5.jsx)(rk,{autoFocus:!0,value:i.filter,onChange:i.setFilter,onKeyDown:i.onKeyDown,placeholder:"Filter PRs..."}),i.filtered.length===0?(0,O5.jsx)(Wit,{text:"No PRs match"}):(0,O5.jsx)(fzr,{prs:i.filtered,highlight:i.highlight,onHighlight:i.setHighlight,onPick:i.select})]})}var bzr=k(P(),1);function vzr({cwd:e,onPick:t,close:r}){return(0,bzr.jsx)(yzr,{cwd:e,onPick:t,close:r})}var B5=k(P(),1);function Szr({cwd:e,disabled:t,onSelect:r}){let{prs:n,loading:o}=V_e(e),[i,a]=(0,xzr.useState)(null);return o||n.length===0?null:(0,B5.jsxs)(B5.Fragment,{children:[(0,B5.jsx)(nSe,{label:"prs",disabled:t,children:s=>(0,B5.jsx)(vzr,{cwd:e,onPick:a,close:s})}),i&&(0,B5.jsx)(N2e,{pr:i,onSelect:s=>{r(i,s),a(null)},onCancel:()=>a(null)})]})}var wzr=k(P(),1);function Tzr({onStartRun:e,cwd:t}){let r=eSe(t);return!t||r.length===0?null:(0,wzr.jsx)(Q2e,{runs:r,onSelect:n=>e(n,t)})}var sne=k(P(),1);function Czr({onCreateAssist:e,onStartRun:t}){let{selectedCwd:r,selectedNode:n}=eo();return(0,sne.jsxs)(_t,{direction:"row",spacing:.5,sx:{alignItems:"center","&:not(:empty)":{ml:1.5}},children:[(0,sne.jsx)(Szr,{cwd:r,disabled:!r,onSelect:(o,i)=>e([...i,String(o.number)],r,{...o4(o),node:n})}),(0,sne.jsx)(Tzr,{onStartRun:(o,i)=>t(o,i,void 0,void 0,n),cwd:r})]})}var Em=k(P(),1),iRo={minHeight:48,pl:1,pr:14};function kzr({socket:e,selection:t}){let{collapsed:r,onToggleCollapsed:n}=hk();return(0,Em.jsxs)(rR,{variant:"dense",disableGutters:!0,sx:iRo,children:[r&&(0,Em.jsx)(Lce,{collapsed:r,onToggleCollapsed:n}),(0,Em.jsx)(azr,{reconnecting:e.reconnecting}),(0,Em.jsx)(tzr,{cwd:t.selectedCwd}),(0,Em.jsx)(GFr,{}),(0,Em.jsx)(uzr,{repos:t.repos,selected:t.selectedCwd,onSelect:t.setSelectedCwd}),(0,Em.jsxs)(G,{sx:{display:"flex",alignItems:"center",ml:1},children:[(0,Em.jsx)(lSe,{cwd:t.selectedCwd}),(0,Em.jsx)(izr,{cwd:t.selectedCwd}),(0,Em.jsx)(nzr,{})]}),(0,Em.jsx)(Czr,{onCreateAssist:e.createAssistSession,onStartRun:e.startRun})]})}var q_e=k(re(),1);function _zr(){let[e,t]=(0,q_e.useState)(null);return(0,q_e.useEffect)(()=>{let r=!1;return(async()=>{try{let o=await(await tr("/api/health")).json();!r&&typeof o?.nodeName=="string"&&t(o.nodeName)}catch(n){Pr(n,"node name")}})(),()=>{r=!0}},[]),e}var Rzr=k(P(),1),aRo={lineHeight:"32px",bgcolor:"transparent"};function Ezr(){let e=_zr();return e?(0,Rzr.jsx)(U5e,{sx:aRo,children:e}):null}var Azr=k(P(),1),Pzr=nt((0,Azr.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 Lzr=k(P(),1),Izr=nt((0,Lzr.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 Mzr=k(P(),1),Dzr=nt((0,Mzr.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 Nzr=k(P(),1),Ozr=nt((0,Nzr.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 Vit=k(P(),1);function Bzr({mode:e}){return e==="dark"?(0,Vit.jsx)(Ozr,{fontSize:"small"}):(0,Vit.jsx)(Dzr,{fontSize:"small"})}var $zr=k(P(),1),Fzr=nt((0,$zr.jsx)("path",{d:"M15.5 1h-8C6.12 1 5 2.12 5 3.5v17C5 21.88 6.12 23 7.5 23h8c1.38 0 2.5-1.12 2.5-2.5v-17C18 2.12 16.88 1 15.5 1m-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m4.5-4H7V4h9z"}),"PhoneIphone");var bG=k(P(),1);function zzr({onClose:e}){let t=nn();return(0,bG.jsxs)(Qr,{onClick:()=>{e(),t("/connect-mobile")},children:[(0,bG.jsx)(Bv,{children:(0,bG.jsx)(Fzr,{fontSize:"small"})}),(0,bG.jsx)(rp,{children:"Connect mobile"})]})}var Uzr=k(P(),1),Hzr=nt((0,Uzr.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 xG=k(P(),1);function Wzr(){let e=W2e();return(0,xG.jsxs)(Qr,{onClick:()=>M5t(!e),children:[(0,xG.jsx)(Bv,{children:(0,xG.jsx)(Hzr,{fontSize:"small"})}),(0,xG.jsx)(rp,{children:e?"Hide render HUD":"Show render HUD"})]})}var dl=k(P(),1);function Gzr({mode:e,restartLabel:t,updateLabel:r,onToggleColorMode:n,onShowShortcuts:o,onConnectMobile:i,onRestart:a,onUpdate:s}){return[(0,dl.jsxs)(Qr,{onClick:n,children:[(0,dl.jsx)(Bv,{children:(0,dl.jsx)(Bzr,{mode:e})}),(0,dl.jsx)(rp,{children:"Toggle dark mode"})]},"color-mode"),(0,dl.jsx)(Wzr,{},"render-hud"),(0,dl.jsxs)(Qr,{onClick:o,children:[(0,dl.jsx)(Bv,{children:(0,dl.jsx)(Pzr,{fontSize:"small"})}),(0,dl.jsx)(rp,{children:"Keyboard shortcuts"})]},"shortcuts"),(0,dl.jsx)(zzr,{onClose:i},"connect-mobile"),(0,dl.jsx)(ao,{},"restart-divider"),(0,dl.jsxs)(Qr,{onClick:a,children:[(0,dl.jsx)(Bv,{children:(0,dl.jsx)(u8,{fontSize:"small"})}),(0,dl.jsx)(rp,{children:t})]},"restart"),(0,dl.jsxs)(Qr,{onClick:s,children:[(0,dl.jsx)(Bv,{children:(0,dl.jsx)(Izr,{fontSize:"small"})}),(0,dl.jsx)(rp,{children:r})]},"update")]}var Vzr=k(re(),1);var jzr=k(P(),1);function qzr({peer:e,onRestart:t,onClose:r}){let[n,o]=(0,Vzr.useState)(!1);return(0,jzr.jsx)(Ho,{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:()=>{o(!0),t(e).finally(r)},onCancel:r})}function Yzr(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 sRo=Object.keys(n8);function Kzr(){let e=o8();return Yzr(sRo.map(t=>sk(t,e)))}var Rm=k(P(),1),lRo={display:"flex",alignItems:"center",justifyContent:"space-between",pr:1},cRo={display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,py:.5};function Xzr({onClose:e}){let t=Kzr();return(0,Rm.jsxs)(Ac,{open:!0,onClose:e,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"shortcuts-dialog-title",children:[(0,Rm.jsxs)(hd,{id:"shortcuts-dialog-title",sx:lRo,children:["Keyboard shortcuts",(0,Rm.jsx)(jt,{size:"small","aria-label":"Close",onClick:e,children:(0,Rm.jsx)(Uo,{fontSize:"small"})})]}),(0,Rm.jsx)(pd,{dividers:!0,children:t.map(r=>(0,Rm.jsxs)(G,{component:"section",sx:{mb:1.5},children:[(0,Rm.jsx)(_e,{variant:"overline",color:"text.secondary",children:r.name}),r.shortcuts.map(n=>(0,Rm.jsxs)(G,{sx:cRo,children:[(0,Rm.jsx)(_e,{variant:"body2",children:n.label}),(0,Rm.jsx)(_t,{direction:"row",spacing:.5,children:(0,Rm.jsx)(cce,{chords:n.chords})})]},n.label))]},r.name))})]})}var VI=k(P(),1);function Zzr({reconnecting:e,onClose:t}){let{pending:r,error:n,clearError:o,restart:i}=p5(zW.target,e);return(0,VI.jsxs)(VI.Fragment,{children:[(0,VI.jsx)(Ho,{title:zW.label,message:zW.message,confirmLabel:"Restart",busy:r,autoFocusConfirm:!0,onConfirm:()=>{i()},onCancel:t}),(0,VI.jsx)(Tl,{error:n,onClose:o})]})}var Jzr=k(P(),1);function uRo(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 Qzr({peer:e,onConfirm:t,onClose:r}){return(0,Jzr.jsx)(Ho,{...uRo(e),confirmLabel:"Update",onConfirm:()=>{t(),r()},onCancel:r})}var uv=k(re(),1);async function dRo(e){try{let t=await tr(`/api/node-doctor?link=${encodeURIComponent(e)}`);return t.ok?(await t.json()).hop:null}catch(t){return Pr(t,"node doctor"),null}}async function eUr(e,t){let r=await dRo(e);if(!r)return t;let n=r.remediation?` \u2014 ${r.remediation}`:"";return`${t}: ${r.hop} hop failed: ${r.error}${n}`}var Lw=k(re(),1);function tUr(e){let{nodes:t}=Sl(),[r,n]=(0,Lw.useState)(null),o=(0,Lw.useRef)(!1),i=r?t?.links.find(l=>l.name===r.peer):void 0;(0,Lw.useEffect)(()=>{if(!(!r||!i)){if(i.state!=="connected"){o.current=!0;return}o.current&&(n(null),e(r.describe(r.peer,i.peerVersion)))}},[r,i,e]);let a=(0,Lw.useCallback)((l,u)=>{o.current=!1,n({peer:l,describe:u})},[]),s=(0,Lw.useCallback)(()=>n(null),[]);return{watch:a,stop:s}}var fRo=9e4;function j_e(){let[e,t]=(0,uv.useState)(null),[r,n]=(0,uv.useState)(null),o=(0,uv.useRef)(void 0),i=(0,uv.useCallback)(d=>{clearTimeout(o.current),t(d)},[]),{watch:a,stop:s}=tUr(i);(0,uv.useEffect)(()=>()=>clearTimeout(o.current),[]);let l=(0,uv.useCallback)(async(d,f)=>{n(await eUr(d,f))},[]);return{requestThenAwait:(0,uv.useCallback)(async(d,f,p,h)=>{let m;try{m=await p()}catch(g){Pr(g,`${f} ${d}`)}return m?.ok?(a(d,h),clearTimeout(o.current),o.current=setTimeout(()=>{s(),l(d,`${d} did not come back`)},fRo),!0):(await l(d,`${f} failed (${await d5(m)})`),!1)},[l,a,s]),back:e,clearBack:()=>t(null),error:r,clearError:()=>n(null)}}var pRo=(e,t)=>t?`${e} is back (v${t})`:`${e} is back`;function rUr(){let{requestThenAwait:e,...t}=j_e();return{restart:n=>e(n,`Restart ${n}`,()=>f5("both",n),pRo),...t}}var lne=k(re(),1);function Y_e(e){return tr(Jr("/api/self-update",e),{method:"POST",timeoutMs:66e4})}var dv=k(re(),1);function nUr(e){return e.commandType==="assist"&&e.assistArgs?.[0]==="update"&&e.status==="done"}function K_e(e,t,r){let[n,o]=(0,dv.useState)(!1),[i,a]=(0,dv.useState)(!1),s=(0,dv.useRef)(!1),l=(0,dv.useRef)(e);l.current=e;let u=(0,dv.useRef)(new Set),d=(0,dv.useCallback)(()=>{s.current=!1,a(!1),u.current=new Set(l.current.filter(nUr).map(f=>f.id)),o(!0)},[]);return(0,dv.useEffect)(()=>{if(!n||i)return;if(t){s.current=!0;return}if(!s.current)return;e.some(p=>nUr(p)&&p.node===r&&!u.current.has(p.id))&&a(!0)},[n,i,t,e,r]),{arm:d,completed:i}}var oUr=(e,t)=>t?`${e} updated to v${t}`:`${e} updated`;function iUr(e){let{nodes:t}=Sl(),{launchAssist:r}=Hl(),{requestThenAwait:n,...o}=j_e(),[i,a]=(0,lne.useState)(null),[s,l]=(0,lne.useState)(),u=m=>t?.links.find(g=>g.name===m)?.state,{arm:d,completed:f}=K_e(e,u(s)!=="connected",s);(0,lne.useEffect)(()=>{!f||!s||(l(void 0),n(s,`Restart ${s}'s web server`,()=>f5("webserver",s),oUr))},[f,s,n]);let p=async m=>{a(`Updating assist on ${m}\u2026`),await n(m,`Update ${m}`,()=>Y_e(m),oUr),a(null)};return{update:m=>{if(u(m)!=="connected"){p(m);return}l(m),d(),r(["update"],void 0,{node:m})},progress:i,...o}}var fv=k(P(),1);function aUr({dialog:e,peer:t,sessions:r,reconnecting:n,onClose:o}){let{launchAssist:i,armUpdateReload:a}=Hl(),s=rUr(),l=iUr(r);return(0,fv.jsxs)(fv.Fragment,{children:[e==="shortcuts"&&(0,fv.jsx)(Xzr,{onClose:o}),e==="restart"&&t&&(0,fv.jsx)(qzr,{peer:t,onRestart:s.restart,onClose:o}),e==="restart"&&!t&&(0,fv.jsx)(Zzr,{reconnecting:n,onClose:o}),e==="update"&&(0,fv.jsx)(Qzr,{peer:t,onConfirm:()=>{if(t){l.update(t);return}a(),i(["update"])},onClose:o}),(0,fv.jsx)(bre,{notices:s}),(0,fv.jsx)(bre,{notices:l})]})}var sUr=k(P(),1),lUr=nt((0,sUr.jsx)("path",{d:"M11 18h2v-2h-2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4"}),"HelpOutlineOutlined");var X_e=k(P(),1),hRo="https://staffordwilliams.com/assist";function cUr(){return(0,X_e.jsx)(ar,{title:"Help",children:(0,X_e.jsx)(jt,{component:"a",href:hRo,target:"_blank",rel:"noopener noreferrer","aria-label":"Help",size:"small",sx:{color:"inherit"},children:(0,X_e.jsx)(lUr,{fontSize:"small"})})})}var uUr=k(P(),1),dUr=nt((0,uUr.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 fUr=k(re(),1);var cne=k(P(),1);function pUr(){let e=nn(),t=(0,fUr.useCallback)(()=>e("/config"),[e]),{matches:r,chords:n}=fo("openConfig");return Ki(r,t),(0,cne.jsx)(ar,{describeChild:!0,title:(0,cne.jsx)(Td,{label:"Config",chords:n}),children:(0,cne.jsx)(jt,{size:"small",sx:{color:"inherit"},"aria-label":"Config",onClick:t,children:(0,cne.jsx)(dUr,{fontSize:"small"})})})}var hUr=k(P(),1),mUr=nt((0,hUr.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var Z_e=k(re(),1);var une=k(P(),1);function gUr({open:e,onOpen:t}){let r=(0,Z_e.useRef)(null),{matches:n,chords:o}=fo("openMenu");return Ki(n,(0,Z_e.useCallback)(()=>{r.current&&t(r.current)},[t])),(0,une.jsx)(ar,{describeChild:!0,title:(0,une.jsx)(Td,{label:"Menu",chords:o}),children:(0,une.jsx)(jt,{ref:r,onClick:i=>t(i.currentTarget),size:"small",sx:{color:"inherit"},"aria-label":"Open menu","aria-haspopup":"true","aria-expanded":e?"true":void 0,children:(0,une.jsx)(mUr,{fontSize:"small"})})})}var SG=k(P(),1);function yUr({open:e,onOpen:t}){return(0,SG.jsxs)(G,{sx:{position:"fixed",top:8,right:16,zIndex:r=>r.zIndex.drawer+2,display:"flex",alignItems:"center",gap:.5,color:r=>r.tokens.color.appBar?.text??r.palette.primary.contrastText},children:[(0,SG.jsx)(cUr,{}),(0,SG.jsx)(pUr,{}),(0,SG.jsx)(gUr,{open:e,onOpen:t})]})}var qI=k(re(),1);var bUr=k(re(),1);var vUr=!0,mRo=new Set(["openMenu","cycleCards"]),gRo=Object.keys(n8).filter(e=>!mRo.has(e));function xUr(e,t){let r=o8();(0,bUr.useEffect)(()=>{if(!e)return;let n=o=>{gRo.some(i=>sk(i,r).matches(o))&&t()};return globalThis.addEventListener("keydown",n,vUr),()=>globalThis.removeEventListener("keydown",n,vUr)},[e,t,r])}function SUr(){let[e,t]=(0,qI.useState)(null),[r,n]=(0,qI.useState)(!0),o=!!e,i=(0,qI.useCallback)(()=>t(null),[]),a=(0,qI.useCallback)(s=>{n(!0),t(s)},[]);return xUr(o,(0,qI.useCallback)(()=>{n(!1),t(null)},[])),{anchorEl:e,open:o,close:i,openAt:a,restoreFocus:r}}var dne=k(re(),1);function TUr(e){Ki(fo("shortcutsSheet").matches,e)}function wUr(){let[e,t]=(0,dne.useState)(null);TUr((0,dne.useCallback)(()=>t("shortcuts"),[]));let r=(0,dne.useCallback)(()=>t(null),[]);return{dialog:e,showDialog:t,closeDialog:r}}function CUr(){let{nodes:e,selected:t}=Sl();return e&&t&&t!==e.local?t:void 0}function kUr(e){return{restartLabel:e?`Restart ${e}`:zW.label,updateLabel:e?`Update assist on ${e}`:"Update assist"}}var Iw=k(P(),1);function _Ur({mode:e,toggle:t,sessions:r,reconnecting:n}){let{anchorEl:o,open:i,close:a,openAt:s,restoreFocus:l}=SUr(),{dialog:u,showDialog:d,closeDialog:f}=wUr(),p=CUr(),h=m=>()=>{a(),d(m)};return(0,Iw.jsxs)(Iw.Fragment,{children:[(0,Iw.jsx)(yUr,{open:i,onOpen:s}),(0,Iw.jsxs)(ks,{anchorEl:o,open:i,onClose:a,disableRestoreFocus:!l,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,Iw.jsx)(Ezr,{}),Gzr({mode:e,...kUr(p),onToggleColorMode:()=>{t(),a()},onShowShortcuts:h("shortcuts"),onConnectMobile:a,onRestart:h("restart"),onUpdate:h("update")})]}),(0,Iw.jsx)(aUr,{dialog:u,peer:p,sessions:r,reconnecting:n,onClose:f})]})}var AUr=k(re(),1);var RUr=k(P(),1);function EUr({conflict:e,onConfirm:t,onCancel:r}){let{name:n,cwd:o,port:i,group:a}=e.existing,s=Ka(o),l=i?` on port ${i}`:"",u=s?` in ${s}`:"",d=a?`, holding the ${a} server slot`:"";return(0,RUr.jsx)(Ho,{title:a?`Replace the ${a} server?`:"Replace running server?",message:`"${n}" is already serving${l}${u}${d}. Replace it \u2014 stop the running server and start this one?`,confirmLabel:"Replace",confirmColor:"error",onConfirm:t,onCancel:r})}var Q_e=k(P(),1);function PUr({socket:e,children:t}){let{serverConflict:r,clearServerConflict:n,retrySession:o,stopSession:i,startRun:a,discardSession:s}=e,l=(0,AUr.useMemo)(()=>({onStop:i,onStart:a,onDiscard:s}),[i,a,s]),u=()=>{r&&(r.runName?a(r.runName,r.cwd,!0,r.launchedFrom,r.node):r.sessionId&&o(r.sessionId,!0),n())};return(0,Q_e.jsxs)(N6e.Provider,{value:l,children:[t,r&&(0,Q_e.jsx)(EUr,{conflict:r,onConfirm:u,onCancel:n})]})}var LUr=new Map;function IUr(e,t){if(!gde())return;let r=LUr.get(e);if(LUr.set(e,t),!!r)for(let[n,o]of Object.entries(t))Object.is(o,r[n])||l1(`\u0394 ${e}.${n}`)}var eEe=k(re(),1);function MUr(e,t,r){if(!t)return null;let n=e[t];if(!n)return null;let o=r.find(i=>i.id===n);return!o||xl(o)!==t?null:n}function wx(e,t,r){if(e)return t.find(n=>n.id===e)??r.find(n=>n.sessionId===e)}function J_e(){let{pathname:e}=mi();return e.startsWith("/backlog")||e.startsWith("/usage")}function DUr({selectedCwd:e,selectedCardId:t,sessions:r,history:n,activeByRepo:o,onSelect:i}){let a=wx(t,r,n),s=a&&xl(a),l=!!(s&&s===e),u=MUr(o,e,r),d=(0,eEe.useRef)(t),f=J_e();(0,eEe.useEffect)(()=>{let p=d.current!==t&&!!s;d.current=t,!(f||p||l||!u)&&i(u)},[t,s,l,u,i,f])}var nEe=k(re(),1);function NUr(e,t,r,n){return wx(e,t,r)?.cwd||n}function OUr(e,t,r,n){let o=NUr(e,t,r,n.cwd),i=wx(e,t,r);return{cwd:o,node:i?.cwd?i.node:n.node}}var qit=k(re(),1);function BUr(e,t,r){let{cwd:n,node:o,origin:i}=r,a=(0,qit.useCallback)((l,u)=>{let d=oh(u,t),f=Wre(e,l);return f?f.clones[d]:d===(l===n?o:Xf)?l:void 0},[e,t,n,o]),s=(0,qit.useCallback)(l=>Wre(e,l)?.origin??(l===n?i:void 0),[e,n,i]);return{cloneOn:a,originOf:s}}var tEe=k(re(),1);function $Ur(e,t,r,n){let o=(0,tEe.useRef)(e);(0,tEe.useEffect)(()=>{if(o.current===e)return;o.current=e;let i=Wre(t,r)?.clones[e];i&&n(i,e)},[e,t,r,n])}var TG=k(re(),1);function FUr(e,t,r){if(t.node!==void 0)return t.node;let n=new Set(e.flatMap(o=>Object.entries(o.clones).filter(([,i])=>i===t.cwd).map(([i])=>i)));return n.has(r)?r:n.size===0||n.has(Xf)?Xf:[...n][0]}function zUr(e,t,r,n){let[o,i]=(0,TG.useState)({cwd:e}),a=(0,TG.useCallback)((l,u,d)=>i({cwd:l,node:u,origin:d}),[]);(0,TG.useEffect)(()=>{e&&!o.cwd&&i({cwd:e})},[e,o.cwd]);let s=FUr(t,{cwd:o.cwd,node:o.node===void 0?void 0:oh(o.node,n)},r);return{selectedCwd:o.cwd,selectedNode:s||void 0,selectedPick:{cwd:o.cwd,node:s,origin:o.origin},setSelectedCwd:a}}var UUr=k(re(),1);function rEe(e,t,r){let n=wx(e,t,r);return n&&xl(n)}function HUr(e,t,r,n){let o=rEe(e,t,r),i=wx(e,t,r),a=i?.node??Xf,s=i?.repoGroup?.origin;(0,UUr.useEffect)(()=>{o&&n(o,a,s)},[o,a,s,n])}function WUr(e,t,r,n,o){let i=o.nodes?.local,a=oh(o.selected,i),s=(0,nEe.useMemo)(()=>S5(e,t),[e,t]),{selectedCwd:l,selectedNode:u,selectedPick:d,setSelectedCwd:f}=zUr(e,s,a,i);HUr(r,n,t,f),$Ur(a,s,l,f);let{cloneOn:p,originOf:h}=BUr(s,i,d),m=(0,nEe.useMemo)(()=>s.map(v=>ZOr(v,a)),[s,a]),{cwd:g,node:y}=OUr(r,n,t,{cwd:l,node:u});return(0,nEe.useMemo)(()=>({repos:m,selectedCwd:l,selectedNode:u,worktreeCwd:g,worktreeNode:y,setSelectedCwd:f,cloneOn:p,originOf:h}),[m,l,u,g,y,f,p,h])}var iEe=k(re(),1);var $5=k(re(),1);var GUr=k(re(),1),oEe="assist:reloaded-after-update";function VUr(e){(0,GUr.useEffect)(()=>{globalThis.sessionStorage?.getItem(oEe)&&(globalThis.sessionStorage.removeItem(oEe),e({message:"Reloaded after updating assist",sessionId:null}))},[e])}function qUr(e,t,r,n){let{arm:o,completed:i}=K_e(e,t),a=(0,$5.useRef)(!1),s=(0,$5.useCallback)(()=>{globalThis.sessionStorage?.setItem(oEe,"1")},[]),{error:l,restart:u}=p5("webserver",t,s);return VUr(r),(0,$5.useEffect)(()=>{l&&n(l)},[l,n]),(0,$5.useEffect)(()=>{!i||a.current||(a.current=!0,u())},[i,u]),{armUpdateReload:(0,$5.useCallback)(()=>{a.current=!1,o()},[o])}}function jUr(e){let{armUpdateReload:t}=qUr(e.sessions,e.reconnecting,e.setSuccess,e.setError),r=e1(e.selectSession),n=(0,iEe.useMemo)(()=>({launchAssist:e.createAssistSession,launchAgentInStream:e.createSessionInStream,resumeSession:e.resumeSession,armUpdateReload:t,activateSession:r,sendInput:e.sendInput}),[e.createAssistSession,e.createSessionInStream,e.resumeSession,t,r,e.sendInput]),o=nn(),i=(0,iEe.useCallback)(a=>{e.selectSession(a),o("/sessions"),e.clearSuccess()},[o,e.selectSession,e.clearSuccess]);return{launch:n,viewLaunchedSession:i}}var YUr=k(re(),1);function KUr(e,t,r,n){let o=rEe(e,t,r);(0,YUr.useEffect)(()=>{e&&o&&n({type:"set-active",cwd:o,sessionId:e})},[e,o,n])}var aEe=k(re(),1);function XUr(e,t){let r=(0,aEe.useRef)(new Map);(0,aEe.useEffect)(()=>{let n=new Set;for(let{id:o,status:i}of e)n.add(o),r.current.get(o)!==i&&(r.current.set(o,i),console.debug(`[sessions] render session ${o} status=${i}`),t({type:"ui-status",sessionId:o,status:i}));for(let o of r.current.keys())n.has(o)||r.current.delete(o)},[e,t])}var wG=k(re(),1),ZUr="assist.sessions.node";function yRo(){try{return localStorage.getItem(ZUr)}catch{return null}}function vRo(e){try{localStorage.setItem(ZUr,e)}catch{}}function QUr(e){let[t,r]=(0,wG.useState)(yRo),n=(0,wG.useCallback)(o=>{r(o),vRo(o)},[]);return(0,wG.useMemo)(()=>{let o=e?[e.local,...e.links.map(i=>i.name)]:[];return{nodes:e,names:o,visible:o.length>1,selected:t&&o.includes(t)?t:e?.local,select:n}},[e,t,n])}var eHr=k(re(),1);function JUr(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 tHr(e,t){return(0,eHr.useCallback)(r=>{let n=e.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify(r));let o=JUr(r);o&&t(o)},[e,t])}var k0=k(re(),1);function sEe(e,t,r,n,o){e({type:"create",prompt:r||void 0,cwd:n,...t,...o?{node:o}:{}})}function rHr(e){return(t,r,n)=>sEe(e,{design:!0},t,r,n)}function nHr(e){return(t,r,n,o)=>sEe(e,{harness:t},r,n,o)}function oHr(e){return(t,r,n)=>sEe(e,{auto:!0},t,r,n)}function iHr(e){return(t,r,n)=>e({type:"create-assist",assistArgs:t,cwd:r,...n})}function aHr(e){return(t,r,n,o,i)=>e({type:"resume",sessionId:t,cwd:r,name:n,harness:o,node:i})}function sHr(e,t){return(r,n)=>{t.delete(r),e({type:"retry",sessionId:r,replace:n})}}function lHr(e,t){return r=>{t.delete(r),e({type:"restart",sessionId:r})}}function cHr(e,t){return r=>{e({type:"dismiss",sessionId:r}),t.delete(r)}}function uHr(e,t){return r=>{e({type:"discard",sessionId:r}),t.delete(r)}}function dHr(e){return t=>e({type:"stop",sessionId:t})}function fHr(e){return(t,r,n)=>e({type:"transfer",sessionId:t,target:r,cwd:n})}function pHr(e){return t=>e({type:"cancel-transfer",sessionId:t})}function hHr(e){return(t,r,n,o,i)=>e({type:"create-run",runName:t,cwd:r,replace:n,launchedFrom:o,node:i})}function mHr(e){return(t,r)=>e({type:"set-autoapprove",sessionId:t,enabled:r})}function gHr(e){return(t,r)=>e({type:"set-autoadvance",sessionId:t,enabled:r})}function yHr(e){return(t,r)=>e({type:"set-starred",sessionId:t,starred:r})}function vHr(e){return(t,r)=>e({type:"input",sessionId:t,data:r,viewerId:gI})}function bHr(e){return(t,r,n,o)=>e({type:"resize",sessionId:t,cols:r,rows:n,viewerId:gI,claim:o==="claim",refresh:o==="refresh"})}function xHr(e){return(t,r,n,o)=>e({type:"pr-decision",sessionId:t,requestId:r,decision:n,...o})}var jI=k(re(),1);function SHr(e){return(t,r,n)=>e({type:"create",prompt:r||void 0,cwd:n,joinSessionId:t,auto:!0})}function THr(e){return{createSession:(0,jI.useMemo)(()=>oHr(e),[e]),createSessionInStream:(0,jI.useMemo)(()=>SHr(e),[e]),createDesignSession:(0,jI.useMemo)(()=>rHr(e),[e]),createHarnessSession:(0,jI.useMemo)(()=>nHr(e),[e]),createAssistSession:(0,jI.useMemo)(()=>iHr(e),[e]),resumeSession:(0,jI.useMemo)(()=>aHr(e),[e])}}var fne=k(re(),1);function wHr(e,t){let r=(0,fne.useCallback)((a,s)=>{sHr(e,t.current)(a,s)},[e,t]),n=(0,fne.useCallback)(a=>{lHr(e,t.current)(a)},[e,t]),o=(0,fne.useCallback)(a=>{cHr(e,t.current)(a)},[e,t]),i=(0,fne.useCallback)(a=>{uHr(e,t.current)(a)},[e,t]);return{retrySession:r,restartSession:n,dismissSession:o,discardSession:i}}function CHr(e,t,r){return(n,o)=>{let i=t.get(n);return i&&(o(i),e({type:"snapshot",sessionId:n})),r.set(n,o),()=>r.delete(n)}}function kHr(e,t,r){let n={...THr(e),sendInput:(0,k0.useMemo)(()=>vHr(e),[e]),sendResize:(0,k0.useMemo)(()=>bHr(e),[e]),sendPrDecision:(0,k0.useMemo)(()=>xHr(e),[e]),setAutoApprove:(0,k0.useMemo)(()=>mHr(e),[e]),setAutoAdvance:(0,k0.useMemo)(()=>gHr(e),[e]),setStarred:(0,k0.useMemo)(()=>yHr(e),[e]),stopSession:(0,k0.useMemo)(()=>dHr(e),[e]),startRun:(0,k0.useMemo)(()=>hHr(e),[e]),transferSession:(0,k0.useMemo)(()=>fHr(e),[e]),cancelTransfer:(0,k0.useMemo)(()=>pHr(e),[e])},o=(0,k0.useMemo)(()=>CHr(e,t.current,r.current),[e,t,r]);return{...n,...wHr(e,t),onOutput:o}}var pne=k(re(),1);function _Hr(e,t,r){let n=(0,pne.useCallback)(s=>{r(s),e({type:"fetch-transcript",sessionId:s})},[e,r]),o=(0,pne.useCallback)(s=>e({type:"fetch-user-messages",sessionId:s}),[e]),i=(0,pne.useCallback)(()=>{r(null)},[r]),a=(0,pne.useCallback)(s=>{r(null),t(s)},[t,r]);return{viewTranscript:n,fetchUserMessages:o,clearTranscript:i,selectSession:a}}var dEe=k(re(),1);function EHr(e,t){let r=new Set(t.map(o=>o.id)),n=null;for(let o of Object.values(e))r.has(o)&&(n=o);return n}var CG=k(re(),1);function RHr(){let[e,t]=(0,CG.useState)(null),r=(0,CG.useRef)(e);r.current=e;let n=(0,CG.useCallback)(()=>r.current,[]);return{activeId:e,setActiveId:t,getActiveId:n}}var PHr=k(re(),1);function AHr(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 LHr(e,t,r){let n=J_e();(0,PHr.useEffect)(()=>{if(n){t(null);return}t(o=>AHr(e,o,r))},[e,t,r,n])}var lEe=k(re(),1);function IHr(){let[e,t]=(0,lEe.useState)({}),[r,n]=(0,lEe.useState)(null),[o,i]=(0,lEe.useState)(null);return{activeByRepo:e,setActiveByRepo:t,daemonVersion:r,setDaemonVersion:n,nodes:o,setNodes:i}}var pv=k(re(),1);function MHr(e,t){for(let r of t)clearTimeout(e.get(r)),e.delete(r)}function DHr(e,t){let r=new Set(t.map(n=>n.id));return[...e.keys()].filter(n=>!r.has(n))}function NHr(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 OHr(e,t){let r=[];for(let n of t){let o=e.get(n.id);o!==void 0&&o!==n.startedAt&&r.push(n.id)}return r}function BHr(e,t){return t.filter(r=>r.commandType==="run"&&e.get(r.id)!==r.startedAt).map(r=>r.id)}var bRo=1500;function $Hr(){let[e,t]=(0,pv.useState)(new Set),r=(0,pv.useRef)(new Map),n=(0,pv.useRef)(new Map),o=(0,pv.useCallback)(s=>{t(l=>l.has(s)?l:new Set(l).add(s))},[]),i=(0,pv.useCallback)(s=>{let l=n.current;for(let u of s)clearTimeout(l.get(u)),l.set(u,setTimeout(()=>{l.delete(u),o(u)},bRo))},[o]);(0,pv.useEffect)(()=>{let s=n.current;return()=>{for(let l of s.values())clearTimeout(l)}},[]);let a=(0,pv.useCallback)(s=>{let l=DHr(r.current,s),u=[...OHr(r.current,s),...l],d=BHr(r.current,s);r.current=new Map(s.map(f=>[f.id,f.startedAt])),MHr(n.current,l),u.length&&t(f=>NHr(f,u)),i(d)},[i]);return{initialized:e,markInitialized:o,syncSessions:a}}var F5=k(re(),1);function FHr(){let[e,t]=(0,F5.useState)(null),[r,n]=(0,F5.useState)(null),[o,i]=(0,F5.useState)(null),a=(0,F5.useCallback)(()=>t(null),[]),s=(0,F5.useCallback)(()=>n(null),[]),l=(0,F5.useCallback)(()=>i(null),[]);return{error:e,setError:t,clearError:a,success:r,setSuccess:n,clearSuccess:s,serverConflict:o,setServerConflict:i,clearServerConflict:l}}var Cx=k(re(),1);function zHr(e,t){return[...e,{...t,status:"launching"}]}function cEe(e){return e.find(t=>t.status==="launching")}function UHr(e){let t=cEe(e);return t?e.filter(r=>r.id!==t.id):e}function HHr(e,t){let r=cEe(e);return r?jit(e,r.id,t):e}function jit(e,t,r){return e.map(n=>n.id===t&&n.status==="launching"?{...n,status:"error",error:r}:n)}function WHr(e,t){return e.filter(r=>r.id!==t)}var GHr=k(re(),1);var xRo=6e4,SRo="Launch timed out \u2014 the session did not start.";function VHr(e,t){(0,GHr.useEffect)(()=>{let r=e.filter(o=>o.status==="launching");if(r.length===0)return;let n=r.map(o=>setTimeout(()=>t(i=>jit(i,o.id,SRo)),Math.max(0,xRo-(Date.now()-o.startedAt))));return()=>n.forEach(clearTimeout)},[e,t])}function qHr(){let[e,t]=(0,Cx.useState)([]),r=(0,Cx.useRef)([]),n=(0,Cx.useCallback)(l=>{r.current=l(r.current),t(r.current)},[]),o=(0,Cx.useCallback)(l=>{n(u=>zHr(u,{id:crypto.randomUUID(),startedAt:Date.now(),...l}))},[n]),i=(0,Cx.useCallback)(()=>{let l=cEe(r.current);return n(UHr),l?.named?l.title:void 0},[n]),a=(0,Cx.useCallback)(l=>n(u=>HHr(u,l)),[n]),s=(0,Cx.useCallback)(l=>n(u=>WHr(u,l)),[n]);return VHr(e,n),{pendingLaunches:e,addPendingLaunch:o,resolvePendingLaunch:i,failPendingLaunch:a,dismissPendingLaunch:s}}var hne=k(re(),1);function jHr(){let[e,t]=(0,hne.useState)(null),[r,n]=(0,hne.useState)({}),o=(0,hne.useCallback)((i,a)=>{i!=="claude"&&n(s=>({...s,[i]:a}))},[]);return{rateLimits:e,setRateLimits:t,harnessRateLimits:r,setHarnessRateLimits:o}}var YHr=k(re(),1);function KHr(e,t){return(0,YHr.useCallback)(r=>{e(r),t(r)},[e,t])}var Yit=k(re(),1);function XHr(){let e=(0,Yit.useRef)(new Map),t=(0,Yit.useRef)(new Map);return{buffers:e,handlers:t}}var uEe=k(re(),1);function ZHr(){let[e,t]=(0,uEe.useState)(null),[r,n]=(0,uEe.useState)(null),[o,i]=(0,uEe.useState)(null);return{transcript:e,setTranscript:t,viewingTranscriptSessionId:r,setViewingTranscriptSessionId:n,userMessages:o,setUserMessages:i}}var z5=k(re(),1);function QHr(e,t){let r=e.sessionId;t.buffers.current?.delete(r),t.handlers.current?.get(r)?.("\x1Bc")}function JHr(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 eWr(e,t){let r=e.message;t.setError(r),t.failPendingLaunch(r)}function tWr(e,t){let r=e.rateLimits,n=e.harness;!n||n==="claude"?t.setRateLimits(r):t.setHarnessRateLimits?.(n,r)}function rWr(e,t){t.setNodes({local:e.local,links:e.links??[]})}function nWr(e,t){t.setSuccess({message:e.message,sessionId:null})}function oWr(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 iWr(e,t){t.setServerConflict({existing:e.existing,runName:e.runName,cwd:e.cwd,sessionId:e.sessionId,launchedFrom:e.launchedFrom,node:e.node})}function aWr(e,t){let r=e.sessions;t.setSessions(r),e.cwd&&t.setCurrentCwd(e.cwd),t.setActiveByRepo(e.active??{})}function sWr(e,t){let r=e.sessionId,n=e.data;t.buffers.current?.set(r,n),t.handlers.current?.get(r)?.(`\x1Bc${n}`)}var TRo={sessions:aWr,created:JHr,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:rWr,error:eWr,notice:nWr,inbox:()=>{Ws.refresh(),Ws.refreshStatus()},"inbox-activity":()=>{Ws.refreshStatus()},"run-conflict":iWr,limits:tWr,clear:QHr,output:oWr,snapshot:sWr};function lWr(e,t){TRo[e.type]?.(e,t)}function cWr(e,t={}){let r=new WebSocket(abt("/ws"));return r.onopen=()=>{t.onOpen?.(),r.send(JSON.stringify({type:"hello"})),r.send(JSON.stringify({type:"history"}))},r.onmessage=n=>{lWr(JSON.parse(n.data),e)},r.onclose=()=>t.onClose?.(),r}function uWr(e,t,r,n){let o=!1,i,a=0,s=!1,l=()=>{o||t(cWr(e,{onOpen:()=>{s&&r(),s=!1,n(!1),a=0},onClose:()=>{if(o)return;s=!0,n(!0);let u=Math.min(300*2**a,2e3);a+=1,i=setTimeout(l,u)}}))};return l(),()=>{o=!0,i&&clearTimeout(i)}}function dWr(e){let t=(0,z5.useRef)(null),[r,n]=(0,z5.useState)(!1),{handleSessions:o,markInitialized:i,buffers:a,handlers:s}=e;(0,z5.useEffect)(()=>{let u=()=>{a.current?.clear();let f=s.current;if(f)for(let p of f.values())p("\x1Bc")},d=uWr({...e,setSessions:o},f=>{t.current=f},u,n);return()=>{d(),t.current?.close()}},[o,i,a,s]);let l=(0,z5.useCallback)(()=>{let u=t.current;u?.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"history"}))},[]);return{wsRef:t,requestHistory:l,reconnecting:r}}function fWr(){let[e,t]=(0,dEe.useState)([]),[r,n]=(0,dEe.useState)([]),{activeId:o,setActiveId:i,getActiveId:a}=RHr(),s=IHr(),l=ZHr(),[u,d]=(0,dEe.useState)(""),f=FHr(),p=qHr(),h=jHr(),{initialized:m,markInitialized:g,syncSessions:y}=$Hr(),v=XHr(),b=KHr(y,t),{wsRef:x,requestHistory:T,reconnecting:w}=dWr({handleSessions:b,setHistory:n,getActiveId:a,setActiveId:i,...s,...l,setCurrentCwd:d,...f,...p,...h,markInitialized:g,...v});return LHr(e,i,EHr(s.activeByRepo,e)),{sessions:e,history:r,activeId:o,setActiveId:i,...s,...l,currentCwd:u,...f,...p,...h,initialized:m,wsRef:x,...v,requestHistory:T,reconnecting:w}}function fEe(){let e=fWr(),{wsRef:t,buffers:r,handlers:n,addPendingLaunch:o,activeId:i,sessions:a}=e,s=QUr(e.nodes),l=tHr(t,o),u=kHr(l,r,n);KUr(i,a,e.history,l),XUr(a,l);let d=_Hr(l,e.setActiveId,e.setViewingTranscriptSessionId);return{...e,...u,...d,nodeSelection:s}}var kG=k(re(),1);var pWr="assist:sidebar-collapsed";function hWr(){let[e,t]=(0,kG.useState)(()=>Ul(pWr).length>0),r=(0,kG.useCallback)(()=>{t(n=>{let o=!n;return ru(pWr,o?[!0]:[]),o})},[]);return(0,kG.useMemo)(()=>({collapsed:e,onToggleCollapsed:r}),[e,r])}var mWr=k(re(),1);function gWr(){(0,mWr.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await tr("/api/hotkeys");if(!t.ok)return;let r=await t.json();e||DR.set(r)}catch(t){Pr(t,"hotkey bindings")}})(),()=>{e=!0}},[])}function yWr(){let e=fEe(),t=qxe(e),r=WUr(e.currentCwd,e.history,t,e.sessions,e.nodeSelection);DUr({selectedCwd:r.selectedCwd,selectedCardId:t,sessions:e.sessions,history:e.history,activeByRepo:e.activeByRepo,onSelect:e.selectSession});let{launch:n,viewLaunchedSession:o}=jUr(e);gWr();let i=hWr();return IUr("shell",{...e,selection:r,launch:n,sidebarCollapse:i}),{socket:e,selection:r,launch:n,viewLaunchedSession:o,sidebarCollapse:i}}var Am=k(P(),1),wRo={zIndex:e=>e.zIndex.drawer+1},CRo={minHeight:48};function bWr({mode:e,toggle:t}){let r=yWr(),{socket:n,selection:o,viewLaunchedSession:i}=r,{nodes:a,transferSession:s,cancelTransfer:l}=n,u=(0,vWr.useMemo)(()=>({nodes:a,transfer:s,cancel:l}),[a,s,l]);return(0,Am.jsx)(zFr,{shell:r,children:(0,Am.jsxs)(Iit.Provider,{value:n.daemonVersion,children:[(0,Am.jsx)(_Ur,{mode:e,toggle:t,sessions:n.sessions,reconnecting:n.reconnecting}),(0,Am.jsx)(k5e,{position:"fixed",sx:wRo,"data-testid":"toolbar",children:(0,Am.jsx)(kzr,{socket:n,selection:o})}),(0,Am.jsx)(rR,{variant:"dense",sx:CRo}),(0,Am.jsx)(r6e.Provider,{value:u,children:(0,Am.jsx)(PUr,{socket:n,children:(0,Am.jsx)(A9r,{socket:n})})}),(0,Am.jsx)(x$r,{socket:n}),(0,Am.jsx)(FFr,{socket:n,onViewLaunchedSession:i})]})})}function TWr(e){return e instanceof Error?e.message:String(e)}function kRo(e){return e.filename?` (${e.filename}:${e.lineno}:${e.colno})`:""}function xWr(e){Vj(e.error)||(AR(e.error),qj("error",`${e.message||TWr(e.error)}${kRo(e)}`))}function SWr(e){Vj(e.reason)||(AR(e.reason),qj("rejection",TWr(e.reason)))}function wWr(){return globalThis.addEventListener("error",xWr),globalThis.addEventListener("unhandledrejection",SWr),()=>{globalThis.removeEventListener("error",xWr),globalThis.removeEventListener("unhandledrejection",SWr)}}var CWr=k(re(),1);function kWr(){let[e,t]=(0,CWr.useState)(()=>{try{return localStorage.getItem("theme-mode")??"dark"}catch{return"dark"}});return{mode:e,toggle:()=>t(n=>{let o=n==="dark"?"light":"dark";try{localStorage.setItem("theme-mode",o)}catch{}return o})}}function _Wr({color:e,radius:t}){return{MuiMenu:{styleOverrides:{paper:{borderRadius:t.md},list:{padding:4}}},MuiMenuItem:{styleOverrides:{root:{minHeight:30,padding:"5px 10px",borderRadius:4,fontSize:13,"&:hover":{backgroundColor:e.raised},"& .MuiListItemIcon-root":{minWidth:28},"& .MuiSvgIcon-root":{fontSize:16},"& .MuiListItemText-primary":{fontSize:13}}}}}}function EWr(e){let{color:t,radius:r,elevation:n,type:o}=e,i={border:`1px solid ${t.line}`};return{..._Wr(e),MuiTooltip:{styleOverrides:{tooltip:{...i,backgroundColor:t.overlay.background,color:t.overlay.text,borderRadius:r.md,boxShadow:n.overlay,fontSize:`${o.scale.caption/16}rem`,padding:"6px 10px"},arrow:{color:t.overlay.background}}},MuiPopover:{styleOverrides:{paper:{...i,boxShadow:n.overlay}}},MuiBackdrop:{styleOverrides:{root:{"&:not(.MuiBackdrop-invisible)":{backgroundColor:t.scrim,backdropFilter:"blur(2px)"}}}},MuiDialog:{styleOverrides:{paper:{...i,backgroundColor:t.surface,borderRadius:r.md+4,boxShadow:n.dialog}}}}}var RWr=({variant:e})=>e==="outlined"||e==="tonal",AWr=[{props:{size:"small"},style:{minHeight:26,padding:"4px 9px",fontSize:12}},{props:RWr,style:{padding:"5px 11px"}},{props:e=>RWr(e)&&e.size==="small",style:{padding:"3px 8px"}}];var pEe=["primary","secondary","success","warning","error","info"];function mne(e,t){return{backgroundColor:Hr(e,t),borderColor:Hr(e,.35),color:e}}function PWr({color:e}){return[{props:{variant:"tonal"},style:{backgroundColor:e.raised,border:`1px solid ${e.line}`,color:e.text.primary,"&:hover":{backgroundColor:e.raised,borderColor:e.text.disabled}}},...pEe.filter(t=>t!=="primary").map(t=>({props:{variant:"tonal",color:t},style:{...mne(e[t].main,.16),"&:hover":mne(e[t].main,.24)}}))]}var LWr={"& > *:nth-of-type(1)":{fontSize:16}};function IWr(e){let{color:t,radius:r,density:n}=e,{minHeight:o,fontSize:i,paddingX:a}=n.button;return{MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:o,padding:`6px ${a}px`,borderRadius:r.sm,fontSize:i,fontWeight:600,lineHeight:"18px"},startIcon:{marginLeft:-2,marginRight:6,...LWr},endIcon:{marginLeft:6,marginRight:-2,...LWr}},variants:[...AWr,{props:{variant:"text",color:"primary"},style:{color:t.text.secondary,"&:hover":{backgroundColor:t.raised,color:t.text.primary}}},...PWr(e),{props:{variant:"outlined",color:"error"},style:{borderColor:Hr(t.error.main,.35),"&:hover":{borderColor:t.error.main,backgroundColor:Hr(t.error.main,.1)}}}]}}}function Kit({color:e},t){return[{props:{variant:t,color:"default"},style:{backgroundColor:"transparent",border:`1px solid ${e.line}`,color:e.text.secondary,"&.MuiChip-clickable:hover":{backgroundColor:e.raised}}},...pEe.map(r=>({props:{variant:t,color:r},style:{...mne(e[r].main,.14),borderColor:"transparent","& .MuiChip-deleteIcon":{color:Hr(e[r].main,.7),"&:hover, &:active":{color:e[r].main}},"&.MuiChip-clickable:hover":{backgroundColor:Hr(e[r].main,.22)}}}))]}function MWr(e){return{MuiChip:{styleOverrides:{root:{height:20,fontSize:11,fontWeight:600,borderRadius:999},sizeSmall:{height:20,"& .MuiChip-label":{padding:"0 7px"}},label:{padding:"0 8px"},icon:{fontSize:14,marginLeft:6,marginRight:-2},deleteIcon:{fontSize:14,marginLeft:-2,marginRight:4},outlined:{borderColor:e.color.line}},variants:[...Kit(e,"tonal"),...Kit(e,"filled")]}}}function DWr(e){return{...IWr(e),MuiButtonGroup:{defaultProps:{disableElevation:!0},variants:[{props:{variant:"tonal"},style:{"& .MuiButtonGroup-middleButton, & .MuiButtonGroup-lastButton":{marginLeft:-1}}}]},...MWr(e)}}var Xit=e=>`color-mix(in srgb, currentColor ${e}%, transparent)`,_Ro={".MuiAppBar-root &":{color:"inherit","&:hover":{backgroundColor:Xit(8)},"&.Mui-selected":{color:"inherit",backgroundColor:Xit(12),boxShadow:`inset 0 0 0 1px ${Xit(18)}`}}};function NWr({color:e,radius:t}){return{MuiTabs:{styleOverrides:{root:{minHeight:40,alignItems:"center"},list:{gap:2},indicator:{display:"none"}}},MuiTab:{styleOverrides:{root:{minHeight:30,padding:"6px 10px",borderRadius:t.sm,textTransform:"none",fontSize:13,fontWeight:500,opacity:1,color:e.text.secondary,"&:hover":{backgroundColor:e.raised,color:e.text.primary},"&.Mui-selected":{color:e.text.primary,backgroundColor:e.raised,boxShadow:`inset 0 0 0 1px ${e.line}`},...!e.appBar&&_Ro}}}}}var OWr=(e,t)=>({width:e,height:e,"& .MuiSvgIcon-root":{fontSize:t}});function BWr({color:e,radius:t,density:r}){let{side:n,icon:o,smallSide:i,smallIcon:a}=r.iconButton;return{MuiIconButton:{styleOverrides:{root:{...OWr(n,o),padding:0,borderRadius:t.sm,"&:hover":{backgroundColor:e.raised}}},variants:[{props:{size:"small"},style:OWr(i,a)},{props:{color:"default"},style:{color:e.text.secondary,"&:hover":{color:e.text.primary},...!e.appBar&&{".MuiAppBar-root &, .MuiAppBar-root &:hover":{color:"inherit"}}}}]}}}function $Wr({color:e,radius:t}){return{MuiToggleButtonGroup:{styleOverrides:{root:{padding:2,gap:2,border:`1px solid ${e.line}`,borderRadius:t.sm,backgroundColor:e.background},grouped:{margin:0,border:0,borderRadius:4}}},MuiToggleButton:{styleOverrides:{root:{padding:"3px 8px",border:0,borderRadius:4,fontSize:13,fontWeight:500,lineHeight:"18px",textTransform:"none",color:e.text.secondary,"& .MuiSvgIcon-root":{fontSize:16},"&:hover":{backgroundColor:"transparent",color:e.text.primary},"&.Mui-selected, &.Mui-selected:hover":{backgroundColor:e.raised,color:e.text.primary}}}}}}var hEe=".MuiOutlinedInput-notchedOutline";function FWr({color:e,radius:t,density:r}){let n=r.inputFontSize;return{MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:e.background,borderRadius:t.sm,fontSize:n,color:e.text.primary,[`& ${hEe}`]:{borderColor:e.line},[`&:hover ${hEe}`]:{borderColor:e.text.disabled},[`&.Mui-focused ${hEe}`]:{borderColor:e.primary.main,borderWidth:1},[`&.Mui-error ${hEe}`]:{borderColor:e.error.main}}}},MuiInputLabel:{styleOverrides:{root:{fontSize:n,color:e.text.secondary,"&.Mui-focused":{color:e.primary.main}}}},MuiSelect:{styleOverrides:{icon:{color:e.text.disabled}}}}}function zWr({color:e,density:t}){let{width:r,height:n,thumb:o}=t.switch;return{MuiSwitch:{styleOverrides:{root:{width:r,height:n,padding:0,"& .MuiSwitch-switchBase":{padding:2,color:e.text.secondary,"&.Mui-checked":{transform:`translateX(${r-n}px)`,color:e.primary.contrastText},"&.Mui-checked + .MuiSwitch-track":{backgroundColor:e.primary.main,opacity:1}},"& .MuiSwitch-thumb":{width:o,height:o,boxShadow:"none"},"& .MuiSwitch-track":{borderRadius:n/2,backgroundColor:e.line,opacity:1}}}},MuiFormControlLabel:{styleOverrides:{root:{"&:has(.MuiSwitch-root)":{marginLeft:0,gap:8}}}}}}function UWr(e){let{appBar:t}=e.color;return{...EWr(e),...DWr(e),...BWr(e),...$Wr(e),...FWr(e),...zWr(e),...NWr(e),MuiPaper:{styleOverrides:{root:{backgroundImage:"none"},outlined:{borderColor:e.color.line}}},MuiAppBar:{defaultProps:{elevation:e.elevation.appBar},styleOverrides:{root:t&&{backgroundColor:t.background,color:t.text,borderBottom:`1px solid ${e.color.line}`}}}}}var hv="#0e1116",Zit="#141820",mEe="#1b202a",gEe="#e3e7ee",Qit="#8a93a3",gne="#8b9cff",yEe="#5fd0a0",vEe="#f2b45a",bEe="#f27a7a",HWr="#6cc8d8",WWr={secondary:"rgba(255, 255, 255, 0.7)",hover:"rgba(255, 255, 255, 0.12)",active:"rgba(255, 255, 255, 0.16)",dot:"#ffb74d",dotRing:"rgba(0, 0, 0, 0.15)"},xEe={dark:{color:{background:hv,surface:Zit,raised:mEe,line:"#262c37",lineSoft:"#1d222b",text:{primary:gEe,secondary:Qit,disabled:"#5c6473"},selected:"rgba(139, 156, 255, 0.14)",wash:{warning:"rgba(242, 180, 90, 0.09)",error:"rgba(242, 122, 122, 0.09)",accent:"rgba(139, 156, 255, 0.1)",check:"rgba(108, 200, 216, 0.09)"},well:hv,stripe:mEe,codeWash:"rgba(255, 255, 255, 0.08)",overlay:{background:mEe,text:gEe},scrim:"rgba(0, 0, 0, 0.5)",appBar:{background:Zit,text:gEe},onAppBar:{...WWr,secondary:Qit,level:{ok:yEe,warn:vEe,over:bEe}},statusBar:{background:Zit,text:Qit,hoverText:gEe,secondary:"#5c6473",hover:mEe,active:"transparent",dot:gne,dotRing:"rgba(139, 156, 255, 0.14)",readyText:gne,level:{ok:yEe,warn:vEe,over:bEe}},primary:{main:gne,contrastText:hv},secondary:{main:"#c99bff",contrastText:hv},success:{main:yEe,contrastText:hv},warning:{main:vEe,contrastText:hv},error:{main:bEe,contrastText:hv},info:{main:"#6cb6ff",contrastText:hv},check:{main:HWr,contrastText:hv}},terminal:{background:hv,foreground:"#d6dbe4",cursor:gne,cursorAccent:hv,selectionBackground:"rgba(139, 156, 255, 0.28)",black:"#1b2029",red:bEe,green:yEe,yellow:vEe,blue:gne,magenta:"#c99bff",cyan:HWr,white:"#c3c9d4",brightBlack:"#5c6473",brightRed:"#ff9a9a",brightGreen:"#82e0b6",brightYellow:"#ffc97a",brightBlue:"#a9b6ff",brightMagenta:"#dcb8ff",brightCyan:"#8fdbe8",brightWhite:"#eef1f6"},elevation:{appBar:0,overlay:"0 14px 34px rgba(0, 0, 0, 0.45)",dialog:"0 30px 60px rgba(0, 0, 0, 0.5)",stuckHeader:"0 8px 8px -9px rgba(0, 0, 0, 0.8)"}},light:{color:{background:"#fff",surface:"#fff",raised:"rgba(0, 0, 0, 0.04)",line:"rgba(0, 0, 0, 0.12)",lineSoft:"rgba(0, 0, 0, 0.12)",text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},selected:"rgba(0, 0, 0, 0.08)",wash:{warning:"rgba(255, 167, 38, 0.09)",error:"rgba(244, 67, 54, 0.09)",accent:"rgba(25, 118, 210, 0.08)",check:"rgba(0, 131, 143, 0.08)"},well:"#f3f4f6",stripe:"rgba(0, 0, 0, 0.1)",codeWash:"rgba(0, 0, 0, 0.06)",overlay:{background:"rgba(97, 97, 97, 0.92)",text:"#fff"},onAppBar:{...WWr,level:{ok:"#b9f6ca",warn:"#ffe57f",over:"#ffcdd2"}},primary:{main:"#1976d2",light:"#42a5f5",dark:"#1565c0",contrastText:"#fff"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2",contrastText:"#fff"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20",contrastText:"#fff"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100",contrastText:"#fff"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828",contrastText:"#fff"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b",contrastText:"#fff"},check:{main:"#00838f",light:"#4fb3bf",dark:"#005662",contrastText:"#fff"},scrim:"rgba(15, 23, 42, 0.32)",statusBar:{background:"#f3f4f6",text:"rgba(0, 0, 0, 0.6)",hoverText:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.38)",hover:"rgba(0, 0, 0, 0.06)",active:"transparent",dot:"#1976d2",dotRing:"rgba(25, 118, 210, 0.16)",readyText:"#1976d2",level:{ok:"#2e7d32",warn:"#ed6c02",over:"#d32f2f"}}},terminal:{background:"#ffffff",foreground:"#333333",cursor:"#333333",cursorAccent:"#ffffff",selectionBackground:"#add6ff",black:"#000000",red:"#cd3131",green:"#107c10",yellow:"#949800",blue:"#0451a5",magenta:"#bc05bc",cyan:"#0598bc",white:"#555555",brightBlack:"#666666",brightRed:"#cd3131",brightGreen:"#14ce14",brightYellow:"#b5ba00",brightBlue:"#0451a5",brightMagenta:"#bc05bc",brightCyan:"#0598bc",brightWhite:"#a5a5a5"},elevation:{appBar:0,overlay:"0 8px 24px rgba(15, 23, 42, 0.12)",dialog:"0 24px 48px rgba(15, 23, 42, 0.18)",stuckHeader:"0 6px 6px -7px rgba(0, 0, 0, 0.2)"}},font:{ui:'"Geist Variable", "Segoe UI", system-ui, sans-serif',mono:'"Geist Mono Variable", ui-monospace, Menlo, Consolas, monospace',terminal:'"Geist Mono Variable", ui-monospace, Menlo, Consolas, monospace'},type:{fontSize:14,terminalFontSize:13,scale:{caption:12,body2:14,body1:15,subtitle2:14,subtitle1:15,h6:16,h5:18,h4:24,button:14},button:{textTransform:"none",fontWeight:600}},radius:{sm:6,md:8},spacing:8,densities:{desktop:{target:30,bar:40,iconButton:{side:30,icon:18,smallSide:26,smallIcon:16},button:{minHeight:30,fontSize:13,paddingX:12},switch:{width:34,height:20,thumb:16},inputFontSize:13,tabBar:{height:44,icon:20,label:10,badge:16,insetTrim:0}},touch:{target:48,bar:60,iconButton:{side:48,icon:30,smallSide:40,smallIcon:24},button:{minHeight:48,fontSize:17,paddingX:20},switch:{width:51,height:31,thumb:27},inputFontSize:16,tabBar:{height:49,icon:26,label:11,badge:18,insetTrim:12}}}};var Mw=e=>`${e/16}rem`;function GWr({font:e,type:t}){let{scale:r}=t;return{fontFamily:e.ui,fontFamilyMono:e.mono,fontSize:t.fontSize,button:{...t.button,fontSize:Mw(r.button)},caption:{fontSize:Mw(r.caption)},body2:{fontSize:Mw(r.body2)},body1:{fontSize:Mw(r.body1)},subtitle2:{fontSize:Mw(r.subtitle2)},subtitle1:{fontSize:Mw(r.subtitle1)},h6:{fontSize:Mw(r.h6)},h5:{fontSize:Mw(r.h5)},h4:{fontSize:Mw(r.h4)}}}function VWr(e){return{MuiButtonBase:{styleOverrides:{root:{cursor:"pointer","&.Mui-disabled":{cursor:"default"}}}},MuiLink:{styleOverrides:{root:{cursor:"pointer"}}},MuiAppBar:{defaultProps:{elevation:e.elevation.appBar}}}}function ERo(e,t){let{dark:r,light:n,densities:o,...i}=xEe;return{...i,...e==="dark"?r:n,mode:e,density:o[t]}}function qWr(e,t="desktop"){let r=ERo(e,t),{color:n}=r;return Lv({tokens:r,palette:{mode:e,background:{default:n.background,paper:n.surface},primary:n.primary,secondary:n.secondary,success:n.success,warning:n.warning,error:n.error,info:n.info,check:n.check,text:n.text,divider:n.line,action:{hover:n.raised,selected:n.selected}},typography:GWr(r),shape:{borderRadius:r.radius.sm},spacing:r.spacing,components:{...VWr(r),...UWr(r)}})}function jWr(){if(typeof document>"u"||!document.fonts)return Promise.resolve();let{font:e,type:t}=xEe;return Promise.allSettled([document.fonts.load(`${t.fontSize}px ${e.ui}`),document.fonts.load(`${t.terminalFontSize}px ${e.terminal}`)])}var uVr=k(re(),1);var U5=k(P(),1);function YWr({status:e,onClose:t}){return(0,U5.jsxs)(U5.Fragment,{children:[(0,U5.jsx)(Lu,{open:e.kind==="probing",children:(0,U5.jsx)(ro,{severity:"info",variant:"filled",children:e.kind==="probing"?`Connecting to ${e.name}\u2026`:""})}),(0,U5.jsx)(Tl,{error:e.kind==="error"?e.message:null,onClose:t})]})}var TEe=k(re(),1);var RRo=/^\d+(\.\d+){3}$/;function YI(e){try{let{hostname:t}=new URL(e);return RRo.test(t)?t:t.split(".")[0]}catch{return""}}var ARo=/^[a-z]+:[/]{2}/i;function SEe(e){let t=e.trim(),r=ARo.test(t)?t:`https://${t}`;try{let n=new URL(r);return n.protocol!=="https:"&&n.protocol!=="http:"?void 0:n.origin}catch{return}}function PRo(e){try{return new URL(e)}catch{return}}function LRo(e){return e.protocol==="assist:"&&e.hostname==="add-node"&&(e.pathname===""||e.pathname==="/")}function KWr(e){let t=PRo(e);if(!t||!LRo(t))return{ok:!1,error:`Not an assist add-node link: ${e}`};let r=t.searchParams.get("url"),n=r?SEe(r):void 0;return n?{ok:!0,node:{name:t.searchParams.get("name")?.trim()||YI(n),url:n}}:{ok:!1,error:`The link has no valid node URL: ${r??"(missing)"}`}}var XWr=5e3,ZWr="/api/health";async function IRo(e){let t=new AbortController,r=setTimeout(()=>t.abort(),XWr);try{let n=await fetch(`${e}${ZWr}`,{signal:t.signal,cache:"no-store"});return n.ok?{ok:!0,health:await n.json()}:{ok:!1,error:`HTTP ${n.status}`,status:n.status}}catch(n){return t.signal.aborted?{ok:!1,error:`timed out after ${XWr/1e3}s`}:{ok:!1,error:n instanceof Error?n.message:String(n)}}finally{clearTimeout(r)}}async function H5(e){let t=Date.now(),r=await IRo(e);return r.ok||j7({at:new Date(t).toISOString(),method:"GET",path:ZWr,base:e,status:r.status,error:r.status===void 0?r.error:void 0,durationMs:Date.now()-t}),r}async function QWr(e,t){let r=KWr(e);if(!r.ok)return r;let{node:n}=r;t(n);let o=await H5(n.url);return o.ok?{ok:!0,node:n,health:o.health}:{ok:!1,error:`Can't reach ${n.name} at ${n.url}: ${o.error}`}}KI();var nat=Nw("App",{web:()=>Promise.resolve().then(()=>(oGr(),nGr)).then(e=>new e.AppWeb)});var EG=k(re(),1);var zRo=5e3;function iGr(e){let t=(0,EG.useRef)(e),r=(0,EG.useRef)(void 0);(0,EG.useEffect)(()=>{t.current=e},[e]),(0,EG.useEffect)(()=>{let n=i=>{let a=Date.now(),s=r.current?.url===i&&a-r.current.at<zRo;r.current={url:i,at:a},s||t.current(i)},o=nat.addListener("appUrlOpen",({url:i})=>n(i));return nat.getLaunchUrl().then(i=>{i?.url&&n(i.url)}).catch(i=>Pr(i,"launch url")),()=>{o.then(i=>i.remove())}},[])}function aGr(e){let[t,r]=(0,TEe.useState)({kind:"idle"});iGr(async o=>{let i=await QWr(o,a=>r({kind:"probing",name:a.name}));if(!i.ok){r({kind:"error",message:i.error});return}e(i.node,i.health),r({kind:"idle"})});let n=(0,TEe.useCallback)(()=>r({kind:"idle"}),[]);return{status:t,dismiss:n}}var bne=k(P(),1);function sGr({name:e}){return(0,bne.jsxs)(G,{sx:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,bgcolor:"background.default"},children:[(0,bne.jsx)(Ao,{size:28}),(0,bne.jsxs)(_e,{variant:"body2",color:"text.secondary",children:["Connecting to ",e??"home node","\u2026"]})]})}var wEe=k(re(),1),oat=(0,wEe.createContext)(null);function W5(){return(0,wEe.useContext)(oat)}var fl={top:"env(safe-area-inset-top, 0px)",bottom:"env(safe-area-inset-bottom, 0px)"};var cGr=k(P(),1);function lGr({value:e,error:t,onChange:r}){return(0,cGr.jsx)(Gn,{autoFocus:!0,label:"Web server URL",placeholder:"https://mac.tail1234.ts.net:3100",value:e,onChange:n=>r(n.target.value),error:!!t,helperText:t??"The address where you open the sessions page in a browser.",slotProps:{htmlInput:{autoCapitalize:"none",autoCorrect:"off",inputMode:"url"}}})}var xne=k(re(),1);function uGr(e,t){let[r,n]=(0,xne.useState)(e?.url??""),[o,i]=(0,xne.useState)(e?.name),[a,s]=(0,xne.useState)(),[l,u]=(0,xne.useState)(!1),d=SEe(r),f=o??(d?YI(d):"");return{url:r,changeUrl:m=>{n(m),s(void 0)},name:f,setName:i,error:a,busy:l,submit:async m=>{if(m.preventDefault(),!d){s("Enter an http(s) URL, e.g. https://mac.tail1234.ts.net:3100");return}u(!0);let g=await t({name:f.trim()||YI(d),url:d});u(!1),s(g)}}}var RG=k(P(),1);function CEe({initial:e,submitLabel:t,onSubmit:r,children:n}){let o=uGr(e,r);return(0,RG.jsxs)(_t,{component:"form",spacing:2,onSubmit:o.submit,children:[(0,RG.jsx)(lGr,{value:o.url,error:o.error,onChange:o.changeUrl}),(0,RG.jsx)(Gn,{label:"Name",value:o.name,onChange:i=>o.setName(i.target.value),helperText:"Filled in from the host name. Shown on the node chip.",slotProps:{htmlInput:{autoCapitalize:"none",autoCorrect:"off"}}}),(0,RG.jsx)(vt,{type:"submit",variant:"contained",size:"large",disabled:!o.url.trim()||o.busy,children:o.busy?"Checking\u2026":t}),n]})}var Ow=k(P(),1),URo={height:"100%",boxSizing:"border-box",overflowY:"auto",display:"flex",justifyContent:"center",pt:`calc(${fl.top} + 28px)`,pb:`calc(${fl.bottom} + 24px)`,px:2.5,bgcolor:"background.default"},HRo={width:56,height:56,borderRadius:"14px",bgcolor:"action.hover",border:1,borderColor:"divider",display:"grid",placeItems:"center",fontFamily:"fontFamilyMono",fontSize:22,fontWeight:600,color:"primary.main"};function dGr({onConnect:e}){return(0,Ow.jsx)(G,{sx:URo,children:(0,Ow.jsxs)(_t,{spacing:2.5,sx:{width:"100%",maxWidth:420},children:[(0,Ow.jsx)(G,{sx:HRo,children:">_"}),(0,Ow.jsx)(_e,{variant:"h5",sx:{fontWeight:700},children:"Connect to a home node"}),(0,Ow.jsxs)(_e,{variant:"body2",color:"text.secondary",children:["The phone connects to one assist web server over Tailscale. You'll see its sessions and the sessions of every node it links to. Make sure Tailscale is connected on this phone and"," ",(0,Ow.jsx)("code",{children:"assist sessions web"})," is running on that machine."]}),(0,Ow.jsx)(CEe,{submitLabel:"Connect",onSubmit:async r=>{let n=await H5(r.url);if(!n.ok)return`Can't reach ${r.url}: ${n.error}`;e(r,n.health)}})]})})}var XGr=k(re(),1);var mv=k(P(),1),WRo={flex:"none",pt:fl.top,bgcolor:"background.default"},GRo={height:e=>e.tokens.density.bar,display:"grid",gridTemplateColumns:"minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr)",columnGap:1,alignItems:"center",px:1.5},VRo={height:e=>e.tokens.density.bar,display:"flex",alignItems:"center",gap:.5,px:.5},qRo={textAlign:"center",minWidth:0,maxWidth:220,fontSize:15,fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},jRo={flex:1,minWidth:0,fontSize:15,fontWeight:600,lineHeight:1.25,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"};function mu({left:e,title:t,right:r,leadingTitle:n}){return(0,mv.jsx)(G,{component:"header",sx:WRo,children:n?(0,mv.jsxs)(G,{sx:VRo,children:[(0,mv.jsx)(G,{sx:{flex:"none"},children:e}),(0,mv.jsx)(G,{component:"h1",sx:[jRo,{m:0}],children:t}),(0,mv.jsx)(G,{sx:{flex:"none",display:"flex"},children:r})]}):(0,mv.jsxs)(G,{sx:GRo,children:[(0,mv.jsx)(G,{sx:{justifySelf:"start",minWidth:0},children:e}),(0,mv.jsx)(G,{sx:qRo,children:t}),(0,mv.jsx)(G,{sx:{justifySelf:"end",display:"flex",gap:.25},children:r})]})})}var kx=e=>e.tokens.color.raised;var fGr=k(P(),1),YRo={ok:e=>e.palette.success.main,warn:e=>e.palette.warning.main,error:e=>e.palette.error.main,off:e=>e.palette.text.disabled};function _0({tone:e}){return(0,fGr.jsx)(G,{component:"span",sx:{width:8,height:8,flex:"none",borderRadius:"50%",bgcolor:YRo[e]}})}var Sc=e=>e.tokens.density.target;var AG=k(P(),1),KRo={display:"inline-flex",alignItems:"center",gap:.75,height:Sc,pl:1.125,pr:.75,borderRadius:"24px",border:1,borderColor:"divider",bgcolor:kx,color:"text.primary",fontFamily:"fontFamilyMono",fontSize:13,maxWidth:140,justifyContent:"flex-start"},XRo={minWidth:0,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"};function kEe({name:e,tone:t,onClick:r}){return(0,AG.jsxs)(ur,{sx:KRo,onClick:r,disabled:!r,"aria-label":"Nodes","data-testid":"phone-node-chip",children:[(0,AG.jsx)(_0,{tone:t}),(0,AG.jsx)(G,{component:"span",sx:XRo,children:e??"\u2026"}),r&&(0,AG.jsx)(ma,{sx:{fontSize:16,flex:"none"}})]})}var GGr=k(re(),1);var _Ee=k(P(),1);function pGr({homeNode:e,node:t,onDone:r}){let n=!!t&&t.url===e.home?.url;return(0,_Ee.jsx)(G,{sx:{px:2.5,pt:1},children:(0,_Ee.jsx)(CEe,{initial:t,submitLabel:t?"Save":"Add node",onSubmit:async i=>{if(e.nodes.some(s=>s.url===i.url&&s.url!==t?.url))return"That URL is already saved";e.saveNode(t?.url??i.url,i),r()},children:t&&(0,_Ee.jsx)(vt,{color:"error",size:"large",disabled:n,onClick:()=>{e.removeNode(t.url),r()},children:n?"Switch home node to delete this one":"Delete node"})})})}var hGr=k(P(),1),ZRo={width:36,height:5,borderRadius:"3px",bgcolor:"text.disabled",opacity:.5,mx:"auto",mb:.75};function PG(){return(0,hGr.jsx)(G,{sx:ZRo})}var Bw=k(P(),1),QRo={display:"flex",justifyContent:"space-between",alignItems:"center",gap:1,px:2,pt:.75,pb:1.25},JRo={color:"primary.main",fontSize:16,minHeight:Sc,px:.5,borderRadius:1};function LG({title:e,actionLabel:t,onAction:r}){return(0,Bw.jsxs)(Bw.Fragment,{children:[(0,Bw.jsx)(PG,{}),(0,Bw.jsxs)(G,{sx:QRo,children:[(0,Bw.jsx)(G,{component:"b",sx:{fontSize:17,fontWeight:600},children:e}),(0,Bw.jsx)(ur,{sx:JRo,onClick:r,children:t})]})]})}var XI=k(P(),1);function mGr({homeNode:e,node:t,onDone:r}){return(0,XI.jsxs)(XI.Fragment,{children:[(0,XI.jsx)(LG,{title:t?"Edit node":"Add node",actionLabel:"Cancel",onAction:r}),(0,XI.jsx)(pGr,{homeNode:e,node:t,onDone:r},t?.url??"add")]})}var Or={group:{flexShrink:0,mx:2,my:.75,borderRadius:"12px",bgcolor:"background.default",border:1,borderColor:"divider",overflow:"hidden","& > *:not(:last-child)":{borderBottom:1,borderColor:e=>e.tokens.color.lineSoft}},item:{width:"100%",minHeight:Sc,display:"flex",alignItems:"center",justifyContent:"flex-start",gap:1.5,px:1.75,py:1,textAlign:"left",fontSize:16},grow:{flex:1,minWidth:0},detail:{display:"block",fontSize:13,color:"text.secondary",fontFamily:"fontFamilyMono",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},end:{display:"flex",alignItems:"center",gap:.75,color:"text.secondary",fontSize:14},label:{px:4,pt:1.75,pb:.25,fontSize:13,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"text.secondary"}};function gGr(e,t){return e.replace(/\/+$/,"")===t.replace(/\/+$/,"")}function IG(e,t){let r=e.split(".").map(Number),n=t.split(".").map(Number);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]||0)-(n[o]||0);if(i!==0)return Math.sign(i)}return 0}function yGr(e,t,r){let n=t.filter(a=>a.node===e.name).length,o=[e.state,`${n} session${n===1?"":"s"}`,e.peerVersion&&`v${e.peerVersion}`,e.state!=="connected"&&e.error],i=e.peerVersion&&r?IG(e.peerVersion,r):0;return{text:o.filter(Boolean).join(" \xB7 "),drift:i<0?"behind":i>0?"ahead":void 0}}var EEe={connected:"ok",connecting:"warn",disconnected:"error","version-blocked":"error"};var iat=k(P(),1);function vGr({name:e,onSave:t}){return(0,iat.jsx)(jt,{"aria-label":`Save ${e} as a home node`,onClick:t,sx:{color:"primary.main",borderRadius:0},children:(0,iat.jsx)(pp,{fontSize:"small"})})}var $w=k(P(),1),eAo={fontFamily:"fontFamilyMono",fontSize:12,px:.75,border:1,borderColor:"currentColor",borderRadius:"4px",color:"warning.main"};function bGr({links:e,sessions:t,homeVersion:r,isSaved:n,onSave:o}){return(0,$w.jsx)(G,{sx:Or.group,children:e.map(i=>{let{text:a,drift:s}=yGr(i,t,r);return(0,$w.jsxs)(G,{sx:[Or.item,{pr:0}],children:[(0,$w.jsx)(_0,{tone:EEe[i.state]}),(0,$w.jsxs)(G,{component:"span",sx:Or.grow,children:[i.name,(0,$w.jsx)(G,{component:"span",sx:Or.detail,children:a})]}),s&&(0,$w.jsx)(G,{component:"span",sx:eAo,children:s}),!n(i.url)&&(0,$w.jsx)(vGr,{name:i.name,onSave:()=>o(i)})]},i.name)})})}var _x=k(P(),1);function MG({title:e,rows:t}){return(0,_x.jsxs)(_x.Fragment,{children:[(0,_x.jsx)(G,{sx:Or.label,children:e}),(0,_x.jsx)(G,{sx:Or.group,children:t.map(r=>(0,_x.jsxs)(G,{sx:Or.item,children:[(0,_x.jsx)(G,{component:"span",sx:Or.grow,children:r.label}),(0,_x.jsx)(G,{component:"span",sx:[Or.end,{fontFamily:"fontFamilyMono"},r.color?{color:r.color}:{}],children:r.value})]},r.key))})]})}var SGr=k(P(),1);function xGr({rateLimits:e,harnessRateLimits:t}){let r=x0(3e4),n=v_e(e,t).flatMap(o=>T_e(o.rateLimits).map(i=>({key:`${o.harness}-${i.label}`,label:`${Dc(o.harness)} \xB7 ${i.label}`,value:i.resetsAt!=null?`${Math.round(i.pct)}% \xB7 ${VW(i.resetsAt,r)}`:`${Math.round(i.pct)}%`,color:Ake(lx(i.pct,i.resetsAt,i.windowSeconds,r))})));return n.length===0?null:(0,SGr.jsx)(MG,{title:"Rate limits",rows:n})}var Ex=k(P(),1);function TGr({status:e,homeVersion:t,homeNode:r}){let n=e.nodes?.links??[];return(0,Ex.jsxs)(Ex.Fragment,{children:[n.length>0&&(0,Ex.jsxs)(Ex.Fragment,{children:[(0,Ex.jsxs)(G,{sx:Or.label,children:["Linked through ",e.nodes?.local]}),(0,Ex.jsx)(bGr,{links:n,sessions:e.sessions,homeVersion:t,isSaved:o=>r.nodes.some(i=>gGr(i.url,o)),onSave:({name:o,url:i})=>r.saveNode("",{name:o,url:i})})]}),(0,Ex.jsx)(xGr,{rateLimits:e.rateLimits,harnessRateLimits:e.harnessRateLimits})]})}var tAo={ok:"ok",ready:"warn",diverged:"warn",retrying:"warn",paused:"off",off:"off",loading:"off",unavailable:"error"};function REe(e,t){let r=v0(e),{status:n}=e,o=!!n&&!!t&&IG(t,n.built)>0,i=u5(e),a=n&&(n.running===n.built?`v${n.running}`:`v${n.running} \u2192 v${n.built}`),s=o?`v${t} available`:i?"restart pending":r.label.toLowerCase();return{tone:o?"warn":tAo[r.kind],detail:[a,s].filter(Boolean).join(" \xB7 "),updateAvailable:o,restartPending:i}}var Pm=k(P(),1);function wGr({updates:e,onOpen:t}){let{entries:r,latest:n,notices:o}=e;return r.length===0?null:(0,Pm.jsxs)(Pm.Fragment,{children:[(0,Pm.jsx)(G,{sx:Or.label,children:"Updates"}),(0,Pm.jsx)(G,{sx:Or.group,children:r.map(i=>{let a=REe(i,n),s=o.busy[i.name];return(0,Pm.jsxs)(ur,{sx:Or.item,onClick:()=>t(i.name),"data-testid":`phone-update-row-${i.name}`,children:[(0,Pm.jsx)(_0,{tone:a.tone}),(0,Pm.jsxs)(G,{component:"span",sx:Or.grow,children:[i.name,(0,Pm.jsx)(G,{component:"span",sx:Or.detail,children:a.detail})]}),(0,Pm.jsxs)(G,{component:"span",sx:Or.end,children:[s&&`${s}\u2026`,(0,Pm.jsx)(ri,{})]})]},i.name)})})]})}var Sne=k(P(),1);function AEe({onAdd:e}){return(0,Sne.jsxs)(ur,{sx:Or.item,onClick:e,children:[(0,Sne.jsx)(pp,{sx:{color:"primary.main"}}),(0,Sne.jsx)(G,{component:"span",sx:{color:"primary.main"},children:"Add node URL"})]})}function Rx(e){try{return new URL(e).host}catch{return e}}function PEe(e){if(!e)return{tone:"off",text:"checking\u2026"};if(!e.ok)return{tone:"error",text:"unreachable"};let t=e.health.version;return{tone:"ok",text:t?`reachable \xB7 v${t}`:"reachable"}}var LEe=k(re(),1);var rAo=15e3;function IEe(e){let[t,r]=(0,LEe.useState)({}),n=e.join(`
4064
4064
  `);return(0,LEe.useEffect)(()=>{if(!n)return;let o=!1,i=()=>{for(let s of n.split(`
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.1021.2",
9
+ version: "0.1022.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -22653,6 +22653,9 @@ function validateCommentText(raw, isHash = false) {
22653
22653
  import { mkdirSync as mkdirSync17, writeFileSync as writeFileSync27 } from "fs";
22654
22654
  import { randomInt } from "crypto";
22655
22655
 
22656
+ // src/commands/notify/deliverPinNotification.ts
22657
+ import { randomUUID as randomUUID12 } from "crypto";
22658
+
22656
22659
  // src/commands/notify/showNotification.ts
22657
22660
  import notifier from "node-notifier";
22658
22661
 
@@ -22708,6 +22711,27 @@ function showNotification(options2) {
22708
22711
  return true;
22709
22712
  }
22710
22713
 
22714
+ // src/commands/notify/deliverPinNotification.ts
22715
+ var ROUTE_TIMEOUT_MS = 1e4;
22716
+ async function relayToViewerNode(notification) {
22717
+ const sessionId = process.env.ASSIST_SESSION_ID;
22718
+ if (!sessionId) return void 0;
22719
+ const requestId = randomUUID12();
22720
+ const reply2 = await requestDaemonReply(
22721
+ { type: "notify-pin", sessionId, requestId, ...notification },
22722
+ "notify-pin-result",
22723
+ ROUTE_TIMEOUT_MS
22724
+ );
22725
+ if (reply2?.requestId !== requestId) return void 0;
22726
+ return reply2.node;
22727
+ }
22728
+ async function deliverPinNotification(notification) {
22729
+ const node = await relayToViewerNode(notification);
22730
+ if (node) return { delivered: true, node };
22731
+ const { title, message: message3 } = notification;
22732
+ return { delivered: showNotification({ title, message: message3 }) };
22733
+ }
22734
+
22711
22735
  // src/commands/codeComment/issuePin.ts
22712
22736
  function issuePin(file, lineNumber, text19) {
22713
22737
  const pin2 = generatePin();
@@ -22717,7 +22741,9 @@ function issuePin(file, lineNumber, text19) {
22717
22741
  getPinStatePath(pin2),
22718
22742
  JSON.stringify({ pin: pin2, file, line: lineNumber, text: text19 })
22719
22743
  );
22720
- return showNotification({
22744
+ return deliverPinNotification({
22745
+ area: "code-comment",
22746
+ pin: pin2,
22721
22747
  title: "assist code-comment pin",
22722
22748
  message: `Pin ${pin2} \u2014 run: assist code-comment confirm ${pin2}`
22723
22749
  });
@@ -22727,7 +22753,7 @@ function generatePin() {
22727
22753
  }
22728
22754
 
22729
22755
  // src/commands/codeComment/codeCommentSet.ts
22730
- function codeCommentSet(file, line, text19) {
22756
+ async function codeCommentSet(file, line, text19) {
22731
22757
  const lineNumber = Number.parseInt(line, 10);
22732
22758
  if (!Number.isInteger(lineNumber) || lineNumber < 1) {
22733
22759
  console.error(chalk119.red(`Invalid line number: ${line}`));
@@ -22748,7 +22774,7 @@ function codeCommentSet(file, line, text19) {
22748
22774
  "THIS IS YOUR LAST CHANCE TO RECONSIDER BEFORE INVOLVING A HUMAN.\nRequesting this pin pages a real person to approve a comment. DO NOT WASTE THEIR TIME.\nYou had BETTER BE RIGHT that this comment is genuinely necessary.\n\nComments are a last resort, not a habit. Almost every comment you reach for is a sign\nthe code should be clearer instead. Before a human is pulled in, ask whether a better\nname, a smaller function, or a test would make the comment redundant. ONLY if you are\ncertain this one line earns its keep should you proceed to the confirm step below."
22749
22775
  )
22750
22776
  );
22751
- const delivered = issuePin(file, lineNumber, validation.text);
22777
+ const { delivered, node } = await issuePin(file, lineNumber, validation.text);
22752
22778
  if (!delivered) {
22753
22779
  console.error(
22754
22780
  chalk119.red(
@@ -22759,8 +22785,8 @@ function codeCommentSet(file, line, text19) {
22759
22785
  return;
22760
22786
  }
22761
22787
  console.log(
22762
- `A confirmation pin was sent to your desktop notifications.
22763
- To insert "${marker2} ${validation.text}" at ${file}:${lineNumber}, run:
22788
+ `A confirmation pin was sent to your desktop notifications${node ? ` on ${node}, the node controlling this session` : ""}.
22789
+ To insert "${marker2} ${validation.text}" at ${file}:${lineNumber}, run${node ? ` on ${node}` : ""}:
22764
22790
  ${chalk119.cyan(" assist code-comment confirm <PIN>")}
22765
22791
  using the pin from that notification.`
22766
22792
  );
@@ -25284,7 +25310,7 @@ function nextMigrationId() {
25284
25310
  }
25285
25311
 
25286
25312
  // src/commands/dbMigration/dbMigrationUnlock.ts
25287
- function dbMigrationUnlock() {
25313
+ async function dbMigrationUnlock() {
25288
25314
  const migrationId = nextMigrationId();
25289
25315
  const pin2 = randomInt2(0, 1e3).toString().padStart(3, "0");
25290
25316
  mkdirSync19(getRestrictedDir(), { recursive: true });
@@ -25295,7 +25321,9 @@ function dbMigrationUnlock() {
25295
25321
  "THIS IS YOUR LAST CHANCE TO RECONSIDER BEFORE INVOLVING A HUMAN.\nRequesting this pin pages a real person to approve a new database migration.\nA schema change is hard to reverse once shipped. You had BETTER have confirmed\nthe change with the user and be certain this migration is genuinely necessary."
25296
25322
  )
25297
25323
  );
25298
- const delivered = showNotification({
25324
+ const { delivered, node } = await deliverPinNotification({
25325
+ area: "db-migration",
25326
+ pin: pin2,
25299
25327
  title: "assist db-migration pin",
25300
25328
  message: `Pin ${pin2} \u2014 run: assist db-migration confirm ${pin2}`
25301
25329
  });
@@ -25309,8 +25337,8 @@ function dbMigrationUnlock() {
25309
25337
  return;
25310
25338
  }
25311
25339
  console.log(
25312
- `A confirmation pin was sent to your desktop notifications.
25313
- To approve creating migration ${migrationId}, run:
25340
+ `A confirmation pin was sent to your desktop notifications${node ? ` on ${node}, the node controlling this session` : ""}.
25341
+ To approve creating migration ${migrationId}, run${node ? ` on ${node}` : ""}:
25314
25342
  ${chalk156.cyan(" assist db-migration confirm <PIN>")}
25315
25343
  using the pin from that notification.`
25316
25344
  );
@@ -26092,30 +26120,6 @@ async function docsConfirm(pin2) {
26092
26120
  import { randomInt as randomInt3 } from "crypto";
26093
26121
  import { mkdirSync as mkdirSync21, unlinkSync as unlinkSync11, writeFileSync as writeFileSync34 } from "fs";
26094
26122
  import chalk167 from "chalk";
26095
-
26096
- // src/commands/notify/deliverPinNotification.ts
26097
- import { randomUUID as randomUUID12 } from "crypto";
26098
- var ROUTE_TIMEOUT_MS = 1e4;
26099
- async function relayToViewerNode(notification) {
26100
- const sessionId = process.env.ASSIST_SESSION_ID;
26101
- if (!sessionId) return void 0;
26102
- const requestId = randomUUID12();
26103
- const reply2 = await requestDaemonReply(
26104
- { type: "notify-pin", sessionId, requestId, ...notification },
26105
- "notify-pin-result",
26106
- ROUTE_TIMEOUT_MS
26107
- );
26108
- if (reply2?.requestId !== requestId) return void 0;
26109
- return reply2.node;
26110
- }
26111
- async function deliverPinNotification(notification) {
26112
- const node = await relayToViewerNode(notification);
26113
- if (node) return { delivered: true, node };
26114
- const { title, message: message3 } = notification;
26115
- return { delivered: showNotification({ title, message: message3 }) };
26116
- }
26117
-
26118
- // src/commands/docs/docsUnlock.ts
26119
26123
  function fail7(message3) {
26120
26124
  console.error(chalk167.red(message3));
26121
26125
  process.exitCode = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1021.2",
3
+ "version": "0.1022.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {